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
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/setup_wizard_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:icon="@drawable/ic_lock"
|
||||
android:layout="@layout/sud_glif_blank_template"
|
||||
settings:sucFooter="@layout/choose_lock_pattern_common_footer"
|
||||
settings:sucHeaderText="@string/lockpassword_choose_your_screen_lock_header">
|
||||
|
||||
<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.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 java.util.ArrayList;
|
||||
@@ -171,7 +173,7 @@ public class ChooseLockPattern extends SettingsActivity {
|
||||
}
|
||||
|
||||
public static class ChooseLockPatternFragment extends InstrumentedFragment
|
||||
implements View.OnClickListener, SaveAndFinishWorker.Listener {
|
||||
implements SaveAndFinishWorker.Listener {
|
||||
|
||||
public static final int CONFIRM_EXISTING_REQUEST = 55;
|
||||
|
||||
@@ -193,8 +195,8 @@ public class ChooseLockPattern extends SettingsActivity {
|
||||
protected TextView mMessageText;
|
||||
protected LockPatternView mLockPatternView;
|
||||
protected TextView mFooterText;
|
||||
private TextView mFooterLeftButton;
|
||||
private TextView mFooterRightButton;
|
||||
protected FooterButton mSkipOrClearButton;
|
||||
private FooterButton mNextButton;
|
||||
protected List<LockPatternView.Cell> mChosenPattern = null;
|
||||
private ColorStateList mDefaultHeaderColorList;
|
||||
|
||||
@@ -232,11 +234,11 @@ public class ChooseLockPattern extends SettingsActivity {
|
||||
}
|
||||
|
||||
protected void setRightButtonEnabled(boolean enabled) {
|
||||
mFooterRightButton.setEnabled(enabled);
|
||||
mNextButton.setEnabled(enabled);
|
||||
}
|
||||
|
||||
protected void setRightButtonText(int text) {
|
||||
mFooterRightButton.setText(text);
|
||||
mNextButton.setText(getActivity(), text);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -287,8 +289,7 @@ public class ChooseLockPattern extends SettingsActivity {
|
||||
mHeaderText.setTextColor(mDefaultHeaderColorList);
|
||||
}
|
||||
mFooterText.setText("");
|
||||
mFooterLeftButton.setEnabled(false);
|
||||
mFooterRightButton.setEnabled(false);
|
||||
mNextButton.setEnabled(false);
|
||||
|
||||
if (mTitleHeaderScrollView != null) {
|
||||
mTitleHeaderScrollView.post(new Runnable() {
|
||||
@@ -487,6 +488,27 @@ public class ChooseLockPattern extends SettingsActivity {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -506,15 +528,9 @@ public class ChooseLockPattern extends SettingsActivity {
|
||||
|
||||
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
|
||||
.scroll_layout_title_header);
|
||||
|
||||
mFooterLeftButton.setOnClickListener(this);
|
||||
mFooterRightButton.setOnClickListener(this);
|
||||
|
||||
// make it so unhandled touch events within the unlock screen go to the
|
||||
// lock pattern view.
|
||||
final LinearLayoutWithDefaultTouchRecepient topLayout
|
||||
@@ -623,12 +639,12 @@ public class ChooseLockPattern extends SettingsActivity {
|
||||
}
|
||||
}
|
||||
|
||||
public void onClick(View v) {
|
||||
if (v == mFooterLeftButton) {
|
||||
protected void onSkipOrClearButtonClick(View view) {
|
||||
handleLeftButton();
|
||||
} else if (v == mFooterRightButton) {
|
||||
handleRightButton();
|
||||
}
|
||||
|
||||
protected void onNextButtonClick(View view) {
|
||||
handleRightButton();
|
||||
}
|
||||
|
||||
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);
|
||||
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) {
|
||||
footerLeftButton.setVisibility(View.GONE);
|
||||
mSkipOrClearButton.setVisibility(View.GONE);
|
||||
} else {
|
||||
footerLeftButton.setVisibility(View.VISIBLE);
|
||||
footerLeftButton.setText(stage.leftMode.text);
|
||||
footerLeftButton.setEnabled(stage.leftMode.enabled);
|
||||
mSkipOrClearButton.setVisibility(View.VISIBLE);
|
||||
mSkipOrClearButton.setText(getActivity(), stage.leftMode.text);
|
||||
mSkipOrClearButton.setEnabled(stage.leftMode.enabled);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -59,7 +59,7 @@ public class SetupChooseLockPattern extends ChooseLockPattern {
|
||||
|
||||
@Nullable
|
||||
private Button mOptionsButton;
|
||||
private Button mSkipButton;
|
||||
private boolean mLeftButtonIsSkip;
|
||||
|
||||
@Override
|
||||
public View onCreateView(
|
||||
@@ -72,14 +72,20 @@ public class SetupChooseLockPattern extends ChooseLockPattern {
|
||||
.show(getChildFragmentManager(), null));
|
||||
}
|
||||
// Show the skip button during SUW but not during Settings > Biometric Enrollment
|
||||
mSkipButton = view.findViewById(R.id.skip_button);
|
||||
mSkipButton.setOnClickListener(v -> {
|
||||
mSkipOrClearButton.setOnClickListener(this::onSkipOrClearButtonClick);
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSkipOrClearButtonClick(View view) {
|
||||
if (mLeftButtonIsSkip) {
|
||||
SetupSkipDialog dialog = SetupSkipDialog.newInstance(
|
||||
getActivity().getIntent()
|
||||
.getBooleanExtra(SetupSkipDialog.EXTRA_FRP_SUPPORTED, false));
|
||||
dialog.show(getFragmentManager());
|
||||
});
|
||||
return view;
|
||||
return;
|
||||
}
|
||||
super.onSkipOrClearButtonClick(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -102,9 +108,11 @@ public class SetupChooseLockPattern extends ChooseLockPattern {
|
||||
}
|
||||
|
||||
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 {
|
||||
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.ShadowUtils;
|
||||
|
||||
import com.google.android.setupcompat.PartnerCustomizationLayout;
|
||||
import com.google.android.setupcompat.template.ButtonFooterMixin;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -143,11 +146,13 @@ public class SetupChooseLockPatternTest {
|
||||
|
||||
@Test
|
||||
public void skipButton_shouldBeVisible_duringNonFingerprintFlow() {
|
||||
Button skipButton = mActivity.findViewById(R.id.skip_button);
|
||||
assertThat(skipButton).isNotNull();
|
||||
assertThat(skipButton.getVisibility()).isEqualTo(View.VISIBLE);
|
||||
PartnerCustomizationLayout layout = mActivity.findViewById(R.id.setup_wizard_layout);
|
||||
final Button skipOrClearButton =
|
||||
layout.getMixin(ButtonFooterMixin.class).getSecondaryButtonView();
|
||||
assertThat(skipOrClearButton).isNotNull();
|
||||
assertThat(skipOrClearButton.getVisibility()).isEqualTo(View.VISIBLE);
|
||||
|
||||
skipButton.performClick();
|
||||
skipOrClearButton.performClick();
|
||||
AlertDialog chooserDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
|
||||
assertThat(chooserDialog).isNotNull();
|
||||
}
|
||||
@@ -156,26 +161,33 @@ public class SetupChooseLockPatternTest {
|
||||
public void clearButton_shouldBeVisible_duringRetryStage() {
|
||||
enterPattern();
|
||||
|
||||
Button clearButton = mActivity.findViewById(R.id.footerLeftButton);
|
||||
assertThat(clearButton.getVisibility()).isEqualTo(View.VISIBLE);
|
||||
assertThat(clearButton.isEnabled()).isTrue();
|
||||
PartnerCustomizationLayout layout = mActivity.findViewById(R.id.setup_wizard_layout);
|
||||
final Button skipOrClearButton =
|
||||
layout.getMixin(ButtonFooterMixin.class).getSecondaryButtonView();
|
||||
assertThat(skipOrClearButton.getVisibility()).isEqualTo(View.VISIBLE);
|
||||
assertThat(skipOrClearButton.isEnabled()).isTrue();
|
||||
|
||||
clearButton.performClick();
|
||||
skipOrClearButton.performClick();
|
||||
assertThat(findFragment(mActivity).mChosenPattern).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createActivity_enterPattern_clearButtonShouldBeVisible() {
|
||||
public void createActivity_enterPattern_clearButtonShouldBeShown() {
|
||||
ChooseLockPatternFragment fragment = findFragment(mActivity);
|
||||
|
||||
Button skipButton = mActivity.findViewById(R.id.skip_button);
|
||||
Button clearButton = mActivity.findViewById(R.id.footerLeftButton);
|
||||
assertThat(skipButton.getVisibility()).isEqualTo(View.VISIBLE);
|
||||
assertThat(clearButton.getVisibility()).isEqualTo(View.GONE);
|
||||
PartnerCustomizationLayout layout = mActivity.findViewById(R.id.setup_wizard_layout);
|
||||
final Button skipOrClearButton =
|
||||
layout.getMixin(ButtonFooterMixin.class).getSecondaryButtonView();
|
||||
assertThat(skipOrClearButton.isEnabled()).isTrue();
|
||||
assertThat(skipOrClearButton.getVisibility()).isEqualTo(View.VISIBLE);
|
||||
assertThat(skipOrClearButton.getText())
|
||||
.isEqualTo(application.getString(R.string.skip_label));
|
||||
|
||||
enterPattern();
|
||||
assertThat(skipButton.getVisibility()).isEqualTo(View.GONE);
|
||||
assertThat(clearButton.getVisibility()).isEqualTo(View.VISIBLE);
|
||||
assertThat(skipOrClearButton.isEnabled()).isTrue();
|
||||
assertThat(skipOrClearButton.getVisibility()).isEqualTo(View.VISIBLE);
|
||||
assertThat(skipOrClearButton.getText())
|
||||
.isEqualTo(application.getString(R.string.lockpattern_retry_button_text));
|
||||
}
|
||||
|
||||
private ChooseLockPatternFragment findFragment(FragmentActivity activity) {
|
||||
|
Reference in New Issue
Block a user