Merge "Remove StateProvider from LockIcon" into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
645fdff012
@@ -50,19 +50,22 @@ public class LockIcon extends KeyguardAffordanceView {
|
|||||||
static final int STATE_BIOMETRICS_ERROR = 3;
|
static final int STATE_BIOMETRICS_ERROR = 3;
|
||||||
private float mDozeAmount;
|
private float mDozeAmount;
|
||||||
private int mIconColor;
|
private int mIconColor;
|
||||||
private StateProvider mStateProvider;
|
|
||||||
private int mOldState;
|
private int mOldState;
|
||||||
|
private int mState;
|
||||||
private boolean mPulsing;
|
private boolean mPulsing;
|
||||||
private boolean mDozing;
|
private boolean mDozing;
|
||||||
private boolean mKeyguardJustShown;
|
private boolean mKeyguardJustShown;
|
||||||
|
private boolean mPredrawRegistered;
|
||||||
private final SparseArray<Drawable> mDrawableCache = new SparseArray<>();
|
private final SparseArray<Drawable> mDrawableCache = new SparseArray<>();
|
||||||
|
|
||||||
private final OnPreDrawListener mOnPreDrawListener = new OnPreDrawListener() {
|
private final OnPreDrawListener mOnPreDrawListener = new OnPreDrawListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreDraw() {
|
public boolean onPreDraw() {
|
||||||
getViewTreeObserver().removeOnPreDrawListener(this);
|
getViewTreeObserver().removeOnPreDrawListener(this);
|
||||||
|
mPredrawRegistered = false;
|
||||||
|
|
||||||
int newState = mStateProvider.getState();
|
int newState = mState;
|
||||||
|
mOldState = mState;
|
||||||
Drawable icon = getIcon(newState);
|
Drawable icon = getIcon(newState);
|
||||||
setImageDrawable(icon, false);
|
setImageDrawable(icon, false);
|
||||||
|
|
||||||
@@ -80,7 +83,7 @@ public class LockIcon extends KeyguardAffordanceView {
|
|||||||
@Override
|
@Override
|
||||||
public void onAnimationEnd(Drawable drawable) {
|
public void onAnimationEnd(Drawable drawable) {
|
||||||
if (getDrawable() == animation
|
if (getDrawable() == animation
|
||||||
&& newState == mStateProvider.getState()
|
&& newState == mState
|
||||||
&& newState == STATE_SCANNING_FACE) {
|
&& newState == STATE_SCANNING_FACE) {
|
||||||
animation.start();
|
animation.start();
|
||||||
} else {
|
} else {
|
||||||
@@ -100,10 +103,6 @@ public class LockIcon extends KeyguardAffordanceView {
|
|||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setStateProvider(StateProvider stateProvider) {
|
|
||||||
mStateProvider = stateProvider;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onConfigurationChanged(Configuration newConfig) {
|
protected void onConfigurationChanged(Configuration newConfig) {
|
||||||
super.onConfigurationChanged(newConfig);
|
super.onConfigurationChanged(newConfig);
|
||||||
@@ -135,13 +134,16 @@ public class LockIcon extends KeyguardAffordanceView {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void update(int oldState, boolean pulsing, boolean dozing, boolean keyguardJustShown) {
|
void update(int newState, boolean pulsing, boolean dozing, boolean keyguardJustShown) {
|
||||||
mOldState = oldState;
|
mState = newState;
|
||||||
mPulsing = pulsing;
|
mPulsing = pulsing;
|
||||||
mDozing = dozing;
|
mDozing = dozing;
|
||||||
mKeyguardJustShown = keyguardJustShown;
|
mKeyguardJustShown = keyguardJustShown;
|
||||||
|
|
||||||
getViewTreeObserver().addOnPreDrawListener(mOnPreDrawListener);
|
if (!mPredrawRegistered) {
|
||||||
|
mPredrawRegistered = true;
|
||||||
|
getViewTreeObserver().addOnPreDrawListener(mOnPreDrawListener);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setDozeAmount(float dozeAmount) {
|
void setDozeAmount(float dozeAmount) {
|
||||||
@@ -175,7 +177,7 @@ public class LockIcon extends KeyguardAffordanceView {
|
|||||||
return mDrawableCache.get(iconRes);
|
return mDrawableCache.get(iconRes);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int getIconForState(int state) {
|
private static int getIconForState(int state) {
|
||||||
int iconRes;
|
int iconRes;
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case STATE_LOCKED:
|
case STATE_LOCKED:
|
||||||
@@ -196,7 +198,7 @@ public class LockIcon extends KeyguardAffordanceView {
|
|||||||
return iconRes;
|
return iconRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int getAnimationIndexForTransition(int oldState, int newState, boolean pulsing,
|
private static int getAnimationIndexForTransition(int oldState, int newState, boolean pulsing,
|
||||||
boolean dozing, boolean keyguardJustShown) {
|
boolean dozing, boolean keyguardJustShown) {
|
||||||
|
|
||||||
// Never animate when screen is off
|
// Never animate when screen is off
|
||||||
@@ -260,9 +262,4 @@ public class LockIcon extends KeyguardAffordanceView {
|
|||||||
}
|
}
|
||||||
return LOCK_ANIM_RES_IDS[0][lockAnimIndex];
|
return LOCK_ANIM_RES_IDS[0][lockAnimIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
interface StateProvider {
|
|
||||||
int getState();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -352,7 +352,6 @@ public class LockscreenLockIconController {
|
|||||||
mLockIcon.setOnClickListener(this::handleClick);
|
mLockIcon.setOnClickListener(this::handleClick);
|
||||||
mLockIcon.setOnLongClickListener(this::handleLongClick);
|
mLockIcon.setOnLongClickListener(this::handleLongClick);
|
||||||
mLockIcon.setAccessibilityDelegate(mAccessibilityDelegate);
|
mLockIcon.setAccessibilityDelegate(mAccessibilityDelegate);
|
||||||
mLockIcon.setStateProvider(this::getState);
|
|
||||||
|
|
||||||
if (mLockIcon.isAttachedToWindow()) {
|
if (mLockIcon.isAttachedToWindow()) {
|
||||||
mOnAttachStateChangeListener.onViewAttachedToWindow(mLockIcon);
|
mOnAttachStateChangeListener.onViewAttachedToWindow(mLockIcon);
|
||||||
@@ -462,7 +461,7 @@ public class LockscreenLockIconController {
|
|||||||
shouldUpdate = false;
|
shouldUpdate = false;
|
||||||
}
|
}
|
||||||
if (shouldUpdate && mLockIcon != null) {
|
if (shouldUpdate && mLockIcon != null) {
|
||||||
mLockIcon.update(mLastState, mPulsing, mDozing, mKeyguardJustShown);
|
mLockIcon.update(state, mPulsing, mDozing, mKeyguardJustShown);
|
||||||
}
|
}
|
||||||
mLastState = state;
|
mLastState = state;
|
||||||
mKeyguardJustShown = false;
|
mKeyguardJustShown = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user