1 /* 2 * Copyright (C) 2020 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.biometrics.face; 18 19 import android.app.AlertDialog; 20 import android.app.Dialog; 21 import android.app.settings.SettingsEnums; 22 import android.os.Bundle; 23 24 import com.android.settings.R; 25 import com.android.settings.core.instrumentation.InstrumentedDialogFragment; 26 27 /** 28 * Confirmation dialog shown to users with accessibility enabled who are trying to start the 29 * non-accessibility enrollment flow. 30 */ 31 public class FaceEnrollAccessibilityDialog extends InstrumentedDialogFragment { 32 private AlertDialog.OnClickListener mPositiveButtonListener; 33 34 /** 35 * @return new instance of the dialog 36 */ newInstance()37 public static FaceEnrollAccessibilityDialog newInstance() { 38 return new FaceEnrollAccessibilityDialog(); 39 } 40 setPositiveButtonListener(AlertDialog.OnClickListener listener)41 public void setPositiveButtonListener(AlertDialog.OnClickListener listener) { 42 mPositiveButtonListener = listener; 43 } 44 45 @Override onCreateDialog(Bundle savedInstanceState)46 public Dialog onCreateDialog(Bundle savedInstanceState) { 47 AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); 48 49 final int titleResId = 50 R.string.security_settings_face_enroll_education_accessibility_dialog_message; 51 final int negativeButtonResId = 52 R.string.security_settings_face_enroll_education_accessibility_dialog_negative; 53 final int positiveButtonResId = 54 R.string.security_settings_face_enroll_education_accessibility_dialog_positive; 55 56 builder.setMessage(titleResId) 57 .setNegativeButton(negativeButtonResId, (dialog, which) -> { 58 dialog.cancel(); 59 }) 60 .setPositiveButton(positiveButtonResId, (dialog, which) -> { 61 mPositiveButtonListener.onClick(dialog, which); 62 }); 63 64 return builder.create(); 65 } 66 67 @Override getMetricsCategory()68 public int getMetricsCategory() { 69 return SettingsEnums.FACE_ENROLL_INTRO; 70 } 71 } 72