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

Commit 10da5908 authored by Amith Yamasani's avatar Amith Yamasani
Browse files

Handle callbacks to CollapsibleActionViews that are in an actionLayout.

Also, the onActionViewCollapsed needs to be called before detaching
the action view, so that the action view can dismiss the keyboard properly.

Fixes the Gmail search case where the keyboard doesn't disappear on hitting
the "up" affordance after a search.

Change-Id: I3c2f3f90f0edf6473404e6ceae3fa08866cad736
parent e3f5edf9
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -330,9 +330,9 @@ public class SearchView extends LinearLayout implements CollapsibleActionView {
    @Override
    public void clearFocus() {
        mClearingFocus = true;
        setImeVisibility(false);
        super.clearFocus();
        mQueryTextView.clearFocus();
        setImeVisibility(false);
        mClearingFocus = false;
    }

@@ -1041,8 +1041,9 @@ public class SearchView extends LinearLayout implements CollapsibleActionView {
     */
    @Override
    public void onActionViewCollapsed() {
        clearFocus();
        updateViewsVisibility(true);
        mQueryTextView.setText("");
        setIconified(true);
        mExpandedInActionView = false;
    }

+1 −1
Original line number Diff line number Diff line
@@ -563,7 +563,7 @@ public final class MenuItemImpl implements MenuItem {
    public MenuItem setActionView(int resId) {
        final Context context = mMenu.getContext();
        final LayoutInflater inflater = LayoutInflater.from(context);
        setActionView(inflater.inflate(resId, new LinearLayout(context)));
        setActionView(inflater.inflate(resId, new LinearLayout(context), false));
        return this;
    }

+7 −4
Original line number Diff line number Diff line
@@ -1323,11 +1323,18 @@ public class ActionBarView extends AbsActionBarView {
            if (mExpandedActionView instanceof CollapsibleActionView) {
                ((CollapsibleActionView) mExpandedActionView).onActionViewExpanded();
            }

            return true;
        }

        @Override
        public boolean collapseItemActionView(MenuBuilder menu, MenuItemImpl item) {
            // Do this before detaching the actionview from the hierarchy, in case
            // it needs to dismiss the soft keyboard, etc.
            if (mExpandedActionView instanceof CollapsibleActionView) {
                ((CollapsibleActionView) mExpandedActionView).onActionViewCollapsed();
            }

            removeView(mExpandedActionView);
            removeView(mExpandedHomeLayout);
            if ((mDisplayOptions & ActionBar.DISPLAY_SHOW_HOME) != 0) {
@@ -1349,16 +1356,12 @@ public class ActionBarView extends AbsActionBarView {
            if (mCustomNavView != null && (mDisplayOptions & ActionBar.DISPLAY_SHOW_CUSTOM) != 0) {
                mCustomNavView.setVisibility(VISIBLE);
            }
            View collapsedView = mExpandedActionView;
            mExpandedActionView = null;
            mExpandedHomeLayout.setIcon(null);
            mCurrentExpandedItem = null;
            requestLayout();
            item.setActionViewExpanded(false);

            if (collapsedView instanceof CollapsibleActionView) {
                ((CollapsibleActionView) collapsedView).onActionViewCollapsed();
            }
            return true;
        }