From e2678cea5161d8d9616074d7bf4c28ae6f404793 Mon Sep 17 00:00:00 2001 From: cretin45 Date: Wed, 3 Feb 2016 15:16:52 -0800 Subject: Trebuchet: Fix background flicker when opening all apps Issue-id: OPO-422 Change-Id: I96136f61fe3b2263f77d162952cf189927334b8b --- .../launcher3/LauncherStateTransitionAnimation.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/com/android/launcher3/LauncherStateTransitionAnimation.java b/src/com/android/launcher3/LauncherStateTransitionAnimation.java index a0fa61d08..4c97727c1 100644 --- a/src/com/android/launcher3/LauncherStateTransitionAnimation.java +++ b/src/com/android/launcher3/LauncherStateTransitionAnimation.java @@ -24,6 +24,7 @@ import android.animation.PropertyValuesHolder; import android.animation.TimeInterpolator; import android.annotation.SuppressLint; import android.content.res.Resources; +import android.graphics.drawable.Drawable; import android.util.Log; import android.view.View; import android.view.animation.AccelerateInterpolator; @@ -287,6 +288,14 @@ public class LauncherStateTransitionAnimation { // Setup the animation for the content view contentView.setVisibility(View.VISIBLE); + /* + * Because the contentView and revealView overlap, if their backgrounds have alpha, + * it will blend and cause a flicker. So get the current alpha of the contentView (for + * later) and set to 0. When the animation is done, reset the alpha. + */ + final Drawable contentBackground = contentView.getBackground(); + final int alpha = contentBackground.getAlpha(); + contentBackground.setAlpha(0); contentView.setAlpha(0f); contentView.setTranslationY(revealViewToYDrift); layerViews.put(contentView, BUILD_AND_SET_LAYER); @@ -327,6 +336,7 @@ public class LauncherStateTransitionAnimation { // Hide the reveal view revealView.setVisibility(View.INVISIBLE); + contentBackground.setAlpha(alpha); // Disable all necessary layers for (View v : layerViews.keySet()) { @@ -521,6 +531,9 @@ public class LauncherStateTransitionAnimation { animation.play(workspaceAnim); } + final Drawable contentBackground = contentView.getBackground(); + final int alpha = contentBackground.getAlpha(); + // hideAppsCustomizeHelper is called in some cases when it is already hidden // don't perform all these no-op animations. In particularly, this was causing // the all-apps button to pop in and out. @@ -528,6 +541,7 @@ public class LauncherStateTransitionAnimation { int width = revealView.getMeasuredWidth(); int height = revealView.getMeasuredHeight(); float revealRadius = (float) Math.hypot(width / 2, height / 2); + contentBackground.setAlpha(0); revealView.setVisibility(View.VISIBLE); revealView.setAlpha(1f); revealView.setTranslationY(0); @@ -650,6 +664,7 @@ public class LauncherStateTransitionAnimation { contentView.setTranslationX(0); contentView.setTranslationY(0); contentView.setAlpha(1); + contentBackground.setAlpha(alpha); } if (overlaySearchBarView != null) { overlaySearchBarView.setAlpha(1f); -- cgit v1.2.3