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
This commit is contained in:
@@ -20,7 +20,6 @@ import static android.widget.LinearLayout.LayoutParams.MATCH_PARENT;
|
||||
import static android.widget.LinearLayout.LayoutParams.WRAP_CONTENT;
|
||||
|
||||
import android.animation.LayoutTransition;
|
||||
import android.annotation.StringRes;
|
||||
import android.annotation.UiThread;
|
||||
import android.app.Activity;
|
||||
import android.app.KeyguardManager;
|
||||
@@ -66,6 +65,7 @@ import com.android.internal.annotations.GuardedBy;
|
||||
import com.android.internal.app.UnlaunchableAppActivity;
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
import com.android.settings.core.InstrumentedPreferenceFragment;
|
||||
|
||||
import java.security.cert.CertificateEncodingException;
|
||||
import java.security.cert.X509Certificate;
|
||||
@@ -75,7 +75,7 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.IntConsumer;
|
||||
|
||||
public class TrustedCredentialsSettings extends OptionsMenuFragment
|
||||
public class TrustedCredentialsSettings extends InstrumentedPreferenceFragment
|
||||
implements TrustedCredentialsDialogBuilder.DelegateInterface {
|
||||
|
||||
public static final String ARG_SHOW_NEW_FOR_USER = "ARG_SHOW_NEW_FOR_USER";
|
||||
@@ -91,12 +91,6 @@ public class TrustedCredentialsSettings extends OptionsMenuFragment
|
||||
private static final String USER_ACTION = "com.android.settings.TRUSTED_CREDENTIALS_USER";
|
||||
private static final int REQUEST_CONFIRM_CREDENTIALS = 1;
|
||||
|
||||
@Override
|
||||
@StringRes
|
||||
protected int getTitle() {
|
||||
return R.string.trusted_credentials;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return MetricsEvent.TRUSTED_CREDENTIALS;
|
||||
@@ -183,10 +177,11 @@ public class TrustedCredentialsSettings extends OptionsMenuFragment
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
mUserManager = (UserManager) getActivity().getSystemService(Context.USER_SERVICE);
|
||||
mKeyguardManager = (KeyguardManager) getActivity()
|
||||
final Activity activity = getActivity();
|
||||
mUserManager = (UserManager) activity.getSystemService(Context.USER_SERVICE);
|
||||
mKeyguardManager = (KeyguardManager) activity
|
||||
.getSystemService(Context.KEYGUARD_SERVICE);
|
||||
mTrustAllCaUserId = getActivity().getIntent().getIntExtra(ARG_SHOW_NEW_FOR_USER,
|
||||
mTrustAllCaUserId = activity.getIntent().getIntExtra(ARG_SHOW_NEW_FOR_USER,
|
||||
UserHandle.USER_NULL);
|
||||
mConfirmedCredentialUsers = new ArraySet<>(2);
|
||||
mConfirmingCredentialUser = UserHandle.USER_NULL;
|
||||
@@ -206,7 +201,11 @@ public class TrustedCredentialsSettings extends OptionsMenuFragment
|
||||
filter.addAction(Intent.ACTION_MANAGED_PROFILE_AVAILABLE);
|
||||
filter.addAction(Intent.ACTION_MANAGED_PROFILE_UNAVAILABLE);
|
||||
filter.addAction(Intent.ACTION_MANAGED_PROFILE_UNLOCKED);
|
||||
getActivity().registerReceiver(mWorkProfileChangedReceiver, filter);
|
||||
activity.registerReceiver(mWorkProfileChangedReceiver, filter);
|
||||
|
||||
if (usePreferenceScreenTitle()) {
|
||||
activity.setTitle(R.string.trusted_credentials);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user