Merge "Update content descriptions when text/icons are updated" into qt-dev

This commit is contained in:
Kevin Chyn
2019-05-14 23:29:50 +00:00
committed by Android (Google) Code Review
4 changed files with 26 additions and 6 deletions

View File

@@ -292,6 +292,14 @@
<string name="biometric_dialog_try_again">Try again</string> <string name="biometric_dialog_try_again">Try again</string>
<!-- Content description for empty spaces that are not taken by the biometric dialog. Clicking on these areas will cancel authentication and dismiss the biometric dialog [CHAR LIMIT=NONE] --> <!-- Content description for empty spaces that are not taken by the biometric dialog. Clicking on these areas will cancel authentication and dismiss the biometric dialog [CHAR LIMIT=NONE] -->
<string name="biometric_dialog_empty_space_description">Empty region, tap to cancel authentication</string> <string name="biometric_dialog_empty_space_description">Empty region, tap to cancel authentication</string>
<!-- Content description for the face icon when the device is not authenticating anymore [CHAR LIMIT=NONE] -->
<string name="biometric_dialog_face_icon_description_idle">Please try again</string>
<!-- Content description for the face icon when the device is authenticating [CHAR LIMIT=NONE] -->
<string name="biometric_dialog_face_icon_description_authenticating">Looking for your face</string>
<!-- Content description for the face icon when the user has been authenticated [CHAR LIMIT=NONE] -->
<string name="biometric_dialog_face_icon_description_authenticated">Face authenticated</string>
<!-- Content description for the face icon when the user has been authenticated and the confirm button has been pressed [CHAR LIMIT=NONE] -->
<string name="biometric_dialog_face_icon_description_confirmed">Confirmed</string>
<!-- Message shown when the system-provided fingerprint dialog is shown, asking for authentication --> <!-- Message shown when the system-provided fingerprint dialog is shown, asking for authentication -->
<string name="fingerprint_dialog_touch_sensor">Touch the fingerprint sensor</string> <string name="fingerprint_dialog_touch_sensor">Touch the fingerprint sensor</string>

View File

@@ -325,7 +325,6 @@ public class BiometricDialogImpl extends SystemUI implements CommandQueue.Callba
private void handleTryAgainPressed() { private void handleTryAgainPressed() {
try { try {
mCurrentDialog.clearTemporaryMessage();
mReceiver.onTryAgainPressed(); mReceiver.onTryAgainPressed();
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "RemoteException when handling try again", e); Log.e(TAG, "RemoteException when handling try again", e);

View File

@@ -223,6 +223,7 @@ public abstract class BiometricDialogView extends LinearLayout {
}); });
mTryAgainButton.setOnClickListener((View v) -> { mTryAgainButton.setOnClickListener((View v) -> {
handleResetMessage();
updateState(STATE_AUTHENTICATING); updateState(STATE_AUTHENTICATING);
showTryAgainButton(false /* show */); showTryAgainButton(false /* show */);
mCallback.onTryAgainPressed(); mCallback.onTryAgainPressed();
@@ -265,6 +266,7 @@ public abstract class BiometricDialogView extends LinearLayout {
if (mRestoredState == null) { if (mRestoredState == null) {
updateState(STATE_AUTHENTICATING); updateState(STATE_AUTHENTICATING);
mErrorText.setText(getHintStringResourceId()); mErrorText.setText(getHintStringResourceId());
mErrorText.setContentDescription(mContext.getString(getHintStringResourceId()));
mErrorText.setVisibility(View.VISIBLE); mErrorText.setVisibility(View.VISIBLE);
} else { } else {
updateState(mState); updateState(mState);
@@ -415,11 +417,6 @@ public abstract class BiometricDialogView extends LinearLayout {
BiometricPrompt.HIDE_DIALOG_DELAY); BiometricPrompt.HIDE_DIALOG_DELAY);
} }
public void clearTemporaryMessage() {
mHandler.removeMessages(MSG_RESET_MESSAGE);
mHandler.obtainMessage(MSG_RESET_MESSAGE).sendToTarget();
}
/** /**
* Transient help message (acquire) is received, dialog stays showing. Sensor stays in * Transient help message (acquire) is received, dialog stays showing. Sensor stays in
* "authenticating" state. * "authenticating" state.
@@ -478,6 +475,7 @@ public abstract class BiometricDialogView extends LinearLayout {
mPositiveButton.setVisibility(bundle.getInt(KEY_CONFIRM_VISIBILITY)); mPositiveButton.setVisibility(bundle.getInt(KEY_CONFIRM_VISIBILITY));
mState = bundle.getInt(KEY_STATE); mState = bundle.getInt(KEY_STATE);
mErrorText.setText(bundle.getCharSequence(KEY_ERROR_TEXT_STRING)); mErrorText.setText(bundle.getCharSequence(KEY_ERROR_TEXT_STRING));
mErrorText.setContentDescription(bundle.getCharSequence(KEY_ERROR_TEXT_STRING));
mErrorText.setVisibility(bundle.getInt(KEY_ERROR_TEXT_VISIBILITY)); mErrorText.setVisibility(bundle.getInt(KEY_ERROR_TEXT_VISIBILITY));
mErrorText.setTextColor(bundle.getInt(KEY_ERROR_TEXT_COLOR)); mErrorText.setTextColor(bundle.getInt(KEY_ERROR_TEXT_COLOR));

View File

@@ -288,6 +288,7 @@ public class FaceDialogView extends BiometricDialogView {
@Override @Override
protected void handleResetMessage() { protected void handleResetMessage() {
mErrorText.setText(getHintStringResourceId()); mErrorText.setText(getHintStringResourceId());
mErrorText.setContentDescription(mContext.getString(getHintStringResourceId()));
mErrorText.setTextColor(mTextColor); mErrorText.setTextColor(mTextColor);
if (getState() == STATE_AUTHENTICATING) { if (getState() == STATE_AUTHENTICATING) {
mErrorText.setVisibility(View.VISIBLE); mErrorText.setVisibility(View.VISIBLE);
@@ -406,13 +407,21 @@ public class FaceDialogView extends BiometricDialogView {
} else { } else {
mIconController.showIcon(R.drawable.face_dialog_pulse_dark_to_light); mIconController.showIcon(R.drawable.face_dialog_pulse_dark_to_light);
} }
mBiometricIcon.setContentDescription(mContext.getString(
R.string.biometric_dialog_face_icon_description_authenticating));
} else if (oldState == STATE_PENDING_CONFIRMATION && newState == STATE_AUTHENTICATED) { } else if (oldState == STATE_PENDING_CONFIRMATION && newState == STATE_AUTHENTICATED) {
mIconController.animateOnce(R.drawable.face_dialog_dark_to_checkmark); mIconController.animateOnce(R.drawable.face_dialog_dark_to_checkmark);
mBiometricIcon.setContentDescription(mContext.getString(
R.string.biometric_dialog_face_icon_description_confirmed));
} else if (oldState == STATE_ERROR && newState == STATE_IDLE) { } else if (oldState == STATE_ERROR && newState == STATE_IDLE) {
mIconController.animateOnce(R.drawable.face_dialog_error_to_idle); mIconController.animateOnce(R.drawable.face_dialog_error_to_idle);
mBiometricIcon.setContentDescription(mContext.getString(
R.string.biometric_dialog_face_icon_description_idle));
} else if (oldState == STATE_ERROR && newState == STATE_AUTHENTICATED) { } else if (oldState == STATE_ERROR && newState == STATE_AUTHENTICATED) {
mHandler.removeCallbacks(mErrorToIdleAnimationRunnable); mHandler.removeCallbacks(mErrorToIdleAnimationRunnable);
mIconController.animateOnce(R.drawable.face_dialog_dark_to_checkmark); mIconController.animateOnce(R.drawable.face_dialog_dark_to_checkmark);
mBiometricIcon.setContentDescription(mContext.getString(
R.string.biometric_dialog_face_icon_description_authenticated));
} else if (newState == STATE_ERROR) { } else if (newState == STATE_ERROR) {
// It's easier to only check newState and gate showing the animation on the // It's easier to only check newState and gate showing the animation on the
// mErrorToIdleAnimationRunnable as a proxy, than add a ton of extra state. For example, // mErrorToIdleAnimationRunnable as a proxy, than add a ton of extra state. For example,
@@ -426,11 +435,17 @@ public class FaceDialogView extends BiometricDialogView {
} }
} else if (oldState == STATE_AUTHENTICATING && newState == STATE_AUTHENTICATED) { } else if (oldState == STATE_AUTHENTICATING && newState == STATE_AUTHENTICATED) {
mIconController.animateOnce(R.drawable.face_dialog_dark_to_checkmark); mIconController.animateOnce(R.drawable.face_dialog_dark_to_checkmark);
mBiometricIcon.setContentDescription(mContext.getString(
R.string.biometric_dialog_face_icon_description_authenticated));
} else if (newState == STATE_PENDING_CONFIRMATION) { } else if (newState == STATE_PENDING_CONFIRMATION) {
mHandler.removeCallbacks(mErrorToIdleAnimationRunnable); mHandler.removeCallbacks(mErrorToIdleAnimationRunnable);
mIconController.animateOnce(R.drawable.face_dialog_wink_from_dark); mIconController.animateOnce(R.drawable.face_dialog_wink_from_dark);
mBiometricIcon.setContentDescription(mContext.getString(
R.string.biometric_dialog_face_icon_description_authenticated));
} else if (newState == STATE_IDLE) { } else if (newState == STATE_IDLE) {
mIconController.showStatic(R.drawable.face_dialog_idle_static); mIconController.showStatic(R.drawable.face_dialog_idle_static);
mBiometricIcon.setContentDescription(mContext.getString(
R.string.biometric_dialog_face_icon_description_idle));
} else { } else {
Log.w(TAG, "Unknown animation from " + oldState + " -> " + newState); Log.w(TAG, "Unknown animation from " + oldState + " -> " + newState);
} }