diff options
author | Jorim Jaggi <jjaggi@google.com> | 2015-04-06 17:47:18 -0700 |
---|---|---|
committer | Jorim Jaggi <jjaggi@google.com> | 2015-04-13 14:59:26 -0700 |
commit | 8a09b619aeb233e2aab1919301f162d8acf1f0f0 (patch) | |
tree | aeec574a47f0f71ab9177b2e4ef7f912e87f61b6 /src/com/android/settings/ChooseLockSettingsHelper.java | |
parent | b5aa73f46f812ba03518a6d1ac218e3af5975236 (diff) | |
download | packages_apps_Settings-8a09b619aeb233e2aab1919301f162d8acf1f0f0.zip packages_apps_Settings-8a09b619aeb233e2aab1919301f162d8acf1f0f0.tar.gz packages_apps_Settings-8a09b619aeb233e2aab1919301f162d8acf1f0f0.tar.bz2 |
Update confirm device credentials to spec, add fingerprint
- New strings in the screen.
- New layout/style.
- Clean up internal API's around it.
- Add fingerprint support if launched from externally
- Separate theme if launched from externally
- If launched from above Keyguard, use SHOW_WHEN_LOCKED flag
Change-Id: Icdf9bf9e0506841f24e8aab5f0f1d1f4b688951f
Diffstat (limited to 'src/com/android/settings/ChooseLockSettingsHelper.java')
-rw-r--r-- | src/com/android/settings/ChooseLockSettingsHelper.java | 113 |
1 files changed, 50 insertions, 63 deletions
diff --git a/src/com/android/settings/ChooseLockSettingsHelper.java b/src/com/android/settings/ChooseLockSettingsHelper.java index bba45ce..65697f6 100644 --- a/src/com/android/settings/ChooseLockSettingsHelper.java +++ b/src/com/android/settings/ChooseLockSettingsHelper.java @@ -16,13 +16,14 @@ package com.android.settings; -import com.android.internal.widget.LockPatternUtils; - +import android.annotation.Nullable; import android.app.Activity; import android.app.Fragment; import android.app.admin.DevicePolicyManager; import android.content.Intent; +import com.android.internal.widget.LockPatternUtils; + public final class ChooseLockSettingsHelper { static final String EXTRA_KEY_TYPE = "type"; @@ -48,64 +49,77 @@ public final class ChooseLockSettingsHelper { /** * If a pattern, password or PIN exists, prompt the user before allowing them to change it. - * @param message optional message to display about the action about to be done - * @param details optional detail message to display + * + * @param title title of the confirmation screen; shown in the action bar + * @return true if one exists and we launched an activity to confirm it + * @see Activity#onActivityResult(int, int, android.content.Intent) + */ + boolean launchConfirmationActivity(int request, CharSequence title) { + return launchConfirmationActivity(request, title, null, null, false, false); + } + + /** + * If a pattern, password or PIN exists, prompt the user before allowing them to change it. + * + * @param title title of the confirmation screen; shown in the action bar + * @param returnCredentials if true, put credentials into intent. Note that if this is true, + * this can only be called internally. * @return true if one exists and we launched an activity to confirm it - * @see #onActivityResult(int, int, android.content.Intent) + * @see Activity#onActivityResult(int, int, android.content.Intent) */ - boolean launchConfirmationActivity(int request, CharSequence message, CharSequence details) { - return launchConfirmationActivity(request, message, details, false); + boolean launchConfirmationActivity(int request, CharSequence title, boolean returnCredentials) { + return launchConfirmationActivity(request, title, null, null, returnCredentials, false); } /** * If a pattern, password or PIN exists, prompt the user before allowing them to change it. - * @param message optional message to display about the action about to be done - * @param details optional detail message to display + * + * @param title title of the confirmation screen; shown in the action bar + * @param header header of the confirmation screen; shown as large text + * @param description description of the confirmation screen * @param returnCredentials if true, put credentials into intent. Note that if this is true, - this can only be called internally. + * this can only be called internally. + * @param external specifies whether this activity is launched externally, meaning that it will + * get a dark theme and allow fingerprint authentication * @return true if one exists and we launched an activity to confirm it - * @see #onActivityResult(int, int, android.content.Intent) + * @see Activity#onActivityResult(int, int, android.content.Intent) */ - boolean launchConfirmationActivity(int request, CharSequence message, CharSequence details, - boolean returnCredentials) { + boolean launchConfirmationActivity(int request, @Nullable CharSequence title, + @Nullable CharSequence header, @Nullable CharSequence description, + boolean returnCredentials, boolean external) { boolean launched = false; switch (mLockPatternUtils.getKeyguardStoredPasswordQuality()) { case DevicePolicyManager.PASSWORD_QUALITY_SOMETHING: - launched = confirmPattern(request, message, details, returnCredentials); + launched = launchConfirmationActivity(request, title, header, description, + returnCredentials + ? ConfirmLockPattern.InternalActivity.class + : ConfirmLockPattern.class, external); break; case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC: case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC_COMPLEX: case DevicePolicyManager.PASSWORD_QUALITY_ALPHABETIC: case DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC: case DevicePolicyManager.PASSWORD_QUALITY_COMPLEX: - // TODO: update UI layout for ConfirmPassword to show message and details - launched = confirmPassword(request, message, returnCredentials); + launched = launchConfirmationActivity(request, title, header, description, + returnCredentials + ? ConfirmLockPassword.InternalActivity.class + : ConfirmLockPassword.class, external); break; } return launched; } - /** - * Launch screen to confirm the existing lock pattern. - * @param message shown in header of ConfirmLockPattern if not null - * @param details shown in footer of ConfirmLockPattern if not null - * @param returnCredentials if true, put credentials into intent. - * @see #onActivityResult(int, int, android.content.Intent) - * @return true if we launched an activity to confirm pattern - */ - private boolean confirmPattern(int request, CharSequence message, - CharSequence details, boolean returnCredentials) { - if (!mLockPatternUtils.isLockPatternEnabled()) { - return false; - } + private boolean launchConfirmationActivity(int request, CharSequence title, CharSequence header, + CharSequence message, Class<?> activityClass, boolean external) { final Intent intent = new Intent(); - // supply header and footer text in the intent - intent.putExtra(ConfirmLockPattern.HEADER_TEXT, message); - intent.putExtra(ConfirmLockPattern.FOOTER_TEXT, details); - intent.setClassName("com.android.settings", - returnCredentials - ? ConfirmLockPattern.InternalActivity.class.getName() - : ConfirmLockPattern.class.getName()); + intent.putExtra(ConfirmDeviceCredentialBaseFragment.TITLE_TEXT, title); + intent.putExtra(ConfirmDeviceCredentialBaseFragment.HEADER_TEXT, header); + intent.putExtra(ConfirmDeviceCredentialBaseFragment.DETAILS_TEXT, message); + intent.putExtra(ConfirmDeviceCredentialBaseFragment.ALLOW_FP_AUTHENTICATION, external); + intent.putExtra(ConfirmDeviceCredentialBaseFragment.DARK_THEME, external); + intent.putExtra(ConfirmDeviceCredentialBaseFragment.SHOW_CANCEL_BUTTON, external); + intent.putExtra(ConfirmDeviceCredentialBaseFragment.SHOW_WHEN_LOCKED, external); + intent.setClassName(ConfirmDeviceCredentialBaseFragment.PACKAGE, activityClass.getName()); if (mFragment != null) { mFragment.startActivityForResult(intent, request); } else { @@ -113,31 +127,4 @@ public final class ChooseLockSettingsHelper { } return true; } - - /** - * Launch screen to confirm the existing lock password. - * @param message shown in header of ConfirmLockPassword if not null - * @param returnCredentials if true, put credentials into intent. - * @see #onActivityResult(int, int, android.content.Intent) - * @return true if we launched an activity to confirm password - */ - private boolean confirmPassword(int request, CharSequence message, - boolean returnCredentials) { - if (!mLockPatternUtils.isLockPasswordEnabled()) return false; - final Intent intent = new Intent(); - // supply header text in the intent - intent.putExtra(ConfirmLockPattern.HEADER_TEXT, message); - intent.setClassName("com.android.settings", - returnCredentials - ? ConfirmLockPassword.InternalActivity.class.getName() - : ConfirmLockPassword.class.getName()); - if (mFragment != null) { - mFragment.startActivityForResult(intent, request); - } else { - mActivity.startActivityForResult(intent, request); - } - return true; - } - - } |