Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c9744ace authored by Kevin Chyn's avatar Kevin Chyn
Browse files

Only show try again button for fingerprint

Change-Id: Idb985b00808f0aeb82f9f67515becf7bf017d7a1
Fixes: 122748115
Test: Try again button is only shown on fingerprint devices
parent 30607ce4
Loading
Loading
Loading
Loading
+3 −20
Original line number Diff line number Diff line
@@ -77,7 +77,6 @@ public abstract class BiometricDialogView extends LinearLayout {
    private final DevicePolicyManager mDevicePolicyManager;
    private final float mAnimationTranslationOffset;
    private final int mErrorColor;
    private final int mTextColor;
    private final float mDialogWidth;
    private final DialogViewCallback mCallback;

@@ -92,6 +91,8 @@ public abstract class BiometricDialogView extends LinearLayout {
    protected final Button mNegativeButton;
    protected final Button mTryAgainButton;

    protected final int mTextColor;

    private Bundle mBundle;

    private int mLastState;
@@ -108,6 +109,7 @@ public abstract class BiometricDialogView extends LinearLayout {
    protected abstract boolean shouldAnimateForTransition(int oldState, int newState);
    protected abstract int getDelayAfterAuthenticatedDurationMs();
    protected abstract boolean shouldGrayAreaDismissDialog();
    protected abstract void handleClearMessage(boolean requireTryAgain);

    private final Runnable mShowAnimationRunnable = new Runnable() {
        @Override
@@ -421,20 +423,6 @@ public abstract class BiometricDialogView extends LinearLayout {
        return mLayout;
    }

    // Clears the temporary message and shows the help message. If requireTryAgain is true,
    // we will start the authenticating state again.
    private void handleClearMessage(boolean requireTryAgain) {
        if (!requireTryAgain) {
            updateState(STATE_AUTHENTICATING);
            mErrorText.setText(getHintStringResourceId());
            mErrorText.setTextColor(mTextColor);
            mErrorText.setVisibility(View.VISIBLE);
        } else {
            updateState(STATE_IDLE);
            mErrorText.setVisibility(View.INVISIBLE);
        }
    }

    // Shows an error/help message
    private void showTemporaryMessage(String message, boolean requireTryAgain) {
        mHandler.removeMessages(MSG_CLEAR_MESSAGE);
@@ -475,11 +463,6 @@ public abstract class BiometricDialogView extends LinearLayout {
    }

    public void showTryAgainButton(boolean show) {
        if (show) {
            mTryAgainButton.setVisibility(View.VISIBLE);
        } else {
            mTryAgainButton.setVisibility(View.GONE);
        }
    }

    public void restoreState(Bundle bundle) {
+21 −1
Original line number Diff line number Diff line
@@ -210,6 +210,22 @@ public class FaceDialogView extends BiometricDialogView {
        bundle.putInt(KEY_DIALOG_SIZE, mSize);
    }


    @Override
    protected void handleClearMessage(boolean requireTryAgain) {
        // Clears the temporary message and shows the help message. If requireTryAgain is true,
        // we will start the authenticating state again.
        if (!requireTryAgain) {
            updateState(STATE_AUTHENTICATING);
            mErrorText.setText(getHintStringResourceId());
            mErrorText.setTextColor(mTextColor);
            mErrorText.setVisibility(View.VISIBLE);
        } else {
            updateState(STATE_IDLE);
            mErrorText.setVisibility(View.INVISIBLE);
        }
    }

    @Override
    public void restoreState(Bundle bundle) {
        super.restoreState(bundle);
@@ -271,7 +287,11 @@ public class FaceDialogView extends BiometricDialogView {
            // of the elements in here.
            updateSize(SIZE_BIG);
        } else {
            super.showTryAgainButton(show);
            if (show) {
                mTryAgainButton.setVisibility(View.VISIBLE);
            } else {
                mTryAgainButton.setVisibility(View.GONE);
            }
        }
    }

+8 −0
Original line number Diff line number Diff line
@@ -32,6 +32,14 @@ public class FingerprintDialogView extends BiometricDialogView {
            DialogViewCallback callback) {
        super(context, callback);
    }

    @Override
    protected void handleClearMessage(boolean requireTryAgain) {
        updateState(STATE_AUTHENTICATING);
        mErrorText.setText(getHintStringResourceId());
        mErrorText.setTextColor(mTextColor);
    }

    @Override
    protected int getHintStringResourceId() {
        return R.string.fingerprint_dialog_touch_sensor;