Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 322d401a authored by Ayush Sharma's avatar Ayush Sharma
Browse files

Move set work lock message from header to footer

Also update the string.

Bug: 206083998
Bug: 230625178
Test: NA
Change-Id: I3e442f6a43e01f3633255551aa42902bf24e4aa8
parent 467b85d0
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1402,7 +1402,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>
+33 −28
Original line number Diff line number Diff line
@@ -66,7 +66,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;
@@ -77,7 +76,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;

@@ -399,36 +400,11 @@ public class ChooseLockGeneric extends SettingsActivity {
                    textView.setText(mDpm.getResources().getString(
                            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("");
                }
            }
        }
        }

        @Override
        public boolean onPreferenceTreeClick(Preference preference) {
@@ -630,10 +606,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);
            }