Bug 1434603 - Settings Header not changed when visiting sub-menus on Oreo; r=mcomella

The ActionBar's title will always be updated with the title of the visiting PreferenceScreen.

MozReview-Commit-ID: b5MyrSaWFC

--HG--
extra : rebase_source : 1ad23955ba940935898a4331debb5554a61b4359
This commit is contained in:
Petru Lingurar 2018-05-15 13:03:44 +03:00
Родитель bf208eff66
Коммит dc645158f1
1 изменённых файлов: 20 добавлений и 23 удалений

Просмотреть файл

@ -7,7 +7,6 @@ package org.mozilla.gecko.preferences;
import java.util.Locale;
import org.mozilla.gecko.AppConstants.Versions;
import org.mozilla.gecko.BrowserLocaleManager;
import org.mozilla.gecko.GeckoApplication;
import org.mozilla.gecko.GeckoSharedPrefs;
@ -21,7 +20,6 @@ import org.mozilla.gecko.fxa.AccountLoader;
import org.mozilla.gecko.fxa.authenticator.AndroidFxAccount;
import android.accounts.Account;
import android.app.ActionBar;
import android.app.Activity;
import android.app.LoaderManager;
import android.content.Context;
@ -29,15 +27,12 @@ import android.content.Loader;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.preference.PreferenceFragment;
import android.preference.PreferenceScreen;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import com.squareup.leakcanary.RefWatcher;
/* A simple implementation of PreferenceFragment for large screen devices
* This will strip category headers (so that they aren't shown to the user twice)
* as well as initializing Gecko prefs when a fragment is shown.
@ -97,29 +92,30 @@ public class GeckoPreferenceFragment extends PreferenceFragment {
/**
* Return the title to use for this preference fragment.
*
* We only return titles for the preference screens that are
* launched directly, and thus might need to be redisplayed.
*
* This method sets the title that you see on non-multi-pane devices.
* The result will be used to set the title that you see on non-multi-pane devices.
*/
private String getTitle() {
final int res = getResource();
if (res == R.xml.preferences) {
return getString(R.string.settings_title);
}
// We can launch this category from the Data Reporting notification.
if (res == R.xml.preferences_privacy) {
return getString(R.string.pref_category_privacy_short);
}
// We can launch this category from the the magnifying glass in the quick search bar.
if (res == R.xml.preferences_search) {
} else if (res == R.xml.preferences_general || res == R.xml.preferences_general_tablet) {
return getString(R.string.pref_category_general);
} else if (res == R.xml.preferences_home) {
return getString(R.string.pref_category_home);
} else if (res == R.xml.preferences_locale) {
return getString(R.string.pref_category_language);
} else if (res == R.xml.preferences_search) {
return getString(R.string.pref_category_search);
}
if (res == R.xml.preferences_notifications) {
} else if (res == R.xml.preferences_privacy) {
return getString(R.string.pref_category_privacy_short);
} else if (res == R.xml.preferences_accessibility) {
return getString(R.string.pref_category_accessibility);
} else if (res == R.xml.preferences_notifications) {
return getString(R.string.pref_category_notifications);
} else if (res == R.xml.preferences_advanced) {
return getString(R.string.pref_category_advanced);
} else if (res == R.xml.preferences_vendor) {
return getString(R.string.pref_category_vendor);
}
return null;
@ -156,7 +152,7 @@ public class GeckoPreferenceFragment extends PreferenceFragment {
return -1;
}
private void updateTitle() {
private void updateParentTitle() {
final String newTitle = getTitle();
if (newTitle == null) {
Log.d(LOGTAG, "No new title to show.");
@ -187,6 +183,7 @@ public class GeckoPreferenceFragment extends PreferenceFragment {
public void onResume() {
// This is a little delicate. Ensure that you do nothing prior to
// super.onResume that you wouldn't do in onCreate.
// This will also set the title in the parent activity's ActionBar to the title of the current PreferenceScreen
applyLocale(Locale.getDefault());
super.onResume();
@ -210,7 +207,7 @@ public class GeckoPreferenceFragment extends PreferenceFragment {
}
// Fix the parent title regardless.
updateTitle();
updateParentTitle();
}
/*