Daniel Sandler | 69bdee7 | 2012-10-23 16:45:50 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 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 | |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 17 | package com.android.keyguard; |
Daniel Sandler | 69bdee7 | 2012-10-23 16:45:50 -0400 | [diff] [blame] | 18 | |
| 19 | import android.content.Context; |
Daniel Sandler | 69bdee7 | 2012-10-23 16:45:50 -0400 | [diff] [blame] | 20 | import android.text.InputType; |
Daniel Sandler | 69bdee7 | 2012-10-23 16:45:50 -0400 | [diff] [blame] | 21 | import android.text.TextWatcher; |
| 22 | import android.text.method.DigitsKeyListener; |
Michael Jurka | 1254f2f | 2012-10-25 11:44:31 -0700 | [diff] [blame] | 23 | import android.util.AttributeSet; |
| 24 | import android.view.View; |
Jorim Jaggi | 15a77f7 | 2014-05-28 16:20:03 +0200 | [diff] [blame] | 25 | import android.view.ViewGroup; |
Daniel Sandler | 69bdee7 | 2012-10-23 16:45:50 -0400 | [diff] [blame] | 26 | import android.widget.TextView.OnEditorActionListener; |
| 27 | |
Daniel Sandler | 69bdee7 | 2012-10-23 16:45:50 -0400 | [diff] [blame] | 28 | /** |
| 29 | * Displays a PIN pad for unlocking. |
| 30 | */ |
Selim Cinek | 4e8b9ed | 2014-06-20 16:37:04 -0700 | [diff] [blame^] | 31 | public class KeyguardPINView extends KeyguardPinBasedInputView { |
Daniel Sandler | 69bdee7 | 2012-10-23 16:45:50 -0400 | [diff] [blame] | 32 | |
Jorim Jaggi | 15a77f7 | 2014-05-28 16:20:03 +0200 | [diff] [blame] | 33 | private final AppearAnimationUtils mAppearAnimationUtils; |
| 34 | private ViewGroup mKeyguardBouncerFrame; |
| 35 | private ViewGroup mRow0; |
| 36 | private ViewGroup mRow1; |
| 37 | private ViewGroup mRow2; |
| 38 | private ViewGroup mRow3; |
| 39 | private View mDivider; |
| 40 | |
Daniel Sandler | 69bdee7 | 2012-10-23 16:45:50 -0400 | [diff] [blame] | 41 | public KeyguardPINView(Context context) { |
| 42 | this(context, null); |
| 43 | } |
| 44 | |
| 45 | public KeyguardPINView(Context context, AttributeSet attrs) { |
| 46 | super(context, attrs); |
Jorim Jaggi | 15a77f7 | 2014-05-28 16:20:03 +0200 | [diff] [blame] | 47 | mAppearAnimationUtils = new AppearAnimationUtils(context); |
Daniel Sandler | 69bdee7 | 2012-10-23 16:45:50 -0400 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | protected void resetState() { |
Selim Cinek | 4e8b9ed | 2014-06-20 16:37:04 -0700 | [diff] [blame^] | 51 | super.resetState(); |
Danielle Millett | 1625e87 | 2012-11-01 15:00:12 -0400 | [diff] [blame] | 52 | if (KeyguardUpdateMonitor.getInstance(mContext).getMaxBiometricUnlockAttemptsReached()) { |
| 53 | mSecurityMessageDisplay.setMessage(R.string.faceunlock_multiple_failures, true); |
| 54 | } else { |
| 55 | mSecurityMessageDisplay.setMessage(R.string.kg_pin_instructions, false); |
| 56 | } |
Daniel Sandler | 69bdee7 | 2012-10-23 16:45:50 -0400 | [diff] [blame] | 57 | } |
| 58 | |
| 59 | @Override |
Daniel Sandler | 8a26bf5 | 2012-10-30 13:29:50 -0400 | [diff] [blame] | 60 | protected int getPasswordTextViewId() { |
| 61 | return R.id.pinEntry; |
| 62 | } |
| 63 | |
| 64 | @Override |
Daniel Sandler | 69bdee7 | 2012-10-23 16:45:50 -0400 | [diff] [blame] | 65 | protected void onFinishInflate() { |
| 66 | super.onFinishInflate(); |
| 67 | |
Jorim Jaggi | 15a77f7 | 2014-05-28 16:20:03 +0200 | [diff] [blame] | 68 | mKeyguardBouncerFrame = (ViewGroup) findViewById(R.id.keyguard_bouncer_frame); |
| 69 | mRow0 = (ViewGroup) findViewById(R.id.row0); |
| 70 | mRow1 = (ViewGroup) findViewById(R.id.row1); |
| 71 | mRow2 = (ViewGroup) findViewById(R.id.row2); |
| 72 | mRow3 = (ViewGroup) findViewById(R.id.row3); |
| 73 | mDivider = findViewById(R.id.divider); |
Daniel Sandler | 69bdee7 | 2012-10-23 16:45:50 -0400 | [diff] [blame] | 74 | } |
Adam Cohen | 6fb841f | 2012-10-24 13:15:38 -0700 | [diff] [blame] | 75 | |
| 76 | @Override |
| 77 | public void showUsabilityHint() { |
| 78 | } |
Daniel Sandler | 16d9092 | 2012-11-01 12:41:14 -0400 | [diff] [blame] | 79 | |
| 80 | @Override |
| 81 | public int getWrongPasswordStringId() { |
| 82 | return R.string.kg_wrong_pin; |
| 83 | } |
Jorim Jaggi | c14f829 | 2014-05-27 02:25:45 +0200 | [diff] [blame] | 84 | |
| 85 | @Override |
| 86 | public void startAppearAnimation() { |
Jorim Jaggi | 15a77f7 | 2014-05-28 16:20:03 +0200 | [diff] [blame] | 87 | enableClipping(false); |
| 88 | setTranslationY(mAppearAnimationUtils.getStartTranslation()); |
| 89 | animate() |
| 90 | .setDuration(500) |
| 91 | .setInterpolator(mAppearAnimationUtils.getInterpolator()) |
| 92 | .translationY(0); |
| 93 | mAppearAnimationUtils.startAppearAnimation(new View[][] { |
| 94 | new View[] { |
| 95 | mRow0, null, null |
| 96 | }, |
| 97 | new View[] { |
| 98 | findViewById(R.id.key1), findViewById(R.id.key2), findViewById(R.id.key3) |
| 99 | }, |
| 100 | new View[] { |
| 101 | findViewById(R.id.key4), findViewById(R.id.key5), findViewById(R.id.key6) |
| 102 | }, |
| 103 | new View[] { |
| 104 | findViewById(R.id.key7), findViewById(R.id.key8), findViewById(R.id.key9) |
| 105 | }, |
| 106 | new View[] { |
| 107 | null, findViewById(R.id.key0), findViewById(R.id.key_enter) |
| 108 | }, |
| 109 | new View[] { |
| 110 | null, mEcaView, null |
| 111 | }}, |
| 112 | new Runnable() { |
| 113 | @Override |
| 114 | public void run() { |
| 115 | enableClipping(true); |
| 116 | } |
| 117 | }); |
| 118 | } |
| 119 | |
| 120 | private void enableClipping(boolean enable) { |
| 121 | mKeyguardBouncerFrame.setClipToPadding(enable); |
| 122 | mKeyguardBouncerFrame.setClipChildren(enable); |
| 123 | mRow1.setClipToPadding(enable); |
| 124 | mRow2.setClipToPadding(enable); |
| 125 | mRow3.setClipToPadding(enable); |
| 126 | setClipChildren(enable); |
Jorim Jaggi | c14f829 | 2014-05-27 02:25:45 +0200 | [diff] [blame] | 127 | } |
Michael Jurka | 1254f2f | 2012-10-25 11:44:31 -0700 | [diff] [blame] | 128 | } |