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
--- 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();
+ }
+
+ }
}