Bug 1140210 - MenuItemActionView -> MenuItemSwitcherLayout. r=liuche
authorMichael Comella <michael.l.comella@gmail.com>
Thu, 15 Oct 2015 14:48:06 -0700
changeset 304773 5b439b4654e00b882c8cfde06b41872b3515161b
parent 304772 66d1252f9864a025273f4b1fdc41022f8137eea7
child 304774 8345f21f651819dddce7412e4f5a7046ed4f0d69
push id1001
push userraliiev@mozilla.com
push dateMon, 18 Jan 2016 19:06:03 +0000
treeherdermozilla-release@8b89261f3ac4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersliuche
bugs1140210
milestone44.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 1140210 - MenuItemActionView -> MenuItemSwitcherLayout. r=liuche
mobile/android/base/menu/GeckoMenu.java
mobile/android/base/menu/MenuItemActionView.java
mobile/android/base/menu/MenuItemSwitcherLayout.java
mobile/android/base/moz.build
mobile/android/base/prompts/PromptListAdapter.java
mobile/android/base/widget/GeckoActionProvider.java
--- a/mobile/android/base/menu/GeckoMenu.java
+++ b/mobile/android/base/menu/GeckoMenu.java
@@ -254,24 +254,24 @@ public class GeckoMenu extends ListView
                 public boolean onLongClick(View view) {
                     if (handleMenuItemLongClick(menuItem)) {
                         GeckoAppShell.vibrateOnHapticFeedbackEnabled(getResources().getIntArray(R.array.long_press_vibrate_msec));
                         return true;
                     }
                     return false;
                 }
             });
-        } else if (actionView instanceof MenuItemActionView) {
-            ((MenuItemActionView) actionView).setMenuItemClickListener(new View.OnClickListener() {
+        } else if (actionView instanceof MenuItemSwitcherLayout) {
+            ((MenuItemSwitcherLayout) actionView).setMenuItemClickListener(new View.OnClickListener() {
                 @Override
                 public void onClick(View view) {
                     handleMenuItemClick(menuItem);
                 }
             });
-            ((MenuItemActionView) actionView).setMenuItemLongClickListener(new View.OnLongClickListener() {
+            ((MenuItemSwitcherLayout) actionView).setMenuItemLongClickListener(new View.OnLongClickListener() {
                 @Override
                 public boolean onLongClick(View view) {
                     if (handleMenuItemLongClick(menuItem)) {
                         GeckoAppShell.vibrateOnHapticFeedbackEnabled(getResources().getIntArray(R.array.long_press_vibrate_msec));
                         return true;
                     }
                     return false;
                 }
@@ -596,17 +596,17 @@ public class GeckoMenu extends ListView
             }
 
             if (actionView != null) {
                 if (item.isVisible()) {
                     actionView.setVisibility(View.VISIBLE);
                     if (actionView instanceof MenuItemActionBar) {
                         ((MenuItemActionBar) actionView).initialize(item);
                     } else {
-                        ((MenuItemActionView) actionView).initialize(item);
+                        ((MenuItemSwitcherLayout) actionView).initialize(item);
                     }
                 } else {
                     actionView.setVisibility(View.GONE);
                 }
             }
         } else {
             mAdapter.notifyDataSetChanged();
         }
@@ -727,18 +727,18 @@ public class GeckoMenu extends ListView
 
             if (actualParams != null) {
                 params = new LinearLayout.LayoutParams(actionItem.getLayoutParams());
                 params.width = 0;
             } else {
                 params = new LinearLayout.LayoutParams(0, mRowHeight);
             }
 
-            if (actionItem instanceof MenuItemActionView) {
-                params.weight = ((MenuItemActionView) actionItem).getChildCount();
+            if (actionItem instanceof MenuItemSwitcherLayout) {
+                params.weight = ((MenuItemSwitcherLayout) actionItem).getChildCount();
             } else {
                 params.weight = 1.0f;
             }
 
             mWeightSum += params.weight;
 
             actionItem.setLayoutParams(params);
             addView(actionItem);
@@ -807,27 +807,27 @@ public class GeckoMenu extends ListView
 
             // Try to re-use the view.
             if (convertView == null && getItemViewType(position) == VIEW_TYPE_DEFAULT) {
                 view = new MenuItemDefault(parent.getContext(), null);
             } else {
                 view = (GeckoMenuItem.Layout) convertView;
             }
 
-            if (view == null || view instanceof MenuItemActionView) {
+            if (view == null || view instanceof MenuItemSwitcherLayout) {
                 // Always get from the menu item.
                 // This will ensure that the default activity is refreshed.
-                view = (MenuItemActionView) item.getActionView();
+                view = (MenuItemSwitcherLayout) item.getActionView();
 
                 // ListView will not perform an item click if the row has a focusable view in it.
                 // Hence, forward the click event on the menu item in the action-view to the ListView.
                 final View actionView = (View) view;
                 final int pos = position;
                 final long id = getItemId(position);
-                ((MenuItemActionView) view).setMenuItemClickListener(new View.OnClickListener() {
+                ((MenuItemSwitcherLayout) view).setMenuItemClickListener(new View.OnClickListener() {
                     @Override
                     public void onClick(View v) {
                         GeckoMenu listView = GeckoMenu.this;
                         listView.performItemClick(actionView, pos + listView.getHeaderViewsCount(), id);
                     }
                 });
             }
 
rename from mobile/android/base/menu/MenuItemActionView.java
rename to mobile/android/base/menu/MenuItemSwitcherLayout.java
--- a/mobile/android/base/menu/MenuItemActionView.java
+++ b/mobile/android/base/menu/MenuItemSwitcherLayout.java
@@ -15,34 +15,34 @@ import android.annotation.TargetApi;
 import android.content.Context;
 import android.graphics.drawable.Drawable;
 import android.util.AttributeSet;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.widget.ImageButton;
 import android.widget.LinearLayout;
 
-public class MenuItemActionView extends LinearLayout
-                                implements GeckoMenuItem.Layout,
-                                           View.OnClickListener {
+public class MenuItemSwitcherLayout extends LinearLayout
+                                    implements GeckoMenuItem.Layout,
+                                               View.OnClickListener {
     private final MenuItemDefault mMenuItem;
     private final MenuItemActionBar mMenuButton;
     private final List<ImageButton> mActionButtons;
     private final List<View.OnClickListener> mActionButtonListeners = new ArrayList<View.OnClickListener>();
 
-    public MenuItemActionView(Context context) {
+    public MenuItemSwitcherLayout(Context context) {
         this(context, null);
     }
 
-    public MenuItemActionView(Context context, AttributeSet attrs) {
+    public MenuItemSwitcherLayout(Context context, AttributeSet attrs) {
         this(context, attrs, R.attr.menuItemActionViewStyle);
     }
 
     @TargetApi(14)
-    public MenuItemActionView(Context context, AttributeSet attrs, int defStyle) {
+    public MenuItemSwitcherLayout(Context context, AttributeSet attrs, int defStyle) {
         super(context, attrs);
 
         LayoutInflater.from(context).inflate(R.layout.menu_item_action_view, this);
         mMenuItem = (MenuItemDefault) findViewById(R.id.menu_item);
         mMenuButton = (MenuItemActionBar) findViewById(R.id.menu_item_button);
         mActionButtons = new ArrayList<ImageButton>();
     }
 
--- a/mobile/android/base/moz.build
+++ b/mobile/android/base/moz.build
@@ -396,18 +396,18 @@ gbjar.sources += [
     'mdns/MulticastDNSManager.java',
     'MediaCastingBar.java',
     'MemoryMonitor.java',
     'menu/GeckoMenu.java',
     'menu/GeckoMenuInflater.java',
     'menu/GeckoMenuItem.java',
     'menu/GeckoSubMenu.java',
     'menu/MenuItemActionBar.java',
-    'menu/MenuItemActionView.java',
     'menu/MenuItemDefault.java',
+    'menu/MenuItemSwitcherLayout.java',
     'menu/MenuPanel.java',
     'menu/MenuPopup.java',
     'MotionEventInterceptor.java',
     'NotificationClient.java',
     'NotificationHandler.java',
     'NotificationHelper.java',
     'NotificationService.java',
     'NSSBridge.java',
--- a/mobile/android/base/prompts/PromptListAdapter.java
+++ b/mobile/android/base/prompts/PromptListAdapter.java
@@ -1,36 +1,29 @@
 package org.mozilla.gecko.prompts;
 
-import org.mozilla.gecko.GeckoAppShell;
 import org.mozilla.gecko.R;
 import org.mozilla.gecko.Telemetry;
 import org.mozilla.gecko.TelemetryContract;
-import org.mozilla.gecko.gfx.BitmapUtils;
-import org.mozilla.gecko.menu.MenuItemActionView;
+import org.mozilla.gecko.menu.MenuItemSwitcherLayout;
 import org.mozilla.gecko.widget.GeckoActionProvider;
 
-import org.json.JSONArray;
-import org.json.JSONObject;
-import org.json.JSONException;
-
 import android.content.Context;
 import android.content.Intent;
 import android.content.res.Resources;
 import android.graphics.drawable.Drawable;
 import android.graphics.Bitmap;
 import android.graphics.drawable.BitmapDrawable;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.CheckedTextView;
 import android.widget.TextView;
 import android.widget.ListView;
 import android.widget.ArrayAdapter;
-import android.widget.AdapterView;
 import android.util.TypedValue;
 
 import java.util.ArrayList;
 
 public class PromptListAdapter extends ArrayAdapter<PromptListItem> {
     private static final int VIEW_TYPE_ITEM = 0;
     private static final int VIEW_TYPE_GROUP = 1;
     private static final int VIEW_TYPE_ACTIONS = 2;
@@ -174,33 +167,33 @@ public class PromptListAdapter extends A
         }
         return -1;
     }
 
     private View getActionView(PromptListItem item, final ListView list, final int position) {
         final GeckoActionProvider provider = GeckoActionProvider.getForType(item.getIntent().getType(), getContext());
         provider.setIntent(item.getIntent());
 
-        final MenuItemActionView view = (MenuItemActionView) provider.onCreateActionView(
+        final MenuItemSwitcherLayout view = (MenuItemSwitcherLayout) provider.onCreateActionView(
                 GeckoActionProvider.ActionViewType.CONTEXT_MENU);
         // If a quickshare button is clicked, we need to close the dialog.
         view.addActionButtonClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
                 ListView.OnItemClickListener listener = list.getOnItemClickListener();
                 if (listener != null) {
                     listener.onItemClick(list, view, position, position);
                 }
             }
         });
 
         return view;
     }
 
-    private void updateActionView(final PromptListItem item, final MenuItemActionView view, final ListView list, final int position) {
+    private void updateActionView(final PromptListItem item, final MenuItemSwitcherLayout view, final ListView list, final int position) {
         view.setTitle(item.label);
         view.setIcon(item.getIcon());
         view.setSubMenuIndicator(item.isParent);
 
         // If the share button is clicked, we need to close the dialog and then show an intent chooser
         view.setMenuItemClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
@@ -255,17 +248,17 @@ public class PromptListAdapter extends A
 
                 convertView.setTag(viewHolder);
             }
         } else {
             viewHolder = (ViewHolder) convertView.getTag();
         }
 
         if (type == VIEW_TYPE_ACTIONS) {
-            updateActionView(item, (MenuItemActionView) convertView, (ListView) parent, position);
+            updateActionView(item, (MenuItemSwitcherLayout) convertView, (ListView) parent, position);
         } else {
             viewHolder.textView.setText(item.label);
             maybeUpdateCheckedState((ListView) parent, position, item, viewHolder);
             maybeUpdateIcon(item, viewHolder.textView);
         }
 
         return convertView;
     }
--- a/mobile/android/base/widget/GeckoActionProvider.java
+++ b/mobile/android/base/widget/GeckoActionProvider.java
@@ -5,18 +5,17 @@
 
 package org.mozilla.gecko.widget;
 
 import android.view.Menu;
 import org.mozilla.gecko.GeckoAppShell;
 import org.mozilla.gecko.R;
 import org.mozilla.gecko.Telemetry;
 import org.mozilla.gecko.TelemetryContract;
-import org.mozilla.gecko.menu.MenuItemActionView;
-import org.mozilla.gecko.overlays.ui.ShareDialog;
+import org.mozilla.gecko.menu.MenuItemSwitcherLayout;
 import org.mozilla.gecko.util.ThreadUtils;
 
 import android.content.Context;
 import android.content.Intent;
 import android.content.pm.PackageManager;
 import android.content.pm.ResolveInfo;
 import android.view.MenuItem;
 import android.view.MenuItem.OnMenuItemClickListener;
@@ -87,24 +86,24 @@ public class GeckoActionProvider {
     }
 
     /**
      * Creates the action view using the default history size.
      */
     public View onCreateActionView(final ActionViewType viewType) {
         // Create the view and set its data model.
         ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, mHistoryFileName);
-        final MenuItemActionView view;
+        final MenuItemSwitcherLayout view;
         switch (viewType) {
             case DEFAULT:
-                view = new MenuItemActionView(mContext, null);
+                view = new MenuItemSwitcherLayout(mContext, null);
                 break;
 
             case CONTEXT_MENU:
-                view = new MenuItemActionView(mContext, null);
+                view = new MenuItemSwitcherLayout(mContext, null);
                 view.initContextMenuStyles();
                 break;
 
             default:
                 throw new IllegalArgumentException(
                         "Unknown " + ActionViewType.class.getSimpleName() + ": " + viewType);
         }
         view.addActionButtonClickListener(mCallbacks);