Bug 880118 - Android resource IDs must be mutable for library projects. r=cpeterson
authorShane Tully <stully@mozilla.com>
Tue, 13 Aug 2013 16:44:00 -0700
changeset 150556 a3cc1c802366567a91fead5b5bd234efa719bfc9
parent 150555 d17e4a0cba942c657dba3a72a2e375c0ff5d2c7b
child 150557 2937f4dc01f967a78fcc386bc045338abe842fc7
push idunknown
push userunknown
push dateunknown
reviewerscpeterson
bugs880118
milestone26.0a1
Bug 880118 - Android resource IDs must be mutable for library projects. r=cpeterson
mobile/android/base/AwesomeBar.java
mobile/android/base/BrowserApp.java
mobile/android/base/FindInPageBar.java
mobile/android/base/GeckoApp.java
mobile/android/base/Makefile.in
mobile/android/base/widget/AboutHome.java
--- a/mobile/android/base/AwesomeBar.java
+++ b/mobile/android/base/AwesomeBar.java
@@ -516,131 +516,134 @@ public class AwesomeBar extends GeckoAct
 
         final int id = mContextMenuSubject.id;
         final String url = mContextMenuSubject.url;
         final byte[] b = mContextMenuSubject.favicon;
         final String title = mContextMenuSubject.title;
         final String keyword = mContextMenuSubject.keyword;
         final int display = mContextMenuSubject.display;
 
-        switch (item.getItemId()) {
-            case R.id.open_private_tab:
-            case R.id.open_new_tab: {
-                if (url == null) {
-                    Log.e(LOGTAG, "Can't open in new tab because URL is null");
-                    break;
+        final int itemId = item.getItemId();
+        if (itemId == R.id.open_private_tab || itemId == R.id.open_new_tab) {
+            if (url == null) {
+                Log.e(LOGTAG, "Can't open in new tab because URL is null");
+            }
+
+            String newTabUrl = url;
+            if (display == Combined.DISPLAY_READER)
+                newTabUrl = ReaderModeUtils.getAboutReaderForUrl(url, true);
+
+            int flags = Tabs.LOADURL_NEW_TAB;
+            if (item.getItemId() == R.id.open_private_tab)
+                flags |= Tabs.LOADURL_PRIVATE;
+
+            Tabs.getInstance().loadUrl(newTabUrl, flags);
+            Toast.makeText(this, R.string.new_tab_opened, Toast.LENGTH_SHORT).show();
+
+            return true;
+        }
+
+        if (itemId == R.id.open_in_reader) {
+            if (url == null) {
+                Log.e(LOGTAG, "Can't open in reader mode because URL is null");
+            } else {
+                openUrlAndFinish(ReaderModeUtils.getAboutReaderForUrl(url, true));
+            }
+            return true;
+        }
+
+        if (itemId == R.id.edit_bookmark) {
+            new EditBookmarkDialog(this).show(id, title, url, keyword);
+            return true;
+        }
+
+        if (itemId == R.id.remove_bookmark) {
+            (new UiAsyncTask<Void, Void, Integer>(ThreadUtils.getBackgroundHandler()) {
+                private boolean mInReadingList;
+
+                @Override
+                public void onPreExecute() {
+                    mInReadingList = mAwesomeTabs.isInReadingList();
                 }
 
-                String newTabUrl = url;
-                if (display == Combined.DISPLAY_READER)
-                    newTabUrl = ReaderModeUtils.getAboutReaderForUrl(url, true);
-
-                int flags = Tabs.LOADURL_NEW_TAB;
-                if (item.getItemId() == R.id.open_private_tab)
-                    flags |= Tabs.LOADURL_PRIVATE;
+                @Override
+                public Integer doInBackground(Void... params) {
+                    BrowserDB.removeBookmark(getContentResolver(), id);
+                    Integer count = mInReadingList ?
+                        BrowserDB.getReadingListCount(getContentResolver()) : 0;
 
-                Tabs.getInstance().loadUrl(newTabUrl, flags);
-                Toast.makeText(this, R.string.new_tab_opened, Toast.LENGTH_SHORT).show();
-                break;
-            }
-            case R.id.open_in_reader: {
-                if (url == null) {
-                    Log.e(LOGTAG, "Can't open in reader mode because URL is null");
-                    break;
+                    return count;
                 }
 
-                openUrlAndFinish(ReaderModeUtils.getAboutReaderForUrl(url, true));
-                break;
-            }
-            case R.id.edit_bookmark: {
-                new EditBookmarkDialog(this).show(id, title, url, keyword);
-                break;
-            }
-            case R.id.remove_bookmark: {
-                (new UiAsyncTask<Void, Void, Integer>(ThreadUtils.getBackgroundHandler()) {
-                    private boolean mInReadingList;
+                @Override
+                public void onPostExecute(Integer aCount) {
+                    int messageId = R.string.bookmark_removed;
+                    if (mInReadingList) {
+                        messageId = R.string.reading_list_removed;
 
-                    @Override
-                    public void onPreExecute() {
-                        mInReadingList = mAwesomeTabs.isInReadingList();
+                        GeckoEvent e = GeckoEvent.createBroadcastEvent("Reader:Remove", url);
+                        GeckoAppShell.sendEventToGecko(e);
+
+                        // Delete from Awesomebar context menu can alter reading list bookmark count
+                        e = GeckoEvent.createBroadcastEvent("Reader:ListCountUpdated", Integer.toString(aCount));
+                        GeckoAppShell.sendEventToGecko(e);
                     }
 
-                    @Override
-                    public Integer doInBackground(Void... params) {
-                        BrowserDB.removeBookmark(getContentResolver(), id);
-                        Integer count = mInReadingList ?
-                            BrowserDB.getReadingListCount(getContentResolver()) : 0;
-
-                        return count;
-                    }
+                    Toast.makeText(AwesomeBar.this, messageId, Toast.LENGTH_SHORT).show();
+                }
+            }).execute();
 
-                    @Override
-                    public void onPostExecute(Integer aCount) {
-                        int messageId = R.string.bookmark_removed;
-                        if (mInReadingList) {
-                            messageId = R.string.reading_list_removed;
-
-                            GeckoEvent e = GeckoEvent.createBroadcastEvent("Reader:Remove", url);
-                            GeckoAppShell.sendEventToGecko(e);
-
-                            // Delete from Awesomebar context menu can alter reading list bookmark count
-                            e = GeckoEvent.createBroadcastEvent("Reader:ListCountUpdated", Integer.toString(aCount));
-                            GeckoAppShell.sendEventToGecko(e);
-                        }
+            return true;
+        }
 
-                        Toast.makeText(AwesomeBar.this, messageId, Toast.LENGTH_SHORT).show();
-                    }
-                }).execute();
-                break;
-            }
-            case R.id.remove_history: {
-                (new UiAsyncTask<Void, Void, Void>(ThreadUtils.getBackgroundHandler()) {
-                    @Override
-                    public Void doInBackground(Void... params) {
-                        BrowserDB.removeHistoryEntry(getContentResolver(), id);
-                        return null;
-                    }
-
-                    @Override
-                    public void onPostExecute(Void result) {
-                        Toast.makeText(AwesomeBar.this, R.string.history_removed, Toast.LENGTH_SHORT).show();
-                    }
-                }).execute();
-                break;
-            }
-            case R.id.add_to_launcher: {
-                if (url == null) {
-                    Log.e(LOGTAG, "Can't add to home screen because URL is null");
-                    break;
+        if (itemId == R.id.remove_history) {
+            (new UiAsyncTask<Void, Void, Void>(ThreadUtils.getBackgroundHandler()) {
+                @Override
+                public Void doInBackground(Void... params) {
+                    BrowserDB.removeHistoryEntry(getContentResolver(), id);
+                    return null;
                 }
 
+                @Override
+                public void onPostExecute(Void result) {
+                    Toast.makeText(AwesomeBar.this, R.string.history_removed, Toast.LENGTH_SHORT).show();
+                }
+            }).execute();
+
+            return true;
+        }
+
+        if (itemId == R.id.add_to_launcher) {
+            if (url == null) {
+                Log.e(LOGTAG, "Can't add to home screen because URL is null");
+            } else {
                 Bitmap bitmap = null;
                 if (b != null) {
                     bitmap = BitmapUtils.decodeByteArray(b);
                 }
 
                 String shortcutTitle = TextUtils.isEmpty(title) ? url.replaceAll("^([a-z]+://)?(www\\.)?", "") : title;
                 GeckoAppShell.createShortcut(shortcutTitle, url, bitmap, "");
-                break;
             }
-            case R.id.share: {
-                if (url == null) {
-                    Log.e(LOGTAG, "Can't share because URL is null");
-                    break;
-                }
+
+            return true;
+        }
 
+        if (itemId == R.id.share) {
+            if (url == null) {
+                Log.e(LOGTAG, "Can't share because URL is null");
+            } else {
                 GeckoAppShell.openUriExternal(url, "text/plain", "", "",
                                               Intent.ACTION_SEND, title);
-                break;
             }
-            default: {
-                return super.onContextItemSelected(item);
-            }
+
+            return true;
         }
-        return true;
+
+        return super.onContextItemSelected(item);
     }
 
     public static String getReaderForUrl(String url) {
         // FIXME: still need to define the final way to open items from
         // reading list. For now, we're using an about:reader page.
         return "about:reader?url=" + Uri.encode(url) + "&readingList=1";
     }
 
--- a/mobile/android/base/BrowserApp.java
+++ b/mobile/android/base/BrowserApp.java
@@ -609,83 +609,89 @@ abstract public class BrowserApp extends
 
     @Override
     public boolean onSearchRequested() {
         return showAwesomebar(AwesomeBar.Target.CURRENT_TAB);
     }
 
     @Override
     public boolean onContextItemSelected(MenuItem item) {
-        switch(item.getItemId()) {
-            case R.id.pasteandgo: {
-                String text = Clipboard.getText();
-                if (!TextUtils.isEmpty(text)) {
-                    Tabs.getInstance().loadUrl(text);
-                }
-                return true;
-            }
-            case R.id.site_settings: {
-                GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Permissions:Get", null));
-                return true;
+        final int itemId = item.getItemId();
+        if (itemId == R.id.pasteandgo) {
+            String text = Clipboard.getText();
+            if (!TextUtils.isEmpty(text)) {
+                Tabs.getInstance().loadUrl(text);
             }
-            case R.id.paste: {
-                String text = Clipboard.getText();
-                if (!TextUtils.isEmpty(text)) {
-                    showAwesomebar(AwesomeBar.Target.CURRENT_TAB, text);
-                }
-                return true;
-            }
-            case R.id.share: {
-                shareCurrentUrl();
-                return true;
+            return true;
+        }
+
+        if (itemId == R.id.site_settings) {
+            GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Permissions:Get", null));
+            return true;
+        }
+
+        if (itemId == R.id.paste) {
+            String text = Clipboard.getText();
+            if (!TextUtils.isEmpty(text)) {
+                showAwesomebar(AwesomeBar.Target.CURRENT_TAB, text);
             }
-            case R.id.subscribe: {
-                Tab tab = Tabs.getInstance().getSelectedTab();
-                if (tab != null && tab.getFeedsEnabled()) {
-                    JSONObject args = new JSONObject();
-                    try {
-                        args.put("tabId", tab.getId());
-                    } catch (JSONException e) {
-                        Log.e(LOGTAG, "error building json arguments");
-                    }
-                    GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Feeds:Subscribe", args.toString()));
+            return true;
+        }
+
+        if (itemId == R.id.share) {
+            shareCurrentUrl();
+            return true;
+        }
+
+        if (itemId == R.id.subscribe) {
+            Tab tab = Tabs.getInstance().getSelectedTab();
+            if (tab != null && tab.getFeedsEnabled()) {
+                JSONObject args = new JSONObject();
+                try {
+                    args.put("tabId", tab.getId());
+                } catch (JSONException e) {
+                    Log.e(LOGTAG, "error building json arguments");
                 }
-                return true;
+                GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Feeds:Subscribe", args.toString()));
             }
-            case R.id.copyurl: {
-                Tab tab = Tabs.getInstance().getSelectedTab();
-                if (tab != null) {
-                    String url = tab.getURL();
-                    if (url != null) {
-                        Clipboard.setText(url);
-                    }
+            return true;
+        }
+
+        if (itemId == R.id.copyurl) {
+            Tab tab = Tabs.getInstance().getSelectedTab();
+            if (tab != null) {
+                String url = tab.getURL();
+                if (url != null) {
+                    Clipboard.setText(url);
                 }
-                return true;
             }
-            case R.id.add_to_launcher: {
-                Tab tab = Tabs.getInstance().getSelectedTab();
-                if (tab != null) {
-                    final String url = tab.getURL();
-                    final String title = tab.getDisplayTitle();
-                    if (url == null || title == null) {
-                        return true;
-                    }
+            return true;
+        }
+
+        if (itemId == R.id.add_to_launcher) {
+            Tab tab = Tabs.getInstance().getSelectedTab();
+            if (tab != null) {
+                final String url = tab.getURL();
+                final String title = tab.getDisplayTitle();
+                if (url == null || title == null) {
+                    return true;
+                }
 
-                    Favicons favicons = Favicons.getInstance();
-                    favicons.loadFavicon(url, tab.getFaviconURL(), 0,
-                    new Favicons.OnFaviconLoadedListener() {
-                        @Override
-                        public void onFaviconLoaded(String url, Bitmap favicon) {
-                            GeckoAppShell.createShortcut(title, url, url, favicon == null ? null : favicon, "");
-                        }
-                    });
-                }
-                return true;
+                Favicons favicons = Favicons.getInstance();
+                favicons.loadFavicon(url, tab.getFaviconURL(), 0,
+                new Favicons.OnFaviconLoadedListener() {
+                    @Override
+                    public void onFaviconLoaded(String url, Bitmap favicon) {
+                        GeckoAppShell.createShortcut(title, url, url, favicon == null ? null : favicon, "");
+                    }
+                });
             }
+            return true;
         }
+
         return false;
     }
 
     public boolean showAwesomebar(AwesomeBar.Target aTarget) {
         return showAwesomebar(aTarget, null);
     }
 
     public boolean showAwesomebar(AwesomeBar.Target aTarget, String aUrl) {
@@ -1714,106 +1720,138 @@ abstract public class BrowserApp extends
 
         return true;
     }
 
     @Override
     public boolean onOptionsItemSelected(MenuItem item) {
         Tab tab = null;
         Intent intent = null;
-        switch (item.getItemId()) {
-            case R.id.bookmark:
-                tab = Tabs.getInstance().getSelectedTab();
-                if (tab != null) {
-                    if (item.isChecked()) {
-                        tab.removeBookmark();
-                        Toast.makeText(this, R.string.bookmark_removed, Toast.LENGTH_SHORT).show();
-                        item.setIcon(R.drawable.ic_menu_bookmark_add);
-                    } else {
-                        tab.addBookmark();
-                        mToast.show(false,
-                            getResources().getString(R.string.bookmark_added),
-                            getResources().getString(R.string.bookmark_options),
-                            null,
-                            new ButtonToast.ToastListener() {
-                                @Override
-                                public void onButtonClicked() {
-                                    showBookmarkDialog();
-                                }
+
+        final int itemId = item.getItemId();
+
+        if (itemId == R.id.bookmark) {
+            tab = Tabs.getInstance().getSelectedTab();
+            if (tab != null) {
+                if (item.isChecked()) {
+                    tab.removeBookmark();
+                    Toast.makeText(this, R.string.bookmark_removed, Toast.LENGTH_SHORT).show();
+                    item.setIcon(R.drawable.ic_menu_bookmark_add);
+                } else {
+                    tab.addBookmark();
+                    mToast.show(false,
+                        getResources().getString(R.string.bookmark_added),
+                        getResources().getString(R.string.bookmark_options),
+                        null,
+                        new ButtonToast.ToastListener() {
+                            @Override
+                            public void onButtonClicked() {
+                                showBookmarkDialog();
+                            }
+
+                            @Override
+                            public void onToastHidden(ButtonToast.ReasonHidden reason) { }
+                        });
+                    item.setIcon(R.drawable.ic_menu_bookmark_remove);
+                }
+            }
+            return true;
+        }
+
+        if (itemId == R.id.share) {
+            shareCurrentUrl();
+            return true;
+        }
+
+        if (itemId == R.id.reload) {
+            tab = Tabs.getInstance().getSelectedTab();
+            if (tab != null)
+                tab.doReload();
+            return true;
+        }
 
-                                @Override
-                                public void onToastHidden(ButtonToast.ReasonHidden reason) { }
-                            });
-                        item.setIcon(R.drawable.ic_menu_bookmark_remove);
-                    }
-                }
-                return true;
-            case R.id.share:
-                shareCurrentUrl();
-                return true;
-            case R.id.reload:
-                tab = Tabs.getInstance().getSelectedTab();
-                if (tab != null)
-                    tab.doReload();
-                return true;
-            case R.id.forward:
-                tab = Tabs.getInstance().getSelectedTab();
-                if (tab != null)
-                    tab.doForward();
-                return true;
-            case R.id.save_as_pdf:
-                GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("SaveAs:PDF", null));
+        if (itemId == R.id.forward) {
+            tab = Tabs.getInstance().getSelectedTab();
+            if (tab != null)
+                tab.doForward();
+            return true;
+        }
+
+        if (itemId == R.id.save_as_pdf) {
+            GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("SaveAs:PDF", null));
+            return true;
+        }
+
+        if (itemId == R.id.settings) {
+            intent = new Intent(this, GeckoPreferences.class);
+            startActivity(intent);
+            return true;
+        }
+
+        if (itemId == R.id.addons) {
+            Tabs.getInstance().loadUrlInTab("about:addons");
+            return true;
+        }
+
+        if (itemId == R.id.downloads) {
+            Tabs.getInstance().loadUrlInTab("about:downloads");
+            return true;
+        }
+
+        if (itemId == R.id.apps) {
+            Tabs.getInstance().loadUrlInTab("about:apps");
+            return true;
+        }
+
+        if (itemId == R.id.char_encoding) {
+            GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("CharEncoding:Get", null));
+            return true;
+        }
+
+        if (itemId == R.id.find_in_page) {
+            mFindInPageBar.show();
+            return true;
+        }
+
+        if (itemId == R.id.desktop_mode) {
+            Tab selectedTab = Tabs.getInstance().getSelectedTab();
+            if (selectedTab == null)
                 return true;
-            case R.id.settings:
-                intent = new Intent(this, GeckoPreferences.class);
-                startActivity(intent);
-                return true;
-            case R.id.addons:
-                Tabs.getInstance().loadUrlInTab("about:addons");
-                return true;
-            case R.id.downloads:
-                Tabs.getInstance().loadUrlInTab("about:downloads");
-                return true;
-            case R.id.apps:
-                Tabs.getInstance().loadUrlInTab("about:apps");
-                return true;
-            case R.id.char_encoding:
-                GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("CharEncoding:Get", null));
-                return true;
-            case R.id.find_in_page:
-                mFindInPageBar.show();
-                return true;
-            case R.id.desktop_mode:
-                Tab selectedTab = Tabs.getInstance().getSelectedTab();
-                if (selectedTab == null)
-                    return true;
-                JSONObject args = new JSONObject();
-                try {
-                    args.put("desktopMode", !item.isChecked());
-                    args.put("tabId", selectedTab.getId());
-                } catch (JSONException e) {
-                    Log.e(LOGTAG, "error building json arguments");
-                }
-                GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("DesktopMode:Change", args.toString()));
-                return true;
-            case R.id.new_tab:
-                addTab();
-                return true;
-            case R.id.new_private_tab:
-                addPrivateTab();
-                return true;
-            case R.id.new_guest_session:
-                showGuestModeDialog(GuestModeDialog.ENTERING);
-                return true;
-            case R.id.exit_guest_session:
-                showGuestModeDialog(GuestModeDialog.LEAVING);
-                return true;
-            default:
-                return super.onOptionsItemSelected(item);
+            JSONObject args = new JSONObject();
+            try {
+                args.put("desktopMode", !item.isChecked());
+                args.put("tabId", selectedTab.getId());
+            } catch (JSONException e) {
+                Log.e(LOGTAG, "error building json arguments");
+            }
+            GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("DesktopMode:Change", args.toString()));
+            return true;
+        }
+
+        if (itemId == R.id.new_tab) {
+            addTab();
+            return true;
         }
+
+        if (itemId == R.id.new_private_tab) {
+            addPrivateTab();
+            return true;
+        }
+
+        if (itemId == R.id.new_guest_session) {
+            showGuestModeDialog(GuestModeDialog.ENTERING);
+            return true;
+        }
+
+        if (itemId == R.id.exit_guest_session) {
+            showGuestModeDialog(GuestModeDialog.LEAVING);
+            return true;
+        }
+
+        return super.onOptionsItemSelected(item);
     }
 
     private void showGuestModeDialog(final GuestModeDialog type) {
         final Prompt ps = new Prompt(this, new Prompt.PromptCallback() {
             @Override
             public void onPromptFinished(String result) {
                 try {
                     int itemId = new JSONObject(result).getInt("button");
--- a/mobile/android/base/FindInPageBar.java
+++ b/mobile/android/base/FindInPageBar.java
@@ -104,28 +104,32 @@ public class FindInPageBar extends Linea
     public void onTextChanged(CharSequence s, int start, int before, int count) {
         // ignore
     }
 
     // View.OnClickListener implementation
 
     @Override
     public void onClick(View v) {
-        switch (v.getId()) {
-            case R.id.find_prev:
-                GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("FindInPage:Prev", mFindText.getText().toString()));
-                getInputMethodManager(mFindText).hideSoftInputFromWindow(mFindText.getWindowToken(), 0);
-                break;
-            case R.id.find_next:
-                GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("FindInPage:Next", mFindText.getText().toString()));
-                getInputMethodManager(mFindText).hideSoftInputFromWindow(mFindText.getWindowToken(), 0);
-                break;
-            case R.id.find_close:
-                hide();
-                break;
+        final int viewId = v.getId();
+
+        if (viewId == R.id.find_prev) {
+            GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("FindInPage:Prev", mFindText.getText().toString()));
+            getInputMethodManager(mFindText).hideSoftInputFromWindow(mFindText.getWindowToken(), 0);
+            return;
+        }
+
+        if (viewId == R.id.find_next) {
+            GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("FindInPage:Next", mFindText.getText().toString()));
+            getInputMethodManager(mFindText).hideSoftInputFromWindow(mFindText.getWindowToken(), 0);
+            return;
+        }
+
+        if (viewId == R.id.find_close) {
+            hide();
         }
     }
 
     // GeckoEventListener implementation
 
     @Override
     public void handleMessage(String event, JSONObject message) {
         if (!event.equals("TextSelection:Data") || !REQUEST_ID.equals(message.optString("requestId"))) {
--- a/mobile/android/base/GeckoApp.java
+++ b/mobile/android/base/GeckoApp.java
@@ -447,27 +447,26 @@ abstract public class GeckoApp
             return true;
         }
 
         return super.onMenuOpened(featureId, menu);
     }
 
     @Override
     public boolean onOptionsItemSelected(MenuItem item) {
-        switch (item.getItemId()) {
-            case R.id.quit:
-                if (GeckoThread.checkAndSetLaunchState(GeckoThread.LaunchState.GeckoRunning, GeckoThread.LaunchState.GeckoExiting)) {
-                    GeckoAppShell.notifyGeckoOfEvent(GeckoEvent.createBroadcastEvent("Browser:Quit", null));
-                } else {
-                    System.exit(0);
-                }
-                return true;
-            default:
-                return super.onOptionsItemSelected(item);
+        if (item.getItemId() == R.id.quit) {
+            if (GeckoThread.checkAndSetLaunchState(GeckoThread.LaunchState.GeckoRunning, GeckoThread.LaunchState.GeckoExiting)) {
+                GeckoAppShell.notifyGeckoOfEvent(GeckoEvent.createBroadcastEvent("Browser:Quit", null));
+            } else {
+                System.exit(0);
+            }
+            return true;
         }
+
+        return super.onOptionsItemSelected(item);
     }
 
     @Override
     public void onOptionsMenuClosed(Menu menu) {
         if (Build.VERSION.SDK_INT >= 11) {
             mMenuPanel.removeAllViews();
             mMenuPanel.addView((GeckoMenu) mMenu);
         }
--- a/mobile/android/base/Makefile.in
+++ b/mobile/android/base/Makefile.in
@@ -1374,17 +1374,17 @@ all_resources = \
   res/values/strings.xml \
   $(MULTILOCALE_STRINGS_XML_FILES) \
   AndroidManifest.xml \
   $(RESOURCES) \
   $(PP_RES_XML) \
   $(NULL)
 
 R.java: $(all_resources)
-	$(AAPT) package -f -M AndroidManifest.xml -I $(ANDROID_SDK)/android.jar -S res -J . --custom-package org.mozilla.gecko
+	$(AAPT) package -f -M AndroidManifest.xml -I $(ANDROID_SDK)/android.jar -S res -J . --custom-package org.mozilla.gecko --non-constant-id
 
 gecko.ap_: $(all_resources)
 	$(AAPT) package -f -M AndroidManifest.xml -I $(ANDROID_SDK)/android.jar  -S res -F $@
 
 fennec_ids.txt: fennec-ids-generator.py R.java
 	$(PYTHON) $(topsrcdir)/mobile/android/base/fennec-ids-generator.py -i R.java -o $@
 
 libs:: classes.dex package-name.txt jni-stubs.inc fennec_ids.txt
--- a/mobile/android/base/widget/AboutHome.java
+++ b/mobile/android/base/widget/AboutHome.java
@@ -184,38 +184,43 @@ public class AboutHome extends Fragment 
     @Override
     public boolean onContextItemSelected(MenuItem item) {
         ContextMenuInfo info = item.getMenuInfo();
 
         if (getView() == null) {
             return true;
         }
 
-        switch (item.getItemId()) {
-            case R.id.abouthome_open_new_tab:
-                mTopSitesView.openNewTab(info);
-                return true;
+        final int itemId = item.getItemId();
 
-            case R.id.abouthome_open_private_tab:
-                mTopSitesView.openNewPrivateTab(info);
-                return true;
+        if (itemId == R.id.abouthome_open_new_tab) {
+            mTopSitesView.openNewTab(info);
+            return true;
+        }
+
+        if (itemId == R.id.abouthome_open_private_tab) {
+            mTopSitesView.openNewPrivateTab(info);
+            return true;
+        }
 
-            case R.id.abouthome_topsites_edit:
-                mTopSitesView.editSite(info);
-                return true;
+        if (itemId == R.id.abouthome_topsites_edit) {
+            mTopSitesView.editSite(info);
+            return true;
+        }
 
-            case R.id.abouthome_topsites_unpin:
-                mTopSitesView.unpinSite(info, TopSitesView.UnpinFlags.REMOVE_PIN);
-                return true;
+        if (itemId == R.id.abouthome_topsites_unpin) {
+            mTopSitesView.unpinSite(info, TopSitesView.UnpinFlags.REMOVE_PIN);
+            return true;
+        }
 
-            case R.id.abouthome_topsites_pin:
-                mTopSitesView.pinSite(info);
-                return true;
+        if (itemId == R.id.abouthome_topsites_pin) {
+            mTopSitesView.pinSite(info);
+            return true;
+        }
 
-        }
         return super.onContextItemSelected(item);
     }
 
     public void update(final EnumSet<UpdateFlags> flags) {
         if (getView() == null) {
             return;
         }