From 3e0d08d7ff471efc3ffd1b73135243fc5d0afc09 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 Conflicts: src/com/android/launcher3/Folder.java Change-Id: I7dc0123300ff2e9aa64713c1091d13ecc93001f3 --- src/com/android/launcher3/Workspace.java | 44 +++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 6f9444513..811c4b255 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; @@ -2305,7 +2303,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); @@ -2414,6 +2412,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; @@ -2427,11 +2434,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 || @@ -2455,7 +2471,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); @@ -2463,15 +2480,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. @@ -2580,8 +2601,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 @@ -2607,6 +2630,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