Bug 1401871 - Check if menu item(home_add_to_launcher) exists or not before accessing it. r=nechen
authorJing-wei Wu <topwu.tw@gmail.com>
Tue, 26 Sep 2017 16:12:15 +0800
changeset 433816 6282e18a63f6161198bc5f1c0c4a450aea132f9d
parent 433815 59596c38ba70cb3b1c3a93d082964b70b64b870b
child 433817 4741b93cfdf29517ff8eae863825fdc2ab5bd7bd
push id8114
push userjlorenzo@mozilla.com
push dateThu, 02 Nov 2017 16:33:21 +0000
treeherdermozilla-beta@73e0d89a540f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnechen
bugs1401871
milestone58.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 1401871 - Check if menu item(home_add_to_launcher) exists or not before accessing it. r=nechen We temporarily hide `home_add_to_launcher` in API 26, which means directly accesses it without checking if it exists or not would cause NullPointerException. MozReview-Commit-ID: KXnP81ZZa6u
mobile/android/base/java/org/mozilla/gecko/home/HomeFragment.java
--- a/mobile/android/base/java/org/mozilla/gecko/home/HomeFragment.java
+++ b/mobile/android/base/java/org/mozilla/gecko/home/HomeFragment.java
@@ -203,17 +203,21 @@ public abstract class HomeFragment exten
         menu.findItem(R.id.home_set_as_homepage).setVisible(distSetAsHomepage);
 
         // Hide unused menu items for bookmark folder.
         if (info.isFolder) {
             menu.findItem(R.id.home_open_new_tab).setVisible(false);
             menu.findItem(R.id.home_open_private_tab).setVisible(false);
             menu.findItem(R.id.home_copyurl).setVisible(false);
             menu.findItem(R.id.home_share).setVisible(false);
-            menu.findItem(R.id.home_add_to_launcher).setVisible(false);
+
+            final MenuItem addToLauncherItem = menu.findItem(R.id.home_add_to_launcher);
+            if (addToLauncherItem != null) {
+                addToLauncherItem.setVisible(false);
+            }
             menu.findItem(R.id.home_set_as_homepage).setVisible(false);
 
             menu.findItem(R.id.home_as_pin).setVisible(false);
             return;
         }
 
         // If Activity Stream is disabled, simply hide "AS Pin" menu item as classic Top Sites do not
         // support pinning from outside of the Top Site tiles.