Bug 1263941 - History is not displayed in the 3-dot menu if History panel is set as default after it was hidden. r=sebastian
authorChenxia Liu <liuche@mozilla.com>
Wed, 20 Apr 2016 11:03:35 -0700
changeset 332181 2570cd8ec0bddf821299063db4094dbbaeccea04
parent 332180 b31b99289389a5e0ddab1ca9eccd4f03a6d81fe4
child 332182 8196ef05d58ea922f91f73289ed06d6894e4b251
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssebastian
bugs1263941
milestone48.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 1263941 - History is not displayed in the 3-dot menu if History panel is set as default after it was hidden. r=sebastian MozReview-Commit-ID: 1hSKJd0r0fv
mobile/android/base/java/org/mozilla/gecko/preferences/PanelsPreferenceCategory.java
--- a/mobile/android/base/java/org/mozilla/gecko/preferences/PanelsPreferenceCategory.java
+++ b/mobile/android/base/java/org/mozilla/gecko/preferences/PanelsPreferenceCategory.java
@@ -158,16 +158,18 @@ public class PanelsPreferenceCategory ex
 
         final String id = pref.getKey();
 
         final String defaultPanelId = mConfigEditor.getDefaultPanelId();
         if (defaultPanelId != null && defaultPanelId.equals(id)) {
             return;
         }
 
+        updateVisibilityPrefsForPanel(id, true);
+
         mConfigEditor.setDefault(id);
         mConfigEditor.apply();
 
         Telemetry.sendUIEvent(TelemetryContract.Event.PANEL_SET_DEFAULT, Method.DIALOG, id);
     }
 
     @Override
     protected void onPrepareForRemoval() {
@@ -227,29 +229,34 @@ public class PanelsPreferenceCategory ex
         mConfigEditor.apply();
 
         if (toHide) {
             Telemetry.sendUIEvent(TelemetryContract.Event.PANEL_HIDE, Method.DIALOG, id);
         } else {
             Telemetry.sendUIEvent(TelemetryContract.Event.PANEL_SHOW, Method.DIALOG, id);
         }
 
-        if (HomeConfig.getIdForBuiltinPanelType(HomeConfig.PanelType.BOOKMARKS).equals(id)) {
-            GeckoSharedPrefs.forProfile(getContext()).edit().putBoolean(HomeConfig.PREF_KEY_BOOKMARKS_PANEL_ENABLED, !toHide).apply();
-        }
-
-        if (HomeConfig.getIdForBuiltinPanelType(HomeConfig.PanelType.HISTORY).equals(id)) {
-            GeckoSharedPrefs.forProfile(getContext()).edit().putBoolean(HomeConfig.PREF_KEY_HISTORY_PANEL_ENABLED, !toHide).apply();
-        }
+        updateVisibilityPrefsForPanel(id, !toHide);
 
         pref.setHidden(toHide);
         setDefaultFromConfig();
     }
 
     /**
      * When the default panel is removed or disabled, find an enabled panel
      * if possible and set it as mDefaultReference.
      */
     @Override
     protected void setFallbackDefault() {
         setDefaultFromConfig();
     }
+
+    private void updateVisibilityPrefsForPanel(String panelId, boolean toShow) {
+        if (HomeConfig.getIdForBuiltinPanelType(HomeConfig.PanelType.BOOKMARKS).equals(panelId)) {
+            GeckoSharedPrefs.forProfile(getContext()).edit().putBoolean(HomeConfig.PREF_KEY_BOOKMARKS_PANEL_ENABLED, toShow).apply();
+        }
+
+        if (HomeConfig.getIdForBuiltinPanelType(HomeConfig.PanelType.HISTORY).equals(panelId)) {
+            GeckoSharedPrefs.forProfile(getContext()).edit().putBoolean(HomeConfig.PREF_KEY_HISTORY_PANEL_ENABLED, toShow).apply();
+        }
+
+    }
 }