Fix pattern rotation header text.
Bug: 278055194
Test: atest ChooseLockPatternTest
Change-Id: I36ec325b46d7a7f583d94dc26f9962cadc3874cd
Merged-In: I36ec325b46d7a7f583d94dc26f9962cadc3874cd
diff --git a/src/com/android/settings/password/ChooseLockPattern.java b/src/com/android/settings/password/ChooseLockPattern.java
index dc36220..a2fd986 100644
--- a/src/com/android/settings/password/ChooseLockPattern.java
+++ b/src/com/android/settings/password/ChooseLockPattern.java
@@ -442,7 +442,8 @@
protected boolean mForFace;
protected boolean mForBiometrics;
- private static final String KEY_UI_STAGE = "uiStage";
+ @VisibleForTesting
+ static final String KEY_UI_STAGE = "uiStage";
private static final String KEY_PATTERN_CHOICE = "chosenPattern";
private static final String KEY_CURRENT_PATTERN = "currentPattern";
@@ -718,10 +719,6 @@
final GlifLayout layout = getActivity().findViewById(R.id.setup_wizard_layout);
mUiStage = stage;
- if (stage == Stage.Introduction) {
- layout.setDescriptionText(stage.headerMessage);
- }
-
// header text, footer text, visibility and
// enabled state all known from the stage
if (stage == Stage.ChoiceTooShort) {
@@ -744,16 +741,13 @@
Theme theme = getActivity().getTheme();
theme.resolveAttribute(R.attr.colorError, typedValue, true);
mHeaderText.setTextColor(typedValue.data);
+ } else if (mDefaultHeaderColorList != null) {
+ mHeaderText.setTextColor(mDefaultHeaderColorList);
+ }
- } else {
- if (mDefaultHeaderColorList != null) {
- mHeaderText.setTextColor(mDefaultHeaderColorList);
- }
- if (stage == Stage.NeedToConfirm) {
- mHeaderText.setText(stage.headerMessage);
- layout.setHeaderText(R.string.lockpassword_draw_your_pattern_again_header);
- }
+ if (stage == Stage.ConfirmWrong || stage == Stage.NeedToConfirm) {
+ layout.setHeaderText(R.string.lockpassword_draw_your_pattern_again_header);
}
updateFooterLeftButton(stage);
diff --git a/tests/robotests/src/com/android/settings/password/ChooseLockPatternTest.java b/tests/robotests/src/com/android/settings/password/ChooseLockPatternTest.java
index 442d021..301a6db 100644
--- a/tests/robotests/src/com/android/settings/password/ChooseLockPatternTest.java
+++ b/tests/robotests/src/com/android/settings/password/ChooseLockPatternTest.java
@@ -18,12 +18,15 @@
import static android.view.WindowManager.LayoutParams.FLAG_SECURE;
+import static com.android.settings.password.ChooseLockPattern.ChooseLockPatternFragment.KEY_UI_STAGE;
+
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static org.robolectric.RuntimeEnvironment.application;
import android.content.Intent;
+import android.os.Bundle;
import android.os.UserHandle;
import android.view.View;
@@ -34,6 +37,8 @@
import com.android.settings.password.ChooseLockPattern.IntentBuilder;
import com.android.settings.testutils.shadow.ShadowUtils;
+import com.google.android.setupdesign.GlifLayout;
+
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -119,6 +124,21 @@
assertThat(flags & FLAG_SECURE).isEqualTo(FLAG_SECURE);
}
+ @Test
+ public void headerText_stageConfirmWrong() {
+ ChooseLockPattern activity = createActivity(true);
+ ChooseLockPatternFragment fragment = (ChooseLockPatternFragment)
+ activity.getSupportFragmentManager().findFragmentById(R.id.main_content);
+ final GlifLayout layout = fragment.getView().findViewById(R.id.setup_wizard_layout);
+ Bundle savedInstanceState = new Bundle();
+ savedInstanceState.putInt(KEY_UI_STAGE,
+ ChooseLockPatternFragment.Stage.ConfirmWrong.ordinal());
+
+ fragment.onViewCreated(layout, savedInstanceState);
+ assertThat(layout.getHeaderText().toString()).isEqualTo(activity.getResources().getString(
+ R.string.lockpassword_draw_your_pattern_again_header));
+ }
+
private ChooseLockPattern createActivity(boolean addFingerprintExtra) {
return Robolectric.buildActivity(
ChooseLockPattern.class,