From d482eb729911a3d85a3edc685c70da0804f51cfc Mon Sep 17 00:00:00 2001 From: Linus Lee Date: Thu, 28 May 2015 15:51:33 -0700 Subject: Fix power save mode broken ui/animations Change-Id: I7dc0123300ff2e9aa64713c1091d13ecc93001f3 --- src/com/android/launcher3/Workspace.java | 44 +++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 9 deletions(-) (limited to 'src/com/android/launcher3/Workspace.java') diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 125caf13b..7a89cbae6 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -64,8 +64,6 @@ import android.view.ViewPropertyAnimator; import android.view.animation.AccelerateDecelerateInterpolator; import android.view.accessibility.AccessibilityManager; -import android.view.animation.Animation; -import android.view.animation.AnimationUtils; import android.view.animation.DecelerateInterpolator; import android.view.animation.Interpolator; import android.widget.TextView; @@ -2307,7 +2305,7 @@ public class Workspace extends SmoothPagedView float finalHotseatAndPageIndicatorAlpha = (stateIsNormal || stateIsSpringLoaded) ? 1f : 0f; final float finalOverviewPanelAlpha = stateIsOverview ? 1f : 0f; float finalSearchBarAlpha = !stateIsNormal ? 0f : 1f; - float finalWorkspaceTranslationY = stateIsOverview || stateIsOverviewHidden ? + final float finalWorkspaceTranslationY = stateIsOverview || stateIsOverviewHidden ? getOverviewModeTranslationY() : 0; boolean workspaceToAllApps = (oldStateIsNormal && stateIsNormalHidden); @@ -2416,6 +2414,15 @@ public class Workspace extends SmoothPagedView .translationY(finalWorkspaceTranslationY) .setDuration(duration) .setInterpolator(mZoomInInterpolator); + scale.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + // in low power mode the animation doesn't play, so set the end value here + setScaleX(mNewScale); + setScaleY(mNewScale); + setTranslationY(finalWorkspaceTranslationY); + } + }); anim.play(scale); for (int index = 0; index < getChildCount(); index++) { final int i = index; @@ -2429,11 +2436,20 @@ public class Workspace extends SmoothPagedView layerViews.add(cl); } if (mOldAlphas[i] != mNewAlphas[i] || currentAlpha != mNewAlphas[i]) { + final View shortcutAndWidgets = cl.getShortcutsAndWidgets(); LauncherViewPropertyAnimator alphaAnim = - new LauncherViewPropertyAnimator(cl.getShortcutsAndWidgets()); + new LauncherViewPropertyAnimator(shortcutAndWidgets); alphaAnim.alpha(mNewAlphas[i]) .setDuration(duration) .setInterpolator(mZoomInInterpolator); + alphaAnim.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + // in low power mode the animation doesn't play, + // so set the end value here + shortcutAndWidgets.setAlpha(mNewAlphas[i]); + } + }); anim.play(alphaAnim); } if (mOldBackgroundAlphas[i] != 0 || @@ -2457,7 +2473,8 @@ public class Workspace extends SmoothPagedView if (pageIndicator != null) { pageIndicatorAlpha = new LauncherViewPropertyAnimator(pageIndicator) .alpha(finalHotseatAndPageIndicatorAlpha).withLayer(); - pageIndicatorAlpha.addListener(new AlphaUpdateListener(pageIndicator)); + pageIndicatorAlpha.addListener( + new AlphaUpdateListener(pageIndicator, finalHotseatAndPageIndicatorAlpha)); } else { // create a dummy animation so we don't need to do null checks later pageIndicatorAlpha = ValueAnimator.ofFloat(0, 0); @@ -2465,15 +2482,19 @@ public class Workspace extends SmoothPagedView Animator hotseatAlpha = new LauncherViewPropertyAnimator(hotseat) .alpha(finalHotseatAndPageIndicatorAlpha).withLayer(); - hotseatAlpha.addListener(new AlphaUpdateListener(hotseat)); + hotseatAlpha.addListener( + new AlphaUpdateListener(hotseat, finalHotseatAndPageIndicatorAlpha)); Animator searchBarAlpha = new LauncherViewPropertyAnimator(searchBar) .alpha(finalSearchBarAlpha).withLayer(); - if (mShowSearchBar) searchBarAlpha.addListener(new AlphaUpdateListener(searchBar)); + if (mShowSearchBar) { + searchBarAlpha.addListener(new AlphaUpdateListener(searchBar, finalSearchBarAlpha)); + } Animator overviewPanelAlpha = new LauncherViewPropertyAnimator(overviewPanel) .alpha(finalOverviewPanelAlpha).withLayer(); - overviewPanelAlpha.addListener(new AlphaUpdateListener(overviewPanel)); + overviewPanelAlpha.addListener( + new AlphaUpdateListener(overviewPanel, finalOverviewPanelAlpha)); // For animation optimations, we may need to provide the Launcher transition // with a set of views on which to force build layers in certain scenarios. @@ -2584,8 +2605,10 @@ public class Workspace extends SmoothPagedView static class AlphaUpdateListener implements AnimatorUpdateListener, AnimatorListener { View view; - public AlphaUpdateListener(View v) { + float endAlpha; + public AlphaUpdateListener(View v, float target) { view = v; + endAlpha = target; } @Override @@ -2611,6 +2634,9 @@ public class Workspace extends SmoothPagedView @Override public void onAnimationEnd(Animator arg0) { + // in low power mode the animation doesn't play, so we need to set the end alpha + // before calling updateVisibility + view.setAlpha(endAlpha); updateVisibility(view); } -- cgit v1.2.3