Bug 1391579 Part 1: add attribute itemType to GeckoMenuItem r=jwu,sebastian
authorJulian_Chu <walkingice0204@gmail.com>
Thu, 24 Aug 2017 01:15:04 -0700
changeset 430420 bb3a37d321e22313ce8d9d8cd71274569fc5121c
parent 430419 a59dee0eecb9f9729f4dde98001207f65fe0353a
child 430421 7048637ef80c14b230d7cde182dbc8d3c93e1554
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwu, sebastian
bugs1391579
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1391579 Part 1: add attribute itemType to GeckoMenuItem r=jwu,sebastian MozReview-Commit-ID: CelYcXveCvO
mobile/android/app/src/main/res/values/attrs.xml
mobile/android/base/java/org/mozilla/gecko/menu/GeckoMenuInflater.java
mobile/android/base/java/org/mozilla/gecko/menu/GeckoMenuItem.java
--- a/mobile/android/app/src/main/res/values/attrs.xml
+++ b/mobile/android/app/src/main/res/values/attrs.xml
@@ -50,16 +50,19 @@
         <attr name="android:orderInCategory"/>
         <attr name="android:title"/>
         <attr name="android:icon"/>
         <attr name="android:checkable"/>
         <attr name="android:checked"/>
         <attr name="android:visible"/>
         <attr name="android:enabled"/>
         <attr name="android:showAsAction"/>
+        <attr name="itemType" type="enum">
+            <enum name="default_menu_item" value="0x00" />
+        </attr>
     </declare-styleable>
 
     <declare-styleable name="MenuItemDefault">
         <attr name="state_more" format="boolean"/>
     </declare-styleable>
 
     <declare-styleable name="TabThumbnailWrapper">
         <attr name="state_recording" format="boolean"/>
--- a/mobile/android/base/java/org/mozilla/gecko/menu/GeckoMenuInflater.java
+++ b/mobile/android/base/java/org/mozilla/gecko/menu/GeckoMenuInflater.java
@@ -36,16 +36,17 @@ public class GeckoMenuInflater extends M
         public CharSequence title;
         public int iconRes;
         public boolean checkable;
         public boolean checked;
         public boolean visible;
         public boolean enabled;
         public int showAsAction;
         public boolean hasSubMenu;
+        public int itemType;
     }
 
     public GeckoMenuInflater(Context context) {
         super(context);
         mContext = context;
     }
 
     @Override
@@ -126,29 +127,31 @@ public class GeckoMenuInflater extends M
         item.title = a.getText(R.styleable.MenuItem_android_title);
         item.checkable = a.getBoolean(R.styleable.MenuItem_android_checkable, false);
         item.checked = a.getBoolean(R.styleable.MenuItem_android_checked, false);
         item.visible = a.getBoolean(R.styleable.MenuItem_android_visible, true);
         item.enabled = a.getBoolean(R.styleable.MenuItem_android_enabled, true);
         item.hasSubMenu = false;
         item.iconRes = a.getResourceId(R.styleable.MenuItem_android_icon, 0);
         item.showAsAction = a.getInt(R.styleable.MenuItem_android_showAsAction, 0);
+        item.itemType = a.getInt(R.styleable.MenuItem_itemType, GeckoMenuItem.ITEM_TYPE_DEFAULT);
 
         a.recycle();
     }
 
     public void setValues(ParsedItem item, MenuItem menuItem) {
         // We are blocking any presenter updates during inflation.
         GeckoMenuItem geckoItem = null;
         if (menuItem instanceof GeckoMenuItem) {
             geckoItem = (GeckoMenuItem) menuItem;
         }
 
         if (geckoItem != null) {
             geckoItem.stopDispatchingChanges();
+            geckoItem.setItemType(item.itemType);
         }
 
         menuItem.setChecked(item.checked)
                 .setVisible(item.visible)
                 .setEnabled(item.enabled)
                 .setCheckable(item.checkable)
                 .setIcon(item.iconRes);
 
--- a/mobile/android/base/java/org/mozilla/gecko/menu/GeckoMenuItem.java
+++ b/mobile/android/base/java/org/mozilla/gecko/menu/GeckoMenuItem.java
@@ -22,32 +22,35 @@ public class GeckoMenuItem implements Me
 
     // These values mirror MenuItem values that are only available on API >= 11.
     public static final int SHOW_AS_ACTION_NEVER = 0;
     public static final int SHOW_AS_ACTION_IF_ROOM = 1;
     public static final int SHOW_AS_ACTION_ALWAYS = 2;
     public static final int SHOW_AS_ACTION_WITH_TEXT = 4;
     public static final int SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW = 8;
 
+    public static final int ITEM_TYPE_DEFAULT = 0x00;
+
     // A View that can show a MenuItem should be able to initialize from
     // the properties of the MenuItem.
     public static interface Layout {
         public void initialize(GeckoMenuItem item);
 
         public void setShowIcon(boolean show);
     }
 
     public static interface OnShowAsActionChangedListener {
         public boolean hasActionItemBar();
 
         public void onShowAsActionChanged(GeckoMenuItem item);
     }
 
     private final int mId;
     private final int mOrder;
+    private int mItemType;
     private View mActionView;
     private int mActionEnum;
     private CharSequence mTitle;
     private CharSequence mTitleCondensed;
     private boolean mCheckable;
     private boolean mChecked;
     private boolean mVisible = true;
     private boolean mEnabled = true;
@@ -445,16 +448,24 @@ public class GeckoMenuItem implements Me
                 mMenu.onItemChanged(this);
             } else {
                 mDidChange = true;
             }
         }
         return this;
     }
 
+    public int getItemType() {
+        return mItemType;
+    }
+
+    public void setItemType(int itemType) {
+        mItemType = itemType;
+    }
+
     public boolean invoke() {
         if (mMenuItemClickListener != null)
             return mMenuItemClickListener.onMenuItemClick(this);
         else
             return false;
     }
 
     public void setOnShowAsActionChangedListener(OnShowAsActionChangedListener listener) {