blob: de3f9471a6bae697feae073001856434db5cda95 [file] [log] [blame]
Kevin Chyn6cf54e82018-09-18 19:13:27 -07001/*
2 * Copyright (C) 2018 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
17package com.android.systemui.biometrics;
18
19import android.content.Context;
20import android.graphics.drawable.Drawable;
Kevin Chyn6cf54e82018-09-18 19:13:27 -070021
22import com.android.systemui.R;
23
24/**
25 * This class loads the view for the system-provided dialog. The view consists of:
Kevin Chyn6bb20772018-12-27 15:14:44 -080026 * Application Icon, Title, Subtitle, Description, Biometric Icon, Error/Help message area,
Kevin Chyn6cf54e82018-09-18 19:13:27 -070027 * and positive/negative buttons.
28 */
29public class FaceDialogView extends BiometricDialogView {
Kevin Chyn6bb20772018-12-27 15:14:44 -080030
31 private static final int HIDE_DIALOG_DELAY = 500; // ms
32
Kevin Chyn6cf54e82018-09-18 19:13:27 -070033 public FaceDialogView(Context context,
34 DialogViewCallback callback) {
35 super(context, callback);
36 }
37
38 @Override
39 protected int getHintStringResourceId() {
40 return R.string.face_dialog_looking_for_face;
41 }
42
43 @Override
44 protected int getAuthenticatedAccessibilityResourceId() {
45 if (mRequireConfirmation) {
46 return com.android.internal.R.string.face_authenticated_confirmation_required;
47 } else {
48 return com.android.internal.R.string.face_authenticated_no_confirmation_required;
49 }
50 }
51
52 @Override
53 protected int getIconDescriptionResourceId() {
54 return R.string.accessibility_face_dialog_face_icon;
55 }
56
57 @Override
Kevin Chyn6bb20772018-12-27 15:14:44 -080058 protected boolean shouldAnimateForTransition(int oldState, int newState) {
59 if (oldState == STATE_NONE && newState == STATE_AUTHENTICATING) {
60 return false;
61 } else if (oldState == STATE_AUTHENTICATING && newState == STATE_ERROR) {
62 return true;
63 } else if (oldState == STATE_ERROR && newState == STATE_AUTHENTICATING) {
64 return true;
65 } else if (oldState == STATE_AUTHENTICATING && newState == STATE_PENDING_CONFIRMATION) {
66 return true;
67 } else if (oldState == STATE_PENDING_CONFIRMATION && newState == STATE_AUTHENTICATED) {
68 return true;
69 } else if (oldState == STATE_AUTHENTICATING && newState == STATE_AUTHENTICATED) {
70 return true;
71 }
72 return false;
73 }
Kevin Chyn6cf54e82018-09-18 19:13:27 -070074
Kevin Chyn6bb20772018-12-27 15:14:44 -080075 @Override
76 protected int getDelayAfterAuthenticatedDurationMs() {
77 return HIDE_DIALOG_DELAY;
78 }
79
80 @Override
81 protected Drawable getAnimationForTransition(int oldState, int newState) {
82 int iconRes;
83 if (oldState == STATE_NONE && newState == STATE_AUTHENTICATING) {
84 iconRes = R.drawable.face_dialog_face_to_error;
85 } else if (oldState == STATE_AUTHENTICATING && newState == STATE_ERROR) {
86 iconRes = R.drawable.face_dialog_face_to_error;
87 } else if (oldState == STATE_ERROR && newState == STATE_AUTHENTICATING) {
88 iconRes = R.drawable.face_dialog_error_to_face;
89 } else if (oldState == STATE_AUTHENTICATING && newState == STATE_PENDING_CONFIRMATION) {
90 iconRes = R.drawable.face_dialog_face_gray_to_face_blue;
91 } else if (oldState == STATE_PENDING_CONFIRMATION && newState == STATE_AUTHENTICATED) {
92 iconRes = R.drawable.face_dialog_face_blue_to_checkmark;
93 } else if (oldState == STATE_AUTHENTICATING && newState == STATE_AUTHENTICATED) {
94 iconRes = R.drawable.face_dialog_face_gray_to_checkmark;
95 } else {
96 return null;
97 }
98 return mContext.getDrawable(iconRes);
Kevin Chyn6cf54e82018-09-18 19:13:27 -070099 }
100}