summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Lee <llee@cyngn.com>2015-05-28 15:51:33 -0700
committerGerrit Code Review <gerrit@cyanogenmod.org>2015-06-01 00:53:49 +0000
commitd482eb729911a3d85a3edc685c70da0804f51cfc (patch)
tree4016b66df2e802be389e034f6c789194f92df174
parent20bf4bd9539e7e1038b7a3f53b3593b37fb184be (diff)
downloadandroid_packages_apps_Trebuchet-d482eb729911a3d85a3edc685c70da0804f51cfc.tar.gz
android_packages_apps_Trebuchet-d482eb729911a3d85a3edc685c70da0804f51cfc.tar.bz2
android_packages_apps_Trebuchet-d482eb729911a3d85a3edc685c70da0804f51cfc.zip
Fix power save mode broken ui/animations
Change-Id: I7dc0123300ff2e9aa64713c1091d13ecc93001f3
-rw-r--r--src/com/android/launcher3/Folder.java86
-rw-r--r--src/com/android/launcher3/Workspace.java44
2 files changed, 95 insertions, 35 deletions
diff --git a/src/com/android/launcher3/Folder.java b/src/com/android/launcher3/Folder.java
index 070eb3722..ccc90d229 100644
--- a/src/com/android/launcher3/Folder.java
+++ b/src/com/android/launcher3/Folder.java
@@ -30,7 +30,9 @@ import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
+import android.os.PowerManager;
import android.os.SystemClock;
+import android.provider.Settings;
import android.support.v4.widget.AutoScrollHelper;
import android.text.InputType;
import android.text.Selection;
@@ -92,6 +94,8 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
private static final int CLOSE_FOLDER_DELAY_MS = 150;
+ private final PowerManager mPowerManager;
+
private int mExpandDuration;
private int mMaterialExpandDuration;
private int mMaterialExpandStagger;
@@ -169,6 +173,8 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
public Folder(Context context, AttributeSet attrs) {
super(context, attrs);
+ mPowerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
+
LauncherAppState app = LauncherAppState.getInstance();
DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
setAlwaysDrawnWithCacheEnabled(false);
@@ -596,6 +602,24 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
fakeFolderIconView.setVisibility(View.INVISIBLE);
}
+ private static Animator setupAlphaAnimator(final View v, final float startAlpha,
+ final float endAlpha, final long duration, final long startDelay) {
+ v.setAlpha(startAlpha);
+ Animator animator = LauncherAnimUtils.ofFloat(v, "alpha", startAlpha, endAlpha);
+ animator.setDuration(duration);
+ animator.setStartDelay(startDelay);
+ animator.setInterpolator(new LogDecelerateInterpolator(60, 0));
+ animator.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ // in low power mode the animation doesn't play, so set the end value here
+ v.setAlpha(endAlpha);
+ }
+ });
+
+ return animator;
+ }
+
public void animateOpen(Workspace workspace) {
if (!(getParent() instanceof DragLayer)) return;
@@ -625,35 +649,37 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
float transX = 0;
float transY = getResources().getInteger(R.integer.folder_translate_y_dist);
+ final float endTransX = 0;
+ final float endTransY = 0;
setTranslationX(transX);
setTranslationY(transY);
- PropertyValuesHolder tx = PropertyValuesHolder.ofFloat("translationX", transX, 0);
- PropertyValuesHolder ty = PropertyValuesHolder.ofFloat("translationY", transY, 0);
+ PropertyValuesHolder tx = PropertyValuesHolder.ofFloat("translationX", transX,
+ endTransX);
+ PropertyValuesHolder ty = PropertyValuesHolder.ofFloat("translationY", transY,
+ endTransY);
AnimatorSet anim = LauncherAnimUtils.createAnimatorSet();
- mFolderLock.setAlpha(0f);
- Animator lockAlpha = LauncherAnimUtils.ofFloat(mFolderLock, "alpha", 0f, 1f);
- lockAlpha.setDuration(mMaterialExpandDuration);
- lockAlpha.setStartDelay(mMaterialExpandStagger);
- lockAlpha.setInterpolator(new LogDecelerateInterpolator(60, 0));
+ View[] alphaViewSet = new View[] { mFolderLock, mContent, mFolderName };
+ for (View view : alphaViewSet) {
+ Animator alphaAnimator = setupAlphaAnimator(view, 0f, 1f,
+ mMaterialExpandDuration, mMaterialExpandStagger);
- mContent.setAlpha(0f);
- Animator iconsAlpha = LauncherAnimUtils.ofFloat(mContent, "alpha", 0f, 1f);
- iconsAlpha.setDuration(mMaterialExpandDuration);
- iconsAlpha.setStartDelay(mMaterialExpandStagger);
- iconsAlpha.setInterpolator(new LogDecelerateInterpolator(60, 0));
-
- mFolderName.setAlpha(0f);
- Animator textAlpha = LauncherAnimUtils.ofFloat(mFolderName, "alpha", 0f, 1f);
- textAlpha.setDuration(mMaterialExpandDuration);
- textAlpha.setStartDelay(mMaterialExpandStagger);
- textAlpha.setInterpolator(new LogDecelerateInterpolator(60, 0));
+ anim.play(alphaAnimator);
+ }
Animator drift = LauncherAnimUtils.ofPropertyValuesHolder(this, tx, ty);
drift.setDuration(mMaterialExpandDuration);
drift.setStartDelay(mMaterialExpandStagger);
drift.setInterpolator(new LogDecelerateInterpolator(60, 0));
+ drift.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ // in low power mode the animation doesn't play, so set the end value here
+ Folder.this.setTranslationX(endTransX);
+ Folder.this.setTranslationY(endTransY);
+ }
+ });
final ArrayList<View> layerViews = new ArrayList<View>();
@@ -719,9 +745,6 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
}
anim.play(fakeFolderIcon);
anim.play(drift);
- anim.play(iconsAlpha);
- anim.play(lockAlpha);
- anim.play(textAlpha);
if (workspaceAnim != null) {
anim.play(workspaceAnim);
}
@@ -839,12 +862,24 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
if (!(getParent() instanceof DragLayer)) return;
AnimatorSet anim = LauncherAnimUtils.createAnimatorSet();
- PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 0);
+ PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 0f);
float transY = getResources().getInteger(R.integer.folder_translate_y_dist);
PropertyValuesHolder translationY = PropertyValuesHolder.ofFloat("translationY", 0f,
transY);
- final ObjectAnimator oa =
- LauncherAnimUtils.ofPropertyValuesHolder(this, alpha, translationY);
+
+ setLayerType(LAYER_TYPE_HARDWARE, null);
+
+ float animatorDurationScale = Settings.Global.getFloat(getContext().getContentResolver(),
+ Settings.Global.ANIMATOR_DURATION_SCALE, 1);
+ ObjectAnimator oa;
+ if (mPowerManager.isPowerSaveMode() || animatorDurationScale < 0.01f) {
+ // power save mode is no fun - skip alpha animation and just set it to 0
+ // otherwise the icons will stay around until the duration of the animation
+ oa = LauncherAnimUtils.ofPropertyValuesHolder(this, translationY);
+ setAlpha(0f);
+ } else {
+ oa = LauncherAnimUtils.ofPropertyValuesHolder(this, alpha, translationY);
+ }
oa.addListener(new AnimatorListenerAdapter() {
@Override
@@ -856,7 +891,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
});
oa.setDuration(mMaterialExpandDuration);
oa.setInterpolator(new LogDecelerateInterpolator(60, 0));
- setLayerType(LAYER_TYPE_HARDWARE, null);
+ anim.play(oa);
Animator workspaceAnim = mLauncher.getWorkspace().getChangeStateAnimation(
Workspace.State.NORMAL, animate, new ArrayList<View>());
@@ -939,7 +974,6 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
mFolderIcon.setPreviewBackground(R.drawable.folder_bg);
}
- anim.play(oa);
if (workspaceAnim != null) {
anim.play(workspaceAnim);
}
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);
}