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

Commit 4348688e authored by Oren Blasberg's avatar Oren Blasberg
Browse files

Call the onDismiss listener in submenus.

For StandardMenuPopup, if user opens a submenu, the ondismiss listener is no
longer called. Instead, it is called when the submenu (which is now open in
the top level menu's place) is dismissed.

Bug: 27877103

Change-Id: I069388fd173142620c667fa8d1cb21e88d5266fe
parent fd39aa14
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
@@ -65,7 +65,6 @@ public class MenuBuilder implements Menu {

    private final Context mContext;
    private final Resources mResources;
    private final boolean mShowCascadingMenus;

    /**
     * Whether the shortcuts should be qwerty-accessible. Use isQwertyMode()
@@ -188,9 +187,6 @@ public class MenuBuilder implements Menu {
    public MenuBuilder(Context context) {
        mContext = context;
        mResources = context.getResources();
        mShowCascadingMenus = context.getResources().getBoolean(
                com.android.internal.R.bool.config_enableCascadingSubmenus);
        
        mItems = new ArrayList<MenuItemImpl>();
        
        mVisibleItems = new ArrayList<MenuItemImpl>();
@@ -915,10 +911,6 @@ public class MenuBuilder implements Menu {
                close(true /* closeAllMenus */);
            }
        } else if (itemImpl.hasSubMenu() || providerHasSubMenu) {
            if (!mShowCascadingMenus) {
                close(false /* closeAllMenus */);
            }

            if (!itemImpl.hasSubMenu()) {
                itemImpl.setSubMenu(new SubMenuBuilder(getContext(), this, itemImpl));
            }
+11 −1
Original line number Diff line number Diff line
@@ -240,8 +240,11 @@ final class StandardMenuPopup extends MenuPopup implements OnDismissListener, On
            mTreeObserver = null;
        }
        mShownAnchorView.removeOnAttachStateChangeListener(mAttachStateChangeListener);

        if (mOnDismissListener != null) {
            mOnDismissListener.onDismiss();
        }
    }

    @Override
    public void updateMenuView(boolean cleared) {
@@ -265,6 +268,13 @@ final class StandardMenuPopup extends MenuPopup implements OnDismissListener, On
            subPopup.setPresenterCallback(mPresenterCallback);
            subPopup.setForceShowIcon(mAdapter.getForceShowIcon());

            // Pass responsibility for handling onDismiss to the submenu.
            subPopup.setOnDismissListener(mOnDismissListener);
            mOnDismissListener = null;

            // Close this menu popup to make room for the submenu popup.
            dismiss();

            // Show the new sub-menu popup at the same location as this popup.
            if (subPopup.tryShow(mXOffset, mYOffset)) {
                if (mPresenterCallback != null) {