Merge "Update the fingerprint skip dialog" into qt-dev
This commit is contained in:
@@ -196,8 +196,14 @@ public class SetupChooseLockGeneric extends ChooseLockGeneric {
|
||||
final String key = preference.getKey();
|
||||
if (KEY_UNLOCK_SET_DO_LATER.equals(key)) {
|
||||
// show warning.
|
||||
SetupSkipDialog dialog = SetupSkipDialog.newInstance(getActivity().getIntent()
|
||||
.getBooleanExtra(SetupSkipDialog.EXTRA_FRP_SUPPORTED, false));
|
||||
SetupSkipDialog dialog = SetupSkipDialog.newInstance(
|
||||
getActivity().getIntent()
|
||||
.getBooleanExtra(SetupSkipDialog.EXTRA_FRP_SUPPORTED, false),
|
||||
/* isPatternMode= */ false,
|
||||
/* isAlphaMode= */ false,
|
||||
/* isFingerprintSupported= */ false,
|
||||
/* isFaceSupported= */ false
|
||||
);
|
||||
dialog.show(getFragmentManager());
|
||||
return true;
|
||||
}
|
||||
|
@@ -106,7 +106,16 @@ public class SetupChooseLockPassword extends ChooseLockPassword {
|
||||
if (mLeftButtonIsSkip) {
|
||||
SetupSkipDialog dialog = SetupSkipDialog.newInstance(
|
||||
getActivity().getIntent()
|
||||
.getBooleanExtra(SetupSkipDialog.EXTRA_FRP_SUPPORTED, false));
|
||||
.getBooleanExtra(SetupSkipDialog.EXTRA_FRP_SUPPORTED, false),
|
||||
/* isPatternMode= */ false,
|
||||
mIsAlphaMode,
|
||||
getActivity().getIntent()
|
||||
.getBooleanExtra(ChooseLockSettingsHelper.EXTRA_KEY_FOR_FINGERPRINT,
|
||||
false),
|
||||
getActivity().getIntent()
|
||||
.getBooleanExtra(ChooseLockSettingsHelper.EXTRA_KEY_FOR_FACE, false)
|
||||
|
||||
);
|
||||
dialog.show(getFragmentManager());
|
||||
return;
|
||||
}
|
||||
|
@@ -92,7 +92,16 @@ public class SetupChooseLockPattern extends ChooseLockPattern {
|
||||
if (mLeftButtonIsSkip) {
|
||||
SetupSkipDialog dialog = SetupSkipDialog.newInstance(
|
||||
getActivity().getIntent()
|
||||
.getBooleanExtra(SetupSkipDialog.EXTRA_FRP_SUPPORTED, false));
|
||||
.getBooleanExtra(SetupSkipDialog.EXTRA_FRP_SUPPORTED, false),
|
||||
/* isPatternMode= */ true,
|
||||
/* isAlphaMode= */ false,
|
||||
getActivity().getIntent()
|
||||
.getBooleanExtra(ChooseLockSettingsHelper.EXTRA_KEY_FOR_FINGERPRINT,
|
||||
false),
|
||||
getActivity().getIntent()
|
||||
.getBooleanExtra(ChooseLockSettingsHelper.EXTRA_KEY_FOR_FACE, false)
|
||||
|
||||
);
|
||||
dialog.show(getFragmentManager());
|
||||
return;
|
||||
}
|
||||
|
@@ -35,13 +35,22 @@ public class SetupSkipDialog extends InstrumentedDialogFragment
|
||||
public static final String EXTRA_FRP_SUPPORTED = ":settings:frp_supported";
|
||||
|
||||
private static final String ARG_FRP_SUPPORTED = "frp_supported";
|
||||
// The key indicates type of lock screen is pattern setup.
|
||||
private static final String ARG_LOCK_TYPE_PATTERN = "lock_type_pattern";
|
||||
// The key indicates type of lock screen setup is alphanumeric for password setup.
|
||||
private static final String ARG_LOCK_TYPE_ALPHANUMERIC = "lock_type_alphanumeric";
|
||||
private static final String TAG_SKIP_DIALOG = "skip_dialog";
|
||||
public static final int RESULT_SKIP = Activity.RESULT_FIRST_USER + 10;
|
||||
|
||||
public static SetupSkipDialog newInstance(boolean isFrpSupported) {
|
||||
public static SetupSkipDialog newInstance(boolean isFrpSupported, boolean isPatternMode,
|
||||
boolean isAlphanumericMode, boolean isFingerprintSupported, boolean isFaceSupported) {
|
||||
SetupSkipDialog dialog = new SetupSkipDialog();
|
||||
Bundle args = new Bundle();
|
||||
args.putBoolean(ARG_FRP_SUPPORTED, isFrpSupported);
|
||||
args.putBoolean(ARG_LOCK_TYPE_PATTERN, isPatternMode);
|
||||
args.putBoolean(ARG_LOCK_TYPE_ALPHANUMERIC, isAlphanumericMode);
|
||||
args.putBoolean(ChooseLockSettingsHelper.EXTRA_KEY_FOR_FINGERPRINT, isFingerprintSupported);
|
||||
args.putBoolean(ChooseLockSettingsHelper.EXTRA_KEY_FOR_FACE, isFaceSupported);
|
||||
dialog.setArguments(args);
|
||||
return dialog;
|
||||
}
|
||||
@@ -59,13 +68,36 @@ public class SetupSkipDialog extends InstrumentedDialogFragment
|
||||
@NonNull
|
||||
public AlertDialog.Builder onCreateDialogBuilder() {
|
||||
Bundle args = getArguments();
|
||||
return new AlertDialog.Builder(getContext())
|
||||
.setPositiveButton(R.string.skip_anyway_button_label, this)
|
||||
.setNegativeButton(R.string.go_back_button_label, this)
|
||||
.setTitle(R.string.lock_screen_intro_skip_title)
|
||||
.setMessage(args.getBoolean(ARG_FRP_SUPPORTED) ?
|
||||
R.string.lock_screen_intro_skip_dialog_text_frp :
|
||||
R.string.lock_screen_intro_skip_dialog_text);
|
||||
final boolean isFaceSupported =
|
||||
args.getBoolean(ChooseLockSettingsHelper.EXTRA_KEY_FOR_FACE);
|
||||
final boolean isFingerprintSupported =
|
||||
args.getBoolean(ChooseLockSettingsHelper.EXTRA_KEY_FOR_FINGERPRINT);
|
||||
if (isFaceSupported || isFingerprintSupported) {
|
||||
final int titleId;
|
||||
|
||||
if (args.getBoolean(ARG_LOCK_TYPE_PATTERN)) {
|
||||
titleId = R.string.lock_screen_pattern_skip_title;
|
||||
} else {
|
||||
titleId = args.getBoolean(ARG_LOCK_TYPE_ALPHANUMERIC) ?
|
||||
R.string.lock_screen_password_skip_title : R.string.lock_screen_pin_skip_title;
|
||||
}
|
||||
|
||||
return new AlertDialog.Builder(getContext())
|
||||
.setPositiveButton(R.string.skip_lock_screen_dialog_button_label, this)
|
||||
.setNegativeButton(R.string.cancel_lock_screen_dialog_button_label, this)
|
||||
.setTitle(titleId)
|
||||
.setMessage(isFaceSupported ?
|
||||
R.string.face_lock_screen_setup_skip_dialog_text :
|
||||
R.string.fingerprint_lock_screen_setup_skip_dialog_text);
|
||||
} else {
|
||||
return new AlertDialog.Builder(getContext())
|
||||
.setPositiveButton(R.string.skip_anyway_button_label, this)
|
||||
.setNegativeButton(R.string.go_back_button_label, this)
|
||||
.setTitle(R.string.lock_screen_intro_skip_title)
|
||||
.setMessage(args.getBoolean(ARG_FRP_SUPPORTED) ?
|
||||
R.string.lock_screen_intro_skip_dialog_text_frp :
|
||||
R.string.lock_screen_intro_skip_dialog_text);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -45,7 +45,8 @@ public class SetupSkipDialogTest {
|
||||
|
||||
@Test
|
||||
public void frpMessages_areShownCorrectly_whenNotSupported() {
|
||||
SetupSkipDialog setupSkipDialog = SetupSkipDialog.newInstance(false);
|
||||
SetupSkipDialog setupSkipDialog =
|
||||
SetupSkipDialog.newInstance(false, false, false, false, false);
|
||||
setupSkipDialog.show(mActivity.getSupportFragmentManager());
|
||||
|
||||
AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
|
||||
@@ -59,7 +60,8 @@ public class SetupSkipDialogTest {
|
||||
|
||||
@Test
|
||||
public void frpMessages_areShownCorrectly_whenSupported() {
|
||||
SetupSkipDialog setupSkipDialog = SetupSkipDialog.newInstance(true);
|
||||
SetupSkipDialog setupSkipDialog =
|
||||
SetupSkipDialog.newInstance(true, false, false, false, false);
|
||||
setupSkipDialog.show(mActivity.getSupportFragmentManager());
|
||||
|
||||
AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
|
||||
@@ -70,4 +72,101 @@ public class SetupSkipDialogTest {
|
||||
assertThat(mActivity.getString(R.string.lock_screen_intro_skip_dialog_text_frp)).isEqualTo(
|
||||
shadowAlertDialog.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void dialogMessage_whenSkipPinSetupForFace_shouldShownCorrectly() {
|
||||
SetupSkipDialog setupSkipDialog =
|
||||
SetupSkipDialog.newInstance(true, false, false, false, true);
|
||||
setupSkipDialog.show(mActivity.getSupportFragmentManager());
|
||||
|
||||
AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
|
||||
assertThat(alertDialog).isNotNull();
|
||||
ShadowAlertDialogCompat shadowAlertDialog = ShadowAlertDialogCompat.shadowOf(alertDialog);
|
||||
assertThat(mActivity.getString(R.string.lock_screen_pin_skip_title)).isEqualTo(
|
||||
shadowAlertDialog.getTitle());
|
||||
|
||||
assertThat(getSkipDialogMessage(false)).isEqualTo(shadowAlertDialog.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void dialogMessage_whenSkipPasswordSetupForFace_shouldShownCorrectly() {
|
||||
SetupSkipDialog setupSkipDialog =
|
||||
SetupSkipDialog.newInstance(true, false, true, false, true);
|
||||
setupSkipDialog.show(mActivity.getSupportFragmentManager());
|
||||
|
||||
AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
|
||||
assertThat(alertDialog).isNotNull();
|
||||
ShadowAlertDialogCompat shadowAlertDialog = ShadowAlertDialogCompat.shadowOf(alertDialog);
|
||||
assertThat(mActivity.getString(R.string.lock_screen_password_skip_title)).isEqualTo(
|
||||
shadowAlertDialog.getTitle());
|
||||
|
||||
assertThat(getSkipDialogMessage(false)).isEqualTo(shadowAlertDialog.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void dialogMessage_whenSkipPatternSetupForFace_shouldShownCorrectly() {
|
||||
SetupSkipDialog setupSkipDialog =
|
||||
SetupSkipDialog.newInstance(true, true, false, false, true);
|
||||
setupSkipDialog.show(mActivity.getSupportFragmentManager());
|
||||
|
||||
AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
|
||||
assertThat(alertDialog).isNotNull();
|
||||
ShadowAlertDialogCompat shadowAlertDialog = ShadowAlertDialogCompat.shadowOf(alertDialog);
|
||||
assertThat(mActivity.getString(R.string.lock_screen_pattern_skip_title)).isEqualTo(
|
||||
shadowAlertDialog.getTitle());
|
||||
|
||||
assertThat(getSkipDialogMessage(false)).isEqualTo(shadowAlertDialog.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void dialogMessage_whenSkipPinSetupForFingerprint_shouldShownCorrectly() {
|
||||
SetupSkipDialog setupSkipDialog =
|
||||
SetupSkipDialog.newInstance(true, false, false, true, false);
|
||||
setupSkipDialog.show(mActivity.getSupportFragmentManager());
|
||||
|
||||
AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
|
||||
assertThat(alertDialog).isNotNull();
|
||||
ShadowAlertDialogCompat shadowAlertDialog = ShadowAlertDialogCompat.shadowOf(alertDialog);
|
||||
assertThat(mActivity.getString(R.string.lock_screen_pin_skip_title)).isEqualTo(
|
||||
shadowAlertDialog.getTitle());
|
||||
|
||||
assertThat(getSkipDialogMessage(true)).isEqualTo(shadowAlertDialog.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void dialogMessage_whenSkipPasswordSetupForFingerprint_shouldShownCorrectly() {
|
||||
SetupSkipDialog setupSkipDialog =
|
||||
SetupSkipDialog.newInstance(true, false, true, true, false);
|
||||
setupSkipDialog.show(mActivity.getSupportFragmentManager());
|
||||
|
||||
AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
|
||||
assertThat(alertDialog).isNotNull();
|
||||
ShadowAlertDialogCompat shadowAlertDialog = ShadowAlertDialogCompat.shadowOf(alertDialog);
|
||||
assertThat(mActivity.getString(R.string.lock_screen_password_skip_title)).isEqualTo(
|
||||
shadowAlertDialog.getTitle());
|
||||
|
||||
assertThat(getSkipDialogMessage(true)).isEqualTo(shadowAlertDialog.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void dialogMessage_whenSkipPatternSetupForFingerprint_shouldShownCorrectly() {
|
||||
SetupSkipDialog setupSkipDialog =
|
||||
SetupSkipDialog.newInstance(true, true, false, true, false);
|
||||
setupSkipDialog.show(mActivity.getSupportFragmentManager());
|
||||
|
||||
AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
|
||||
assertThat(alertDialog).isNotNull();
|
||||
ShadowAlertDialogCompat shadowAlertDialog = ShadowAlertDialogCompat.shadowOf(alertDialog);
|
||||
assertThat(mActivity.getString(R.string.lock_screen_pattern_skip_title)).isEqualTo(
|
||||
shadowAlertDialog.getTitle());
|
||||
|
||||
assertThat(getSkipDialogMessage(true)).isEqualTo(shadowAlertDialog.getMessage());
|
||||
}
|
||||
|
||||
public String getSkipDialogMessage(boolean isFingerprintSupported) {
|
||||
return String.format(
|
||||
mActivity.getString(isFingerprintSupported ?
|
||||
R.string.fingerprint_lock_screen_setup_skip_dialog_text :
|
||||
R.string.face_lock_screen_setup_skip_dialog_text));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user