blob: 66c30c717e6a3feba4ebd83f4c874ee07bc27bc9 [file] [log] [blame]
Daniel Sandler69bdee72012-10-23 16:45:50 -04001/*
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 Miller5ecd8112013-01-09 18:50:26 -080017package com.android.keyguard;
Daniel Sandler69bdee72012-10-23 16:45:50 -040018
19import android.content.Context;
Michael Jurka1254f2f2012-10-25 11:44:31 -070020import android.util.AttributeSet;
21import android.view.View;
Jorim Jaggi15a77f72014-05-28 16:20:03 +020022import android.view.ViewGroup;
Jorim Jaggi76a16232014-08-08 17:00:47 +020023import android.view.animation.AnimationUtils;
Daniel Sandler69bdee72012-10-23 16:45:50 -040024
Daniel Sandler69bdee72012-10-23 16:45:50 -040025/**
26 * Displays a PIN pad for unlocking.
27 */
Selim Cinek4e8b9ed2014-06-20 16:37:04 -070028public class KeyguardPINView extends KeyguardPinBasedInputView {
Daniel Sandler69bdee72012-10-23 16:45:50 -040029
Jorim Jaggi15a77f72014-05-28 16:20:03 +020030 private final AppearAnimationUtils mAppearAnimationUtils;
31 private ViewGroup mKeyguardBouncerFrame;
32 private ViewGroup mRow0;
33 private ViewGroup mRow1;
34 private ViewGroup mRow2;
35 private ViewGroup mRow3;
36 private View mDivider;
Jorim Jaggi76a16232014-08-08 17:00:47 +020037 private int mDisappearYTranslation;
Jorim Jaggi15a77f72014-05-28 16:20:03 +020038
Daniel Sandler69bdee72012-10-23 16:45:50 -040039 public KeyguardPINView(Context context) {
40 this(context, null);
41 }
42
43 public KeyguardPINView(Context context, AttributeSet attrs) {
44 super(context, attrs);
Jorim Jaggi15a77f72014-05-28 16:20:03 +020045 mAppearAnimationUtils = new AppearAnimationUtils(context);
Jorim Jaggi76a16232014-08-08 17:00:47 +020046 mDisappearYTranslation = getResources().getDimensionPixelSize(
47 R.dimen.disappear_y_translation);
Daniel Sandler69bdee72012-10-23 16:45:50 -040048 }
49
50 protected void resetState() {
Selim Cinek4e8b9ed2014-06-20 16:37:04 -070051 super.resetState();
Danielle Millett1625e872012-11-01 15:00:12 -040052 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 Sandler69bdee72012-10-23 16:45:50 -040057 }
58
59 @Override
Daniel Sandler8a26bf52012-10-30 13:29:50 -040060 protected int getPasswordTextViewId() {
61 return R.id.pinEntry;
62 }
63
64 @Override
Daniel Sandler69bdee72012-10-23 16:45:50 -040065 protected void onFinishInflate() {
66 super.onFinishInflate();
67
Jorim Jaggi15a77f72014-05-28 16:20:03 +020068 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 Sandler69bdee72012-10-23 16:45:50 -040074 }
Adam Cohen6fb841f2012-10-24 13:15:38 -070075
76 @Override
77 public void showUsabilityHint() {
78 }
Daniel Sandler16d90922012-11-01 12:41:14 -040079
80 @Override
81 public int getWrongPasswordStringId() {
82 return R.string.kg_wrong_pin;
83 }
Jorim Jaggic14f8292014-05-27 02:25:45 +020084
85 @Override
86 public void startAppearAnimation() {
Jorim Jaggi15a77f72014-05-28 16:20:03 +020087 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
Jorim Jaggi76a16232014-08-08 17:00:47 +0200120 @Override
121 public boolean startDisappearAnimation(Runnable finishRunnable) {
122 animate()
123 .alpha(0f)
124 .translationY(mDisappearYTranslation)
125 .setInterpolator(AnimationUtils
126 .loadInterpolator(mContext, android.R.interpolator.fast_out_linear_in))
127 .setDuration(100)
128 .withEndAction(finishRunnable);
129 return true;
130 }
131
Jorim Jaggi15a77f72014-05-28 16:20:03 +0200132 private void enableClipping(boolean enable) {
133 mKeyguardBouncerFrame.setClipToPadding(enable);
134 mKeyguardBouncerFrame.setClipChildren(enable);
135 mRow1.setClipToPadding(enable);
136 mRow2.setClipToPadding(enable);
137 mRow3.setClipToPadding(enable);
138 setClipChildren(enable);
Jorim Jaggic14f8292014-05-27 02:25:45 +0200139 }
Jorim Jaggi76a16232014-08-08 17:00:47 +0200140
141 @Override
142 public boolean hasOverlappingRendering() {
143 return false;
144 }
Michael Jurka1254f2f2012-10-25 11:44:31 -0700145}