Announce dynamic content changes in lock confirmation settings.

Also re-orders updateStage() and setText/Selection calls so that text
events don't flush announcements. This does not change functionality.

Bug: 7256500
Change-Id: I8b10d66e9f73c7a630a8c3c5128372e18f26234c
This commit is contained in:
alanv
2012-10-03 17:10:50 -07:00
parent a8f3a204d9
commit eef72c39ae
4 changed files with 24 additions and 3 deletions

View File

@@ -40,6 +40,7 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.view.accessibility.AccessibilityEvent;
import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo;
import android.widget.Button; import android.widget.Button;
import android.widget.TextView; import android.widget.TextView;
@@ -272,8 +273,15 @@ public class ChooseLockPassword extends PreferenceActivity {
} }
protected void updateStage(Stage stage) { protected void updateStage(Stage stage) {
final Stage previousStage = mUiStage;
mUiStage = stage; mUiStage = stage;
updateUi(); updateUi();
// If the stage changed, announce the header for accessibility. This
// is a no-op when accessibility is disabled.
if (previousStage != stage) {
mHeaderText.announceForAccessibility(mHeaderText.getText());
}
} }
/** /**
@@ -378,8 +386,8 @@ public class ChooseLockPassword extends PreferenceActivity {
errorMsg = validatePassword(pin); errorMsg = validatePassword(pin);
if (errorMsg == null) { if (errorMsg == null) {
mFirstPin = pin; mFirstPin = pin;
updateStage(Stage.NeedToConfirm);
mPasswordEntry.setText(""); mPasswordEntry.setText("");
updateStage(Stage.NeedToConfirm);
} }
} else if (mUiStage == Stage.NeedToConfirm) { } else if (mUiStage == Stage.NeedToConfirm) {
if (mFirstPin.equals(pin)) { if (mFirstPin.equals(pin)) {
@@ -389,11 +397,11 @@ public class ChooseLockPassword extends PreferenceActivity {
mLockPatternUtils.saveLockPassword(pin, mRequestedQuality, isFallback); mLockPatternUtils.saveLockPassword(pin, mRequestedQuality, isFallback);
getActivity().finish(); getActivity().finish();
} else { } else {
updateStage(Stage.ConfirmWrong);
CharSequence tmp = mPasswordEntry.getText(); CharSequence tmp = mPasswordEntry.getText();
if (tmp != null) { if (tmp != null) {
Selection.setSelection((Spannable) tmp, 0, tmp.length()); Selection.setSelection((Spannable) tmp, 0, tmp.length());
} }
updateStage(Stage.ConfirmWrong);
} }
} }
if (errorMsg != null) { if (errorMsg != null) {
@@ -415,6 +423,7 @@ public class ChooseLockPassword extends PreferenceActivity {
private void showError(String msg, final Stage next) { private void showError(String msg, final Stage next) {
mHeaderText.setText(msg); mHeaderText.setText(msg);
mHeaderText.announceForAccessibility(mHeaderText.getText());
Message mesg = mHandler.obtainMessage(MSG_SHOW_ERROR, next); Message mesg = mHandler.obtainMessage(MSG_SHOW_ERROR, next);
mHandler.removeMessages(MSG_SHOW_ERROR); mHandler.removeMessages(MSG_SHOW_ERROR);
mHandler.sendMessageDelayed(mesg, ERROR_MESSAGE_TIMEOUT); mHandler.sendMessageDelayed(mesg, ERROR_MESSAGE_TIMEOUT);

View File

@@ -429,6 +429,7 @@ public class ChooseLockPattern extends PreferenceActivity {
* @param stage * @param stage
*/ */
protected void updateStage(Stage stage) { protected void updateStage(Stage stage) {
final Stage previousStage = mUiStage;
mUiStage = stage; mUiStage = stage;
@@ -493,6 +494,12 @@ public class ChooseLockPattern extends PreferenceActivity {
case ChoiceConfirmed: case ChoiceConfirmed:
break; break;
} }
// If the stage changed, announce the header for accessibility. This
// is a no-op when accessibility is disabled.
if (previousStage != stage) {
mHeaderText.announceForAccessibility(mHeaderText.getText());
}
} }

View File

@@ -35,6 +35,7 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo;
import android.widget.Button; import android.widget.Button;
import android.widget.TextView; import android.widget.TextView;
@@ -173,6 +174,7 @@ public class ConfirmLockPassword extends PreferenceActivity {
private void showError(int msg) { private void showError(int msg) {
mHeaderText.setText(msg); mHeaderText.setText(msg);
mHeaderText.announceForAccessibility(mHeaderText.getText());
mPasswordEntry.setText(null); mPasswordEntry.setText(null);
mHandler.postDelayed(new Runnable() { mHandler.postDelayed(new Runnable() {
public void run() { public void run() {

View File

@@ -180,7 +180,6 @@ public class ConfirmLockPattern extends PreferenceActivity {
} }
private void updateStage(Stage stage) { private void updateStage(Stage stage) {
switch (stage) { switch (stage) {
case NeedToUnlock: case NeedToUnlock:
if (mHeaderText != null) { if (mHeaderText != null) {
@@ -220,6 +219,10 @@ public class ConfirmLockPattern extends PreferenceActivity {
mLockPatternView.setEnabled(false); // appearance of being disabled mLockPatternView.setEnabled(false); // appearance of being disabled
break; break;
} }
// Always announce the header for accessibility. This is a no-op
// when accessibility is disabled.
mHeaderTextView.announceForAccessibility(mHeaderTextView.getText());
} }
private Runnable mClearPatternRunnable = new Runnable() { private Runnable mClearPatternRunnable = new Runnable() {