Merge "Rework action bar menus." into honeycomb
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -20,10 +20,11 @@
|
||||
android:layout_gravity="center"
|
||||
android:addStatesFromChildren="true"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:minWidth="64dip"
|
||||
android:minHeight="?attr/actionBarSize"
|
||||
android:gravity="center"
|
||||
android:paddingLeft="12dip"
|
||||
android:paddingRight="12dip">
|
||||
android:paddingRight="12dip"
|
||||
android:minWidth="64dip"
|
||||
android:minHeight="?attr/actionBarSize">
|
||||
<ImageButton android:id="@+id/imageButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@@ -19,6 +19,6 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="2dip"
|
||||
android:layout_marginRight="8dip"
|
||||
android:duplicateParentState="true" />
|
||||
|
||||
|
||||
@@ -16,7 +16,8 @@
|
||||
|
||||
<com.android.internal.view.menu.ListMenuItemView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?android:attr/listPreferredItemHeight"
|
||||
android:layout_height="48dip"
|
||||
android:minWidth="196dip"
|
||||
android:paddingLeft="16dip"
|
||||
android:paddingRight="16dip">
|
||||
|
||||
@@ -28,8 +29,6 @@
|
||||
android:layout_weight="1"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="6dip"
|
||||
android:layout_marginRight="6dip"
|
||||
android:duplicateParentState="true">
|
||||
|
||||
<TextView
|
||||
|
||||
@@ -2349,6 +2349,8 @@
|
||||
<attr name="windowAnimationStyle" />
|
||||
<!-- Default disabled icon alpha for each menu item that shows an icon. -->
|
||||
<attr name="itemIconDisabledAlpha" format="float" />
|
||||
<!-- Whether space should be reserved in layout when an icon is missing. -->
|
||||
<attr name="preserveIconSpacing" format="boolean" />
|
||||
</declare-styleable>
|
||||
<declare-styleable name="IconMenuView">
|
||||
<!-- Defines the height of each row. -->
|
||||
|
||||
@@ -1194,7 +1194,7 @@
|
||||
</style>
|
||||
|
||||
<style name="TextAppearance.Holo.Widget.PopupMenu.Large">
|
||||
<item name="android:textSize">22sp</item>
|
||||
<item name="android:textSize">18sp</item>
|
||||
</style>
|
||||
|
||||
<style name="TextAppearance.Holo.Widget.PopupMenu.Small">
|
||||
@@ -1578,7 +1578,6 @@
|
||||
</style>
|
||||
|
||||
<style name="Widget.Holo.Spinner.DropDown.ActionBar">
|
||||
<item name="android:background">@android:drawable/spinner_cab_background_holo_dark</item>
|
||||
</style>
|
||||
|
||||
<style name="Widget.Holo.CompoundButton.Star" parent="Widget.CompoundButton.Star">
|
||||
@@ -1651,6 +1650,8 @@
|
||||
</style>
|
||||
|
||||
<style name="Widget.Holo.ActionButton" parent="Widget.ActionButton">
|
||||
<item name="android:minWidth">64dip</item>
|
||||
<item name="android:gravity">center</item>
|
||||
<item name="android:paddingLeft">16dip</item>
|
||||
<item name="android:paddingRight">16dip</item>
|
||||
<item name="android:minHeight">56dip</item>
|
||||
@@ -1677,9 +1678,6 @@
|
||||
</style>
|
||||
|
||||
<style name="Widget.Holo.ActionBarView_TabBar" parent="Widget.ActionBarView_TabBar">
|
||||
<item name="divider">?android:attr/dividerVertical</item>
|
||||
<item name="showDividers">beginning|end</item>
|
||||
<item name="dividerPadding">8dip</item>
|
||||
</style>
|
||||
|
||||
<style name="Widget.Holo.ActionBarView_TabText" parent="Widget.ActionBarView_TabText">
|
||||
@@ -1920,7 +1918,6 @@
|
||||
</style>
|
||||
|
||||
<style name="Widget.Holo.Light.Spinner.DropDown.ActionBar">
|
||||
<item name="android:background">@android:drawable/spinner_cab_background_holo_light</item>
|
||||
</style>
|
||||
|
||||
<style name="Widget.Holo.Light.CompoundButton.Star" parent="Widget.CompoundButton.Star">
|
||||
|
||||
Reference in New Issue
Block a user