Skip to content

Commit 7f3eb49

Browse files
author
John Wang
committed
Update PUK unlock screen.
1. Make Pin and Puk focusable EditText. 2. Add hint text for pin and puk. 3. Update focusEntry logic. bug:5243771 Change-Id: I65bd52510bbbf0ebd7830ecac7e31159ae750c6c
1 parent 9c71128 commit 7f3eb49

2 files changed

Lines changed: 41 additions & 68 deletions

File tree

core/res/res/layout/keyguard_screen_sim_puk_portrait.xml

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
android:layout_height="wrap_content"
3535
android:gravity="center"
3636
android:singleLine="true"
37+
android:ellipsize="marquee"
38+
android:layout_marginRight="6dip"
39+
android:layout_marginLeft="6dip"
3740
android:textAppearance="?android:attr/textAppearanceLarge"/>
3841

3942
<!-- Carrier info -->
@@ -44,35 +47,15 @@
4447
android:gravity="center"
4548
android:singleLine="true"
4649
android:ellipsize="marquee"
50+
android:layout_marginRight="6dip"
51+
android:layout_marginLeft="6dip"
4752
android:textAppearance="?android:attr/textAppearanceMedium"/>
4853

4954
<LinearLayout
5055
android:orientation="horizontal"
5156
android:layout_width="match_parent"
5257
android:layout_height="wrap_content">
5358

54-
<LinearLayout
55-
android:orientation="vertical"
56-
android:layout_width="wrap_content"
57-
android:layout_height="match_parent"
58-
android:layout_marginRight="10dip"
59-
android:layout_marginLeft="10dip">
60-
<TextView android:id="@+id/enter_puk"
61-
android:layout_width="wrap_content"
62-
android:layout_height="wrap_content"
63-
android:gravity="center_vertical"
64-
android:text="@android:string/keyguard_password_enter_puk_prompt"
65-
android:textSize="30sp"
66-
android:layout_marginBottom="10dip"/>
67-
<TextView android:id="@+id/enter_pin"
68-
android:layout_width="wrap_content"
69-
android:layout_height="wrap_content"
70-
android:gravity="center_vertical"
71-
android:text="@android:string/keyguard_password_enter_pin_prompt"
72-
android:textSize="30sp"
73-
android:layout_marginTop="10dip"/>
74-
</LinearLayout>
75-
7659
<LinearLayout
7760
android:orientation="vertical"
7861
android:layout_width="wrap_content"
@@ -92,14 +75,15 @@
9275
android:background="@android:drawable/edit_text">
9376

9477
<!-- displays dots as user enters puk -->
95-
<TextView android:id="@+id/pukDisplay"
78+
<EditText android:id="@+id/pukDisplay"
9679
android:layout_width="0dip"
9780
android:layout_height="wrap_content"
9881
android:layout_weight="1"
9982
android:maxLines="1"
100-
android:textAppearance="?android:attr/textAppearanceLargeInverse"
10183
android:textStyle="bold"
10284
android:inputType="textPassword"
85+
android:textColor="#000"
86+
android:hint="@android:string/keyguard_password_enter_puk_prompt"
10387
/>
10488

10589
<ImageButton android:id="@+id/pukDel"
@@ -122,14 +106,15 @@
122106
android:background="@android:drawable/edit_text">
123107

124108
<!-- displays dots as user enters new pin -->
125-
<TextView android:id="@+id/pinDisplay"
109+
<EditText android:id="@+id/pinDisplay"
126110
android:layout_width="0dip"
127111
android:layout_height="wrap_content"
128112
android:layout_weight="1"
129113
android:maxLines="1"
130-
android:textAppearance="?android:attr/textAppearanceLargeInverse"
131114
android:textStyle="bold"
132115
android:inputType="textPassword"
116+
android:textColor="#000"
117+
android:hint="@android:string/keyguard_password_enter_pin_prompt"
133118
/>
134119

135120
<ImageButton android:id="@+id/pinDel"
@@ -177,7 +162,7 @@
177162
android:layout_width="wrap_content"
178163
android:layout_height="wrap_content"
179164
android:drawableLeft="@android:drawable/ic_emergency"
180-
android:drawablePadding="8dip"
165+
android:drawablePadding="4dip"
181166
android:text="@android:string/lockscreen_emergency_call"
182167
/>
183168
</LinearLayout>

policy/src/com/android/internal/policy/impl/SimPukUnlockScreen.java

Lines changed: 29 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import com.android.internal.widget.LockPatternUtils;
2828

2929
import android.text.Editable;
30+
import android.util.Log;
3031
import android.view.KeyEvent;
3132
import android.view.LayoutInflater;
3233
import android.view.View;
@@ -40,21 +41,20 @@
4041
* Displays a dialer like interface to unlock the SIM PUK.
4142
*/
4243
public class SimPukUnlockScreen extends LinearLayout implements KeyguardScreen,
43-
View.OnClickListener {
44+
View.OnClickListener, View.OnFocusChangeListener {
4445

4546
private static final int DIGIT_PRESS_WAKE_MILLIS = 5000;
4647

4748
private final KeyguardUpdateMonitor mUpdateMonitor;
4849
private final KeyguardScreenCallback mCallback;
50+
private KeyguardStatusViewManager mKeyguardStatusViewManager;
4951

5052
private TextView mHeaderText;
5153
private TextView mPukText;
5254
private TextView mPinText;
53-
5455
private TextView mFocusedEntry;
5556

56-
private TextView mOkButton;
57-
57+
private View mOkButton;
5858
private View mDelPukButton;
5959
private View mDelPinButton;
6060

@@ -66,8 +66,6 @@ public class SimPukUnlockScreen extends LinearLayout implements KeyguardScreen,
6666

6767
private int mKeyboardHidden;
6868

69-
private KeyguardStatusViewManager mKeyguardStatusViewManager;
70-
7169
private static final char[] DIGITS = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
7270

7371
public SimPukUnlockScreen(Context context, Configuration configuration,
@@ -92,44 +90,33 @@ public SimPukUnlockScreen(Context context, Configuration configuration,
9290
}
9391

9492
mHeaderText = (TextView) findViewById(R.id.headerText);
93+
9594
mPukText = (TextView) findViewById(R.id.pukDisplay);
96-
mPukText.setOnClickListener(new OnClickListener() {
97-
public void onClick(View v) {
98-
requestFocus(mPukText);
99-
mCallback.pokeWakelock();
100-
}
101-
});
10295
mPinText = (TextView) findViewById(R.id.pinDisplay);
103-
mPinText.setOnClickListener(this);
104-
10596
mDelPukButton = findViewById(R.id.pukDel);
106-
mDelPukButton.setOnClickListener(this);
10797
mDelPinButton = findViewById(R.id.pinDel);
108-
mDelPinButton.setOnClickListener(this);
98+
mOkButton = findViewById(R.id.ok);
10999

110-
mOkButton = (TextView) findViewById(R.id.ok);
111-
112-
mHeaderText.setText(R.string.keyguard_password_enter_puk_code);
113-
mPukText.setFocusable(false);
114-
mPinText.setFocusable(false);
100+
mDelPinButton.setOnClickListener(this);
101+
mDelPukButton.setOnClickListener(this);
115102
mOkButton.setOnClickListener(this);
116103

117-
requestFocus(mPukText);
104+
mHeaderText.setText(R.string.keyguard_password_enter_puk_code);
105+
// To make marquee work
106+
mHeaderText.setSelected(true);
118107

119108
mKeyguardStatusViewManager = new KeyguardStatusViewManager(this, updateMonitor,
120109
lockpatternutils, callback);
121110

122-
setFocusableInTouchMode(true);
123-
}
124-
125-
private void requestFocus(TextView entry) {
126-
mFocusedEntry = entry;
127-
mFocusedEntry.setText("");
111+
mPinText.setFocusableInTouchMode(true);
112+
mPinText.setOnFocusChangeListener(this);
113+
mPukText.setFocusableInTouchMode(true);
114+
mPukText.setOnFocusChangeListener(this);
128115
}
129116

130117
/** {@inheritDoc} */
131118
public boolean needsInput() {
132-
return true;
119+
return false;
133120
}
134121

135122
/** {@inheritDoc} */
@@ -141,9 +128,6 @@ public void onPause() {
141128
public void onResume() {
142129
// start fresh
143130
mHeaderText.setText(R.string.keyguard_password_enter_puk_code);
144-
requestFocus(mPukText);
145-
mPinText.setText("");
146-
147131
mKeyguardStatusViewManager.onResume();
148132
}
149133

@@ -196,25 +180,32 @@ public void run() {
196180

197181
public void onClick(View v) {
198182
if (v == mDelPukButton) {
183+
if (mFocusedEntry != mPukText)
184+
mPukText.requestFocus();
199185
final Editable digits = mPukText.getEditableText();
200186
final int len = digits.length();
201187
if (len > 0) {
202188
digits.delete(len-1, len);
203189
}
204-
mCallback.pokeWakelock();
205190
} else if (v == mDelPinButton) {
191+
if (mFocusedEntry != mPinText)
192+
mPinText.requestFocus();
206193
final Editable digits = mPinText.getEditableText();
207194
final int len = digits.length();
208195
if (len > 0) {
209196
digits.delete(len-1, len);
210197
}
211-
mCallback.pokeWakelock();
212-
} else if (v == mPinText) {
213-
requestFocus(mPinText);
214-
mCallback.pokeWakelock();
215198
} else if (v == mOkButton) {
216199
checkPuk();
217200
}
201+
mCallback.pokeWakelock(DIGIT_PRESS_WAKE_MILLIS);
202+
203+
}
204+
205+
@Override
206+
public void onFocusChange(View v, boolean hasFocus) {
207+
if (hasFocus)
208+
mFocusedEntry = (TextView)v;
218209
}
219210

220211
private Dialog getSimUnlockProgressDialog() {
@@ -236,7 +227,6 @@ private void checkPuk() {
236227
// otherwise, display a message to the user, and don't submit.
237228
mHeaderText.setText(R.string.invalidPuk);
238229
mPukText.setText("");
239-
mCallback.pokeWakelock();
240230
return;
241231
}
242232

@@ -245,7 +235,6 @@ private void checkPuk() {
245235
// otherwise, display a message to the user, and don't submit.
246236
mHeaderText.setText(R.string.invalidPin);
247237
mPinText.setText("");
248-
mCallback.pokeWakelock();
249238
return;
250239
}
251240

@@ -267,7 +256,6 @@ void onSimLockChangedResponse(boolean success) {
267256
mPukText.setText("");
268257
mPinText.setText("");
269258
}
270-
mCallback.pokeWakelock();
271259
}
272260
}.start();
273261
}
@@ -290,7 +278,7 @@ public boolean onKeyDown(int keyCode, KeyEvent event) {
290278
if (len > 0) {
291279
digits.delete(len-1, len);
292280
}
293-
mCallback.pokeWakelock();
281+
mCallback.pokeWakelock(DIGIT_PRESS_WAKE_MILLIS);
294282
return true;
295283
}
296284

0 commit comments

Comments
 (0)