From d67cd2320ef1b023dff804738357a9316c5daea4 Mon Sep 17 00:00:00 2001 From: Ayush Sharma Date: Tue, 10 May 2022 13:39:57 +0100 Subject: [PATCH] Fix issue no action on clicking link in footer Links are not allowed in footer preference title now, so splitting the string in to title text and learn more text for set a separate work lock message Bug: 206083998 Bug: 231296099 Test: NA Change-Id: Ic19b4b7a9c8239726b1d53cecad1e341458610cb --- res/values/strings.xml | 6 ++-- .../settings/password/ChooseLockGeneric.java | 32 +++++++++++-------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 68de5849b7c..6259e8af650 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -1413,8 +1413,10 @@ Choose your backup screen lock method - - If you forget your screen lock, your IT admin can\u2019t reset it. Set a separate work lock + + If you forget your screen lock, your IT admin can\u2019t reset it. + + Set a separate work lock If you forget this lock, ask your IT admin to reset it diff --git a/src/com/android/settings/password/ChooseLockGeneric.java b/src/com/android/settings/password/ChooseLockGeneric.java index d3988faf8a9..8a4e9bb6c13 100644 --- a/src/com/android/settings/password/ChooseLockGeneric.java +++ b/src/com/android/settings/password/ChooseLockGeneric.java @@ -25,6 +25,7 @@ import static android.app.admin.DevicePolicyManager.PASSWORD_COMPLEXITY_NONE; import static android.app.admin.DevicePolicyResources.Strings.Settings.LOCK_SETTINGS_NEW_PROFILE_LOCK_TITLE; import static android.app.admin.DevicePolicyResources.Strings.Settings.LOCK_SETTINGS_UPDATE_PROFILE_LOCK_TITLE; import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_IT_ADMIN_CANT_RESET_SCREEN_LOCK; +import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_IT_ADMIN_CANT_RESET_SCREEN_LOCK_ACTION; import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_SCREEN_LOCK_SETUP_MESSAGE; import static com.android.settings.password.ChooseLockPassword.ChooseLockPasswordFragment.RESULT_FINISHED; @@ -78,7 +79,6 @@ 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; @@ -621,15 +621,20 @@ public class ChooseLockGeneric extends SettingsActivity { } 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 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))); + footer.setVisible(true); + footer.setTitle(description); + + final StringBuilder setLockText = new StringBuilder( + mDpm.getResources().getString( + WORK_PROFILE_IT_ADMIN_CANT_RESET_SCREEN_LOCK_ACTION, + () -> getString( + R.string.lock_settings_picker_admin_restricted_personal_message_action))); + View.OnClickListener setLockClickListener = (v) -> { final Bundle extras = new Bundle(); extras.putInt(Intent.EXTRA_USER_ID, profileUserId); if (mUserPassword != null) { @@ -642,10 +647,9 @@ public class ChooseLockGeneric extends SettingsActivity { .setArguments(extras) .launch(); finish(); - }); - CharSequence footerText = AnnotationSpan.linkify(description, linkInfo); - footer.setVisible(true); - footer.setTitle(footerText); + }; + footer.setLearnMoreText(setLockText); + footer.setLearnMoreAction(setLockClickListener); } else { footer.setVisible(false); }