Separate skip and clear button in pattern screen
So that the action performed is always the same as what the button label says. Test: m -j RunSettingsRoboTests Bug: 72197171 Change-Id: Ia2a02b630a86874d002e462e41fdf676c2d27203
This commit is contained in:
@@ -22,7 +22,15 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<!-- left : cancel, or re-try -->
|
||||
<!-- left : skip -->
|
||||
<Button android:id="@+id/skip_button"
|
||||
style="@style/SuwGlifButton.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/SuwGlifButton.Secondary"
|
||||
android:layout_width="wrap_content"
|
||||
|
@@ -25,7 +25,6 @@ import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SetupRedactionInterstitial;
|
||||
@@ -70,6 +69,17 @@ public class SetupChooseLockPattern extends ChooseLockPattern {
|
||||
ChooseLockTypeDialogFragment.newInstance(mUserId)
|
||||
.show(getChildFragmentManager(), null));
|
||||
}
|
||||
// enable skip button only during setup wizard and not with fingerprint flow.
|
||||
if (!mForFingerprint) {
|
||||
Button skipButton = view.findViewById(R.id.skip_button);
|
||||
skipButton.setVisibility(View.VISIBLE);
|
||||
skipButton.setOnClickListener(v -> {
|
||||
SetupSkipDialog dialog = SetupSkipDialog.newInstance(
|
||||
getActivity().getIntent()
|
||||
.getBooleanExtra(SetupSkipDialog.EXTRA_FRP_SUPPORTED, false));
|
||||
dialog.show(getFragmentManager());
|
||||
});
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
@@ -81,16 +91,6 @@ public class SetupChooseLockPattern extends ChooseLockPattern {
|
||||
startChooseLockActivity(lock, getActivity());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateFooterLeftButton(Stage stage, TextView footerLeftButton) {
|
||||
super.updateFooterLeftButton(stage, footerLeftButton);
|
||||
// enable skip button only during setupwizard and not with fingerprint flow.
|
||||
if (!mForFingerprint) {
|
||||
footerLeftButton.setVisibility(View.VISIBLE);
|
||||
footerLeftButton.setText(R.string.skip_label);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateStage(Stage stage) {
|
||||
super.updateStage(stage);
|
||||
@@ -101,14 +101,6 @@ public class SetupChooseLockPattern extends ChooseLockPattern {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleLeftButton() {
|
||||
SetupSkipDialog dialog = SetupSkipDialog.newInstance(
|
||||
getActivity().getIntent()
|
||||
.getBooleanExtra(SetupSkipDialog.EXTRA_FRP_SUPPORTED, false));
|
||||
dialog.show(getFragmentManager());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Intent getRedactionInterstitialIntent(Context context) {
|
||||
// Setup wizard's redaction interstitial is deferred to optional step. Enable that
|
||||
|
@@ -29,6 +29,8 @@ import android.view.View;
|
||||
import android.widget.Button;
|
||||
|
||||
import com.android.internal.widget.LockPatternView;
|
||||
import com.android.internal.widget.LockPatternView.Cell;
|
||||
import com.android.internal.widget.LockPatternView.DisplayMode;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SetupRedactionInterstitial;
|
||||
import com.android.settings.password.ChooseLockPattern.ChooseLockPatternFragment;
|
||||
@@ -47,6 +49,9 @@ import org.robolectric.annotation.Config;
|
||||
import org.robolectric.shadows.ShadowAlertDialog;
|
||||
import org.robolectric.shadows.ShadowPackageManager;
|
||||
import org.robolectric.util.ReflectionHelpers;
|
||||
import org.robolectric.util.ReflectionHelpers.ClassParameter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(shadows = {
|
||||
@@ -120,15 +125,27 @@ public class SetupChooseLockPatternTest {
|
||||
|
||||
@Test
|
||||
public void skipButton_shouldBeVisible_duringNonFingerprintFlow() {
|
||||
Button button = mActivity.findViewById(R.id.footerLeftButton);
|
||||
assertThat(button).isNotNull();
|
||||
assertThat(button.getVisibility()).isEqualTo(View.VISIBLE);
|
||||
Button skipButton = mActivity.findViewById(R.id.skip_button);
|
||||
assertThat(skipButton).isNotNull();
|
||||
assertThat(skipButton.getVisibility()).isEqualTo(View.VISIBLE);
|
||||
|
||||
button.performClick();
|
||||
skipButton.performClick();
|
||||
AlertDialog chooserDialog = ShadowAlertDialog.getLatestAlertDialog();
|
||||
assertThat(chooserDialog).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void clearButton_shouldBeVisible_duringRetryStage() {
|
||||
enterPattern();
|
||||
|
||||
Button clearButton = mActivity.findViewById(R.id.footerLeftButton);
|
||||
assertThat(clearButton.getVisibility()).isEqualTo(View.VISIBLE);
|
||||
assertThat(clearButton.isEnabled()).isTrue();
|
||||
|
||||
clearButton.performClick();
|
||||
assertThat(findFragment(mActivity).mChosenPattern).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void skipButton_shouldNotBeVisible_duringFingerprintFlow() {
|
||||
mActivity = Robolectric.buildActivity(
|
||||
@@ -140,13 +157,32 @@ public class SetupChooseLockPatternTest {
|
||||
.setForFingerprint(true)
|
||||
.build()))
|
||||
.setup().get();
|
||||
Button button = mActivity.findViewById(R.id.footerLeftButton);
|
||||
assertThat(button).isNotNull();
|
||||
assertThat(button.getVisibility()).isEqualTo(View.GONE);
|
||||
Button skipButton = mActivity.findViewById(R.id.skip_button);
|
||||
assertThat(skipButton).isNotNull();
|
||||
assertThat(skipButton.getVisibility()).isEqualTo(View.GONE);
|
||||
}
|
||||
|
||||
private ChooseLockPatternFragment findFragment(Activity activity) {
|
||||
return (ChooseLockPatternFragment)
|
||||
activity.getFragmentManager().findFragmentById(R.id.main_content);
|
||||
}
|
||||
|
||||
private void enterPattern() {
|
||||
LockPatternView lockPatternView = mActivity.findViewById(R.id.lockPattern);
|
||||
lockPatternView.setPattern(
|
||||
DisplayMode.Animate,
|
||||
Arrays.asList(
|
||||
createCell(0, 0),
|
||||
createCell(0, 1),
|
||||
createCell(1, 1),
|
||||
createCell(1, 0)));
|
||||
ReflectionHelpers.callInstanceMethod(lockPatternView, "notifyPatternDetected");
|
||||
}
|
||||
|
||||
private Cell createCell(int row, int column) {
|
||||
return ReflectionHelpers.callConstructor(
|
||||
Cell.class,
|
||||
ClassParameter.from(int.class, row),
|
||||
ClassParameter.from(int.class, column));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user