Update activity titles for fragments without preference screen.
1. Move getPreferenceScreenResId() from individual subclass to
InstrumentedPreferenceFragment.
2. Removed InstrumentedPreferenceFragment.getTitle() and let the
preference fragments that do not have preference screen set the activity
title directly instead.
3. Removed OptionsMenuFragment as all it does is call
setHasOptionMenu().
- changed subclasses of OptionsMenuFragment to extend from
InstrumentedPreferenceFragment directly.
- none of the exisitng subclasses actually implements the option menu
related methods to provide any option menu. So, the setHasOptionMenu()
call is not added to the subclasses.
4. Update Languages preference title.
- launch the fragment from the preference controller instead of from the
default handling, as we need the title res id at launch time to get it
work properly when retrieving the title from back stack.
Bug: 64564191
Test: blaze-bin/screenshots/android/i18nscreenshots/i18nscreenshots
Change-Id: Ibecdcab32cbaed8bf604ec5ebe0a926b4e489a7d
diff --git a/src/com/android/settings/MasterClear.java b/src/com/android/settings/MasterClear.java
index bac0a61..96cc390 100644
--- a/src/com/android/settings/MasterClear.java
+++ b/src/com/android/settings/MasterClear.java
@@ -21,7 +21,7 @@
import android.accounts.Account;
import android.accounts.AccountManager;
import android.accounts.AuthenticatorDescription;
-import android.annotation.StringRes;
+import android.annotation.Nullable;
import android.app.Activity;
import android.content.ComponentName;
import android.content.ContentResolver;
@@ -39,7 +39,6 @@
import android.provider.Settings;
import android.support.annotation.VisibleForTesting;
import android.telephony.euicc.EuiccManager;
-import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
@@ -54,6 +53,7 @@
import android.widget.TextView;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+import com.android.settings.core.InstrumentedPreferenceFragment;
import com.android.settings.password.ChooseLockSettingsHelper;
import com.android.settings.password.ConfirmLockPattern;
import com.android.settingslib.RestrictedLockUtils;
@@ -70,7 +70,7 @@
*
* This is the initial screen.
*/
-public class MasterClear extends OptionsMenuFragment {
+public class MasterClear extends InstrumentedPreferenceFragment {
private static final String TAG = "MasterClear";
private static final int KEYGUARD_REQUEST = 55;
@@ -93,9 +93,11 @@
};
@Override
- @StringRes
- protected int getTitle() {
- return R.string.master_clear_title;
+ public void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ if (usePreferenceScreenTitle()) {
+ getActivity().setTitle(R.string.master_clear_title);
+ }
}
/**