Merge "Update PUK unlock screen." into ics-factoryrom

This commit is contained in:
John Wang
2011-09-22 15:44:40 -07:00
committed by Android (Google) Code Review
2 changed files with 41 additions and 68 deletions

View File

@ -34,6 +34,9 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center" android:gravity="center"
android:singleLine="true" android:singleLine="true"
android:ellipsize="marquee"
android:layout_marginRight="6dip"
android:layout_marginLeft="6dip"
android:textAppearance="?android:attr/textAppearanceLarge"/> android:textAppearance="?android:attr/textAppearanceLarge"/>
<!-- Carrier info --> <!-- Carrier info -->
@ -44,6 +47,8 @@
android:gravity="center" android:gravity="center"
android:singleLine="true" android:singleLine="true"
android:ellipsize="marquee" android:ellipsize="marquee"
android:layout_marginRight="6dip"
android:layout_marginLeft="6dip"
android:textAppearance="?android:attr/textAppearanceMedium"/> android:textAppearance="?android:attr/textAppearanceMedium"/>
<LinearLayout <LinearLayout
@ -51,28 +56,6 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginRight="10dip"
android:layout_marginLeft="10dip">
<TextView android:id="@+id/enter_puk"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:text="@android:string/keyguard_password_enter_puk_prompt"
android:textSize="30sp"
android:layout_marginBottom="10dip"/>
<TextView android:id="@+id/enter_pin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:text="@android:string/keyguard_password_enter_pin_prompt"
android:textSize="30sp"
android:layout_marginTop="10dip"/>
</LinearLayout>
<LinearLayout <LinearLayout
android:orientation="vertical" android:orientation="vertical"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -92,14 +75,15 @@
android:background="@android:drawable/edit_text"> android:background="@android:drawable/edit_text">
<!-- displays dots as user enters puk --> <!-- displays dots as user enters puk -->
<TextView android:id="@+id/pukDisplay" <EditText android:id="@+id/pukDisplay"
android:layout_width="0dip" android:layout_width="0dip"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:maxLines="1" android:maxLines="1"
android:textAppearance="?android:attr/textAppearanceLargeInverse"
android:textStyle="bold" android:textStyle="bold"
android:inputType="textPassword" android:inputType="textPassword"
android:textColor="#000"
android:hint="@android:string/keyguard_password_enter_puk_prompt"
/> />
<ImageButton android:id="@+id/pukDel" <ImageButton android:id="@+id/pukDel"
@ -122,14 +106,15 @@
android:background="@android:drawable/edit_text"> android:background="@android:drawable/edit_text">
<!-- displays dots as user enters new pin --> <!-- displays dots as user enters new pin -->
<TextView android:id="@+id/pinDisplay" <EditText android:id="@+id/pinDisplay"
android:layout_width="0dip" android:layout_width="0dip"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:maxLines="1" android:maxLines="1"
android:textAppearance="?android:attr/textAppearanceLargeInverse"
android:textStyle="bold" android:textStyle="bold"
android:inputType="textPassword" android:inputType="textPassword"
android:textColor="#000"
android:hint="@android:string/keyguard_password_enter_pin_prompt"
/> />
<ImageButton android:id="@+id/pinDel" <ImageButton android:id="@+id/pinDel"
@ -177,7 +162,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:drawableLeft="@android:drawable/ic_emergency" android:drawableLeft="@android:drawable/ic_emergency"
android:drawablePadding="8dip" android:drawablePadding="4dip"
android:text="@android:string/lockscreen_emergency_call" android:text="@android:string/lockscreen_emergency_call"
/> />
</LinearLayout> </LinearLayout>

View File

@ -27,6 +27,7 @@ import com.android.internal.telephony.ITelephony;
import com.android.internal.widget.LockPatternUtils; import com.android.internal.widget.LockPatternUtils;
import android.text.Editable; import android.text.Editable;
import android.util.Log;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -40,21 +41,20 @@ import com.android.internal.R;
* Displays a dialer like interface to unlock the SIM PUK. * Displays a dialer like interface to unlock the SIM PUK.
*/ */
public class SimPukUnlockScreen extends LinearLayout implements KeyguardScreen, public class SimPukUnlockScreen extends LinearLayout implements KeyguardScreen,
View.OnClickListener { View.OnClickListener, View.OnFocusChangeListener {
private static final int DIGIT_PRESS_WAKE_MILLIS = 5000; private static final int DIGIT_PRESS_WAKE_MILLIS = 5000;
private final KeyguardUpdateMonitor mUpdateMonitor; private final KeyguardUpdateMonitor mUpdateMonitor;
private final KeyguardScreenCallback mCallback; private final KeyguardScreenCallback mCallback;
private KeyguardStatusViewManager mKeyguardStatusViewManager;
private TextView mHeaderText; private TextView mHeaderText;
private TextView mPukText; private TextView mPukText;
private TextView mPinText; private TextView mPinText;
private TextView mFocusedEntry; private TextView mFocusedEntry;
private TextView mOkButton; private View mOkButton;
private View mDelPukButton; private View mDelPukButton;
private View mDelPinButton; private View mDelPinButton;
@ -66,8 +66,6 @@ public class SimPukUnlockScreen extends LinearLayout implements KeyguardScreen,
private int mKeyboardHidden; private int mKeyboardHidden;
private KeyguardStatusViewManager mKeyguardStatusViewManager;
private static final char[] DIGITS = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}; private static final char[] DIGITS = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
public SimPukUnlockScreen(Context context, Configuration configuration, public SimPukUnlockScreen(Context context, Configuration configuration,
@ -92,44 +90,33 @@ public class SimPukUnlockScreen extends LinearLayout implements KeyguardScreen,
} }
mHeaderText = (TextView) findViewById(R.id.headerText); mHeaderText = (TextView) findViewById(R.id.headerText);
mPukText = (TextView) findViewById(R.id.pukDisplay); mPukText = (TextView) findViewById(R.id.pukDisplay);
mPukText.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
requestFocus(mPukText);
mCallback.pokeWakelock();
}
});
mPinText = (TextView) findViewById(R.id.pinDisplay); mPinText = (TextView) findViewById(R.id.pinDisplay);
mPinText.setOnClickListener(this);
mDelPukButton = findViewById(R.id.pukDel); mDelPukButton = findViewById(R.id.pukDel);
mDelPukButton.setOnClickListener(this);
mDelPinButton = findViewById(R.id.pinDel); mDelPinButton = findViewById(R.id.pinDel);
mOkButton = findViewById(R.id.ok);
mDelPinButton.setOnClickListener(this); mDelPinButton.setOnClickListener(this);
mDelPukButton.setOnClickListener(this);
mOkButton = (TextView) findViewById(R.id.ok);
mHeaderText.setText(R.string.keyguard_password_enter_puk_code);
mPukText.setFocusable(false);
mPinText.setFocusable(false);
mOkButton.setOnClickListener(this); mOkButton.setOnClickListener(this);
requestFocus(mPukText); mHeaderText.setText(R.string.keyguard_password_enter_puk_code);
// To make marquee work
mHeaderText.setSelected(true);
mKeyguardStatusViewManager = new KeyguardStatusViewManager(this, updateMonitor, mKeyguardStatusViewManager = new KeyguardStatusViewManager(this, updateMonitor,
lockpatternutils, callback, true); lockpatternutils, callback, true);
setFocusableInTouchMode(true); mPinText.setFocusableInTouchMode(true);
} mPinText.setOnFocusChangeListener(this);
mPukText.setFocusableInTouchMode(true);
private void requestFocus(TextView entry) { mPukText.setOnFocusChangeListener(this);
mFocusedEntry = entry;
mFocusedEntry.setText("");
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
public boolean needsInput() { public boolean needsInput() {
return true; return false;
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@ -141,9 +128,6 @@ public class SimPukUnlockScreen extends LinearLayout implements KeyguardScreen,
public void onResume() { public void onResume() {
// start fresh // start fresh
mHeaderText.setText(R.string.keyguard_password_enter_puk_code); mHeaderText.setText(R.string.keyguard_password_enter_puk_code);
requestFocus(mPukText);
mPinText.setText("");
mKeyguardStatusViewManager.onResume(); mKeyguardStatusViewManager.onResume();
} }
@ -196,25 +180,32 @@ public class SimPukUnlockScreen extends LinearLayout implements KeyguardScreen,
public void onClick(View v) { public void onClick(View v) {
if (v == mDelPukButton) { if (v == mDelPukButton) {
if (mFocusedEntry != mPukText)
mPukText.requestFocus();
final Editable digits = mPukText.getEditableText(); final Editable digits = mPukText.getEditableText();
final int len = digits.length(); final int len = digits.length();
if (len > 0) { if (len > 0) {
digits.delete(len-1, len); digits.delete(len-1, len);
} }
mCallback.pokeWakelock();
} else if (v == mDelPinButton) { } else if (v == mDelPinButton) {
if (mFocusedEntry != mPinText)
mPinText.requestFocus();
final Editable digits = mPinText.getEditableText(); final Editable digits = mPinText.getEditableText();
final int len = digits.length(); final int len = digits.length();
if (len > 0) { if (len > 0) {
digits.delete(len-1, len); digits.delete(len-1, len);
} }
mCallback.pokeWakelock();
} else if (v == mPinText) {
requestFocus(mPinText);
mCallback.pokeWakelock();
} else if (v == mOkButton) { } else if (v == mOkButton) {
checkPuk(); checkPuk();
} }
mCallback.pokeWakelock(DIGIT_PRESS_WAKE_MILLIS);
}
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus)
mFocusedEntry = (TextView)v;
} }
private Dialog getSimUnlockProgressDialog() { private Dialog getSimUnlockProgressDialog() {
@ -236,7 +227,6 @@ public class SimPukUnlockScreen extends LinearLayout implements KeyguardScreen,
// otherwise, display a message to the user, and don't submit. // otherwise, display a message to the user, and don't submit.
mHeaderText.setText(R.string.invalidPuk); mHeaderText.setText(R.string.invalidPuk);
mPukText.setText(""); mPukText.setText("");
mCallback.pokeWakelock();
return; return;
} }
@ -245,7 +235,6 @@ public class SimPukUnlockScreen extends LinearLayout implements KeyguardScreen,
// otherwise, display a message to the user, and don't submit. // otherwise, display a message to the user, and don't submit.
mHeaderText.setText(R.string.invalidPin); mHeaderText.setText(R.string.invalidPin);
mPinText.setText(""); mPinText.setText("");
mCallback.pokeWakelock();
return; return;
} }
@ -267,7 +256,6 @@ public class SimPukUnlockScreen extends LinearLayout implements KeyguardScreen,
mPukText.setText(""); mPukText.setText("");
mPinText.setText(""); mPinText.setText("");
} }
mCallback.pokeWakelock();
} }
}.start(); }.start();
} }
@ -290,7 +278,7 @@ public class SimPukUnlockScreen extends LinearLayout implements KeyguardScreen,
if (len > 0) { if (len > 0) {
digits.delete(len-1, len); digits.delete(len-1, len);
} }
mCallback.pokeWakelock(); mCallback.pokeWakelock(DIGIT_PRESS_WAKE_MILLIS);
return true; return true;
} }