Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 17d7ce6e authored by Ralston Da Silva's avatar Ralston Da Silva
Browse files

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
parent dbc97088
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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);
+35 −3
Original line number Diff line number Diff line
@@ -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,13 +1249,38 @@ 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>
     */