Bug 760267: Using proper naming convention for non-static menu variable. r=mfinkle r=blassey
authorSriram Ramasubramanian <sriram@mozilla.com>
Wed, 13 Jun 2012 13:28:00 -0700
changeset 96641 880f30ecdf6bb7fcd8ea96e07adc1e461e0728bb
parent 96640 34f233d3d770dfcf0edeac91c7266e9be1e1ccd4
child 96642 8cf5423b021396e96c096443431e0e0b0f0c6d69
push id10644
push userryanvm@gmail.com
push dateThu, 14 Jun 2012 01:13:01 +0000
treeherdermozilla-inbound@13f46ad244fc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle, blassey
bugs760267
milestone16.0a1
first release with
nightly linux32
880f30ecdf6b / 16.0a1 / 20120613165914 / files
nightly linux64
880f30ecdf6b / 16.0a1 / 20120613165914 / files
nightly mac
880f30ecdf6b / 16.0a1 / 20120613165914 / files
nightly win32
880f30ecdf6b / 16.0a1 / 20120613165914 / files
nightly win64
880f30ecdf6b / 16.0a1 / 20120613165914 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 760267: Using proper naming convention for non-static menu variable. r=mfinkle r=blassey
mobile/android/base/BrowserApp.java
mobile/android/base/GeckoApp.java
--- a/mobile/android/base/BrowserApp.java
+++ b/mobile/android/base/BrowserApp.java
@@ -493,24 +493,24 @@ abstract public class BrowserApp extends
                 findViewById(R.id.abouthome_content).setVisibility(View.GONE);
             }
         } 
     }
 
     @Override
     public boolean onCreateOptionsMenu(Menu menu)
     {
-        sMenu = menu;
+        mMenu = menu;
 
         // Inform the menu about the action-items bar. 
         if (menu instanceof GeckoMenu && isTablet())
             ((GeckoMenu) menu).setActionItemBarPresenter(mBrowserToolbar);
 
         MenuInflater inflater = getMenuInflater();
-        inflater.inflate(R.menu.gecko_menu, sMenu);
+        inflater.inflate(R.menu.gecko_menu, mMenu);
         return true;
     }
 
     @Override
     public void openOptionsMenu() {
         // Scroll custom menu to the top
         if (mMenuPanel != null)
             mMenuPanel.scrollTo(0, 0);
--- a/mobile/android/base/GeckoApp.java
+++ b/mobile/android/base/GeckoApp.java
@@ -88,17 +88,17 @@ abstract public class GeckoApp
     StartupMode mStartupMode = null;
     protected LinearLayout mMainLayout;
     protected RelativeLayout mGeckoLayout;
     public View getView() { return mGeckoLayout; }
     public static SurfaceView cameraView;
     public static GeckoApp mAppContext;
     public static boolean mDOMFullScreen = false;
     protected MenuPanel mMenuPanel;
-    public Menu sMenu;
+    protected Menu mMenu;
     private static GeckoThread sGeckoThread = null;
     public Handler mMainHandler;
     private GeckoProfile mProfile;
     public static boolean sIsGeckoReady = false;
     public static int mOrientation;
 
     private GeckoConnectivityReceiver mConnectivityReceiver;
     private GeckoBatteryManager mBatteryReceiver;
@@ -405,20 +405,20 @@ abstract public class GeckoApp
         Context pluginContext = mAppContext.createPackageContext(packageName,
                 Context.CONTEXT_INCLUDE_CODE |
                 Context.CONTEXT_IGNORE_SECURITY);
         ClassLoader pluginCL = pluginContext.getClassLoader();
         return pluginCL.loadClass(className);
     }
 
     private void addAddonMenuItem(final int id, final String label, final String icon) {
-        if (sMenu == null)
+        if (mMenu == null)
             return;
 
-        final MenuItem item = sMenu.add(Menu.NONE, id, Menu.NONE, label);
+        final MenuItem item = mMenu.add(Menu.NONE, id, Menu.NONE, label);
 
         item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
             @Override
             public boolean onMenuItemClick(MenuItem item) {
                 Log.i(LOGTAG, "menu item clicked");
                 GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Menu:Clicked", Integer.toString(id)));
                 ((Activity) GeckoApp.mAppContext).closeOptionsMenu();
                 return true;
@@ -450,52 +450,55 @@ abstract public class GeckoApp
         sAddonMenuItems.add(item);
     }
 
     private void removeAddonMenuItem(int id) {
         for (MenuItem item : sAddonMenuItems) {
             if (item.getItemId() == id) {
                 sAddonMenuItems.remove(item);
 
-                if (sMenu == null)
+                if (mMenu == null)
                     break;
 
-                MenuItem menuItem = sMenu.findItem(id);
+                MenuItem menuItem = mMenu.findItem(id);
                 if (menuItem != null)
-                    sMenu.removeItem(id);
+                    mMenu.removeItem(id);
 
                 break;
             }
         }
     }
 
     @Override
     public void invalidateOptionsMenu() {
-        if (sMenu == null)
+        if (mMenu == null)
             return;
 
-        onPrepareOptionsMenu(sMenu);
+        onPrepareOptionsMenu(mMenu);
 
         if (Build.VERSION.SDK_INT >= 11)
             super.invalidateOptionsMenu();
     }
 
     @Override
     public boolean onCreateOptionsMenu(Menu menu)
     {
-        sMenu = menu;
+        mMenu = menu;
 
         MenuInflater inflater = getMenuInflater();
-        inflater.inflate(R.menu.gecko_menu, sMenu);
+        inflater.inflate(R.menu.gecko_menu, mMenu);
         return true;
     }
 
     @Override
     public boolean onPrepareOptionsMenu(Menu aMenu)
     {
+        if (aMenu == null)
+            return false;
+
         if (!sIsGeckoReady)
             aMenu.findItem(R.id.settings).setEnabled(false);
 
         Tab tab = Tabs.getInstance().getSelectedTab();
         MenuItem bookmark = aMenu.findItem(R.id.bookmark);
         MenuItem forward = aMenu.findItem(R.id.forward);
         MenuItem share = aMenu.findItem(R.id.share);
         MenuItem saveAsPDF = aMenu.findItem(R.id.save_as_pdf);
@@ -585,17 +588,17 @@ abstract public class GeckoApp
 
     @Override
     public View onCreatePanelView(int featureId) {
         if (Build.VERSION.SDK_INT >= 11 && featureId == Window.FEATURE_OPTIONS_PANEL) {
             if (mMenuPanel == null) {
                 mMenuPanel = new MenuPanel(mAppContext, null);
             } else {
                 // Prepare the panel everytime before showing the menu.
-                onPreparePanel(featureId, mMenuPanel, sMenu);
+                onPreparePanel(featureId, mMenuPanel, mMenu);
             }
 
             return mMenuPanel; 
         }
   
         return super.onCreatePanelView(featureId);
     }
 
@@ -622,19 +625,19 @@ abstract public class GeckoApp
             return onPrepareOptionsMenu(menu);
 
         return super.onPreparePanel(featureId, view, menu);
     }
 
     @Override
     public boolean onMenuOpened(int featureId, Menu menu) {
         if (Build.VERSION.SDK_INT >= 11 && featureId == Window.FEATURE_OPTIONS_PANEL) {
-            if (sMenu == null) {
+            if (mMenu == null) {
                 onCreatePanelMenu(featureId, menu);
-                onPreparePanel(featureId, mMenuPanel, sMenu);
+                onPreparePanel(featureId, mMenuPanel, mMenu);
             }
 
             // Scroll custom menu to the top
             if (mMenuPanel != null)
                 mMenuPanel.scrollTo(0, 0);
 
             return true;
         }
@@ -1024,17 +1027,17 @@ abstract public class GeckoApp
                 final int tabId = message.getInt("tabID");
                 handlePageShow(tabId);
             } else if (event.equals("Doorhanger:Add")) {
                 handleDoorHanger(message);
             } else if (event.equals("Doorhanger:Remove")) {
                 handleDoorHangerRemove(message);
             } else if (event.equals("Gecko:Ready")) {
                 sIsGeckoReady = true;
-                final Menu menu = sMenu;
+                final Menu menu = mMenu;
                 mMainHandler.post(new Runnable() {
                     public void run() {
                         if (menu != null)
                             menu.findItem(R.id.settings).setEnabled(true);
                     }
                 });
                 setLaunchState(GeckoApp.LaunchState.GeckoRunning);
                 GeckoAppShell.sendPendingEventsToGecko();
@@ -1084,17 +1087,17 @@ abstract public class GeckoApp
                 mMainHandler.post(new Runnable() {
                     public void run() {
                         dialogBuilder.show();
                     }
                 });
             } else if (event.equals("CharEncoding:State")) {
                 final boolean visible = message.getString("visible").equals("true");
                 GeckoPreferences.setCharEncodingState(visible);
-                final Menu menu = sMenu;
+                final Menu menu = mMenu;
                 mMainHandler.post(new Runnable() {
                     public void run() {
                         if (menu != null)
                             menu.findItem(R.id.char_encoding).setVisible(visible);
                     }
                 });
             } else if (event.equals("Update:Restart")) {
                 doRestart("org.mozilla.gecko.restart_update");