Merge "Get enrollment animation from overlay"
This commit is contained in:
committed by
Android (Google) Code Review
commit
3f5966bb48
@@ -29,6 +29,7 @@ import android.graphics.Rect;
|
|||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
|
||||||
import com.android.settings.biometrics.BiometricEnrollSidecar;
|
import com.android.settings.biometrics.BiometricEnrollSidecar;
|
||||||
|
import com.android.settings.overlay.FeatureFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A drawable containing the circle cutout as well as the animations.
|
* A drawable containing the circle cutout as well as the animations.
|
||||||
@@ -41,17 +42,17 @@ public class FaceEnrollAnimationDrawable extends Drawable
|
|||||||
private static final int BORDER_BOUNDS = 20;
|
private static final int BORDER_BOUNDS = 20;
|
||||||
|
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
private final ParticleCollection.Listener mListener;
|
private final FaceFeatureProvider.Listener mListener;
|
||||||
private Rect mBounds;
|
private Rect mBounds;
|
||||||
private final Paint mSquarePaint;
|
private final Paint mSquarePaint;
|
||||||
private final Paint mCircleCutoutPaint;
|
private final Paint mCircleCutoutPaint;
|
||||||
|
|
||||||
private ParticleCollection mParticleCollection;
|
private FaceFeatureProvider.EnrollingAnimation mEnrollingAnimation;
|
||||||
|
|
||||||
private TimeAnimator mTimeAnimator;
|
private TimeAnimator mTimeAnimator;
|
||||||
|
|
||||||
private final ParticleCollection.Listener mAnimationListener
|
private final FaceFeatureProvider.Listener mAnimationListener
|
||||||
= new ParticleCollection.Listener() {
|
= new FaceFeatureProvider.Listener() {
|
||||||
@Override
|
@Override
|
||||||
public void onEnrolled() {
|
public void onEnrolled() {
|
||||||
if (mTimeAnimator != null && mTimeAnimator.isStarted()) {
|
if (mTimeAnimator != null && mTimeAnimator.isStarted()) {
|
||||||
@@ -61,7 +62,7 @@ public class FaceEnrollAnimationDrawable extends Drawable
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public FaceEnrollAnimationDrawable(Context context, ParticleCollection.Listener listener) {
|
public FaceEnrollAnimationDrawable(Context context, FaceFeatureProvider.Listener listener) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mListener = listener;
|
mListener = listener;
|
||||||
|
|
||||||
@@ -77,29 +78,29 @@ public class FaceEnrollAnimationDrawable extends Drawable
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnrollmentHelp(int helpMsgId, CharSequence helpString) {
|
public void onEnrollmentHelp(int helpMsgId, CharSequence helpString) {
|
||||||
mParticleCollection.onEnrollmentHelp(helpMsgId, helpString);
|
mEnrollingAnimation.onEnrollmentHelp(helpMsgId, helpString);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnrollmentError(int errMsgId, CharSequence errString) {
|
public void onEnrollmentError(int errMsgId, CharSequence errString) {
|
||||||
mParticleCollection.onEnrollmentError(errMsgId, errString);
|
mEnrollingAnimation.onEnrollmentError(errMsgId, errString);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnrollmentProgressChange(int steps, int remaining) {
|
public void onEnrollmentProgressChange(int steps, int remaining) {
|
||||||
mParticleCollection.onEnrollmentProgressChange(steps, remaining);
|
mEnrollingAnimation.onEnrollmentProgressChange(steps, remaining);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onBoundsChange(Rect bounds) {
|
protected void onBoundsChange(Rect bounds) {
|
||||||
mBounds = bounds;
|
mBounds = bounds;
|
||||||
mParticleCollection =
|
mEnrollingAnimation = FeatureFactory.getFactory(mContext).getFaceFeatureProvider()
|
||||||
new ParticleCollection(mContext, mAnimationListener, bounds, BORDER_BOUNDS);
|
.getEnrollingAnimation(mContext, mAnimationListener, bounds, BORDER_BOUNDS);
|
||||||
|
|
||||||
if (mTimeAnimator == null) {
|
if (mTimeAnimator == null) {
|
||||||
mTimeAnimator = new TimeAnimator();
|
mTimeAnimator = new TimeAnimator();
|
||||||
mTimeAnimator.setTimeListener((animation, totalTimeMs, deltaTimeMs) -> {
|
mTimeAnimator.setTimeListener((animation, totalTimeMs, deltaTimeMs) -> {
|
||||||
mParticleCollection.update(totalTimeMs, deltaTimeMs);
|
mEnrollingAnimation.update(totalTimeMs, deltaTimeMs);
|
||||||
FaceEnrollAnimationDrawable.this.invalidateSelf();
|
FaceEnrollAnimationDrawable.this.invalidateSelf();
|
||||||
});
|
});
|
||||||
mTimeAnimator.start();
|
mTimeAnimator.start();
|
||||||
@@ -121,7 +122,7 @@ public class FaceEnrollAnimationDrawable extends Drawable
|
|||||||
mBounds.height() / 2 - BORDER_BOUNDS, mCircleCutoutPaint);
|
mBounds.height() / 2 - BORDER_BOUNDS, mCircleCutoutPaint);
|
||||||
|
|
||||||
// Draw the animation
|
// Draw the animation
|
||||||
mParticleCollection.draw(canvas);
|
mEnrollingAnimation.draw(canvas);
|
||||||
|
|
||||||
canvas.restore();
|
canvas.restore();
|
||||||
}
|
}
|
||||||
|
@@ -47,7 +47,7 @@ public class FaceEnrollEnrolling extends BiometricsEnrollEnrolling {
|
|||||||
private boolean mShouldFinishOnStop = true;
|
private boolean mShouldFinishOnStop = true;
|
||||||
private FaceEnrollPreviewFragment mPreviewFragment;
|
private FaceEnrollPreviewFragment mPreviewFragment;
|
||||||
|
|
||||||
private ParticleCollection.Listener mListener = new ParticleCollection.Listener() {
|
private FaceFeatureProvider.Listener mListener = new FaceFeatureProvider.Listener() {
|
||||||
@Override
|
@Override
|
||||||
public void onEnrolled() {
|
public void onEnrolled() {
|
||||||
FaceEnrollEnrolling.this.launchFinish(mToken);
|
FaceEnrollEnrolling.this.launchFinish(mToken);
|
||||||
|
@@ -63,7 +63,7 @@ public class FaceEnrollPreviewFragment extends InstrumentedPreferenceFragment
|
|||||||
private CameraCaptureSession mCaptureSession;
|
private CameraCaptureSession mCaptureSession;
|
||||||
private CaptureRequest mPreviewRequest;
|
private CaptureRequest mPreviewRequest;
|
||||||
private Size mPreviewSize;
|
private Size mPreviewSize;
|
||||||
private ParticleCollection.Listener mListener;
|
private FaceFeatureProvider.Listener mListener;
|
||||||
|
|
||||||
// View used to contain the circular cutout and enrollment animation drawable
|
// View used to contain the circular cutout and enrollment animation drawable
|
||||||
private ImageView mCircleView;
|
private ImageView mCircleView;
|
||||||
@@ -75,8 +75,8 @@ public class FaceEnrollPreviewFragment extends InstrumentedPreferenceFragment
|
|||||||
private FaceSquareTextureView mTextureView;
|
private FaceSquareTextureView mTextureView;
|
||||||
|
|
||||||
// Listener sent to the animation drawable
|
// Listener sent to the animation drawable
|
||||||
private final ParticleCollection.Listener mAnimationListener
|
private final FaceFeatureProvider.Listener mAnimationListener
|
||||||
= new ParticleCollection.Listener() {
|
= new FaceFeatureProvider.Listener() {
|
||||||
@Override
|
@Override
|
||||||
public void onEnrolled() {
|
public void onEnrolled() {
|
||||||
mListener.onEnrolled();
|
mListener.onEnrolled();
|
||||||
@@ -234,7 +234,7 @@ public class FaceEnrollPreviewFragment extends InstrumentedPreferenceFragment
|
|||||||
mAnimationDrawable.onEnrollmentProgressChange(steps, remaining);
|
mAnimationDrawable.onEnrollmentProgressChange(steps, remaining);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setListener(ParticleCollection.Listener listener) {
|
public void setListener(FaceFeatureProvider.Listener listener) {
|
||||||
mListener = listener;
|
mListener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* 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,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* 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);
|
||||||
|
}
|
||||||
|
}
|
@@ -35,7 +35,7 @@ import java.util.List;
|
|||||||
* are updated/drawn in a special order so that the overlap is correct during the final completion
|
* are updated/drawn in a special order so that the overlap is correct during the final completion
|
||||||
* effect.
|
* effect.
|
||||||
*/
|
*/
|
||||||
public class ParticleCollection implements BiometricEnrollSidecar.Listener {
|
public class ParticleCollection implements FaceFeatureProviderImpl.EnrollingAnimation {
|
||||||
|
|
||||||
private static final String TAG = "AnimationController";
|
private static final String TAG = "AnimationController";
|
||||||
|
|
||||||
@@ -49,11 +49,7 @@ public class ParticleCollection implements BiometricEnrollSidecar.Listener {
|
|||||||
private final List<AnimationParticle> mParticleList;
|
private final List<AnimationParticle> mParticleList;
|
||||||
private final List<Integer> mPrimariesInProgress; // primary particles not done animating yet
|
private final List<Integer> mPrimariesInProgress; // primary particles not done animating yet
|
||||||
private int mState;
|
private int mState;
|
||||||
private Listener mListener;
|
private FaceFeatureProvider.Listener mListener;
|
||||||
|
|
||||||
public interface Listener {
|
|
||||||
void onEnrolled();
|
|
||||||
}
|
|
||||||
|
|
||||||
private final AnimationParticle.Listener mParticleListener = new AnimationParticle.Listener() {
|
private final AnimationParticle.Listener mParticleListener = new AnimationParticle.Listener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -72,7 +68,8 @@ public class ParticleCollection implements BiometricEnrollSidecar.Listener {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public ParticleCollection(Context context, Listener listener, Rect bounds, int borderWidth) {
|
public ParticleCollection(Context context, FaceFeatureProvider.Listener listener, Rect bounds,
|
||||||
|
int borderWidth) {
|
||||||
mParticleList = new ArrayList<>();
|
mParticleList = new ArrayList<>();
|
||||||
mListener = listener;
|
mListener = listener;
|
||||||
|
|
||||||
@@ -103,12 +100,14 @@ public class ParticleCollection implements BiometricEnrollSidecar.Listener {
|
|||||||
updateState(STATE_STARTED);
|
updateState(STATE_STARTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void update(long t, long dt) {
|
public void update(long t, long dt) {
|
||||||
for (int i = 0; i < mParticleList.size(); i++) {
|
for (int i = 0; i < mParticleList.size(); i++) {
|
||||||
mParticleList.get(i).update(t, dt);
|
mParticleList.get(i).update(t, dt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void draw(Canvas canvas) {
|
public void draw(Canvas canvas) {
|
||||||
for (int i = 0; i < mParticleList.size(); i++) {
|
for (int i = 0; i < mParticleList.size(); i++) {
|
||||||
mParticleList.get(i).draw(canvas);
|
mParticleList.get(i).draw(canvas);
|
||||||
|
@@ -23,6 +23,7 @@ import android.util.Log;
|
|||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.accounts.AccountFeatureProvider;
|
import com.android.settings.accounts.AccountFeatureProvider;
|
||||||
import com.android.settings.applications.ApplicationFeatureProvider;
|
import com.android.settings.applications.ApplicationFeatureProvider;
|
||||||
|
import com.android.settings.biometrics.face.FaceFeatureProvider;
|
||||||
import com.android.settings.dashboard.DashboardFeatureProvider;
|
import com.android.settings.dashboard.DashboardFeatureProvider;
|
||||||
import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
|
import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
|
||||||
import com.android.settings.enterprise.EnterprisePrivacyFeatureProvider;
|
import com.android.settings.enterprise.EnterprisePrivacyFeatureProvider;
|
||||||
@@ -111,6 +112,8 @@ public abstract class FeatureFactory {
|
|||||||
|
|
||||||
public abstract ContextualCardFeatureProvider getContextualCardFeatureProvider();
|
public abstract ContextualCardFeatureProvider getContextualCardFeatureProvider();
|
||||||
|
|
||||||
|
public abstract FaceFeatureProvider getFaceFeatureProvider();
|
||||||
|
|
||||||
public static final class FactoryNotFoundException extends RuntimeException {
|
public static final class FactoryNotFoundException extends RuntimeException {
|
||||||
public FactoryNotFoundException(Throwable throwable) {
|
public FactoryNotFoundException(Throwable throwable) {
|
||||||
super("Unable to create factory. Did you misconfigure Proguard?", throwable);
|
super("Unable to create factory. Did you misconfigure Proguard?", throwable);
|
||||||
|
@@ -28,6 +28,8 @@ import com.android.settings.accounts.AccountFeatureProvider;
|
|||||||
import com.android.settings.accounts.AccountFeatureProviderImpl;
|
import com.android.settings.accounts.AccountFeatureProviderImpl;
|
||||||
import com.android.settings.applications.ApplicationFeatureProvider;
|
import com.android.settings.applications.ApplicationFeatureProvider;
|
||||||
import com.android.settings.applications.ApplicationFeatureProviderImpl;
|
import com.android.settings.applications.ApplicationFeatureProviderImpl;
|
||||||
|
import com.android.settings.biometrics.face.FaceFeatureProvider;
|
||||||
|
import com.android.settings.biometrics.face.FaceFeatureProviderImpl;
|
||||||
import com.android.settings.connecteddevice.dock.DockUpdaterFeatureProviderImpl;
|
import com.android.settings.connecteddevice.dock.DockUpdaterFeatureProviderImpl;
|
||||||
import com.android.settings.core.instrumentation.SettingsMetricsFeatureProvider;
|
import com.android.settings.core.instrumentation.SettingsMetricsFeatureProvider;
|
||||||
import com.android.settings.dashboard.DashboardFeatureProvider;
|
import com.android.settings.dashboard.DashboardFeatureProvider;
|
||||||
@@ -78,6 +80,7 @@ public class FeatureFactoryImpl extends FeatureFactory {
|
|||||||
private AccountFeatureProvider mAccountFeatureProvider;
|
private AccountFeatureProvider mAccountFeatureProvider;
|
||||||
private PanelFeatureProvider mPanelFeatureProvider;
|
private PanelFeatureProvider mPanelFeatureProvider;
|
||||||
private ContextualCardFeatureProvider mContextualCardFeatureProvider;
|
private ContextualCardFeatureProvider mContextualCardFeatureProvider;
|
||||||
|
private FaceFeatureProvider mFaceFeatureProvider;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SupportFeatureProvider getSupportFeatureProvider(Context context) {
|
public SupportFeatureProvider getSupportFeatureProvider(Context context) {
|
||||||
@@ -224,10 +227,19 @@ public class FeatureFactoryImpl extends FeatureFactory {
|
|||||||
return mPanelFeatureProvider;
|
return mPanelFeatureProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ContextualCardFeatureProvider getContextualCardFeatureProvider() {
|
public ContextualCardFeatureProvider getContextualCardFeatureProvider() {
|
||||||
if (mContextualCardFeatureProvider == null) {
|
if (mContextualCardFeatureProvider == null) {
|
||||||
mContextualCardFeatureProvider = new ContextualCardFeatureProviderImpl();
|
mContextualCardFeatureProvider = new ContextualCardFeatureProviderImpl();
|
||||||
}
|
}
|
||||||
return mContextualCardFeatureProvider;
|
return mContextualCardFeatureProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FaceFeatureProvider getFaceFeatureProvider() {
|
||||||
|
if (mFaceFeatureProvider == null) {
|
||||||
|
mFaceFeatureProvider = new FaceFeatureProviderImpl();
|
||||||
|
}
|
||||||
|
return mFaceFeatureProvider;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -23,6 +23,7 @@ import android.content.Context;
|
|||||||
|
|
||||||
import com.android.settings.accounts.AccountFeatureProvider;
|
import com.android.settings.accounts.AccountFeatureProvider;
|
||||||
import com.android.settings.applications.ApplicationFeatureProvider;
|
import com.android.settings.applications.ApplicationFeatureProvider;
|
||||||
|
import com.android.settings.biometrics.face.FaceFeatureProvider;
|
||||||
import com.android.settings.dashboard.DashboardFeatureProvider;
|
import com.android.settings.dashboard.DashboardFeatureProvider;
|
||||||
import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
|
import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
|
||||||
import com.android.settings.enterprise.EnterprisePrivacyFeatureProvider;
|
import com.android.settings.enterprise.EnterprisePrivacyFeatureProvider;
|
||||||
@@ -64,6 +65,7 @@ public class FakeFeatureFactory extends FeatureFactory {
|
|||||||
public final AssistGestureFeatureProvider assistGestureFeatureProvider;
|
public final AssistGestureFeatureProvider assistGestureFeatureProvider;
|
||||||
public final AccountFeatureProvider mAccountFeatureProvider;
|
public final AccountFeatureProvider mAccountFeatureProvider;
|
||||||
public final ContextualCardFeatureProvider mContextualCardFeatureProvider;
|
public final ContextualCardFeatureProvider mContextualCardFeatureProvider;
|
||||||
|
public final FaceFeatureProvider mFaceFeatureProvider;
|
||||||
|
|
||||||
public PanelFeatureProvider panelFeatureProvider;
|
public PanelFeatureProvider panelFeatureProvider;
|
||||||
public SlicesFeatureProvider slicesFeatureProvider;
|
public SlicesFeatureProvider slicesFeatureProvider;
|
||||||
@@ -108,6 +110,7 @@ public class FakeFeatureFactory extends FeatureFactory {
|
|||||||
mAccountFeatureProvider = mock(AccountFeatureProvider.class);
|
mAccountFeatureProvider = mock(AccountFeatureProvider.class);
|
||||||
mContextualCardFeatureProvider = mock(ContextualCardFeatureProvider.class);
|
mContextualCardFeatureProvider = mock(ContextualCardFeatureProvider.class);
|
||||||
panelFeatureProvider = mock(PanelFeatureProvider.class);
|
panelFeatureProvider = mock(PanelFeatureProvider.class);
|
||||||
|
mFaceFeatureProvider = mock(FaceFeatureProvider.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -195,7 +198,13 @@ public class FakeFeatureFactory extends FeatureFactory {
|
|||||||
return panelFeatureProvider;
|
return panelFeatureProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ContextualCardFeatureProvider getContextualCardFeatureProvider() {
|
public ContextualCardFeatureProvider getContextualCardFeatureProvider() {
|
||||||
return mContextualCardFeatureProvider;
|
return mContextualCardFeatureProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FaceFeatureProvider getFaceFeatureProvider() {
|
||||||
|
return mFaceFeatureProvider;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user