From 2d89ea84530559e2002a3a4009a50bac1e568507 Mon Sep 17 00:00:00 2001 From: Jon Miranda Date: Thu, 4 May 2017 11:47:53 -0700 Subject: [PATCH] Fade in background scrim when resuming from screen off. This change hides the hard cut off that appears when the Launcher window is transitioning upwards when resuming from when the screen is off. Bug: 36446766 Change-Id: I0c0fe13ee9e08d27b94916d0407ef431d82b8d6a --- src/com/android/launcher3/Launcher.java | 22 +++++++++++++++++++ .../android/launcher3/LauncherAnimUtils.java | 13 +++++++++++ .../allapps/AllAppsBackgroundDrawable.java | 4 +++- 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index c96c2a7b9a..f77308e144 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -18,7 +18,9 @@ package com.android.launcher3; import android.Manifest; import android.animation.Animator; +import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; +import android.animation.ObjectAnimator; import android.animation.ValueAnimator; import android.annotation.SuppressLint; import android.annotation.TargetApi; @@ -267,6 +269,8 @@ public class Launcher extends BaseActivity private boolean mHasFocus = false; private boolean mAttached = false; + private ObjectAnimator mScrimAnimator; + private PopupDataProvider mPopupDataProvider; private View.OnTouchListener mHapticFeedbackTouchListener; @@ -920,6 +924,24 @@ public class Launcher extends BaseActivity if (!isWorkspaceLoading()) { NotificationListener.setNotificationsChangedListener(mPopupDataProvider); } + + if (mIsResumeFromActionScreenOff && mDragLayer.getBackground() != null) { + if (mScrimAnimator != null) { + mScrimAnimator.cancel(); + } + mDragLayer.getBackground().setAlpha(0); + mScrimAnimator = ObjectAnimator.ofInt(mDragLayer.getBackground(), + LauncherAnimUtils.DRAWABLE_ALPHA, 0, 255); + mScrimAnimator.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + mScrimAnimator = null; + } + }); + mScrimAnimator.setDuration(600); + mScrimAnimator.setStartDelay(getWindow().getTransitionBackgroundFadeDuration()); + mScrimAnimator.start(); + } } @Override diff --git a/src/com/android/launcher3/LauncherAnimUtils.java b/src/com/android/launcher3/LauncherAnimUtils.java index 2be2021f1c..cfb9b570b0 100644 --- a/src/com/android/launcher3/LauncherAnimUtils.java +++ b/src/com/android/launcher3/LauncherAnimUtils.java @@ -21,6 +21,7 @@ import android.animation.AnimatorSet; import android.animation.ObjectAnimator; import android.animation.PropertyValuesHolder; import android.animation.ValueAnimator; +import android.graphics.drawable.Drawable; import android.util.Property; import android.view.View; import android.view.ViewTreeObserver; @@ -128,4 +129,16 @@ public class LauncherAnimUtils { return anim; } + public static final Property DRAWABLE_ALPHA = + new Property(Integer.TYPE, "drawableAlpha") { + @Override + public Integer get(Drawable drawable) { + return drawable.getAlpha(); + } + + @Override + public void set(Drawable drawable, Integer alpha) { + drawable.setAlpha(alpha); + } + }; } diff --git a/src/com/android/launcher3/allapps/AllAppsBackgroundDrawable.java b/src/com/android/launcher3/allapps/AllAppsBackgroundDrawable.java index c71bc3166b..54c5bd0b21 100644 --- a/src/com/android/launcher3/allapps/AllAppsBackgroundDrawable.java +++ b/src/com/android/launcher3/allapps/AllAppsBackgroundDrawable.java @@ -25,6 +25,7 @@ import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.view.Gravity; +import com.android.launcher3.LauncherAnimUtils; import com.android.launcher3.R; /** @@ -119,7 +120,8 @@ public class AllAppsBackgroundDrawable extends Drawable { int finalAlphaI = (int) (finalAlpha * 255f); if (getAlpha() != finalAlphaI) { mBackgroundAnim = cancelAnimator(mBackgroundAnim); - mBackgroundAnim = ObjectAnimator.ofInt(this, "alpha", finalAlphaI); + mBackgroundAnim = ObjectAnimator.ofInt(this, LauncherAnimUtils.DRAWABLE_ALPHA, + finalAlphaI); mBackgroundAnim.setDuration(duration); mBackgroundAnim.start(); }