diff --git a/core/java/com/android/internal/app/RestrictionsPinActivity.java b/core/java/com/android/internal/app/RestrictionsPinActivity.java
index f8ce10873a50a..211247488ff38 100644
--- a/core/java/com/android/internal/app/RestrictionsPinActivity.java
+++ b/core/java/com/android/internal/app/RestrictionsPinActivity.java
@@ -16,9 +16,7 @@
package com.android.internal.app;
-import android.app.AlertDialog;
import android.content.Context;
-import android.content.DialogInterface;
import android.os.Bundle;
import android.os.UserManager;
import android.text.Editable;
@@ -26,7 +24,8 @@ import android.text.TextWatcher;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
-import android.view.WindowManager;
+import android.view.View.OnClickListener;
+import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener;
@@ -38,14 +37,15 @@ import com.android.internal.R;
* challenge for an existing PIN. The PIN is maintained by UserManager.
*/
public class RestrictionsPinActivity extends AlertActivity
- implements DialogInterface.OnClickListener, TextWatcher, OnEditorActionListener {
+ implements OnClickListener, TextWatcher, OnEditorActionListener {
protected UserManager mUserManager;
protected boolean mHasRestrictionsPin;
protected EditText mPinText;
protected TextView mPinErrorMessage;
- protected TextView mPinMessage;
+ private Button mOkButton;
+ private Button mCancelButton;
@Override
public void onCreate(Bundle icicle) {
@@ -59,19 +59,20 @@ public class RestrictionsPinActivity extends AlertActivity
protected void initUi() {
AlertController.AlertParams ap = mAlertParams;
- ap.mTitle = getString(R.string.restr_pin_enter_pin);
- ap.mPositiveButtonText = getString(R.string.ok);
- ap.mNegativeButtonText = getString(R.string.cancel);
- ap.mPositiveButtonListener = this;
- ap.mNegativeButtonListener = this;
+ ap.mTitle = getString(R.string.restr_pin_enter_admin_pin);
LayoutInflater inflater =
(LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
ap.mView = inflater.inflate(R.layout.restrictions_pin_challenge, null);
- mPinMessage = (TextView) ap.mView.findViewById(R.id.pin_message);
- mPinText = (EditText) ap.mView.findViewById(R.id.pin_text);
mPinErrorMessage = (TextView) ap.mView.findViewById(R.id.pin_error_message);
+ mPinText = (EditText) ap.mView.findViewById(R.id.pin_text);
+ mOkButton = (Button) ap.mView.findViewById(R.id.pin_ok_button);
+ mCancelButton = (Button) ap.mView.findViewById(R.id.pin_cancel_button);
+
mPinText.addTextChangedListener(this);
+
+ mOkButton.setOnClickListener(this);
+ mCancelButton.setOnClickListener(this);
}
protected boolean verifyingPin() {
@@ -84,8 +85,7 @@ public class RestrictionsPinActivity extends AlertActivity
setPositiveButtonState(false);
boolean hasPin = mUserManager.hasRestrictionsPin();
if (hasPin) {
- mPinMessage.setVisibility(View.GONE);
- mPinErrorMessage.setVisibility(View.GONE);
+ mPinErrorMessage.setVisibility(View.INVISIBLE);
mPinText.setOnEditorActionListener(this);
updatePinTimer(-1);
} else if (verifyingPin()) {
@@ -94,39 +94,37 @@ public class RestrictionsPinActivity extends AlertActivity
}
}
- private void setPositiveButtonState(boolean enabled) {
- mAlert.getButton(DialogInterface.BUTTON_POSITIVE).setEnabled(enabled);
+ protected void setPositiveButtonState(boolean enabled) {
+ mOkButton.setEnabled(enabled);
}
- private void updatePinTimer(int pinTimerMs) {
+ private boolean updatePinTimer(int pinTimerMs) {
if (pinTimerMs < 0) {
pinTimerMs = mUserManager.checkRestrictionsPin(null);
}
+ boolean enableInput;
if (pinTimerMs >= 200) {
- final int seconds = (pinTimerMs + 200) / 1000;
- final String formatString = getResources().getQuantityString(
- R.plurals.restr_pin_countdown,
- seconds);
- mPinErrorMessage.setText(String.format(formatString, seconds));
+ // Do the count down timer for less than a minute, otherwise just say try again later.
+ if (pinTimerMs <= 60000) {
+ final int seconds = (pinTimerMs + 200) / 1000;
+ final String formatString = getResources().getQuantityString(
+ R.plurals.restr_pin_countdown,
+ seconds);
+ mPinErrorMessage.setText(String.format(formatString, seconds));
+ } else {
+ mPinErrorMessage.setText(R.string.restr_pin_try_later);
+ }
+ enableInput = false;
mPinErrorMessage.setVisibility(View.VISIBLE);
- mPinText.setEnabled(false);
mPinText.setText("");
- setPositiveButtonState(false);
mPinText.postDelayed(mCountdownRunnable, Math.min(1000, pinTimerMs));
} else {
- mPinErrorMessage.setVisibility(View.INVISIBLE);
- mPinText.setEnabled(true);
- mPinText.setText("");
- }
- }
-
- public void onClick(DialogInterface dialog, int which) {
- setResult(RESULT_CANCELED);
- if (which == AlertDialog.BUTTON_POSITIVE) {
- performPositiveButtonAction();
- } else if (which == AlertDialog.BUTTON_NEGATIVE) {
- finish();
+ enableInput = true;
+ mPinErrorMessage.setText(R.string.restr_pin_incorrect);
}
+ mPinText.setEnabled(enableInput);
+ setPositiveButtonState(enableInput);
+ return enableInput;
}
protected void performPositiveButtonAction() {
@@ -135,7 +133,10 @@ public class RestrictionsPinActivity extends AlertActivity
setResult(RESULT_OK);
finish();
} else if (result >= 0) {
+ mPinErrorMessage.setText(R.string.restr_pin_incorrect);
+ mPinErrorMessage.setVisibility(View.VISIBLE);
updatePinTimer(result);
+ mPinText.setText("");
}
}
@@ -161,7 +162,20 @@ public class RestrictionsPinActivity extends AlertActivity
private Runnable mCountdownRunnable = new Runnable() {
public void run() {
- updatePinTimer(-1);
+ if (updatePinTimer(-1)) {
+ // If we are no longer counting down, clear the message.
+ mPinErrorMessage.setVisibility(View.INVISIBLE);
+ }
}
};
+
+ @Override
+ public void onClick(View v) {
+ if (v == mOkButton) {
+ performPositiveButtonAction();
+ } else if (v == mCancelButton) {
+ setResult(RESULT_CANCELED);
+ finish();
+ }
+ }
}
diff --git a/core/java/com/android/internal/app/RestrictionsPinSetupActivity.java b/core/java/com/android/internal/app/RestrictionsPinSetupActivity.java
index 1d092920628fb..f7fc6c67ed83e 100644
--- a/core/java/com/android/internal/app/RestrictionsPinSetupActivity.java
+++ b/core/java/com/android/internal/app/RestrictionsPinSetupActivity.java
@@ -16,9 +16,7 @@
package com.android.internal.app;
-import android.app.AlertDialog;
import android.content.Context;
-import android.content.DialogInterface;
import android.os.UserManager;
import android.text.Editable;
import android.text.TextUtils;
@@ -44,17 +42,13 @@ public class RestrictionsPinSetupActivity extends RestrictionsPinActivity {
ap.mTitle = getString(R.string.restr_pin_enter_pin);
ap.mPositiveButtonText = getString(R.string.ok);
ap.mNegativeButtonText = getString(R.string.cancel);
- ap.mPositiveButtonListener = this;
- ap.mNegativeButtonListener = this;
LayoutInflater inflater =
(LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
ap.mView = inflater.inflate(R.layout.restrictions_pin_setup, null);
mPinText = (EditText) ap.mView.findViewById(R.id.pin_text);
- mPinMessage = (TextView) ap.mView.findViewById(R.id.pin_message);
mNewPinText = (EditText) ap.mView.findViewById(R.id.pin_new_text);
mConfirmPinText = (EditText) ap.mView.findViewById(R.id.pin_confirm_text);
- mPinErrorMessage = (TextView) ap.mView.findViewById(R.id.pin_error_message);
mNewPinText.addTextChangedListener(this);
mConfirmPinText.addTextChangedListener(this);
@@ -72,19 +66,7 @@ public class RestrictionsPinSetupActivity extends RestrictionsPinActivity {
return false;
}
- private void setPositiveButtonState(boolean enabled) {
- mAlert.getButton(DialogInterface.BUTTON_POSITIVE).setEnabled(enabled);
- }
-
- public void onClick(DialogInterface dialog, int which) {
- setResult(RESULT_CANCELED);
- if (which == AlertDialog.BUTTON_POSITIVE) {
- performPositiveButtonAction();
- } else if (which == AlertDialog.BUTTON_NEGATIVE) {
- finish();
- }
- }
-
+ @Override
protected void performPositiveButtonAction() {
if (mHasRestrictionsPin) {
int result = mUserManager.checkRestrictionsPin(mPinText.getText().toString());
@@ -115,7 +97,6 @@ public class RestrictionsPinSetupActivity extends RestrictionsPinActivity {
boolean showError = !TextUtils.isEmpty(pin1) && !TextUtils.isEmpty(pin2);
// TODO: Check recovery email address as well
setPositiveButtonState(match);
- mPinErrorMessage.setVisibility((match || !showError) ? View.INVISIBLE : View.VISIBLE);
}
@Override
diff --git a/core/res/res/layout/restrictions_pin_challenge.xml b/core/res/res/layout/restrictions_pin_challenge.xml
index 954af92c60b75..f41924cf13f63 100644
--- a/core/res/res/layout/restrictions_pin_challenge.xml
+++ b/core/res/res/layout/restrictions_pin_challenge.xml
@@ -18,42 +18,73 @@
-
-
+ android:padding="8dip"
+ android:orientation="vertical">
-
+
+
+
+
+
-
-
-
+ android:minHeight="@dimen/alert_dialog_button_bar_height"
+ android:orientation="vertical"
+ android:divider="?android:attr/dividerHorizontal"
+ android:showDividers="beginning"
+ android:dividerPadding="0dip">
+
+
+
+
+
-
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 4b32e2be3f41e..f5f9bf6f66d3a 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -4296,8 +4296,12 @@
unknown
+
+ Enter administrator PIN
Enter PIN
+
+ Incorrect
Current PIN
@@ -4313,9 +4317,11 @@
- - Incorrect PIN. Try again in 1 second.
- - Incorrect PIN. Try again in %d seconds.
+ - Try again in 1 second
+ - Try again in %d seconds
+
+ Try again later
Swipe edge of screen to reveal bar
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index cce19e82c8e98..2b3c2876ea639 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -212,7 +212,8 @@
-
+
+
@@ -871,7 +872,10 @@
+
+
+