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

Commit e7d46841 authored by Adam Powell's avatar Adam Powell
Browse files

Rework action bar menus.

Fix bug 3328810 - remove icons from action bar overflow menu.  Popup
menus now will not show icons. Give popup menu items a minimum width.
Alter the sizing of popup menus.

Fix bug 3192635 - revise rules for action menu dividers. Dividers now
appear between the overflow button and any other items next to it, and
anywhere they disambiguate touch targets between text and other
content. Action views are on their own and should include their own
dividers if needed.

Remove dividers from around action bar spinners and tabs.

Change-Id: I935b48b473606ac2adde5e2b251bf30ebe2a3da9
parent 783e6c8b
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -66,7 +66,7 @@ public class ActionMenuItemView extends LinearLayout
        mItemData = itemData;

        setIcon(itemData.getIcon());
        setTitle(itemData.getTitle()); // Title only takes effect if there is no icon
        setTitle(itemData.getTitleForItemView(this)); // Title only takes effect if there is no icon
        setId(itemData.getItemId());

        setVisibility(itemData.isVisible() ? View.VISIBLE : View.GONE);
@@ -91,7 +91,7 @@ public class ActionMenuItemView extends LinearLayout
    }

    public boolean prefersCondensedTitle() {
        return false;
        return true;
    }

    public void setCheckable(boolean checkable) {
+17 −5
Original line number Diff line number Diff line
@@ -20,9 +20,9 @@ import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
@@ -186,10 +186,14 @@ public class ActionMenuView extends LinearLayout implements MenuBuilder.ItemInvo
        
        boolean needsDivider = false;
        for (int i = 0; i < itemCount; i++) {
            final MenuItemImpl itemData = itemsToShow.get(i);
            boolean hasDivider = false;

            if (needsDivider) {
                addView(makeDividerView(), makeDividerLayoutParams());
                hasDivider = true;
            }
            final MenuItemImpl itemData = itemsToShow.get(i);

            View actionView = itemData.getActionView();

            if (actionView != null) {
@@ -199,14 +203,22 @@ public class ActionMenuView extends LinearLayout implements MenuBuilder.ItemInvo
                }
                addView(actionView, makeActionViewLayoutParams(actionView));
            } else {
                needsDivider = addItemView(i == 0 || !needsDivider,
                        (ActionMenuItemView) itemData.getItemView(
                                MenuBuilder.TYPE_ACTION_BUTTON, this));
                ActionMenuItemView view = (ActionMenuItemView) itemData.getItemView(
                        MenuBuilder.TYPE_ACTION_BUTTON, this);
                view.setItemInvoker(this);
                if (i > 0 && !hasDivider && view.hasText() && itemData.getIcon() == null) {
                    addView(makeDividerView(), makeDividerLayoutParams());
                }
                addView(view);
                needsDivider = view.hasText();
            }
        }

        if (reserveOverflow) {
            if (mMenu.getNonActionItems(true).size() > 0) {
                if (itemCount > 0) {
                    addView(makeDividerView(), makeDividerLayoutParams());
                }
                OverflowMenuButton button = new OverflowMenuButton(mContext);
                addView(button);
                mOverflowButton = button;
+7 −4
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ public class ListMenuItemView extends LinearLayout implements MenuView.ItemView
    private Drawable mBackground;
    private int mTextAppearance;
    private Context mTextAppearanceContext;
    private boolean mPreserveIconSpacing;
    
    private int mMenuType;
    
@@ -57,6 +58,8 @@ public class ListMenuItemView extends LinearLayout implements MenuView.ItemView
        mBackground = a.getDrawable(com.android.internal.R.styleable.MenuView_itemBackground);
        mTextAppearance = a.getResourceId(com.android.internal.R.styleable.
                                          MenuView_itemTextAppearance, -1);
        mPreserveIconSpacing = a.getBoolean(
                com.android.internal.R.styleable.MenuView_preserveIconSpacing, false);
        mTextAppearanceContext = context;
        
        a.recycle();
@@ -184,8 +187,8 @@ public class ListMenuItemView extends LinearLayout implements MenuView.ItemView
    }
    
    public void setIcon(Drawable icon) {
        
        if (!mItemData.shouldShowIcon(mMenuType)) {
        final boolean showIcon = mItemData.shouldShowIcon(mMenuType);
        if (!showIcon && !mPreserveIconSpacing) {
            return;
        }
        
@@ -197,8 +200,8 @@ public class ListMenuItemView extends LinearLayout implements MenuView.ItemView
            insertIconView();
        }
        
        if (icon != null) {
            mIconView.setImageDrawable(icon);
        if (icon != null || mPreserveIconSpacing) {
            mIconView.setImageDrawable(showIcon ? icon : null);

            if (mIconView.getVisibility() != VISIBLE) {
                mIconView.setVisibility(VISIBLE);
+0 −1
Original line number Diff line number Diff line
@@ -644,7 +644,6 @@ public final class MenuItemImpl implements MenuItem {
    public boolean shouldShowIcon(int menuType) {
        return menuType == MenuBuilder.TYPE_ICON ||
                menuType == MenuBuilder.TYPE_ACTION_BUTTON ||
                menuType == MenuBuilder.TYPE_POPUP ||
                mMenu.getOptionalIconsVisible();
    }
    
+1 −1
Original line number Diff line number Diff line
@@ -437,7 +437,7 @@ public class ActionBarView extends ViewGroup {
                    mListNavLayout = new LinearLayout(mContext, null,
                            com.android.internal.R.attr.actionBarTabBarStyle);
                    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
                            LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
                            LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
                    params.gravity = Gravity.CENTER;
                    mListNavLayout.addView(mSpinner, params);
                }
Loading