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

Commit 94613752 authored by Adam Powell's avatar Adam Powell Committed by Android (Google) Code Review
Browse files

Merge "Rework action bar menus." into honeycomb

parents 3506d885 e7d46841
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