blob: 1a6cee281c84304de08912d6f6a6b36d78febd40 [file] [log] [blame]
Kevin Chyn0be1f332018-09-18 18:15:16 -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;
Kevin Chyn0be1f332018-09-18 18:15:16 -070020import android.graphics.drawable.Drawable;
Kevin Chyn0be1f332018-09-18 18:15:16 -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 Chyn0be1f332018-09-18 18:15:16 -070027 * and positive/negative buttons.
28 */
29public class FingerprintDialogView extends BiometricDialogView {
Kevin Chyn0be1f332018-09-18 18:15:16 -070030
Kevin Chyn6bb20772018-12-27 15:14:44 -080031 public FingerprintDialogView(Context context,
32 DialogViewCallback callback) {
33 super(context, callback);
34 }
Kevin Chyn0be1f332018-09-18 18:15:16 -070035 @Override
Kevin Chyn6cf54e82018-09-18 19:13:27 -070036 protected int getHintStringResourceId() {
Kevin Chyn0be1f332018-09-18 18:15:16 -070037 return R.string.fingerprint_dialog_touch_sensor;
38 }
39
40 @Override
Kevin Chyn6cf54e82018-09-18 19:13:27 -070041 protected int getAuthenticatedAccessibilityResourceId() {
42 return com.android.internal.R.string.fingerprint_authenticated;
43 }
44
45 @Override
46 protected int getIconDescriptionResourceId() {
47 return R.string.accessibility_fingerprint_dialog_fingerprint_icon;
Kevin Chyn0be1f332018-09-18 18:15:16 -070048 }
49
50 @Override
Kevin Chyn6bb20772018-12-27 15:14:44 -080051 protected boolean shouldAnimateForTransition(int oldState, int newState) {
Kevin Chyn0be1f332018-09-18 18:15:16 -070052 if (oldState == STATE_NONE && newState == STATE_AUTHENTICATING) {
53 return false;
54 } else if (oldState == STATE_AUTHENTICATING && newState == STATE_ERROR) {
55 return true;
56 } else if (oldState == STATE_ERROR && newState == STATE_AUTHENTICATING) {
57 return true;
58 } else if (oldState == STATE_AUTHENTICATING && newState == STATE_AUTHENTICATED) {
59 // TODO(b/77328470): add animation when fingerprint is authenticated
60 return false;
61 }
62 return false;
63 }
64
Kevin Chyn6bb20772018-12-27 15:14:44 -080065 @Override
66 protected int getDelayAfterAuthenticatedDurationMs() {
67 return 0;
68 }
69
70 @Override
71 protected Drawable getAnimationForTransition(int oldState, int newState) {
Kevin Chyn0be1f332018-09-18 18:15:16 -070072 int iconRes;
73 if (oldState == STATE_NONE && newState == STATE_AUTHENTICATING) {
74 iconRes = R.drawable.fingerprint_dialog_fp_to_error;
75 } else if (oldState == STATE_AUTHENTICATING && newState == STATE_ERROR) {
76 iconRes = R.drawable.fingerprint_dialog_fp_to_error;
77 } else if (oldState == STATE_ERROR && newState == STATE_AUTHENTICATING) {
78 iconRes = R.drawable.fingerprint_dialog_error_to_fp;
79 } else if (oldState == STATE_AUTHENTICATING && newState == STATE_AUTHENTICATED) {
80 // TODO(b/77328470): add animation when fingerprint is authenticated
Kevin Chyn6bb20772018-12-27 15:14:44 -080081 iconRes = R.drawable.fingerprint_dialog_fp_to_error;
Kevin Chyn0be1f332018-09-18 18:15:16 -070082 } else {
83 return null;
84 }
85 return mContext.getDrawable(iconRes);
86 }
87}