Kevin Chyn | 6cf54e8 | 2018-09-18 19:13:27 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package com.android.systemui.biometrics; |
| 18 | |
| 19 | import android.content.Context; |
| 20 | import android.graphics.drawable.Drawable; |
Kevin Chyn | 6cf54e8 | 2018-09-18 19:13:27 -0700 | [diff] [blame] | 21 | |
| 22 | import com.android.systemui.R; |
| 23 | |
| 24 | /** |
| 25 | * This class loads the view for the system-provided dialog. The view consists of: |
Kevin Chyn | 6bb2077 | 2018-12-27 15:14:44 -0800 | [diff] [blame] | 26 | * Application Icon, Title, Subtitle, Description, Biometric Icon, Error/Help message area, |
Kevin Chyn | 6cf54e8 | 2018-09-18 19:13:27 -0700 | [diff] [blame] | 27 | * and positive/negative buttons. |
| 28 | */ |
| 29 | public class FaceDialogView extends BiometricDialogView { |
Kevin Chyn | 6bb2077 | 2018-12-27 15:14:44 -0800 | [diff] [blame] | 30 | |
| 31 | private static final int HIDE_DIALOG_DELAY = 500; // ms |
| 32 | |
Kevin Chyn | 6cf54e8 | 2018-09-18 19:13:27 -0700 | [diff] [blame] | 33 | 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 Chyn | 6bb2077 | 2018-12-27 15:14:44 -0800 | [diff] [blame] | 58 | 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 Chyn | 6cf54e8 | 2018-09-18 19:13:27 -0700 | [diff] [blame] | 74 | |
Kevin Chyn | 6bb2077 | 2018-12-27 15:14:44 -0800 | [diff] [blame] | 75 | @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 Chyn | 6cf54e8 | 2018-09-18 19:13:27 -0700 | [diff] [blame] | 99 | } |
| 100 | } |