summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorOren Blasberg <orenb@google.com>2015-08-31 12:27:24 -0700
committerOren Blasberg <orenb@google.com>2015-09-01 16:38:06 -0700
commitddc453a342c4eab5b44dc1c3e96b767203725237 (patch)
treeec2137a6a18345df921fe851fcbc07bfc66e15b9 /core/java
parent008d6d034ea68a7ccc5b7c454f642fcaaf9dc2cb (diff)
Add a new submenu arrow for popup menu items.
This arrow is shown when the item corresponds to a submenu. Bug: 20127825 Change-Id: Ida70d7707e00e1cda84ed6135333f09a511cd6c5
Diffstat (limited to 'core/java')
-rw-r--r--core/java/com/android/internal/view/menu/ListMenuItemView.java16
1 files changed, 15 insertions, 1 deletions
diff --git a/core/java/com/android/internal/view/menu/ListMenuItemView.java b/core/java/com/android/internal/view/menu/ListMenuItemView.java
index 29ac3f349d0a..25263932bb75 100644
--- a/core/java/com/android/internal/view/menu/ListMenuItemView.java
+++ b/core/java/com/android/internal/view/menu/ListMenuItemView.java
@@ -43,11 +43,13 @@ public class ListMenuItemView extends LinearLayout implements MenuView.ItemView
private TextView mTitleView;
private CheckBox mCheckBox;
private TextView mShortcutView;
+ private ImageView mSubMenuArrowView;
private Drawable mBackground;
private int mTextAppearance;
private Context mTextAppearanceContext;
private boolean mPreserveIconSpacing;
+ private Drawable mSubMenuArrow;
private int mMenuType;
@@ -68,6 +70,7 @@ public class ListMenuItemView extends LinearLayout implements MenuView.ItemView
mPreserveIconSpacing = a.getBoolean(
com.android.internal.R.styleable.MenuView_preserveIconSpacing, false);
mTextAppearanceContext = context;
+ mSubMenuArrow = a.getDrawable(com.android.internal.R.styleable.MenuView_subMenuArrow);
a.recycle();
}
@@ -77,7 +80,7 @@ public class ListMenuItemView extends LinearLayout implements MenuView.ItemView
}
public ListMenuItemView(Context context, AttributeSet attrs) {
- this(context, attrs, 0);
+ this(context, attrs, com.android.internal.R.attr.listMenuViewStyle);
}
@Override
@@ -93,6 +96,10 @@ public class ListMenuItemView extends LinearLayout implements MenuView.ItemView
}
mShortcutView = (TextView) findViewById(com.android.internal.R.id.shortcut);
+ mSubMenuArrowView = (ImageView) findViewById(com.android.internal.R.id.submenuarrow);
+ if (mSubMenuArrowView != null) {
+ mSubMenuArrowView.setImageDrawable(mSubMenuArrow);
+ }
}
public void initialize(MenuItemImpl itemData, int menuType) {
@@ -106,6 +113,7 @@ public class ListMenuItemView extends LinearLayout implements MenuView.ItemView
setShortcut(itemData.shouldShowShortcut(), itemData.getShortcut());
setIcon(itemData.getIcon());
setEnabled(itemData.isEnabled());
+ setSubMenuArrowVisible(itemData.hasSubMenu());
}
public void setForceShowIcon(boolean forceShow) {
@@ -186,6 +194,12 @@ public class ListMenuItemView extends LinearLayout implements MenuView.ItemView
compoundButton.setChecked(checked);
}
+ private void setSubMenuArrowVisible(boolean hasSubmenu) {
+ if (mSubMenuArrowView != null) {
+ mSubMenuArrowView.setVisibility(hasSubmenu ? View.VISIBLE : View.GONE);
+ }
+ }
+
public void setShortcut(boolean showShortcut, char shortcutKey) {
final int newVisibility = (showShortcut && mItemData.shouldShowShortcut())
? VISIBLE : GONE;