mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Follow-up for fixing xiaomi NullPointer crash
Summary: This is a follow-up for fixing the xiaomi NullPointer crash (D23331828 (https://github.com/facebook/react-native/commit/07a597ad185c8c31ac38bdd4d022b0b880d02859) D23451929 (https://github.com/facebook/react-native/commit/b5b4a7041027fd767850a564b5d80fa4a98ba2a2)): 1, Clean up previous temporary fix in js. 2, Cover all cases including caretHidden is set and isn't set, in previous fix if caretHidden isn't set then fix won't be executed. Changelog: [Internal] Reviewed By: makovkastar Differential Revision: D23816541 fbshipit-source-id: a7543f6767430abb74141a747b08391986662958
This commit is contained in:
committed by
Facebook GitHub Bot
parent
abff021261
commit
c2447d3f76
+16
-11
@@ -477,21 +477,17 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean shouldHideCursorForEmailTextInput() {
|
||||
String manufacturer = Build.MANUFACTURER.toLowerCase();
|
||||
return (Build.VERSION.SDK_INT == Build.VERSION_CODES.Q && manufacturer.contains("xiaomi"));
|
||||
}
|
||||
|
||||
@ReactProp(name = "caretHidden", defaultBoolean = false)
|
||||
public void setCaretHidden(ReactEditText view, boolean caretHidden) {
|
||||
// Set cursor's visibility to False to fix a crash on some Xiaomi devices with Android Q. This
|
||||
// crash happens when focusing on a email EditText, during which a prompt will be triggered but
|
||||
// the system fail to locate it properly. Here is an example post discussing about this
|
||||
// issue: https://github.com/facebook/react-native/issues/27204
|
||||
String manufacturer = Build.MANUFACTURER.toLowerCase();
|
||||
if ((view.getInputType() == InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS
|
||||
|| view.getInputType() == InputType.TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS)
|
||||
&& Build.VERSION.SDK_INT == Build.VERSION_CODES.Q
|
||||
&& manufacturer.contains("xiaomi")) {
|
||||
view.setCursorVisible(false);
|
||||
if (view.getStagedInputType() == InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS
|
||||
&& shouldHideCursorForEmailTextInput()) {
|
||||
return;
|
||||
}
|
||||
|
||||
view.setCursorVisible(!caretHidden);
|
||||
}
|
||||
|
||||
@@ -763,6 +759,15 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
|
||||
flagsToSet = INPUT_TYPE_KEYBOARD_DECIMAL_PAD;
|
||||
} else if (KEYBOARD_TYPE_EMAIL_ADDRESS.equalsIgnoreCase(keyboardType)) {
|
||||
flagsToSet = InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS | InputType.TYPE_CLASS_TEXT;
|
||||
|
||||
// Set cursor's visibility to False to fix a crash on some Xiaomi devices with Android Q. This
|
||||
// crash happens when focusing on a email EditText, during which a prompt will be triggered
|
||||
// but
|
||||
// the system fail to locate it properly. Here is an example post discussing about this
|
||||
// issue: https://github.com/facebook/react-native/issues/27204
|
||||
if (shouldHideCursorForEmailTextInput()) {
|
||||
view.setCursorVisible(false);
|
||||
}
|
||||
} else if (KEYBOARD_TYPE_PHONE_PAD.equalsIgnoreCase(keyboardType)) {
|
||||
flagsToSet = InputType.TYPE_CLASS_PHONE;
|
||||
} else if (KEYBOARD_TYPE_VISIBLE_PASSWORD.equalsIgnoreCase(keyboardType)) {
|
||||
|
||||
Reference in New Issue
Block a user