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

Commit 3205fe64 authored by Kevin Chyn's avatar Kevin Chyn Committed by Android (Google) Code Review
Browse files

Merge "Revert "Get enrollment animation from overlay""

parents 19ce3764 4cedaafe
Loading
Loading
Loading
Loading
+12 −13
Original line number Diff line number Diff line
@@ -29,7 +29,6 @@ import android.graphics.Rect;
import android.graphics.drawable.Drawable;

import com.android.settings.biometrics.BiometricEnrollSidecar;
import com.android.settings.overlay.FeatureFactory;

/**
 * A drawable containing the circle cutout as well as the animations.
@@ -42,17 +41,17 @@ public class FaceEnrollAnimationDrawable extends Drawable
    private static final int BORDER_BOUNDS = 20;

    private final Context mContext;
    private final FaceFeatureProvider.Listener mListener;
    private final ParticleCollection.Listener mListener;
    private Rect mBounds;
    private final Paint mSquarePaint;
    private final Paint mCircleCutoutPaint;

    private FaceFeatureProvider.EnrollingAnimation mEnrollingAnimation;
    private ParticleCollection mParticleCollection;

    private TimeAnimator mTimeAnimator;

    private final FaceFeatureProvider.Listener mAnimationListener
            = new FaceFeatureProvider.Listener() {
    private final ParticleCollection.Listener mAnimationListener
            = new ParticleCollection.Listener() {
        @Override
        public void onEnrolled() {
            if (mTimeAnimator != null && mTimeAnimator.isStarted()) {
@@ -62,7 +61,7 @@ public class FaceEnrollAnimationDrawable extends Drawable
        }
    };

    public FaceEnrollAnimationDrawable(Context context, FaceFeatureProvider.Listener listener) {
    public FaceEnrollAnimationDrawable(Context context, ParticleCollection.Listener listener) {
        mContext = context;
        mListener = listener;

@@ -78,29 +77,29 @@ public class FaceEnrollAnimationDrawable extends Drawable

    @Override
    public void onEnrollmentHelp(int helpMsgId, CharSequence helpString) {
        mEnrollingAnimation.onEnrollmentHelp(helpMsgId, helpString);
        mParticleCollection.onEnrollmentHelp(helpMsgId, helpString);
    }

    @Override
    public void onEnrollmentError(int errMsgId, CharSequence errString) {
        mEnrollingAnimation.onEnrollmentError(errMsgId, errString);
        mParticleCollection.onEnrollmentError(errMsgId, errString);
    }

    @Override
    public void onEnrollmentProgressChange(int steps, int remaining) {
        mEnrollingAnimation.onEnrollmentProgressChange(steps, remaining);
        mParticleCollection.onEnrollmentProgressChange(steps, remaining);
    }

    @Override
    protected void onBoundsChange(Rect bounds) {
        mBounds = bounds;
        mEnrollingAnimation = FeatureFactory.getFactory(mContext).getFaceFeatureProvider()
                .getEnrollingAnimation(mContext, mAnimationListener, bounds, BORDER_BOUNDS);
        mParticleCollection =
                new ParticleCollection(mContext, mAnimationListener, bounds, BORDER_BOUNDS);

        if (mTimeAnimator == null) {
            mTimeAnimator = new TimeAnimator();
            mTimeAnimator.setTimeListener((animation, totalTimeMs, deltaTimeMs) -> {
                mEnrollingAnimation.update(totalTimeMs, deltaTimeMs);
                mParticleCollection.update(totalTimeMs, deltaTimeMs);
                FaceEnrollAnimationDrawable.this.invalidateSelf();
            });
            mTimeAnimator.start();
@@ -122,7 +121,7 @@ public class FaceEnrollAnimationDrawable extends Drawable
                mBounds.height() / 2 - BORDER_BOUNDS, mCircleCutoutPaint);

        // Draw the animation
        mEnrollingAnimation.draw(canvas);
        mParticleCollection.draw(canvas);

        canvas.restore();
    }
+1 −2
Original line number Diff line number Diff line
@@ -49,8 +49,7 @@ public class FaceEnrollEnrolling extends BiometricsEnrollEnrolling {
    private FaceEnrollPreviewFragment mPreviewFragment;

    private ArrayList<Integer> mDisabledFeatures = new ArrayList<>();

    private FaceFeatureProvider.Listener mListener = new FaceFeatureProvider.Listener() {
    private ParticleCollection.Listener mListener = new ParticleCollection.Listener() {
        @Override
        public void onEnrolled() {
            FaceEnrollEnrolling.this.launchFinish(mToken);
+4 −4
Original line number Diff line number Diff line
@@ -63,7 +63,7 @@ public class FaceEnrollPreviewFragment extends InstrumentedPreferenceFragment
    private CameraCaptureSession mCaptureSession;
    private CaptureRequest mPreviewRequest;
    private Size mPreviewSize;
    private FaceFeatureProvider.Listener mListener;
    private ParticleCollection.Listener mListener;

    // View used to contain the circular cutout and enrollment animation drawable
    private ImageView mCircleView;
@@ -75,8 +75,8 @@ public class FaceEnrollPreviewFragment extends InstrumentedPreferenceFragment
    private FaceSquareTextureView mTextureView;

    // Listener sent to the animation drawable
    private final FaceFeatureProvider.Listener mAnimationListener
            = new FaceFeatureProvider.Listener() {
    private final ParticleCollection.Listener mAnimationListener
            = new ParticleCollection.Listener() {
        @Override
        public void onEnrolled() {
            mListener.onEnrolled();
@@ -234,7 +234,7 @@ public class FaceEnrollPreviewFragment extends InstrumentedPreferenceFragment
        mAnimationDrawable.onEnrollmentProgressChange(steps, remaining);
    }

    public void setListener(FaceFeatureProvider.Listener listener) {
    public void setListener(ParticleCollection.Listener listener) {
        mListener = listener;
    }

+0 −42
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License
 */

package com.android.settings.biometrics.face;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Rect;

/**
 * Feature provider for face authentication.
 */
public interface FaceFeatureProvider {

    interface EnrollingAnimation {
        void onEnrollmentHelp(int helpMsgId, CharSequence helpString);
        void onEnrollmentError(int errMsgId, CharSequence errString);
        void onEnrollmentProgressChange(int steps, int remaining);
        void draw(Canvas canvas);
        void update(long t, long dt);
    }

    interface Listener {
        void onEnrolled();
    }

    EnrollingAnimation getEnrollingAnimation(Context context, Listener listener, Rect bounds,
            int borderWidth);
}
+0 −28
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License
 */

package com.android.settings.biometrics.face;

import android.content.Context;
import android.graphics.Rect;

public class FaceFeatureProviderImpl implements FaceFeatureProvider {
    @Override
    public EnrollingAnimation getEnrollingAnimation(Context context, Listener listener, Rect bounds,
            int borderWidth) {
        return new ParticleCollection(context, listener, bounds, borderWidth);
    }
}
Loading