Fix face/fingerprint consent primary footer button logic

Currently, the primary footer button on the face and fingerprint enroll
consent pages reads "I agree" even before the user has scrolled to the
bottom of the screen. This commit fixes the issue so that "More" is
displayed until the user scrolls to the bottom. The remaining logic is
left intact.

Test: Manual:
1. Start face or fingerprint enrollment
2. Confirm primary button shows "More" and secondary button is hidden
3. Press the "More" button or scroll to the bottom of the screen
4. Ensure primary button shows "I agree" and secondary shows "No thanks"

Fixes: 189268868
Change-Id: I02fa47d1de83bd5b5d82c733495ae579cbd2d6c6
This commit is contained in:
Curtis Belmonte
2021-06-10 16:34:01 -07:00
parent ad84b3dd39
commit e301d59536
3 changed files with 78 additions and 71 deletions

View File

@@ -26,6 +26,10 @@ import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StringRes;
import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.biometrics.BiometricEnrollIntroduction;
@@ -34,7 +38,6 @@ import com.android.settings.overlay.FeatureFactory;
import com.android.settings.password.ChooseLockSettingsHelper;
import com.android.settingslib.RestrictedLockUtilsInternal;
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;
@@ -50,6 +53,8 @@ public class FaceEnrollIntroduction extends BiometricEnrollIntroduction {
private FaceManager mFaceManager;
private FaceFeatureProvider mFaceFeatureProvider;
@Nullable private FooterButton mPrimaryFooterButton;
@Nullable private FooterButton mSecondaryFooterButton;
@Override
protected void onCancelButtonClick(View view) {
@@ -207,38 +212,42 @@ public class FaceEnrollIntroduction extends BiometricEnrollIntroduction {
}
@Override
@NonNull
protected FooterButton getPrimaryFooterButton() {
if (mFooterBarMixin == null) {
mFooterBarMixin = getLayout().getMixin(FooterBarMixin.class);
}
if (mFooterBarMixin.getPrimaryButton() == null) {
final FooterButton nextButtonBuilder = new FooterButton.Builder(this)
if (mPrimaryFooterButton == null) {
mPrimaryFooterButton = 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();
return mPrimaryFooterButton;
}
@Override
@NonNull
protected FooterButton getSecondaryFooterButton() {
if (mFooterBarMixin == null) {
mFooterBarMixin = getLayout().getMixin(FooterBarMixin.class);
}
if (mFooterBarMixin.getSecondaryButton() == null) {
final FooterButton noThanksButton = new FooterButton.Builder(this)
if (mSecondaryFooterButton == null) {
mSecondaryFooterButton = 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();
return mSecondaryFooterButton;
}
@Override
@StringRes
protected int getAgreeButtonTextRes() {
return R.string.security_settings_fingerprint_enroll_introduction_agree;
}
@Override
@StringRes
protected int getMoreButtonTextRes() {
return R.string.security_settings_face_enroll_introduction_more;
}
}