[Search][Motion] Separate AllApps scrim and content interpolation

video: https://drive.google.com/file/d/18jTh8Lc8hf-c1GBGaWERHo4QIvAHBA8J/view?usp=sharing&resourcekey=0-RDJgw-ecOW3nnF6_tWkgCg
Bug: 183001675
Test: visual
Change-Id: Idb177fd3e31ac41f57379ac45b80e7246c0dd156
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index a54c791..36d3625 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -1197,7 +1197,7 @@
 
         // Setup the drag controller (drop targets have to be added in reverse order in priority)
         mDropTargetBar.setup(mDragController);
-        mAllAppsController.setupViews(mAppsView);
+        mAllAppsController.setupViews(mAppsView, mScrimView);
     }
 
     /**
diff --git a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
index ed854dc..41962a4 100644
--- a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
+++ b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
@@ -36,7 +36,6 @@
 import static com.android.launcher3.states.StateAnimationConfig.ANIM_HOTSEAT_TRANSLATE;
 import static com.android.launcher3.states.StateAnimationConfig.ANIM_WORKSPACE_FADE;
 import static com.android.launcher3.states.StateAnimationConfig.ANIM_WORKSPACE_SCALE;
-import static com.android.launcher3.states.StateAnimationConfig.ANIM_WORKSPACE_SCRIM_FADE;
 import static com.android.launcher3.states.StateAnimationConfig.ANIM_WORKSPACE_TRANSLATE;
 import static com.android.launcher3.states.StateAnimationConfig.SKIP_SCRIM;
 
@@ -165,10 +164,6 @@
         SysUiScrim sysUiScrim = mLauncher.getDragLayer().getSysUiScrim();
         propertySetter.setFloat(sysUiScrim, SYSUI_PROGRESS,
                 state.hasFlag(FLAG_HAS_SYS_UI_SCRIM) ? 1 : 0, LINEAR);
-
-        propertySetter.setViewAlpha(mLauncher.getScrimView(),
-                state.getWorkspaceScrimAlpha(mLauncher),
-                config.getInterpolator(ANIM_WORKSPACE_SCRIM_FADE, LINEAR));
     }
 
     public void applyChildState(LauncherState state, CellLayout cl, int childIndex) {
diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
index c61c0d6..5c1bffb 100644
--- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java
+++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
@@ -43,6 +43,7 @@
 import com.android.launcher3.config.FeatureFlags;
 import com.android.launcher3.statemanager.StateManager.StateHandler;
 import com.android.launcher3.states.StateAnimationConfig;
+import com.android.launcher3.views.ScrimView;
 
 /**
  * Handles AllApps view transition.
@@ -70,10 +71,11 @@
                     controller.setProgress(progress);
                 }
             };
+    private final Launcher mLauncher;
 
     private AllAppsContainerView mAppsView;
+    private ScrimView mScrimView;
 
-    private final Launcher mLauncher;
     private boolean mIsVerticalLayout;
 
     // Animation in this class is controlled by a single variable {@link mProgress}.
@@ -121,6 +123,8 @@
      */
     public void setProgress(float progress) {
         mProgress = progress;
+        //Note: Take inverted progress so progress=0 maps to a transparent scrim
+        mScrimView.setProgress(1 - progress);
         mAppsView.setTranslationY(mProgress * mShiftRange);
     }
 
@@ -185,8 +189,12 @@
         return AnimationSuccessListener.forRunnable(this::onProgressAnimationEnd);
     }
 
-    public void setupViews(AllAppsContainerView appsView) {
+    /**
+     * Setup views
+     */
+    public void setupViews(AllAppsContainerView appsView, ScrimView scrimView) {
         mAppsView = appsView;
+        mScrimView = scrimView;
         if (FeatureFlags.ENABLE_DEVICE_SEARCH.get() && Utilities.ATLEAST_R) {
             mLauncher.getSystemUiController().updateUiState(UI_STATE_ALLAPPS,
                     View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
diff --git a/src/com/android/launcher3/views/ScrimView.java b/src/com/android/launcher3/views/ScrimView.java
index c9424de..9b809ae 100644
--- a/src/com/android/launcher3/views/ScrimView.java
+++ b/src/com/android/launcher3/views/ScrimView.java
@@ -15,18 +15,21 @@
  */
 package com.android.launcher3.views;
 
+import static com.android.launcher3.anim.Interpolators.ACCEL;
 import static com.android.launcher3.util.SystemUiController.UI_STATE_SCRIM_VIEW;
 
 import android.content.Context;
 import android.graphics.Rect;
 import android.util.AttributeSet;
 import android.view.View;
+import android.view.animation.Interpolator;
 
 import androidx.core.graphics.ColorUtils;
 
 import com.android.launcher3.Insettable;
 import com.android.launcher3.Launcher;
 import com.android.launcher3.R;
+import com.android.launcher3.anim.Interpolators;
 import com.android.launcher3.util.SystemUiController;
 import com.android.launcher3.util.Themes;
 
@@ -36,9 +39,22 @@
 public class ScrimView extends View implements Insettable {
     private static final float STATUS_BAR_COLOR_FORCE_UPDATE_THRESHOLD = 0.9f;
 
+
+    private static final float TINT_DECAY_MULTIPLIER = .5f;
+
+    //min progress for scrim to become visible
+    private static final float SCRIM_VISIBLE_THRESHOLD = .1f;
+    //max progress where scrim alpha animates.
+    private static final float SCRIM_SOLID_THRESHOLD = .5f;
+    private final Interpolator mScrimInterpolator = Interpolators.clampToProgress(ACCEL,
+            SCRIM_VISIBLE_THRESHOLD,
+            SCRIM_SOLID_THRESHOLD);
+
     private final boolean mIsScrimDark;
     private SystemUiController mSystemUiController;
 
+    private float mProgress;
+
     public ScrimView(Context context, AttributeSet attrs) {
         super(context, attrs);
         mIsScrimDark = ColorUtils.calculateLuminance(
@@ -47,17 +63,23 @@
     }
 
     @Override
-    public void setInsets(Rect insets) { }
+    public void setInsets(Rect insets) {
+    }
 
     @Override
     public boolean hasOverlappingRendering() {
         return false;
     }
 
-    @Override
-    protected boolean onSetAlpha(int alpha) {
-        updateSysUiColors();
-        return super.onSetAlpha(alpha);
+    /**
+     * Set progress of scrim animation.
+     * Note: progress should range from 0 for transparent to 1 for solid
+     */
+    public void setProgress(float progress) {
+        if (mProgress != progress) {
+            mProgress = progress;
+            setAlpha(mScrimInterpolator.getInterpolation(progress));
+        }
     }
 
     @Override