From 34ec5f97feaf8d73d533f104cfc2c2e68e995ae3 Mon Sep 17 00:00:00 2001 From: Clara Bayarri Date: Fri, 22 Jan 2016 14:59:24 +0000 Subject: [PATCH] Fix Confirm/Choose Credentials strings related to profile The messages in ConfirmDeviceCredentials have been updated to inform the user that the pattern/pin/password to be entered is the profile one. The strings in the confirmation dialog when the user removes the lock have also been updated. Ideally we would have a parametrized approach to strings here, but capitalization makes it a hard problem. Bug: 26706338, 26709116 Change-Id: I9f5508d6f449f9e572d65e5b2dcb15cca23832b3 --- res/values/strings.xml | 28 ++++++++ .../android/settings/ChooseLockGeneric.java | 70 ++++++++++++++----- .../android/settings/ConfirmLockPassword.java | 13 +++- .../android/settings/ConfirmLockPattern.java | 7 +- 4 files changed, 99 insertions(+), 19 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 7a5d768002d..9f3dddd2a60 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -1042,6 +1042,8 @@ Remove device protection? + + Remove profile protection? "Device protection features will not work without your pattern." @@ -1060,6 +1062,23 @@ "Device protection features will not work without your screen lock.\n\nYour saved fingerprints will also be removed from this device and you won't be able to unlock your phone, authorize purchases, or sign in to apps with them." + + "Profile protection features will not work without your pattern." + + "Profile protection features will not work without your pattern.\n\nYour saved fingerprints will also be removed from this profile and you won't be able to unlock your profile, authorize purchases, or sign in to apps with them." + + "Profile protection features will not work without your PIN." + + "Profile protection features will not work without your PIN.\n\nYour saved fingerprints will also be removed from this profile and you won't be able to unlock your profile, authorize purchases, or sign in to apps with them." + + "Profile protection features will not work without your password." + + "Profile protection features will not work without your password.\n\nYour saved fingerprints will also be removed from this profile and you won't be able to unlock your profile, authorize purchases, or sign in to apps with them." + + "Profile protection features will not work without your screen lock." + + "Profile protection features will not work without your screen lock.\n\nYour saved fingerprints will also be removed from this profile and you won't be able to unlock your profile, authorize purchases, or sign in to apps with them." + Yes, remove @@ -2973,6 +2992,15 @@ Enter your device password to continue. + + Use your profile pattern to continue. + + Enter your profile PIN to continue. + + Enter your profile password to continue. diff --git a/src/com/android/settings/ChooseLockGeneric.java b/src/com/android/settings/ChooseLockGeneric.java index c576897c675..0e6cf3bd415 100644 --- a/src/com/android/settings/ChooseLockGeneric.java +++ b/src/com/android/settings/ChooseLockGeneric.java @@ -581,28 +581,62 @@ public class ChooseLockGeneric extends SettingsActivity { return R.string.help_url_choose_lockscreen; } + private int getResIdForFactoryResetProtectionWarningTitle() { + boolean isProfile = Utils.isManagedProfile(UserManager.get(getActivity()), mUserId); + return isProfile ? R.string.unlock_disable_frp_warning_title_profile + : R.string.unlock_disable_frp_warning_title; + } + private int getResIdForFactoryResetProtectionWarningMessage() { boolean hasFingerprints = mFingerprintManager.hasEnrolledFingerprints(); + boolean isProfile = Utils.isManagedProfile(UserManager.get(getActivity()), mUserId); switch (mLockPatternUtils.getKeyguardStoredPasswordQuality(mUserId)) { case DevicePolicyManager.PASSWORD_QUALITY_SOMETHING: - return hasFingerprints - ? R.string.unlock_disable_frp_warning_content_pattern_fingerprint - : R.string.unlock_disable_frp_warning_content_pattern; + if (hasFingerprints && isProfile) { + return R.string + .unlock_disable_frp_warning_content_pattern_fingerprint_profile; + } else if (hasFingerprints && !isProfile) { + return R.string.unlock_disable_frp_warning_content_pattern_fingerprint; + } else if (isProfile) { + return R.string.unlock_disable_frp_warning_content_pattern_profile; + } else { + return R.string.unlock_disable_frp_warning_content_pattern; + } case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC: case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC_COMPLEX: - return hasFingerprints - ? R.string.unlock_disable_frp_warning_content_pin_fingerprint - : R.string.unlock_disable_frp_warning_content_pin; + if (hasFingerprints && isProfile) { + return R.string.unlock_disable_frp_warning_content_pin_fingerprint_profile; + } else if (hasFingerprints && !isProfile) { + return R.string.unlock_disable_frp_warning_content_pin_fingerprint; + } else if (isProfile) { + return R.string.unlock_disable_frp_warning_content_pin_profile; + } else { + return R.string.unlock_disable_frp_warning_content_pin; + } case DevicePolicyManager.PASSWORD_QUALITY_ALPHABETIC: case DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC: case DevicePolicyManager.PASSWORD_QUALITY_COMPLEX: - return hasFingerprints - ? R.string.unlock_disable_frp_warning_content_password_fingerprint - : R.string.unlock_disable_frp_warning_content_password; + if (hasFingerprints && isProfile) { + return R.string + .unlock_disable_frp_warning_content_password_fingerprint_profile; + } else if (hasFingerprints && !isProfile) { + return R.string.unlock_disable_frp_warning_content_password_fingerprint; + } else if (isProfile) { + return R.string.unlock_disable_frp_warning_content_password_profile; + } else { + return R.string.unlock_disable_frp_warning_content_password; + } default: - return hasFingerprints - ? R.string.unlock_disable_frp_warning_content_unknown_fingerprint - : R.string.unlock_disable_frp_warning_content_unknown; + if (hasFingerprints && isProfile) { + return R.string + .unlock_disable_frp_warning_content_unknown_fingerprint_profile; + } else if (hasFingerprints && !isProfile) { + return R.string.unlock_disable_frp_warning_content_unknown_fingerprint; + } else if (isProfile) { + return R.string.unlock_disable_frp_warning_content_unknown_profile; + } else { + return R.string.unlock_disable_frp_warning_content_unknown; + } } } @@ -637,22 +671,26 @@ public class ChooseLockGeneric extends SettingsActivity { } private void showFactoryResetProtectionWarningDialog(String unlockMethodToSet) { + int title = getResIdForFactoryResetProtectionWarningTitle(); int message = getResIdForFactoryResetProtectionWarningMessage(); FactoryResetProtectionWarningDialog dialog = - FactoryResetProtectionWarningDialog.newInstance(message, unlockMethodToSet); + FactoryResetProtectionWarningDialog.newInstance( + title, message, unlockMethodToSet); dialog.show(getChildFragmentManager(), TAG_FRP_WARNING_DIALOG); } public static class FactoryResetProtectionWarningDialog extends DialogFragment { + private static final String ARG_TITLE_RES = "titleRes"; private static final String ARG_MESSAGE_RES = "messageRes"; private static final String ARG_UNLOCK_METHOD_TO_SET = "unlockMethodToSet"; - public static FactoryResetProtectionWarningDialog newInstance(int messageRes, - String unlockMethodToSet) { + public static FactoryResetProtectionWarningDialog newInstance( + int titleRes, int messageRes, String unlockMethodToSet) { FactoryResetProtectionWarningDialog frag = new FactoryResetProtectionWarningDialog(); Bundle args = new Bundle(); + args.putInt(ARG_TITLE_RES, titleRes); args.putInt(ARG_MESSAGE_RES, messageRes); args.putString(ARG_UNLOCK_METHOD_TO_SET, unlockMethodToSet); frag.setArguments(args); @@ -672,7 +710,7 @@ public class ChooseLockGeneric extends SettingsActivity { final Bundle args = getArguments(); return new AlertDialog.Builder(getActivity()) - .setTitle(R.string.unlock_disable_frp_warning_title) + .setTitle(args.getInt(ARG_TITLE_RES)) .setMessage(args.getInt(ARG_MESSAGE_RES)) .setPositiveButton(R.string.unlock_disable_frp_warning_ok, new DialogInterface.OnClickListener() { diff --git a/src/com/android/settings/ConfirmLockPassword.java b/src/com/android/settings/ConfirmLockPassword.java index 00a68bf3272..f6347c18595 100644 --- a/src/com/android/settings/ConfirmLockPassword.java +++ b/src/com/android/settings/ConfirmLockPassword.java @@ -26,6 +26,7 @@ import android.os.Bundle; import android.os.CountDownTimer; import android.os.Handler; import android.os.SystemClock; +import android.os.UserManager; import android.os.storage.StorageManager; import android.text.InputType; import android.text.TextUtils; @@ -180,8 +181,16 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity { } private int getDefaultDetails() { - return mIsAlpha ? R.string.lockpassword_confirm_your_password_generic - : R.string.lockpassword_confirm_your_pin_generic; + boolean isProfile = Utils.isManagedProfile( + UserManager.get(getActivity()), mEffectiveUserId); + if (mIsAlpha && !isProfile) { + return R.string.lockpassword_confirm_your_password_generic; + } else if (mIsAlpha && isProfile) { + return R.string.lockpassword_confirm_your_password_generic_profile; + } else if (!isProfile) { + return R.string.lockpassword_confirm_your_pin_generic; + } + return R.string.lockpassword_confirm_your_pin_generic_profile; } private int getErrorMessage() { diff --git a/src/com/android/settings/ConfirmLockPattern.java b/src/com/android/settings/ConfirmLockPattern.java index 087a0b997d4..5c72bd1e43c 100644 --- a/src/com/android/settings/ConfirmLockPattern.java +++ b/src/com/android/settings/ConfirmLockPattern.java @@ -23,6 +23,7 @@ import android.os.AsyncTask; import android.os.Bundle; import android.os.CountDownTimer; import android.os.SystemClock; +import android.os.UserManager; import android.os.storage.StorageManager; import android.view.LayoutInflater; import android.view.View; @@ -279,9 +280,13 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity { } if (mDetailsText != null) { mDetailsTextView.setText(mDetailsText); - } else { + } else if (!Utils.isManagedProfile( + UserManager.get(getActivity()), mEffectiveUserId)) { mDetailsTextView.setText( R.string.lockpassword_confirm_your_pattern_generic); + } else { + mDetailsTextView.setText( + R.string.lockpassword_confirm_your_pattern_generic_profile); } mErrorTextView.setText("");