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

Commit 4182e684 authored by Android (Google) Code Review's avatar Android (Google) Code Review
Browse files

Merge change 8255 into donut

* changes:
  Add new hidden API setForceIgnoreOutsideTouch to AutoCompleteTextView for use by SearchDialog. SearchDialog wants to be able to say a dropdown should not always be visible but still let it ignore outside touch when it does show.
parents eba337ad d4760d77
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -541,6 +541,8 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS
            mSearchAutoComplete.setDropDownAlwaysVisible(false);
        }

        mSearchAutoComplete.setForceIgnoreOutsideTouch(true);

        // attach the suggestions adapter, if suggestions are available
        // The existence of a suggestions authority is the proxy for "suggestions available here"
        if (mSearchable.getSuggestAuthority() != null) {
+16 −1
Original line number Diff line number Diff line
@@ -117,6 +117,8 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe

    private boolean mDropDownDismissedOnCompletion = true;
    
    private boolean mForceIgnoreOutsideTouch = false;

    private int mLastKeyCode = KeyEvent.KEYCODE_UNKNOWN;
    private boolean mOpenBefore;

@@ -1142,6 +1144,8 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe
                heightSpec = mDropDownHeight;
            }

            mPopup.setOutsideTouchable(mForceIgnoreOutsideTouch ? false : !mDropDownAlwaysVisible);

            mPopup.update(getDropDownAnchorView(), mDropDownHorizontalOffset,
                    mDropDownVerticalOffset, widthSpec, heightSpec);
        } else {
@@ -1170,7 +1174,7 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe
            
            // use outside touchable to dismiss drop down when touching outside of it, so
            // only set this if the dropdown is not always visible
            mPopup.setOutsideTouchable(!mDropDownAlwaysVisible);
            mPopup.setOutsideTouchable(mForceIgnoreOutsideTouch ? false : !mDropDownAlwaysVisible);
            mPopup.setTouchInterceptor(new PopupTouchIntercepter());
            mPopup.showAsDropDown(getDropDownAnchorView(),
                    mDropDownHorizontalOffset, mDropDownVerticalOffset);
@@ -1180,6 +1184,17 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe
        }
    }
    
    /**
     * Forces outside touches to be ignored. Normally if {@link #isDropDownAlwaysVisible()} is
     * false, we allow outside touch to dismiss the dropdown. If this is set to true, then we
     * ignore outside touch even when the drop down is not set to always visible.
     * 
     * @hide used only by SearchDialog
     */
    public void setForceIgnoreOutsideTouch(boolean forceIgnoreOutsideTouch) {
        mForceIgnoreOutsideTouch = forceIgnoreOutsideTouch;
    }

    /**
     * <p>Builds the popup window's content and returns the height the popup
     * should have. Returns -1 when the content already exists.</p>