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

Commit 6c6f5754 authored by Adam Powell's avatar Adam Powell
Browse files

More ActionBar/config change tweaks. Preserve open overflow menus

Change-Id: Ic8ad2b1e3909fbf84ff4d852ae046a9f9508477c
parent d6284799
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -225218,6 +225218,19 @@
<parameter name="modal" type="boolean">
</parameter>
</method>
<method name="setOnDismissListener"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="listener" type="android.widget.PopupWindow.OnDismissListener">
</parameter>
</method>
<method name="setOnItemClickListener"
 return="void"
 abstract="false"
+9 −0
Original line number Diff line number Diff line
@@ -604,6 +604,15 @@ public class ListPopupWindow {
        mDropDownList = null;
    }

    /**
     * Set a listener to receive a callback when the popup is dismissed.
     *
     * @param listener Listener that will be notified when the popup is dismissed.
     */
    public void setOnDismissListener(PopupWindow.OnDismissListener listener) {
        mPopup.setOnDismissListener(listener);
    }

    private void removePromptView() {
        if (mPromptView != null) {
            final ViewParent parent = mPromptView.getParent();
+16 −5
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@ import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.LinearLayout;

import java.lang.ref.WeakReference;
import java.util.ArrayList;

/**
@@ -41,7 +40,13 @@ public class ActionMenuView extends LinearLayout implements MenuBuilder.ItemInvo
    private int mMaxItems;
    private boolean mReserveOverflow;
    private OverflowMenuButton mOverflowButton;
    private WeakReference<MenuPopupHelper> mOverflowPopup;
    private MenuPopupHelper mOverflowPopup;

    private Runnable mShowOverflow = new Runnable() {
        public void run() {
            showOverflowMenu();
        }
    };
    
    public ActionMenuView(Context context) {
        this(context, null);
@@ -66,6 +71,7 @@ public class ActionMenuView extends LinearLayout implements MenuBuilder.ItemInvo
                Configuration.SCREENLAYOUT_SIZE_XLARGE;
    }

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        final int screen = newConfig.screenLayout;
        mReserveOverflow = (screen & Configuration.SCREENLAYOUT_SIZE_MASK) ==
@@ -75,6 +81,11 @@ public class ActionMenuView extends LinearLayout implements MenuBuilder.ItemInvo
            mMenu.setMaxActionItems(mMaxItems);
            updateChildren(false);
        }

        if (mOverflowPopup != null && mOverflowPopup.isShowing()) {
            mOverflowPopup.dismiss();
            post(mShowOverflow);
        }
    }

    private int measureMaxActionButtons() {
@@ -172,14 +183,14 @@ public class ActionMenuView extends LinearLayout implements MenuBuilder.ItemInvo
                    popup.show();
                }
            });
            mOverflowPopup = new WeakReference<MenuPopupHelper>(popup);
            mOverflowPopup = popup;
            return true;
        }
        return false;
    }

    public boolean isOverflowMenuShowing() {
        MenuPopupHelper popup = mOverflowPopup != null ? mOverflowPopup.get() : null;
        MenuPopupHelper popup = mOverflowPopup;
        if (popup != null) {
            return popup.isShowing();
        }
@@ -187,7 +198,7 @@ public class ActionMenuView extends LinearLayout implements MenuBuilder.ItemInvo
    }

    public boolean hideOverflowMenu() {
        MenuPopupHelper popup = mOverflowPopup != null ? mOverflowPopup.get() : null;
        MenuPopupHelper popup = mOverflowPopup;
        if (popup != null) {
            popup.dismiss();
            return true;
+8 −1
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.view.View;
import android.view.View.MeasureSpec;
import android.widget.AdapterView;
import android.widget.ListPopupWindow;
import android.widget.PopupWindow;

import java.lang.ref.WeakReference;

@@ -42,6 +43,12 @@ public class MenuPopupHelper implements AdapterView.OnItemClickListener, View.On
    private WeakReference<View> mAnchorView;
    private boolean mOverflowOnly;

    private PopupWindow.OnDismissListener mDismissListener = new PopupWindow.OnDismissListener() {
        public void onDismiss() {
            mPopup = null;
        }
    };

    public MenuPopupHelper(Context context, MenuBuilder menu) {
        this(context, menu, null, false);
    }
@@ -69,6 +76,7 @@ public class MenuPopupHelper implements AdapterView.OnItemClickListener, View.On
        mPopup = new ListPopupWindow(mContext, null, 0,
                com.android.internal.R.style.Widget_Spinner);
        mPopup.setOnItemClickListener(this);
        mPopup.setOnDismissListener(mDismissListener);

        final MenuAdapter adapter = mOverflowOnly ?
                mMenu.getOverflowMenuAdapter(MenuBuilder.TYPE_POPUP) :
@@ -95,7 +103,6 @@ public class MenuPopupHelper implements AdapterView.OnItemClickListener, View.On
        if (isShowing()) {
            mPopup.dismiss();
        }
        mPopup = null;
    }

    public boolean isShowing() {
+8 −0
Original line number Diff line number Diff line
@@ -221,6 +221,14 @@ public class ActionBarView extends ViewGroup {
        return false;
    }

    public void postShowOverflowMenu() {
        post(new Runnable() {
            public void run() {
                showOverflowMenu();
            }
        });
    }

    public boolean hideOverflowMenu() {
        if (mMenuView != null) {
            return mMenuView.hideOverflowMenu();
Loading