BiometricEnrollIntroduction button update

No longer show the "No thanks" button until the user has
scrolled to the bottom of the introduction text.

This applies for both face and fingerprint enroll introduction screens.

Fixes: 189268868
Test: Manual
Change-Id: I0ccf6ae1d329df06f769f05288706ef22183bc21
This commit is contained in:
Joshua Mccloskey
2021-06-08 16:52:11 -07:00
parent 35e1f0d189
commit e80c5cddd2
3 changed files with 122 additions and 51 deletions

View File

@@ -39,6 +39,8 @@ import com.android.settings.password.ChooseLockSettingsHelper;
import com.google.android.setupcompat.template.FooterButton;
import com.google.android.setupcompat.util.WizardManagerHelper;
import com.google.android.setupdesign.span.LinkSpan;
import com.google.android.setupdesign.template.RequireScrollMixin;
import com.google.android.setupdesign.template.RequireScrollMixin.OnRequireScrollStateChangedListener;
import com.google.android.setupdesign.util.DynamicColorPalette;
/**
@@ -180,6 +182,35 @@ public abstract class BiometricEnrollIntroduction extends BiometricEnrollBase
launchConfirmLock(getConfirmLockTitleResId());
}
}
FooterButton primaryButton = getPrimaryFooterButton();
FooterButton secondaryButton = getSecondaryFooterButton();
if (primaryButton == null) {
Log.d(TAG, "getPrimaryFooterButton() was null");
return;
}
if (secondaryButton == null) {
Log.d(TAG, "getSecondaryFooterButton() was null");
return;
}
// Setup scroll mixin
final RequireScrollMixin requireScrollMixin = getLayout().getMixin(
RequireScrollMixin.class);
requireScrollMixin.requireScrollWithButton(this, primaryButton, getScrollCompletedText(),
this::onNextButtonClick);
secondaryButton.setVisibility(View.INVISIBLE);
requireScrollMixin.setOnRequireScrollStateChangedListener(
new OnRequireScrollStateChangedListener() {
@Override
public void onRequireScrollStateChanged(boolean scrollNeeded) {
if (!scrollNeeded && secondaryButton.getVisibility() == View.INVISIBLE) {
secondaryButton.setVisibility(View.VISIBLE);
}
}
});
}
@Override
@@ -335,4 +366,18 @@ public abstract class BiometricEnrollIntroduction extends BiometricEnrollBase
}
return mIconColorFilter;
}
@Nullable
protected FooterButton getPrimaryFooterButton() {
return null;
}
@Nullable
protected FooterButton getSecondaryFooterButton() {
return null;
}
protected int getScrollCompletedText() {
return R.string.security_settings_face_enroll_introduction_more;
}
}

View File

@@ -38,7 +38,6 @@ import com.google.android.setupcompat.template.FooterBarMixin;
import com.google.android.setupcompat.template.FooterButton;
import com.google.android.setupcompat.util.WizardManagerHelper;
import com.google.android.setupdesign.span.LinkSpan;
import com.google.android.setupdesign.template.RequireScrollMixin;
import java.util.List;
@@ -81,32 +80,6 @@ public class FaceEnrollIntroduction extends BiometricEnrollIntroduction {
mFaceFeatureProvider = FeatureFactory.getFactory(getApplicationContext())
.getFaceFeatureProvider();
mFooterBarMixin = getLayout().getMixin(FooterBarMixin.class);
mFooterBarMixin.setSecondaryButton(
new FooterButton.Builder(this)
.setText(R.string.security_settings_face_enroll_introduction_no_thanks)
.setListener(this::onSkipButtonClick)
.setButtonType(FooterButton.ButtonType.NEXT)
.setTheme(R.style.SudGlifButton_Primary)
.build(),
true /* usePrimaryStyle */);
FooterButton.Builder nextButtonBuilder = new FooterButton.Builder(this)
.setText(R.string.security_settings_face_enroll_introduction_agree)
.setButtonType(FooterButton.ButtonType.OPT_IN)
.setTheme(R.style.SudGlifButton_Primary);
if (maxFacesEnrolled()) {
nextButtonBuilder.setListener(this::onNextButtonClick);
mFooterBarMixin.setPrimaryButton(nextButtonBuilder.build());
} else {
final FooterButton agreeButton = nextButtonBuilder.build();
mFooterBarMixin.setPrimaryButton(agreeButton);
final RequireScrollMixin requireScrollMixin = getLayout().getMixin(
RequireScrollMixin.class);
requireScrollMixin.requireScrollWithButton(this, agreeButton,
R.string.security_settings_face_enroll_introduction_more,
this::onNextButtonClick);
}
// This path is an entry point for SetNewPasswordController, e.g.
// adb shell am start -a android.app.action.SET_NEW_PASSWORD
@@ -232,4 +205,40 @@ public class FaceEnrollIntroduction extends BiometricEnrollIntroduction {
public void onClick(LinkSpan span) {
// TODO(b/110906762)
}
@Override
protected FooterButton getPrimaryFooterButton() {
if (mFooterBarMixin == null) {
mFooterBarMixin = getLayout().getMixin(FooterBarMixin.class);
}
if (mFooterBarMixin.getPrimaryButton() == null) {
final FooterButton nextButtonBuilder = new FooterButton.Builder(this)
.setText(R.string.security_settings_face_enroll_introduction_agree)
.setButtonType(FooterButton.ButtonType.OPT_IN)
.setListener(this::onNextButtonClick)
.setTheme(R.style.SudGlifButton_Primary)
.build();
mFooterBarMixin.setPrimaryButton(nextButtonBuilder);
}
return mFooterBarMixin.getPrimaryButton();
}
@Override
protected FooterButton getSecondaryFooterButton() {
if (mFooterBarMixin == null) {
mFooterBarMixin = getLayout().getMixin(FooterBarMixin.class);
}
if (mFooterBarMixin.getSecondaryButton() == null) {
final FooterButton noThanksButton = new FooterButton.Builder(this)
.setText(R.string.security_settings_face_enroll_introduction_no_thanks)
.setListener(this::onSkipButtonClick)
.setButtonType(FooterButton.ButtonType.NEXT)
.setTheme(R.style.SudGlifButton_Primary)
.build();
mFooterBarMixin.setSecondaryButton(noThanksButton, true /* usePrimaryStyle */);
}
return mFooterBarMixin.getSecondaryButton();
}
}

View File

@@ -38,7 +38,6 @@ import com.android.settingslib.RestrictedLockUtilsInternal;
import com.google.android.setupcompat.template.FooterBarMixin;
import com.google.android.setupcompat.template.FooterButton;
import com.google.android.setupdesign.span.LinkSpan;
import com.google.android.setupdesign.template.RequireScrollMixin;
import java.util.List;
@@ -69,29 +68,6 @@ public class FingerprintEnrollIntroduction extends BiometricEnrollIntroduction {
iconDelete.getDrawable().setColorFilter(getIconColorFilter());
iconInfo.getDrawable().setColorFilter(getIconColorFilter());
iconLink.getDrawable().setColorFilter(getIconColorFilter());
mFooterBarMixin = getLayout().getMixin(FooterBarMixin.class);
mFooterBarMixin.setSecondaryButton(
new FooterButton.Builder(this)
.setText(getNegativeButtonTextId())
.setListener(this::onSkipButtonClick)
.setButtonType(FooterButton.ButtonType.NEXT)
.setTheme(R.style.SudGlifButton_Primary)
.build(),
true /* usePrimaryStyle */);
final FooterButton nextButton = new FooterButton.Builder(this)
.setText(R.string.security_settings_fingerprint_enroll_introduction_agree)
.setListener(this::onNextButtonClick)
.setButtonType(FooterButton.ButtonType.OPT_IN)
.setTheme(R.style.SudGlifButton_Primary)
.build();
mFooterBarMixin.setPrimaryButton(nextButton);
final RequireScrollMixin requireScrollMixin =
getLayout().getMixin(RequireScrollMixin.class);
requireScrollMixin.requireScrollWithButton(this, nextButton,
R.string.security_settings_face_enroll_introduction_more, this::onNextButtonClick);
}
int getNegativeButtonTextId() {
@@ -216,4 +192,45 @@ public class FingerprintEnrollIntroduction extends BiometricEnrollIntroduction {
}
}
}
@Override
protected FooterButton getPrimaryFooterButton() {
if (mFooterBarMixin == null) {
mFooterBarMixin = getLayout().getMixin(FooterBarMixin.class);
}
if (mFooterBarMixin.getPrimaryButton() == null) {
final FooterButton nextButtonBuilder = new FooterButton.Builder(this)
.setText(R.string.security_settings_fingerprint_enroll_introduction_agree)
.setListener(this::onNextButtonClick)
.setButtonType(FooterButton.ButtonType.OPT_IN)
.setTheme(R.style.SudGlifButton_Primary)
.build();
mFooterBarMixin.setPrimaryButton(nextButtonBuilder);
}
return mFooterBarMixin.getPrimaryButton();
}
@Override
protected FooterButton getSecondaryFooterButton() {
if (mFooterBarMixin == null) {
mFooterBarMixin = getLayout().getMixin(FooterBarMixin.class);
}
if (mFooterBarMixin.getSecondaryButton() == null) {
final FooterButton noThanksButton = new FooterButton.Builder(this)
.setText(getNegativeButtonTextId())
.setListener(this::onSkipButtonClick)
.setButtonType(FooterButton.ButtonType.NEXT)
.setTheme(R.style.SudGlifButton_Primary)
.build();
mFooterBarMixin.setSecondaryButton(noThanksButton, true /* usePrimaryStyle */);
}
return mFooterBarMixin.getSecondaryButton();
}
@Override
protected int getScrollCompletedText() {
return R.string.security_settings_face_enroll_introduction_more;
}
}