Loading packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java +32 −11 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import static android.app.ActivityManager.StackId.INVALID_STACK_ID; import android.animation.Animator; import android.animation.ObjectAnimator; import android.app.ActivityOptions.OnAnimationStartedListener; import android.app.WallpaperManager; import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; Loading Loading @@ -76,6 +77,9 @@ import com.android.systemui.recents.views.RecentsTransitionHelper.AnimationSpecC import com.android.systemui.stackdivider.WindowManagerProxy; import com.android.systemui.statusbar.FlingAnimationUtils; import com.google.android.colorextraction.ColorExtractor; import com.google.android.colorextraction.drawable.GradientDrawable; import java.io.FileDescriptor; import java.io.PrintWriter; import java.util.ArrayList; Loading @@ -85,13 +89,12 @@ import java.util.List; * This view is the the top level layout that contains TaskStacks (which are laid out according * to their SpaceNode bounds. */ public class RecentsView extends FrameLayout { public class RecentsView extends FrameLayout implements ColorExtractor.OnColorsChangedListener { private static final String TAG = "RecentsView"; private static final int DEFAULT_UPDATE_SCRIM_DURATION = 200; private static final float DEFAULT_SCRIM_ALPHA = 0.33f; private static final float GRID_LAYOUT_SCRIM_ALPHA = 0.45f; private static final float DEFAULT_SCRIM_ALPHA = 0.8f; private static final int SHOW_STACK_ACTION_BUTTON_DURATION = 134; private static final int HIDE_STACK_ACTION_BUTTON_DURATION = 100; Loading @@ -108,7 +111,8 @@ public class RecentsView extends FrameLayout { private int mDividerSize; private final float mScrimAlpha; private final Drawable mBackgroundScrim; private final GradientDrawable mBackgroundScrim; private final ColorExtractor mColorExtractor; private Animator mBackgroundScrimAnimator; private RecentsTransitionHelper mTransitionHelper; Loading Loading @@ -137,10 +141,15 @@ public class RecentsView extends FrameLayout { mDividerSize = ssp.getDockedDividerSize(context); mTouchHandler = new RecentsViewTouchHandler(this); mFlingAnimationUtils = new FlingAnimationUtils(context, 0.3f); mScrimAlpha = Recents.getConfiguration().isGridEnabled ? GRID_LAYOUT_SCRIM_ALPHA : DEFAULT_SCRIM_ALPHA; mBackgroundScrim = new ColorDrawable( Color.argb((int) (mScrimAlpha * 255), 0, 0, 0)).mutate(); mScrimAlpha = DEFAULT_SCRIM_ALPHA; mBackgroundScrim = new GradientDrawable(context); mBackgroundScrim.setCallback(this); mBackgroundScrim.setAlpha((int) (mScrimAlpha * 255)); mColorExtractor = new ColorExtractor(context); mColorExtractor.setListener(this); // We don't want to interpolate colors because we're defining the initial state. // Gradient should be set/ready when you open "Recents". mBackgroundScrim.setColors(mColorExtractor.getColors(WallpaperManager.FLAG_SYSTEM), false); LayoutInflater inflater = LayoutInflater.from(context); if (RecentsDebugFlags.Static.EnableStackActionButton) { Loading Loading @@ -188,7 +197,7 @@ public class RecentsView extends FrameLayout { // the tasks for the home animation. if (launchState.launchedViaDockGesture || launchState.launchedFromApp || isTaskStackEmpty) { mBackgroundScrim.setAlpha(255); mBackgroundScrim.setAlpha((int) (mScrimAlpha * 255)); } else { mBackgroundScrim.setAlpha(0); } Loading Loading @@ -373,6 +382,11 @@ public class RecentsView extends FrameLayout { mEmptyView.layout(childLeft, childTop, childLeft + childWidth, childTop + childHeight); } // Needs to know the screen size since the gradient never scales up or down // even when bounds change. mBackgroundScrim.setScreenSize(right - left, bottom - top); mBackgroundScrim.setBounds(left, top, right, bottom); if (RecentsDebugFlags.Static.EnableStackActionButton) { // Layout the stack action button such that its drawable is start-aligned with the // stack, vertically centered in the available space above the stack Loading Loading @@ -763,8 +777,8 @@ public class RecentsView extends FrameLayout { private void animateBackgroundScrim(float alpha, int duration) { Utilities.cancelAnimationWithoutCallbacks(mBackgroundScrimAnimator); // Calculate the absolute alpha to animate from int fromAlpha = (int) ((mBackgroundScrim.getAlpha() / (mScrimAlpha * 255)) * 255); int toAlpha = (int) (alpha * 255); int fromAlpha = mBackgroundScrim.getAlpha(); int toAlpha = (int) (alpha * mScrimAlpha * 255); mBackgroundScrimAnimator = ObjectAnimator.ofInt(mBackgroundScrim, Utilities.DRAWABLE_ALPHA, fromAlpha, toAlpha); mBackgroundScrimAnimator.setDuration(duration); Loading Loading @@ -807,4 +821,11 @@ public class RecentsView extends FrameLayout { mTaskStackView.dump(innerPrefix, writer); } } @Override public void onColorsChanged(ColorExtractor.GradientColors colors, int which) { if ((which & WallpaperManager.FLAG_SYSTEM) != 0) { mBackgroundScrim.setColors(colors); } } } Loading
packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java +32 −11 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import static android.app.ActivityManager.StackId.INVALID_STACK_ID; import android.animation.Animator; import android.animation.ObjectAnimator; import android.app.ActivityOptions.OnAnimationStartedListener; import android.app.WallpaperManager; import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; Loading Loading @@ -76,6 +77,9 @@ import com.android.systemui.recents.views.RecentsTransitionHelper.AnimationSpecC import com.android.systemui.stackdivider.WindowManagerProxy; import com.android.systemui.statusbar.FlingAnimationUtils; import com.google.android.colorextraction.ColorExtractor; import com.google.android.colorextraction.drawable.GradientDrawable; import java.io.FileDescriptor; import java.io.PrintWriter; import java.util.ArrayList; Loading @@ -85,13 +89,12 @@ import java.util.List; * This view is the the top level layout that contains TaskStacks (which are laid out according * to their SpaceNode bounds. */ public class RecentsView extends FrameLayout { public class RecentsView extends FrameLayout implements ColorExtractor.OnColorsChangedListener { private static final String TAG = "RecentsView"; private static final int DEFAULT_UPDATE_SCRIM_DURATION = 200; private static final float DEFAULT_SCRIM_ALPHA = 0.33f; private static final float GRID_LAYOUT_SCRIM_ALPHA = 0.45f; private static final float DEFAULT_SCRIM_ALPHA = 0.8f; private static final int SHOW_STACK_ACTION_BUTTON_DURATION = 134; private static final int HIDE_STACK_ACTION_BUTTON_DURATION = 100; Loading @@ -108,7 +111,8 @@ public class RecentsView extends FrameLayout { private int mDividerSize; private final float mScrimAlpha; private final Drawable mBackgroundScrim; private final GradientDrawable mBackgroundScrim; private final ColorExtractor mColorExtractor; private Animator mBackgroundScrimAnimator; private RecentsTransitionHelper mTransitionHelper; Loading Loading @@ -137,10 +141,15 @@ public class RecentsView extends FrameLayout { mDividerSize = ssp.getDockedDividerSize(context); mTouchHandler = new RecentsViewTouchHandler(this); mFlingAnimationUtils = new FlingAnimationUtils(context, 0.3f); mScrimAlpha = Recents.getConfiguration().isGridEnabled ? GRID_LAYOUT_SCRIM_ALPHA : DEFAULT_SCRIM_ALPHA; mBackgroundScrim = new ColorDrawable( Color.argb((int) (mScrimAlpha * 255), 0, 0, 0)).mutate(); mScrimAlpha = DEFAULT_SCRIM_ALPHA; mBackgroundScrim = new GradientDrawable(context); mBackgroundScrim.setCallback(this); mBackgroundScrim.setAlpha((int) (mScrimAlpha * 255)); mColorExtractor = new ColorExtractor(context); mColorExtractor.setListener(this); // We don't want to interpolate colors because we're defining the initial state. // Gradient should be set/ready when you open "Recents". mBackgroundScrim.setColors(mColorExtractor.getColors(WallpaperManager.FLAG_SYSTEM), false); LayoutInflater inflater = LayoutInflater.from(context); if (RecentsDebugFlags.Static.EnableStackActionButton) { Loading Loading @@ -188,7 +197,7 @@ public class RecentsView extends FrameLayout { // the tasks for the home animation. if (launchState.launchedViaDockGesture || launchState.launchedFromApp || isTaskStackEmpty) { mBackgroundScrim.setAlpha(255); mBackgroundScrim.setAlpha((int) (mScrimAlpha * 255)); } else { mBackgroundScrim.setAlpha(0); } Loading Loading @@ -373,6 +382,11 @@ public class RecentsView extends FrameLayout { mEmptyView.layout(childLeft, childTop, childLeft + childWidth, childTop + childHeight); } // Needs to know the screen size since the gradient never scales up or down // even when bounds change. mBackgroundScrim.setScreenSize(right - left, bottom - top); mBackgroundScrim.setBounds(left, top, right, bottom); if (RecentsDebugFlags.Static.EnableStackActionButton) { // Layout the stack action button such that its drawable is start-aligned with the // stack, vertically centered in the available space above the stack Loading Loading @@ -763,8 +777,8 @@ public class RecentsView extends FrameLayout { private void animateBackgroundScrim(float alpha, int duration) { Utilities.cancelAnimationWithoutCallbacks(mBackgroundScrimAnimator); // Calculate the absolute alpha to animate from int fromAlpha = (int) ((mBackgroundScrim.getAlpha() / (mScrimAlpha * 255)) * 255); int toAlpha = (int) (alpha * 255); int fromAlpha = mBackgroundScrim.getAlpha(); int toAlpha = (int) (alpha * mScrimAlpha * 255); mBackgroundScrimAnimator = ObjectAnimator.ofInt(mBackgroundScrim, Utilities.DRAWABLE_ALPHA, fromAlpha, toAlpha); mBackgroundScrimAnimator.setDuration(duration); Loading Loading @@ -807,4 +821,11 @@ public class RecentsView extends FrameLayout { mTaskStackView.dump(innerPrefix, writer); } } @Override public void onColorsChanged(ColorExtractor.GradientColors colors, int which) { if ((which & WallpaperManager.FLAG_SYSTEM) != 0) { mBackgroundScrim.setColors(colors); } } }