Merge "Move set work lock message from header to footer" into tm-dev

This commit is contained in:
Ayush Sharma
2022-05-06 10:42:10 +00:00
committed by Android (Google) Code Review
2 changed files with 34 additions and 29 deletions

View File

@@ -1406,7 +1406,7 @@
<string name="lock_settings_picker_biometric_message">Choose your backup screen lock method</string>
<!-- Text shown on the screen lock menu. This text is letting the user know that their IT admin can't reset their screen lock if they forget it, and they can choose to set another lock that would be specifically for their work apps. The place-holders "LINK_BEGIN" and "LINK_END" must NOT be translated. They mark a link to bring the user to enroll a work profile screen lock instead. [CHAR LIMIT=100] -->
<string name="lock_settings_picker_admin_restricted_personal_message">This lock can\u2019t be reset by your IT admin. <xliff:g id="link_begin" example="">LINK_BEGIN</xliff:g>Set a separate work lock instead<xliff:g id="link_end" example="">LINK_END</xliff:g></string>
<string name="lock_settings_picker_admin_restricted_personal_message">If you forget your screen lock, your IT admin can\u2019t reset it. <annotation id="link">Set a separate work lock</annotation></string>
<!-- Message shown in screen lock picker for setting up a work profile screen lock. [CHAR LIMIT=80] -->
<string name="lock_settings_picker_profile_message">If you forget this lock, ask your IT admin to reset it</string>

View File

@@ -67,7 +67,6 @@ import com.android.internal.widget.LockPatternUtils;
import com.android.internal.widget.LockscreenCredential;
import com.android.settings.EncryptionInterstitial;
import com.android.settings.EventLogTags;
import com.android.settings.LinkifyUtils;
import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.SettingsPreferenceFragment;
@@ -78,7 +77,9 @@ import com.android.settings.core.SubSettingLauncher;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import com.android.settings.safetycenter.LockScreenSafetySource;
import com.android.settings.search.SearchFeatureProvider;
import com.android.settings.utils.AnnotationSpan;
import com.android.settingslib.RestrictedPreference;
import com.android.settingslib.widget.FooterPreference;
import com.google.android.setupcompat.util.WizardManagerHelper;
@@ -403,32 +404,7 @@ public class ChooseLockGeneric extends SettingsActivity {
WORK_PROFILE_SCREEN_LOCK_SETUP_MESSAGE,
() -> getString(R.string.lock_settings_picker_profile_message)));
} else {
int profileUserId = Utils.getManagedProfileId(mUserManager, mUserId);
if (mController.isScreenLockRestrictedByAdmin()
&& profileUserId != UserHandle.USER_NULL) {
final StringBuilder description = new StringBuilder(
mDpm.getResources().getString(
WORK_PROFILE_IT_ADMIN_CANT_RESET_SCREEN_LOCK,
() -> getString(
R.string.lock_settings_picker_admin_restricted_personal_message)));
final LinkifyUtils.OnClickListener clickListener = () -> {
final Bundle extras = new Bundle();
extras.putInt(Intent.EXTRA_USER_ID, profileUserId);
if (mUserPassword != null) {
extras.putParcelable(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD,
mUserPassword);
}
new SubSettingLauncher(getActivity())
.setDestination(ChooseLockGenericFragment.class.getName())
.setSourceMetricsCategory(getMetricsCategory())
.setArguments(extras)
.launch();
finish();
};
LinkifyUtils.linkify(textView, description, clickListener);
} else {
textView.setText("");
}
textView.setText("");
}
}
}
@@ -633,10 +609,39 @@ public class ChooseLockGeneric extends SettingsActivity {
protected void addPreferences() {
addPreferencesFromResource(R.xml.security_settings_picker);
final Preference footer = findPreference(KEY_LOCK_SETTINGS_FOOTER);
int profileUserId = Utils.getManagedProfileId(mUserManager, mUserId);
final FooterPreference footer = findPreference(KEY_LOCK_SETTINGS_FOOTER);
if (!TextUtils.isEmpty(mCallerAppName) && !mIsCallingAppAdmin) {
footer.setVisible(true);
footer.setTitle(getFooterString());
} else if (!mForFace && !mForBiometrics && !mForFingerprint && !mIsManagedProfile
&& mController.isScreenLockRestrictedByAdmin()
&& profileUserId != UserHandle.USER_NULL) {
CharSequence description =
mDpm.getResources().getString(WORK_PROFILE_IT_ADMIN_CANT_RESET_SCREEN_LOCK,
() -> null);
if (description == null) {
description = getText(
R.string.lock_settings_picker_admin_restricted_personal_message);
}
final AnnotationSpan.LinkInfo linkInfo = new AnnotationSpan.LinkInfo(
AnnotationSpan.LinkInfo.DEFAULT_ANNOTATION, (view) -> {
final Bundle extras = new Bundle();
extras.putInt(Intent.EXTRA_USER_ID, profileUserId);
if (mUserPassword != null) {
extras.putParcelable(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD,
mUserPassword);
}
new SubSettingLauncher(getActivity())
.setDestination(ChooseLockGenericFragment.class.getName())
.setSourceMetricsCategory(getMetricsCategory())
.setArguments(extras)
.launch();
finish();
});
CharSequence footerText = AnnotationSpan.linkify(description, linkInfo);
footer.setVisible(true);
footer.setTitle(footerText);
} else {
footer.setVisible(false);
}