Improving scrim debugging
Moving modifying scrim colors in debug mode closer to it's actual usage - ScrimView.setTint(). That makes debug mode more spread but also more universal even if colors are manually overriden at any point. Also moving DEBUG flag to ScrimController where it probably makes a bit more sense. Bug: 200031548 Test: enable debug mode and see colors Change-Id: I20a053c9f4f926176cbcbe5ebd159b1607c55a6a
This commit is contained in:
@@ -79,6 +79,13 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump
|
|||||||
static final String TAG = "ScrimController";
|
static final String TAG = "ScrimController";
|
||||||
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
|
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
|
||||||
|
|
||||||
|
// debug mode colors scrims with below debug colors, irrespectively of which state they're in
|
||||||
|
public static final boolean DEBUG_MODE = false;
|
||||||
|
|
||||||
|
public static final int DEBUG_NOTIFICATIONS_TINT = Color.RED;
|
||||||
|
public static final int DEBUG_FRONT_TINT = Color.GREEN;
|
||||||
|
public static final int DEBUG_BEHIND_TINT = Color.BLUE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* General scrim animation duration.
|
* General scrim animation duration.
|
||||||
*/
|
*/
|
||||||
@@ -994,6 +1001,9 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump
|
|||||||
alpha = Math.max(0, Math.min(1.0f, alpha));
|
alpha = Math.max(0, Math.min(1.0f, alpha));
|
||||||
if (scrim instanceof ScrimView) {
|
if (scrim instanceof ScrimView) {
|
||||||
ScrimView scrimView = (ScrimView) scrim;
|
ScrimView scrimView = (ScrimView) scrim;
|
||||||
|
if (DEBUG_MODE) {
|
||||||
|
tint = getDebugScrimTint(scrimView);
|
||||||
|
}
|
||||||
|
|
||||||
Trace.traceCounter(Trace.TRACE_TAG_APP, getScrimName(scrimView) + "_alpha",
|
Trace.traceCounter(Trace.TRACE_TAG_APP, getScrimName(scrimView) + "_alpha",
|
||||||
(int) (alpha * 255));
|
(int) (alpha * 255));
|
||||||
@@ -1008,6 +1018,13 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump
|
|||||||
dispatchScrimsVisible();
|
dispatchScrimsVisible();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int getDebugScrimTint(ScrimView scrim) {
|
||||||
|
if (scrim == mScrimBehind) return DEBUG_BEHIND_TINT;
|
||||||
|
if (scrim == mScrimInFront) return DEBUG_FRONT_TINT;
|
||||||
|
if (scrim == mNotificationsScrim) return DEBUG_NOTIFICATIONS_TINT;
|
||||||
|
throw new RuntimeException("scrim can't be matched with known scrims");
|
||||||
|
}
|
||||||
|
|
||||||
private void startScrimAnimation(final View scrim, float current) {
|
private void startScrimAnimation(final View scrim, float current) {
|
||||||
ValueAnimator anim = ValueAnimator.ofFloat(0f, 1f);
|
ValueAnimator anim = ValueAnimator.ofFloat(0f, 1f);
|
||||||
if (mAnimatorListener != null) {
|
if (mAnimatorListener != null) {
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ public enum ScrimState {
|
|||||||
// to make sure correct color is returned before "prepare" is called
|
// to make sure correct color is returned before "prepare" is called
|
||||||
@Override
|
@Override
|
||||||
public int getBehindTint() {
|
public int getBehindTint() {
|
||||||
return DEBUG_MODE ? DEBUG_BEHIND_TINT : Color.BLACK;
|
return Color.BLACK;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -264,12 +264,6 @@ public enum ScrimState {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private static final boolean DEBUG_MODE = false;
|
|
||||||
|
|
||||||
private static final int DEBUG_NOTIFICATIONS_TINT = Color.RED;
|
|
||||||
private static final int DEBUG_FRONT_TINT = Color.GREEN;
|
|
||||||
private static final int DEBUG_BEHIND_TINT = Color.BLUE;
|
|
||||||
|
|
||||||
boolean mBlankScreen = false;
|
boolean mBlankScreen = false;
|
||||||
long mAnimationDuration = ScrimController.ANIMATION_DURATION;
|
long mAnimationDuration = ScrimController.ANIMATION_DURATION;
|
||||||
int mFrontTint = Color.TRANSPARENT;
|
int mFrontTint = Color.TRANSPARENT;
|
||||||
@@ -329,15 +323,15 @@ public enum ScrimState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getFrontTint() {
|
public int getFrontTint() {
|
||||||
return DEBUG_MODE ? DEBUG_FRONT_TINT : mFrontTint;
|
return mFrontTint;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getBehindTint() {
|
public int getBehindTint() {
|
||||||
return DEBUG_MODE ? DEBUG_BEHIND_TINT : mBehindTint;
|
return mBehindTint;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getNotifTint() {
|
public int getNotifTint() {
|
||||||
return DEBUG_MODE ? DEBUG_NOTIFICATIONS_TINT : mNotifTint;
|
return mNotifTint;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getAnimationDuration() {
|
public long getAnimationDuration() {
|
||||||
@@ -349,6 +343,10 @@ public enum ScrimState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateScrimColor(ScrimView scrim, float alpha, int tint) {
|
public void updateScrimColor(ScrimView scrim, float alpha, int tint) {
|
||||||
|
if (ScrimController.DEBUG_MODE) {
|
||||||
|
tint = scrim == mScrimInFront ? ScrimController.DEBUG_FRONT_TINT
|
||||||
|
: ScrimController.DEBUG_BEHIND_TINT;
|
||||||
|
}
|
||||||
Trace.traceCounter(Trace.TRACE_TAG_APP,
|
Trace.traceCounter(Trace.TRACE_TAG_APP,
|
||||||
scrim == mScrimInFront ? "front_scrim_alpha" : "back_scrim_alpha",
|
scrim == mScrimInFront ? "front_scrim_alpha" : "back_scrim_alpha",
|
||||||
(int) (alpha * 255));
|
(int) (alpha * 255));
|
||||||
|
|||||||
Reference in New Issue
Block a user