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"
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;
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;
}
}
@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);
if (!getResources().getBoolean(R.bool.config_lock_pattern_minimal_ui)
}
@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
// optional step if the lock screen was set up.
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;
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 = {
@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(
SetupChooseLockPattern.class,
.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));
+ }
}