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

Commit 213ef8df authored by Kevin Chyn's avatar Kevin Chyn Committed by Automerger Merge Worker
Browse files

Merge changes I95f2f13d,Ie6aed9d7 into sc-dev am: e571aacd

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14884772

Change-Id: I3b95d27c593b49a96f73054f0e9d5cb364bb57db
parents 23d6a4fe e571aacd
Loading
Loading
Loading
Loading
+0 −1
Original line number Original line Diff line number Diff line
@@ -187,7 +187,6 @@
    <!-- UDFPS colors -->
    <!-- UDFPS colors -->
    <color name="udfps_enroll_icon">#000000</color>                         <!-- 100% black -->
    <color name="udfps_enroll_icon">#000000</color>                         <!-- 100% black -->
    <color name="udfps_moving_target_fill">#cc4285f4</color>                <!-- 80% blue -->
    <color name="udfps_moving_target_fill">#cc4285f4</color>                <!-- 80% blue -->
    <color name="udfps_moving_target_stroke">#ff669DF6</color>              <!-- 100% blue -->
    <color name="udfps_enroll_progress">#ff669DF6</color>                   <!-- 100% blue -->
    <color name="udfps_enroll_progress">#ff669DF6</color>                   <!-- 100% blue -->


    <!-- Logout button -->
    <!-- Logout button -->
+11 −0
Original line number Original line Diff line number Diff line
@@ -211,6 +211,12 @@ public class UdfpsController implements DozeReceiver {
            }
            }
        }
        }


        void onAcquiredGood() {
            if (mEnrollHelper != null) {
                mEnrollHelper.animateIfLastStep();
            }
        }

        void onEnrollmentHelp() {
        void onEnrollmentHelp() {
            if (mEnrollHelper != null) {
            if (mEnrollHelper != null) {
                mEnrollHelper.onEnrollmentHelp();
                mEnrollHelper.onEnrollmentHelp();
@@ -260,6 +266,11 @@ public class UdfpsController implements DozeReceiver {
                }
                }
                mGoodCaptureReceived = true;
                mGoodCaptureReceived = true;
                mView.stopIllumination();
                mView.stopIllumination();
                if (mServerRequest != null) {
                    mServerRequest.onAcquiredGood();
                } else {
                    Log.e(TAG, "Null serverRequest when onAcquiredGood");
                }
            });
            });
        }
        }


+4 −9
Original line number Original line Diff line number Diff line
@@ -47,7 +47,6 @@ public class UdfpsEnrollDrawable extends UdfpsDrawable {
    @NonNull private final Drawable mMovingTargetFpIcon;
    @NonNull private final Drawable mMovingTargetFpIcon;
    @NonNull private final Paint mSensorOutlinePaint;
    @NonNull private final Paint mSensorOutlinePaint;
    @NonNull private final Paint mBlueFill;
    @NonNull private final Paint mBlueFill;
    @NonNull private final Paint mBlueStroke;


    @Nullable private RectF mSensorRect;
    @Nullable private RectF mSensorRect;
    @Nullable private UdfpsEnrollHelper mEnrollHelper;
    @Nullable private UdfpsEnrollHelper mEnrollHelper;
@@ -76,12 +75,6 @@ public class UdfpsEnrollDrawable extends UdfpsDrawable {
        mBlueFill.setColor(context.getColor(R.color.udfps_moving_target_fill));
        mBlueFill.setColor(context.getColor(R.color.udfps_moving_target_fill));
        mBlueFill.setStyle(Paint.Style.FILL);
        mBlueFill.setStyle(Paint.Style.FILL);


        mBlueStroke = new Paint(0 /* flags */);
        mBlueStroke.setAntiAlias(true);
        mBlueStroke.setColor(context.getColor(R.color.udfps_moving_target_stroke));
        mBlueStroke.setStyle(Paint.Style.STROKE);
        mBlueStroke.setStrokeWidth(12);

        mMovingTargetFpIcon = context.getResources().getDrawable(R.drawable.ic_fingerprint, null);
        mMovingTargetFpIcon = context.getResources().getDrawable(R.drawable.ic_fingerprint, null);
        mMovingTargetFpIcon.setTint(Color.WHITE);
        mMovingTargetFpIcon.setTint(Color.WHITE);
        mMovingTargetFpIcon.mutate();
        mMovingTargetFpIcon.mutate();
@@ -146,6 +139,10 @@ public class UdfpsEnrollDrawable extends UdfpsDrawable {
        }
        }
    }
    }


    void onLastStepAcquired() {
        mProgressDrawable.onLastStepAcquired();
    }

    @Override
    @Override
    public void draw(@NonNull Canvas canvas) {
    public void draw(@NonNull Canvas canvas) {
        mProgressDrawable.draw(canvas);
        mProgressDrawable.draw(canvas);
@@ -163,7 +160,6 @@ public class UdfpsEnrollDrawable extends UdfpsDrawable {
                canvas.scale(mCurrentScale, mCurrentScale,
                canvas.scale(mCurrentScale, mCurrentScale,
                        mSensorRect.centerX(), mSensorRect.centerY());
                        mSensorRect.centerX(), mSensorRect.centerY());
                canvas.drawOval(mSensorRect, mBlueFill);
                canvas.drawOval(mSensorRect, mBlueFill);
                canvas.drawOval(mSensorRect, mBlueStroke);
            }
            }


            mMovingTargetFpIcon.draw(canvas);
            mMovingTargetFpIcon.draw(canvas);
@@ -188,7 +184,6 @@ public class UdfpsEnrollDrawable extends UdfpsDrawable {
        super.setAlpha(alpha);
        super.setAlpha(alpha);
        mSensorOutlinePaint.setAlpha(alpha);
        mSensorOutlinePaint.setAlpha(alpha);
        mBlueFill.setAlpha(alpha);
        mBlueFill.setAlpha(alpha);
        mBlueStroke.setAlpha(alpha);
        mMovingTargetFpIcon.setAlpha(alpha);
        mMovingTargetFpIcon.setAlpha(alpha);
        invalidateSelf();
        invalidateSelf();
    }
    }
+12 −0
Original line number Original line Diff line number Diff line
@@ -49,6 +49,7 @@ public class UdfpsEnrollHelper {


    interface Listener {
    interface Listener {
        void onEnrollmentProgress(int remaining, int totalSteps);
        void onEnrollmentProgress(int remaining, int totalSteps);
        void onLastStepAcquired();
    }
    }


    @NonNull private final Context mContext;
    @NonNull private final Context mContext;
@@ -178,4 +179,15 @@ public class UdfpsEnrollHelper {
                .get(index % mGuidedEnrollmentPoints.size());
                .get(index % mGuidedEnrollmentPoints.size());
        return new PointF(originalPoint.x * scale, originalPoint.y * scale);
        return new PointF(originalPoint.x * scale, originalPoint.y * scale);
    }
    }

    void animateIfLastStep() {
        if (mListener == null) {
            Log.e(TAG, "animateIfLastStep, null listener");
            return;
        }

        if (mRemainingSteps <= 2 && mRemainingSteps >= 0) {
            mListener.onLastStepAcquired();
        }
    }
}
}
+31 −2
Original line number Original line Diff line number Diff line
@@ -23,6 +23,7 @@ import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.Paint;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Drawable;
import android.util.Log;
import android.util.TypedValue;
import android.util.TypedValue;


import androidx.annotation.NonNull;
import androidx.annotation.NonNull;
@@ -46,6 +47,8 @@ public class UdfpsEnrollProgressBarDrawable extends Drawable {


    @Nullable private ValueAnimator mProgressAnimator;
    @Nullable private ValueAnimator mProgressAnimator;
    private float mProgress;
    private float mProgress;
    private int mRotation; // After last step, rotate the progress bar once
    private boolean mLastStepAcquired;


    public UdfpsEnrollProgressBarDrawable(@NonNull Context context,
    public UdfpsEnrollProgressBarDrawable(@NonNull Context context,
            @NonNull UdfpsEnrollDrawable parent) {
            @NonNull UdfpsEnrollDrawable parent) {
@@ -81,13 +84,34 @@ public class UdfpsEnrollProgressBarDrawable extends Drawable {
        // Add one so that the first steps actually changes progress, but also so that the last
        // Add one so that the first steps actually changes progress, but also so that the last
        // step ends at 1.0
        // step ends at 1.0
        final float progress = (totalSteps - remaining + 1) / (float) (totalSteps + 1);
        final float progress = (totalSteps - remaining + 1) / (float) (totalSteps + 1);
        setEnrollmentProgress(progress);
    }

    private void setEnrollmentProgress(float progress) {
        if (mLastStepAcquired) {
            return;
        }

        long animationDuration = 150;

        if (progress == 1.f) {
            animationDuration = 400;
            final ValueAnimator rotationAnimator = ValueAnimator.ofInt(0, 400);
            rotationAnimator.setDuration(animationDuration);
            rotationAnimator.addUpdateListener(animation -> {
                Log.d(TAG, "Rotation: " + mRotation);
                mRotation = (int) animation.getAnimatedValue();
                mParent.invalidateSelf();
            });
            rotationAnimator.start();
        }


        if (mProgressAnimator != null && mProgressAnimator.isRunning()) {
        if (mProgressAnimator != null && mProgressAnimator.isRunning()) {
            mProgressAnimator.cancel();
            mProgressAnimator.cancel();
        }
        }


        mProgressAnimator = ValueAnimator.ofFloat(mProgress, progress);
        mProgressAnimator = ValueAnimator.ofFloat(mProgress, progress);
        mProgressAnimator.setDuration(150);
        mProgressAnimator.setDuration(animationDuration);
        mProgressAnimator.addUpdateListener(animation -> {
        mProgressAnimator.addUpdateListener(animation -> {
            mProgress = (float) animation.getAnimatedValue();
            mProgress = (float) animation.getAnimatedValue();
            // Use the parent to invalidate, since it's the one that's attached as the view's
            // Use the parent to invalidate, since it's the one that's attached as the view's
@@ -99,12 +123,17 @@ public class UdfpsEnrollProgressBarDrawable extends Drawable {
        mProgressAnimator.start();
        mProgressAnimator.start();
    }
    }


    void onLastStepAcquired() {
        setEnrollmentProgress(1.f);
        mLastStepAcquired = true;
    }

    @Override
    @Override
    public void draw(@NonNull Canvas canvas) {
    public void draw(@NonNull Canvas canvas) {
        canvas.save();
        canvas.save();


        // Progress starts from the top, instead of the right
        // Progress starts from the top, instead of the right
        canvas.rotate(-90, getBounds().centerX(), getBounds().centerY());
        canvas.rotate(-90 + mRotation, getBounds().centerX(), getBounds().centerY());


        // Progress bar "background track"
        // Progress bar "background track"
        final float halfPaddingPx = Utils.dpToPixels(mContext, PROGRESS_BAR_THICKNESS_DP) / 2;
        final float halfPaddingPx = Utils.dpToPixels(mContext, PROGRESS_BAR_THICKNESS_DP) / 2;
Loading