Migrating to new footer button for ChooseLockPattern page
Bug: 120805516 Test: RunSettingsRoboTests Change-Id: Ifeaf402548146fca9f5fd5dfe0d976d38246b7e9
This commit is contained in:
@@ -19,11 +19,11 @@
|
|||||||
<com.google.android.setupdesign.GlifLayout
|
<com.google.android.setupdesign.GlifLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:id="@+id/setup_wizard_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:icon="@drawable/ic_lock"
|
android:icon="@drawable/ic_lock"
|
||||||
android:layout="@layout/sud_glif_blank_template"
|
android:layout="@layout/sud_glif_blank_template"
|
||||||
settings:sucFooter="@layout/choose_lock_pattern_common_footer"
|
|
||||||
settings:sucHeaderText="@string/lockpassword_choose_your_screen_lock_header">
|
settings:sucHeaderText="@string/lockpassword_choose_your_screen_lock_header">
|
||||||
|
|
||||||
<com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient
|
<com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient
|
||||||
|
@@ -1,52 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!--
|
|
||||||
Copyright (C) 2017 The Android Open Source Project
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License")
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<!-- TODO: Use aapt:attr when it is fixed (b/36809755) -->
|
|
||||||
<com.google.android.setupdesign.view.ButtonBarLayout
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
style="@style/SudGlifButtonBar.Stackable"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content">
|
|
||||||
|
|
||||||
<!-- left : skip -->
|
|
||||||
<Button android:id="@+id/skip_button"
|
|
||||||
style="@style/SudGlifButton.Secondary"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="@string/skip_label"
|
|
||||||
android:visibility="gone" />
|
|
||||||
|
|
||||||
<!-- left : retry -->
|
|
||||||
<Button android:id="@+id/footerLeftButton"
|
|
||||||
style="@style/SudGlifButton.Secondary"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="@string/lockpattern_tutorial_cancel_label" />
|
|
||||||
|
|
||||||
<Space
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
android:layout_weight="1" />
|
|
||||||
|
|
||||||
<!-- right : confirm or ok -->
|
|
||||||
<Button android:id="@+id/footerRightButton"
|
|
||||||
style="@style/SudGlifButton.Primary"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="@string/lockpattern_tutorial_continue_label" />
|
|
||||||
|
|
||||||
</com.google.android.setupdesign.view.ButtonBarLayout>
|
|
@@ -50,6 +50,8 @@ import com.android.settings.core.InstrumentedFragment;
|
|||||||
import com.android.settings.notification.RedactionInterstitial;
|
import com.android.settings.notification.RedactionInterstitial;
|
||||||
|
|
||||||
import com.google.android.collect.Lists;
|
import com.google.android.collect.Lists;
|
||||||
|
import com.google.android.setupcompat.item.FooterButton;
|
||||||
|
import com.google.android.setupcompat.template.ButtonFooterMixin;
|
||||||
import com.google.android.setupdesign.GlifLayout;
|
import com.google.android.setupdesign.GlifLayout;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -171,7 +173,7 @@ public class ChooseLockPattern extends SettingsActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class ChooseLockPatternFragment extends InstrumentedFragment
|
public static class ChooseLockPatternFragment extends InstrumentedFragment
|
||||||
implements View.OnClickListener, SaveAndFinishWorker.Listener {
|
implements SaveAndFinishWorker.Listener {
|
||||||
|
|
||||||
public static final int CONFIRM_EXISTING_REQUEST = 55;
|
public static final int CONFIRM_EXISTING_REQUEST = 55;
|
||||||
|
|
||||||
@@ -193,8 +195,8 @@ public class ChooseLockPattern extends SettingsActivity {
|
|||||||
protected TextView mMessageText;
|
protected TextView mMessageText;
|
||||||
protected LockPatternView mLockPatternView;
|
protected LockPatternView mLockPatternView;
|
||||||
protected TextView mFooterText;
|
protected TextView mFooterText;
|
||||||
private TextView mFooterLeftButton;
|
protected FooterButton mSkipOrClearButton;
|
||||||
private TextView mFooterRightButton;
|
private FooterButton mNextButton;
|
||||||
protected List<LockPatternView.Cell> mChosenPattern = null;
|
protected List<LockPatternView.Cell> mChosenPattern = null;
|
||||||
private ColorStateList mDefaultHeaderColorList;
|
private ColorStateList mDefaultHeaderColorList;
|
||||||
|
|
||||||
@@ -232,11 +234,11 @@ public class ChooseLockPattern extends SettingsActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void setRightButtonEnabled(boolean enabled) {
|
protected void setRightButtonEnabled(boolean enabled) {
|
||||||
mFooterRightButton.setEnabled(enabled);
|
mNextButton.setEnabled(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setRightButtonText(int text) {
|
protected void setRightButtonText(int text) {
|
||||||
mFooterRightButton.setText(text);
|
mNextButton.setText(getActivity(), text);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -287,8 +289,7 @@ public class ChooseLockPattern extends SettingsActivity {
|
|||||||
mHeaderText.setTextColor(mDefaultHeaderColorList);
|
mHeaderText.setTextColor(mDefaultHeaderColorList);
|
||||||
}
|
}
|
||||||
mFooterText.setText("");
|
mFooterText.setText("");
|
||||||
mFooterLeftButton.setEnabled(false);
|
mNextButton.setEnabled(false);
|
||||||
mFooterRightButton.setEnabled(false);
|
|
||||||
|
|
||||||
if (mTitleHeaderScrollView != null) {
|
if (mTitleHeaderScrollView != null) {
|
||||||
mTitleHeaderScrollView.post(new Runnable() {
|
mTitleHeaderScrollView.post(new Runnable() {
|
||||||
@@ -487,6 +488,27 @@ public class ChooseLockPattern extends SettingsActivity {
|
|||||||
layout.setIcon(getActivity().getDrawable(R.drawable.ic_face_header));
|
layout.setIcon(getActivity().getDrawable(R.drawable.ic_face_header));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final ButtonFooterMixin mixin = layout.getMixin(ButtonFooterMixin.class);
|
||||||
|
mixin.setSecondaryButton(
|
||||||
|
new FooterButton.Builder(getActivity())
|
||||||
|
.setText(R.string.lockpattern_tutorial_cancel_label)
|
||||||
|
.setListener(this::onSkipOrClearButtonClick)
|
||||||
|
.setButtonType(FooterButton.ButtonType.OTHER)
|
||||||
|
.setTheme(R.style.SudGlifButton_Secondary)
|
||||||
|
.build()
|
||||||
|
);
|
||||||
|
mixin.setPrimaryButton(
|
||||||
|
new FooterButton.Builder(getActivity())
|
||||||
|
.setText(R.string.lockpattern_tutorial_continue_label)
|
||||||
|
.setListener(this::onNextButtonClick)
|
||||||
|
.setButtonType(FooterButton.ButtonType.NEXT)
|
||||||
|
.setTheme(R.style.SudGlifButton_Primary)
|
||||||
|
.build()
|
||||||
|
);
|
||||||
|
mSkipOrClearButton = mixin.getSecondaryButton();
|
||||||
|
mNextButton = mixin.getPrimaryButton();
|
||||||
|
|
||||||
return layout;
|
return layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -506,15 +528,9 @@ public class ChooseLockPattern extends SettingsActivity {
|
|||||||
|
|
||||||
mFooterText = (TextView) view.findViewById(R.id.footerText);
|
mFooterText = (TextView) view.findViewById(R.id.footerText);
|
||||||
|
|
||||||
mFooterLeftButton = (TextView) view.findViewById(R.id.footerLeftButton);
|
|
||||||
mFooterRightButton = (TextView) view.findViewById(R.id.footerRightButton);
|
|
||||||
|
|
||||||
mTitleHeaderScrollView = (ScrollView) view.findViewById(R.id
|
mTitleHeaderScrollView = (ScrollView) view.findViewById(R.id
|
||||||
.scroll_layout_title_header);
|
.scroll_layout_title_header);
|
||||||
|
|
||||||
mFooterLeftButton.setOnClickListener(this);
|
|
||||||
mFooterRightButton.setOnClickListener(this);
|
|
||||||
|
|
||||||
// make it so unhandled touch events within the unlock screen go to the
|
// make it so unhandled touch events within the unlock screen go to the
|
||||||
// lock pattern view.
|
// lock pattern view.
|
||||||
final LinearLayoutWithDefaultTouchRecepient topLayout
|
final LinearLayoutWithDefaultTouchRecepient topLayout
|
||||||
@@ -623,12 +639,12 @@ public class ChooseLockPattern extends SettingsActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onClick(View v) {
|
protected void onSkipOrClearButtonClick(View view) {
|
||||||
if (v == mFooterLeftButton) {
|
handleLeftButton();
|
||||||
handleLeftButton();
|
}
|
||||||
} else if (v == mFooterRightButton) {
|
|
||||||
handleRightButton();
|
protected void onNextButtonClick(View view) {
|
||||||
}
|
handleRightButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||||
@@ -711,7 +727,7 @@ public class ChooseLockPattern extends SettingsActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateFooterLeftButton(stage, mFooterLeftButton);
|
updateFooterLeftButton(stage);
|
||||||
|
|
||||||
setRightButtonText(stage.rightMode.text);
|
setRightButtonText(stage.rightMode.text);
|
||||||
setRightButtonEnabled(stage.rightMode.enabled);
|
setRightButtonEnabled(stage.rightMode.enabled);
|
||||||
@@ -761,13 +777,13 @@ public class ChooseLockPattern extends SettingsActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateFooterLeftButton(Stage stage, TextView footerLeftButton) {
|
protected void updateFooterLeftButton(Stage stage) {
|
||||||
if (stage.leftMode == LeftButtonMode.Gone) {
|
if (stage.leftMode == LeftButtonMode.Gone) {
|
||||||
footerLeftButton.setVisibility(View.GONE);
|
mSkipOrClearButton.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
footerLeftButton.setVisibility(View.VISIBLE);
|
mSkipOrClearButton.setVisibility(View.VISIBLE);
|
||||||
footerLeftButton.setText(stage.leftMode.text);
|
mSkipOrClearButton.setText(getActivity(), stage.leftMode.text);
|
||||||
footerLeftButton.setEnabled(stage.leftMode.enabled);
|
mSkipOrClearButton.setEnabled(stage.leftMode.enabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -59,7 +59,7 @@ public class SetupChooseLockPattern extends ChooseLockPattern {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private Button mOptionsButton;
|
private Button mOptionsButton;
|
||||||
private Button mSkipButton;
|
private boolean mLeftButtonIsSkip;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(
|
public View onCreateView(
|
||||||
@@ -72,14 +72,20 @@ public class SetupChooseLockPattern extends ChooseLockPattern {
|
|||||||
.show(getChildFragmentManager(), null));
|
.show(getChildFragmentManager(), null));
|
||||||
}
|
}
|
||||||
// Show the skip button during SUW but not during Settings > Biometric Enrollment
|
// Show the skip button during SUW but not during Settings > Biometric Enrollment
|
||||||
mSkipButton = view.findViewById(R.id.skip_button);
|
mSkipOrClearButton.setOnClickListener(this::onSkipOrClearButtonClick);
|
||||||
mSkipButton.setOnClickListener(v -> {
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onSkipOrClearButtonClick(View view) {
|
||||||
|
if (mLeftButtonIsSkip) {
|
||||||
SetupSkipDialog dialog = SetupSkipDialog.newInstance(
|
SetupSkipDialog dialog = SetupSkipDialog.newInstance(
|
||||||
getActivity().getIntent()
|
getActivity().getIntent()
|
||||||
.getBooleanExtra(SetupSkipDialog.EXTRA_FRP_SUPPORTED, false));
|
.getBooleanExtra(SetupSkipDialog.EXTRA_FRP_SUPPORTED, false));
|
||||||
dialog.show(getFragmentManager());
|
dialog.show(getFragmentManager());
|
||||||
});
|
return;
|
||||||
return view;
|
}
|
||||||
|
super.onSkipOrClearButtonClick(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -102,9 +108,11 @@ public class SetupChooseLockPattern extends ChooseLockPattern {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (stage.leftMode == LeftButtonMode.Gone && stage == Stage.Introduction) {
|
if (stage.leftMode == LeftButtonMode.Gone && stage == Stage.Introduction) {
|
||||||
mSkipButton.setVisibility(View.VISIBLE);
|
mSkipOrClearButton.setVisibility(View.VISIBLE);
|
||||||
|
mSkipOrClearButton.setText(getActivity(), R.string.skip_label);
|
||||||
|
mLeftButtonIsSkip = true;
|
||||||
} else {
|
} else {
|
||||||
mSkipButton.setVisibility(View.GONE);
|
mLeftButtonIsSkip = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -40,6 +40,9 @@ import com.android.settings.password.ChooseLockPattern.IntentBuilder;
|
|||||||
import com.android.settings.testutils.shadow.ShadowAlertDialogCompat;
|
import com.android.settings.testutils.shadow.ShadowAlertDialogCompat;
|
||||||
import com.android.settings.testutils.shadow.ShadowUtils;
|
import com.android.settings.testutils.shadow.ShadowUtils;
|
||||||
|
|
||||||
|
import com.google.android.setupcompat.PartnerCustomizationLayout;
|
||||||
|
import com.google.android.setupcompat.template.ButtonFooterMixin;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
@@ -143,11 +146,13 @@ public class SetupChooseLockPatternTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void skipButton_shouldBeVisible_duringNonFingerprintFlow() {
|
public void skipButton_shouldBeVisible_duringNonFingerprintFlow() {
|
||||||
Button skipButton = mActivity.findViewById(R.id.skip_button);
|
PartnerCustomizationLayout layout = mActivity.findViewById(R.id.setup_wizard_layout);
|
||||||
assertThat(skipButton).isNotNull();
|
final Button skipOrClearButton =
|
||||||
assertThat(skipButton.getVisibility()).isEqualTo(View.VISIBLE);
|
layout.getMixin(ButtonFooterMixin.class).getSecondaryButtonView();
|
||||||
|
assertThat(skipOrClearButton).isNotNull();
|
||||||
|
assertThat(skipOrClearButton.getVisibility()).isEqualTo(View.VISIBLE);
|
||||||
|
|
||||||
skipButton.performClick();
|
skipOrClearButton.performClick();
|
||||||
AlertDialog chooserDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
|
AlertDialog chooserDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
|
||||||
assertThat(chooserDialog).isNotNull();
|
assertThat(chooserDialog).isNotNull();
|
||||||
}
|
}
|
||||||
@@ -156,26 +161,33 @@ public class SetupChooseLockPatternTest {
|
|||||||
public void clearButton_shouldBeVisible_duringRetryStage() {
|
public void clearButton_shouldBeVisible_duringRetryStage() {
|
||||||
enterPattern();
|
enterPattern();
|
||||||
|
|
||||||
Button clearButton = mActivity.findViewById(R.id.footerLeftButton);
|
PartnerCustomizationLayout layout = mActivity.findViewById(R.id.setup_wizard_layout);
|
||||||
assertThat(clearButton.getVisibility()).isEqualTo(View.VISIBLE);
|
final Button skipOrClearButton =
|
||||||
assertThat(clearButton.isEnabled()).isTrue();
|
layout.getMixin(ButtonFooterMixin.class).getSecondaryButtonView();
|
||||||
|
assertThat(skipOrClearButton.getVisibility()).isEqualTo(View.VISIBLE);
|
||||||
|
assertThat(skipOrClearButton.isEnabled()).isTrue();
|
||||||
|
|
||||||
clearButton.performClick();
|
skipOrClearButton.performClick();
|
||||||
assertThat(findFragment(mActivity).mChosenPattern).isNull();
|
assertThat(findFragment(mActivity).mChosenPattern).isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void createActivity_enterPattern_clearButtonShouldBeVisible() {
|
public void createActivity_enterPattern_clearButtonShouldBeShown() {
|
||||||
ChooseLockPatternFragment fragment = findFragment(mActivity);
|
ChooseLockPatternFragment fragment = findFragment(mActivity);
|
||||||
|
|
||||||
Button skipButton = mActivity.findViewById(R.id.skip_button);
|
PartnerCustomizationLayout layout = mActivity.findViewById(R.id.setup_wizard_layout);
|
||||||
Button clearButton = mActivity.findViewById(R.id.footerLeftButton);
|
final Button skipOrClearButton =
|
||||||
assertThat(skipButton.getVisibility()).isEqualTo(View.VISIBLE);
|
layout.getMixin(ButtonFooterMixin.class).getSecondaryButtonView();
|
||||||
assertThat(clearButton.getVisibility()).isEqualTo(View.GONE);
|
assertThat(skipOrClearButton.isEnabled()).isTrue();
|
||||||
|
assertThat(skipOrClearButton.getVisibility()).isEqualTo(View.VISIBLE);
|
||||||
|
assertThat(skipOrClearButton.getText())
|
||||||
|
.isEqualTo(application.getString(R.string.skip_label));
|
||||||
|
|
||||||
enterPattern();
|
enterPattern();
|
||||||
assertThat(skipButton.getVisibility()).isEqualTo(View.GONE);
|
assertThat(skipOrClearButton.isEnabled()).isTrue();
|
||||||
assertThat(clearButton.getVisibility()).isEqualTo(View.VISIBLE);
|
assertThat(skipOrClearButton.getVisibility()).isEqualTo(View.VISIBLE);
|
||||||
|
assertThat(skipOrClearButton.getText())
|
||||||
|
.isEqualTo(application.getString(R.string.lockpattern_retry_button_text));
|
||||||
}
|
}
|
||||||
|
|
||||||
private ChooseLockPatternFragment findFragment(FragmentActivity activity) {
|
private ChooseLockPatternFragment findFragment(FragmentActivity activity) {
|
||||||
|
Reference in New Issue
Block a user