diff options
| author | 2019-02-13 12:04:41 -0800 | |
|---|---|---|
| committer | 2019-02-14 11:02:23 -0800 | |
| commit | 17d7ce6e4a181b12cf37dcf2852b9efe739f8492 (patch) | |
| tree | b39dd75c650376c310dbd561b18c4342dea3e97a | |
| parent | dbc9708897b7043a3ea7d8fe8db48da0fdd4cc0d (diff) | |
Removing hidden api usage from AutoCompleteTextView
ensureImeVisible() was added to show the keyboard in SearchDialog go/ensureImeVisible-added. A better fix would be to expose a function to setInputMethodMode(), as showDropDown() is public and can be called externally. Adding this new API in this CL.
Bug: 123768913
Test: Added tests to android.widget.AutoCompleteTextViewTest.
Change-Id: I07e53c6d5e93d1e33381f8f87f75a7dee2f2f5a5
| -rw-r--r-- | api/current.txt | 2 | ||||
| -rw-r--r-- | core/java/android/widget/AutoCompleteTextView.java | 38 |
2 files changed, 37 insertions, 3 deletions
diff --git a/api/current.txt b/api/current.txt index 747a3f5d7c53..10695af94c56 100644 --- a/api/current.txt +++ b/api/current.txt @@ -55745,6 +55745,7 @@ package android.widget { method public int getDropDownVerticalOffset(); method public int getDropDownWidth(); method protected android.widget.Filter getFilter(); + method public int getInputMethodMode(); method @Deprecated public android.widget.AdapterView.OnItemClickListener getItemClickListener(); method @Deprecated public android.widget.AdapterView.OnItemSelectedListener getItemSelectedListener(); method public int getListSelection(); @@ -55769,6 +55770,7 @@ package android.widget { method public void setDropDownHorizontalOffset(int); method public void setDropDownVerticalOffset(int); method public void setDropDownWidth(int); + method public void setInputMethodMode(int); method public void setListSelection(int); method public void setOnDismissListener(android.widget.AutoCompleteTextView.OnDismissListener); method public void setOnItemClickListener(android.widget.AdapterView.OnItemClickListener); diff --git a/core/java/android/widget/AutoCompleteTextView.java b/core/java/android/widget/AutoCompleteTextView.java index 904a86261e6c..89e205caa693 100644 --- a/core/java/android/widget/AutoCompleteTextView.java +++ b/core/java/android/widget/AutoCompleteTextView.java @@ -1230,9 +1230,16 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe * Ensures that the drop down is not obscuring the IME. * @param visible whether the ime should be in front. If false, the ime is pushed to * the background. + * + * This method is deprecated. Please use the following methods instead. + * Use {@link #setInputMethodMode} to ensure that the drop down is not obscuring the IME. + * Use {@link #showDropDown()} to show the drop down immediately + * A combination of {@link #isDropDownAlwaysVisible()} and {@link #enoughToFilter()} to decide + * whether to manually trigger {@link #showDropDown()} or not. + * * @hide internal used only here and SearchDialog */ - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 123768913) public void ensureImeVisible(boolean visible) { mPopup.setInputMethodMode(visible ? ListPopupWindow.INPUT_METHOD_NEEDED : ListPopupWindow.INPUT_METHOD_NOT_NEEDED); @@ -1242,14 +1249,39 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe } /** - * @hide internal used only here and SearchDialog + * This method is deprecated. Please use {@link #getInputMethodMode()} instead. + * + * @hide This API is not being used and can be removed. */ - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) public boolean isInputMethodNotNeeded() { return mPopup.getInputMethodMode() == ListPopupWindow.INPUT_METHOD_NOT_NEEDED; } /** + * Returns the input method mode used by the auto complete dropdown. + */ + public int getInputMethodMode() { + return mPopup.getInputMethodMode(); + } + + /** + * Use this method to specify when the IME should be displayed. This function can be used to + * prevent the dropdown from obscuring the IME. + * + * @param mode speficies the input method mode. use one of the following values: + * + * {@link ListPopupWindow#INPUT_METHOD_FROM_FOCUSABLE} IME Displayed if the auto-complete box is + * focusable. + * {@link ListPopupWindow#INPUT_METHOD_NEEDED} Always display the IME. + * {@link ListPopupWindow#INPUT_METHOD_NOT_NEEDED}. The auto-complete suggestions are always + * displayed, even if the suggestions cover/hide the input method. + */ + public void setInputMethodMode(int mode) { + mPopup.setInputMethodMode(mode); + } + + /** * <p>Displays the drop down on screen.</p> */ public void showDropDown() { |