Bug 1263941 - History is not displayed in the 3-dot menu if History panel is set as default after it was hidden. r=sebastian draft
authorChenxia Liu <liuche@mozilla.com>
Wed, 20 Apr 2016 11:03:35 -0700
changeset 354341 a9e9a1e75b36d3e40523b9ca7f16785e0ab5a67f
parent 354334 b29a652d68e85d25953a2bb371d35114cd8036a0
child 518979 acdbd276f2e204f77e72d91003f0a4e28e0371b7
push id16052
push usercliu@mozilla.com
push dateWed, 20 Apr 2016 18:13:58 +0000
reviewerssebastian
bugs1263941
milestone48.0a1
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();
+        }
+
+    }
 }