Update fingerprint enrolling flow
1. Make FingerprintEnrollFinish stay on the back stack during "add another" 2. Remove skip button from the enrolling screen, since the user can now back out of the enrollment flow, or back to FingerprintEnrollFinish and press "done" there. Test: Run FingerprintEnrollFinishTest with `am instrument` Bug: 32054268 Change-Id: Icaf017952d6582a14b4d0904b7ee67ad22e5280d
This commit is contained in:
@@ -237,12 +237,15 @@ public class FingerprintEnrollEnrolling extends FingerprintEnrollBase
|
||||
|
||||
private void launchFinish(byte[] token) {
|
||||
Intent intent = getFinishIntent();
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT
|
||||
| Intent.FLAG_ACTIVITY_CLEAR_TOP
|
||||
| Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, token);
|
||||
if (mUserId != UserHandle.USER_NULL) {
|
||||
intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
|
||||
}
|
||||
startActivity(intent);
|
||||
overridePendingTransition(R.anim.suw_slide_next_in, R.anim.suw_slide_next_out);
|
||||
finish();
|
||||
}
|
||||
|
||||
|
@@ -17,7 +17,6 @@
|
||||
package com.android.settings.fingerprint;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.hardware.fingerprint.FingerprintManager;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
@@ -32,19 +31,31 @@ import com.android.settings.Utils;
|
||||
*/
|
||||
public class FingerprintEnrollFinish extends FingerprintEnrollBase {
|
||||
|
||||
private static final int REQUEST_ADD_ANOTHER = 1;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.fingerprint_enroll_finish);
|
||||
setHeaderText(R.string.security_settings_fingerprint_enroll_finish_title);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
Button addButton = (Button) findViewById(R.id.add_another_button);
|
||||
|
||||
final FingerprintManager fpm = Utils.getFingerprintManagerOrNull(this);
|
||||
int enrolled = fpm.getEnrolledFingerprints(mUserId).size();
|
||||
int max = getResources().getInteger(
|
||||
com.android.internal.R.integer.config_fingerprintMaxTemplatesPerUser);
|
||||
if (enrolled >= max) {
|
||||
/* Don't show "Add" button if too many fingerprints already added */
|
||||
boolean hideAddAnother = false;
|
||||
if (fpm != null) {
|
||||
int enrolled = fpm.getEnrolledFingerprints(mUserId).size();
|
||||
int max = getResources().getInteger(
|
||||
com.android.internal.R.integer.config_fingerprintMaxTemplatesPerUser);
|
||||
hideAddAnother = enrolled >= max;
|
||||
}
|
||||
if (hideAddAnother) {
|
||||
// Don't show "Add" button if too many fingerprints already added
|
||||
addButton.setVisibility(View.INVISIBLE);
|
||||
} else {
|
||||
addButton.setOnClickListener(this);
|
||||
@@ -60,14 +71,21 @@ public class FingerprintEnrollFinish extends FingerprintEnrollBase {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (v.getId() == R.id.add_another_button) {
|
||||
final Intent intent = getEnrollingIntent();
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
startActivityForResult(getEnrollingIntent(), REQUEST_ADD_ANOTHER);
|
||||
}
|
||||
super.onClick(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (requestCode == REQUEST_ADD_ANOTHER && resultCode != RESULT_CANCELED) {
|
||||
setResult(resultCode, data);
|
||||
finish();
|
||||
} else {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return MetricsEvent.FINGERPRINT_ENROLL_FINISH;
|
||||
|
@@ -16,26 +16,14 @@
|
||||
|
||||
package com.android.settings.fingerprint;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.FragmentManager;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SetupWizardUtils;
|
||||
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
||||
|
||||
public class SetupFingerprintEnrollEnrolling extends FingerprintEnrollEnrolling {
|
||||
|
||||
private static final String TAG_DIALOG = "dialog";
|
||||
|
||||
@Override
|
||||
protected Intent getFinishIntent() {
|
||||
final Intent intent = new Intent(this, SetupFingerprintEnrollFinish.class);
|
||||
@@ -49,72 +37,8 @@ public class SetupFingerprintEnrollEnrolling extends FingerprintEnrollEnrolling
|
||||
super.onApplyThemeResource(theme, resid, first);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initViews() {
|
||||
super.initViews();
|
||||
final Button skipButton = (Button) findViewById(R.id.skip_button);
|
||||
skipButton.setVisibility(View.VISIBLE);
|
||||
skipButton.setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.skip_button:
|
||||
new SkipDialog().show(getFragmentManager(), TAG_DIALOG);
|
||||
break;
|
||||
default:
|
||||
super.onClick(v);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return MetricsEvent.FINGERPRINT_ENROLLING_SETUP;
|
||||
}
|
||||
|
||||
public static class SkipDialog extends InstrumentedDialogFragment {
|
||||
|
||||
@Override
|
||||
public void show(FragmentManager manager, String tag) {
|
||||
if (manager.findFragmentByTag(tag) == null) {
|
||||
super.show(manager, tag);
|
||||
}
|
||||
}
|
||||
|
||||
public SkipDialog() {
|
||||
// no-arg constructor for fragment
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
return new AlertDialog.Builder(getActivity())
|
||||
.setTitle(R.string.setup_fingerprint_enroll_enrolling_skip_title)
|
||||
.setMessage(R.string.setup_fingerprint_enroll_enrolling_skip_message)
|
||||
.setCancelable(false)
|
||||
.setPositiveButton(R.string.skip_anyway_button_label,
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
Activity activity = getActivity();
|
||||
if (activity != null) {
|
||||
activity.setResult(RESULT_SKIP);
|
||||
activity.finish();
|
||||
}
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.go_back_button_label,
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
}
|
||||
})
|
||||
.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return MetricsEvent.DIALOG_FINGERPRINT_CANCEL_SETUP;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user