Merge "Enhance subclassing support in ScrimController."
This commit is contained in:
@@ -23,6 +23,7 @@ import android.animation.ValueAnimator;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Rect;
|
||||
import android.support.v4.graphics.ColorUtils;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewTreeObserver;
|
||||
@@ -60,21 +61,22 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener,
|
||||
private final UnlockMethodCache mUnlockMethodCache;
|
||||
private final View mHeadsUpScrim;
|
||||
|
||||
private float mScrimBehindAlpha = SCRIM_BEHIND_ALPHA;
|
||||
private float mScrimBehindAlphaKeyguard = SCRIM_BEHIND_ALPHA_KEYGUARD;
|
||||
private float mScrimBehindAlphaUnlocking = SCRIM_BEHIND_ALPHA_UNLOCKING;
|
||||
protected float mScrimBehindAlpha = SCRIM_BEHIND_ALPHA;
|
||||
protected float mScrimBehindAlphaKeyguard = SCRIM_BEHIND_ALPHA_KEYGUARD;
|
||||
protected float mScrimBehindAlphaUnlocking = SCRIM_BEHIND_ALPHA_UNLOCKING;
|
||||
|
||||
protected boolean mKeyguardShowing;
|
||||
private float mFraction;
|
||||
|
||||
private boolean mDarkenWhileDragging;
|
||||
protected boolean mBouncerShowing;
|
||||
protected boolean mBouncerIsKeyguard = false;
|
||||
private boolean mWakeAndUnlocking;
|
||||
private boolean mAnimateChange;
|
||||
protected boolean mAnimateChange;
|
||||
private boolean mUpdatePending;
|
||||
private boolean mExpanding;
|
||||
private boolean mAnimateKeyguardFadingOut;
|
||||
private long mDurationOverride = -1;
|
||||
protected long mDurationOverride = -1;
|
||||
private long mAnimationDelay;
|
||||
private Runnable mOnAnimationFinished;
|
||||
private final Interpolator mInterpolator = new DecelerateInterpolator();
|
||||
@@ -107,19 +109,6 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener,
|
||||
scheduleUpdate();
|
||||
}
|
||||
|
||||
public void setShowScrimBehind(boolean show) {
|
||||
if (show) {
|
||||
mScrimBehindAlpha = SCRIM_BEHIND_ALPHA;
|
||||
mScrimBehindAlphaKeyguard = SCRIM_BEHIND_ALPHA_KEYGUARD;
|
||||
mScrimBehindAlphaUnlocking = SCRIM_BEHIND_ALPHA_UNLOCKING;
|
||||
} else {
|
||||
mScrimBehindAlpha = 0;
|
||||
mScrimBehindAlphaKeyguard = 0;
|
||||
mScrimBehindAlphaUnlocking = 0;
|
||||
}
|
||||
scheduleUpdate();
|
||||
}
|
||||
|
||||
public void onTrackingStarted() {
|
||||
mExpanding = true;
|
||||
mDarkenWhileDragging = !mUnlockMethodCache.canSkipBouncer();
|
||||
@@ -211,7 +200,7 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener,
|
||||
return mDozeInFrontAlpha;
|
||||
}
|
||||
|
||||
private void scheduleUpdate() {
|
||||
protected void scheduleUpdate() {
|
||||
if (mUpdatePending) return;
|
||||
|
||||
// Make sure that a frame gets scheduled.
|
||||
@@ -252,9 +241,12 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener,
|
||||
behindFraction = (float) Math.pow(behindFraction, 0.8f);
|
||||
setScrimInFrontColor(fraction * SCRIM_IN_FRONT_ALPHA);
|
||||
setScrimBehindColor(behindFraction * mScrimBehindAlphaKeyguard);
|
||||
} else if (mBouncerShowing) {
|
||||
} else if (mBouncerShowing && !mBouncerIsKeyguard) {
|
||||
setScrimInFrontColor(SCRIM_IN_FRONT_ALPHA);
|
||||
setScrimBehindColor(0f);
|
||||
} else if (mBouncerShowing) {
|
||||
setScrimInFrontColor(0f);
|
||||
setScrimBehindColor(mScrimBehindAlpha);
|
||||
} else {
|
||||
float fraction = Math.max(0, Math.min(mFraction, 1));
|
||||
setScrimInFrontColor(0f);
|
||||
@@ -296,11 +288,11 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener,
|
||||
updateScrim(mAnimateChange, scrim, alpha, getCurrentScrimAlpha(scrim));
|
||||
}
|
||||
|
||||
private float getDozeAlpha(View scrim) {
|
||||
protected float getDozeAlpha(View scrim) {
|
||||
return scrim == mScrimBehind ? mDozeBehindAlpha : mDozeInFrontAlpha;
|
||||
}
|
||||
|
||||
private float getCurrentScrimAlpha(View scrim) {
|
||||
protected float getCurrentScrimAlpha(View scrim) {
|
||||
return scrim == mScrimBehind ? mCurrentBehindAlpha
|
||||
: scrim == mScrimInFront ? mCurrentInFrontAlpha
|
||||
: mCurrentHeadsUpAlpha;
|
||||
@@ -317,12 +309,14 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener,
|
||||
}
|
||||
}
|
||||
|
||||
private void updateScrimColor(View scrim) {
|
||||
protected void updateScrimColor(View scrim) {
|
||||
float alpha1 = getCurrentScrimAlpha(scrim);
|
||||
if (scrim instanceof ScrimView) {
|
||||
float alpha2 = getDozeAlpha(scrim);
|
||||
float alpha = 1 - (1 - alpha1) * (1 - alpha2);
|
||||
((ScrimView) scrim).setScrimColor(Color.argb((int) (alpha * 255), 0, 0, 0));
|
||||
int baseColor = ((ScrimView) scrim).getScrimColor();
|
||||
((ScrimView) scrim).setScrimColor(
|
||||
ColorUtils.setAlphaComponent(baseColor, (int) (alpha * 255)));
|
||||
} else {
|
||||
scrim.setAlpha(alpha1);
|
||||
}
|
||||
@@ -369,7 +363,7 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener,
|
||||
scrim.setTag(TAG_KEY_ANIM_TARGET, target);
|
||||
}
|
||||
|
||||
private Interpolator getInterpolator() {
|
||||
protected Interpolator getInterpolator() {
|
||||
return mAnimateKeyguardFadingOut ? KEYGUARD_FADE_OUT_INTERPOLATOR : mInterpolator;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user