1 /* 2 * Copyright (C) 2015 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License 15 */ 16 17 package com.android.settings.fingerprint; 18 19 import android.app.Activity; 20 import android.app.AlertDialog; 21 import android.app.Dialog; 22 import android.app.FragmentManager; 23 import android.content.DialogInterface; 24 import android.content.Intent; 25 import android.os.Bundle; 26 import android.os.UserHandle; 27 import android.support.annotation.NonNull; 28 29 import com.android.internal.logging.nano.MetricsProto; 30 import com.android.internal.logging.nano.MetricsProto.MetricsEvent; 31 import com.android.settings.R; 32 import com.android.settings.SetupWizardUtils; 33 import com.android.settings.core.instrumentation.InstrumentedDialogFragment; 34 import com.android.settings.password.ChooseLockSettingsHelper; 35 36 public class SetupFingerprintEnrollFindSensor extends FingerprintEnrollFindSensor { 37 38 @Override getContentView()39 protected int getContentView() { 40 return R.layout.fingerprint_enroll_find_sensor; 41 } 42 43 @Override getEnrollingIntent()44 protected Intent getEnrollingIntent() { 45 Intent intent = new Intent(this, SetupFingerprintEnrollEnrolling.class); 46 intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, mToken); 47 if (mUserId != UserHandle.USER_NULL) { 48 intent.putExtra(Intent.EXTRA_USER_ID, mUserId); 49 } 50 SetupWizardUtils.copySetupExtras(getIntent(), intent); 51 return intent; 52 } 53 54 @Override onSkipButtonClick()55 protected void onSkipButtonClick() { 56 new SkipFingerprintDialog().show(getFragmentManager()); 57 } 58 59 @Override getMetricsCategory()60 public int getMetricsCategory() { 61 return MetricsEvent.FINGERPRINT_FIND_SENSOR_SETUP; 62 } 63 64 public static class SkipFingerprintDialog extends InstrumentedDialogFragment 65 implements DialogInterface.OnClickListener { 66 private static final String TAG_SKIP_DIALOG = "skip_dialog"; 67 68 @Override getMetricsCategory()69 public int getMetricsCategory() { 70 return MetricsProto.MetricsEvent.DIALOG_FINGERPRINT_SKIP_SETUP; 71 } 72 73 @Override onCreateDialog(Bundle savedInstanceState)74 public Dialog onCreateDialog(Bundle savedInstanceState) { 75 return onCreateDialogBuilder().create(); 76 } 77 78 @NonNull onCreateDialogBuilder()79 public AlertDialog.Builder onCreateDialogBuilder() { 80 return new AlertDialog.Builder(getContext()) 81 .setTitle(R.string.setup_fingerprint_enroll_skip_title) 82 .setPositiveButton(R.string.skip_anyway_button_label, this) 83 .setNegativeButton(R.string.go_back_button_label, this) 84 .setMessage(R.string.setup_fingerprint_enroll_skip_after_adding_lock_text); 85 } 86 87 @Override onClick(DialogInterface dialog, int button)88 public void onClick(DialogInterface dialog, int button) { 89 switch (button) { 90 case DialogInterface.BUTTON_POSITIVE: 91 Activity activity = getActivity(); 92 if (activity != null) { 93 activity.setResult(RESULT_SKIP); 94 activity.finish(); 95 } 96 break; 97 } 98 } 99 show(FragmentManager manager)100 public void show(FragmentManager manager) { 101 show(manager, TAG_SKIP_DIALOG); 102 } 103 } 104 } 105