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

Commit 6e4579a8 authored by Ayush Sharma's avatar Ayush Sharma Committed by Android (Google) Code Review
Browse files

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

parents 64b42270 322d401a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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>
+33 −28
Original line number Diff line number Diff line
@@ -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;

@@ -402,36 +403,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) {
@@ -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);
            }