diff options
| author | Ming-Shin Lu <lumark@google.com> | 2020-08-14 01:23:33 +0800 |
|---|---|---|
| committer | Ming-Shin Lu <lumark@google.com> | 2020-08-22 00:33:46 +0800 |
| commit | d5ae401390b2dd9b44127a161d0f66075db91dcb (patch) | |
| tree | 179a18962a882cc44ddb58433b914fa621697bae /core/java/android/preference/EditTextPreference.java | |
| parent | a806511dca36a61853152724f514d3ef840e69ed (diff) | |
Fix showing keyboard without editor focused in some cases (2/2)
As CL[1] mentioned issue symptom, we also need to remove
STATE_ALWAYS_VISIBLE in EditTextPreference
and using new WindowInsets API to show soft-keyboard, to prevent the
keyboard may be shown without focusing editor case.
[1]: I37ae6e30d1de581ba15131c2a90396b3a522a4d6
Fix: 165910518
Test: atest CtsInputMethodTestCases
Test: manual as issue steps
1. Enter Dialer-> Menu -> Settings-> calling accounts -> Fixed Dialing Numbers
2. Tap change pin2 code, input old pin2 -> pressing ok button
3. Check if password keyboard shown
Change-Id: I763838fb7b887e09b46b1fb2360a515b77de8dd4
Diffstat (limited to 'core/java/android/preference/EditTextPreference.java')
| -rw-r--r-- | core/java/android/preference/EditTextPreference.java | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/core/java/android/preference/EditTextPreference.java b/core/java/android/preference/EditTextPreference.java index af6f18416870..75c5102d04f5 100644 --- a/core/java/android/preference/EditTextPreference.java +++ b/core/java/android/preference/EditTextPreference.java @@ -21,6 +21,7 @@ import android.compat.annotation.UnsupportedAppUsage; import android.content.Context; import android.content.SharedPreferences; import android.content.res.TypedArray; +import android.os.Bundle; import android.os.Parcel; import android.os.Parcelable; import android.text.TextUtils; @@ -28,6 +29,7 @@ import android.util.AttributeSet; import android.view.View; import android.view.ViewGroup; import android.view.ViewParent; +import android.view.WindowInsets; import android.widget.EditText; /** @@ -123,7 +125,7 @@ public class EditTextPreference extends DialogPreference { EditText editText = mEditText; editText.setText(getText()); - + ViewParent oldParent = editText.getParent(); if (oldParent != view) { if (oldParent != null) { @@ -133,6 +135,13 @@ public class EditTextPreference extends DialogPreference { } } + @Override + protected void showDialog(Bundle state) { + super.showDialog(state); + mEditText.requestFocus(); + mEditText.getWindowInsetsController().show(WindowInsets.Type.ime()); + } + /** * Adds the EditText widget of this preference to the dialog's view. * @@ -183,13 +192,6 @@ public class EditTextPreference extends DialogPreference { return mEditText; } - /** @hide */ - @Override - protected boolean needInputMethod() { - // We want the input method to show, if possible, when dialog is displayed - return true; - } - @Override protected Parcelable onSaveInstanceState() { final Parcelable superState = super.onSaveInstanceState(); |
