From 99c4becf246726dcfeea16bd65c134f4fc875293 Mon Sep 17 00:00:00 2001 From: vadimt Date: Tue, 16 May 2023 14:21:31 -0700 Subject: [PATCH] Switch ScrimView to use view alpha MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Using view alpha instead of background paint’s color alpha component will make ScrimView alpha and visibility available to View Capture and any analysis tool that’s based on it. The change makes ScimView background completely opaque, and makes Scrim View use variable alpha instead of always-1.0 alpha. Changes some code that depends on the old way of representing ScrimView opacity. Also moves “updateSysUiColors()” call in ScrimView#setBackgroundColor below updating alpha and background color so the new values are used in the calculations. Bug: 282991128 Test: local, presubmit Change-Id: I6ca089bae55adfb9c3140d06da4fbb3b08f2bf8b --- .../NoButtonQuickSwitchTouchController.java | 3 +- .../FallbackRecentsStateController.java | 2 +- .../android/launcher3/LauncherAnimUtils.java | 5 ++++ .../WorkspaceStateTransitionAnimation.java | 2 +- .../anim/AnimatedPropertySetter.java | 9 +++--- .../launcher3/anim/PropertySetter.java | 5 +++- .../android/launcher3/views/ScrimView.java | 30 +++++++------------ 7 files changed, 27 insertions(+), 29 deletions(-) diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java index d3ef58936e..9f9cb00c07 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java @@ -16,7 +16,6 @@ package com.android.launcher3.uioverrides.touchcontrollers; import static android.view.MotionEvent.ACTION_DOWN; -import static android.view.MotionEvent.ACTION_MOVE; import static com.android.app.animation.Interpolators.ACCELERATE_0_75; import static com.android.app.animation.Interpolators.DECELERATE_3; @@ -262,7 +261,7 @@ public class NoButtonQuickSwitchTouchController implements TouchController, xAnim.setFloat(mRecentsView, ADJACENT_PAGE_HORIZONTAL_OFFSET, scaleAndOffset[1], LINEAR); // Use QuickSwitchState instead of OverviewState to determine scrim color, // since we need to take potential taskbar into account. - xAnim.setViewBackgroundColor(mLauncher.getScrimView(), + xAnim.setScrimViewBackgroundColor(mLauncher.getScrimView(), QUICK_SWITCH_FROM_HOME.getWorkspaceScrimColor(mLauncher), LINEAR); if (mRecentsView.getTaskViewCount() == 0) { xAnim.addFloat(mRecentsView, CONTENT_ALPHA, 0f, 1f, LINEAR); diff --git a/quickstep/src/com/android/quickstep/fallback/FallbackRecentsStateController.java b/quickstep/src/com/android/quickstep/fallback/FallbackRecentsStateController.java index 8a9e04e488..ca8381b4bf 100644 --- a/quickstep/src/com/android/quickstep/fallback/FallbackRecentsStateController.java +++ b/quickstep/src/com/android/quickstep/fallback/FallbackRecentsStateController.java @@ -114,7 +114,7 @@ public class FallbackRecentsStateController implements StateHandler threshold - && (Color.alpha(mBackgroundColor) / 255f) > threshold; + && getAlpha() > threshold; if (forceChange) { getSystemUiController().updateUiState(UI_STATE_SCRIM_VIEW, !isScrimDark()); } else { @@ -148,13 +144,7 @@ public class ScrimView extends View implements Insettable { } private boolean isScrimDark() { - if (!(getBackground() instanceof ColorDrawable)) { - throw new IllegalStateException( - "ScrimView must have a ColorDrawable background, this one has: " - + getBackground()); - } - return ColorUtils.calculateLuminance( - ((ColorDrawable) getBackground()).getColor()) < 0.5f; + return ColorUtils.calculateLuminance(mBackgroundColor) < 0.5f; } /**