summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaj Yengisetty <rajesh@cyngn.com>2014-08-07 23:09:24 (GMT)
committerRajesh Yengisetty <rajesh@cyngn.com>2014-08-14 18:16:27 (GMT)
commit277cfe5d91b4594ba3155d0d2917b9d20b7d3684 (patch)
tree8126a77fa28e0a669669014a9a2fd77554baad93
parentcddb4bbc70ee010d5e95d7a43600ff8e6458eb4d (diff)
downloadandroid_packages_apps_Trebuchet-277cfe5d91b4594ba3155d0d2917b9d20b7d3684.zip
android_packages_apps_Trebuchet-277cfe5d91b4594ba3155d0d2917b9d20b7d3684.tar.gz
android_packages_apps_Trebuchet-277cfe5d91b4594ba3155d0d2917b9d20b7d3684.tar.bz2
Fix for shadow folders.
Repro: - Set low animation scale (.3-.5) - Pkill Trebuchet - Open home screen and click open folder with ~12+ https://jira.cyanogenmod.org/browse/CYAN-4907 Change-Id: Ib927101e72674d5ffa3733f5c093c3f9970fa273
-rw-r--r--AndroidManifest.xml2
-rw-r--r--src/com/android/launcher3/Launcher.java49
-rw-r--r--src/com/android/launcher3/LauncherAnimUtils.java21
-rw-r--r--src/com/android/launcher3/LauncherViewPropertyAnimator.java11
4 files changed, 77 insertions, 6 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 222d20a..0dd98d6 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -25,7 +25,7 @@
<original-package android:name="com.android.launcher3" />
- <uses-sdk android:targetSdkVersion="19" android:minSdkVersion="16"/>
+ <uses-sdk android:targetSdkVersion="19" android:minSdkVersion="17"/>
<permission
android:name="com.android.launcher3.permission.PRELOAD_WORKSPACE"
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 8233429..01a52d4 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -66,6 +66,7 @@ import android.os.Handler;
import android.os.Message;
import android.os.StrictMode;
import android.os.SystemClock;
+import android.provider.Settings;
import android.speech.RecognizerIntent;
import android.text.Selection;
import android.text.SpannableStringBuilder;
@@ -403,6 +404,12 @@ public class Launcher extends Activity
}
}
+ public static float sAnimatorDurationScale = 1f;
+
+ public static boolean isAnimatorScaleSafe() {
+ return sAnimatorDurationScale >= 1f;
+ }
+
private CustomContentMode mCustomContentMode = CustomContentMode.CUSTOM_HOME;
// Preferences
@@ -457,6 +464,38 @@ public class Launcher extends Activity
}
};
+ private class AnimatorScaleObserver extends ContentObserver {
+
+ /**
+ * Creates a content observer.
+ *
+ * @param handler The handler to run {@link #onChange} on, or null if none.
+ */
+ public AnimatorScaleObserver(Handler handler) {
+ super(handler);
+ }
+
+ @Override
+ public void onChange(boolean selfChange) {
+ onChange(selfChange, null);
+ }
+
+ @Override
+ public void onChange(boolean selfChange, Uri uri) {
+ try {
+ Float curAnimationDurationScale = Settings.Global.getFloat(getContentResolver(),
+ Settings.Global.ANIMATOR_DURATION_SCALE);
+ if (curAnimationDurationScale != sAnimatorDurationScale) {
+ // the Animator Duration scale has changed, restart the Launcher to respect
+ // these changes
+ android.os.Process.killProcess(android.os.Process.myPid());
+ }
+ } catch (Settings.SettingNotFoundException e) {
+ sAnimatorDurationScale = 1f;
+ }
+ }
+ }
+
@Override
protected void onCreate(Bundle savedInstanceState) {
if (DEBUG_STRICT_MODE) {
@@ -564,6 +603,16 @@ public class Launcher extends Activity
"cyanogenmod.intent.action.PROTECTED_COMPONENT_UPDATE");
registerReceiver(protectedAppsChangedReceiver, protectedAppsFilter,
"cyanogenmod.permission.PROTECTED_APP", null);
+
+ try {
+ sAnimatorDurationScale = Settings.Global.getFloat(getContentResolver(),
+ Settings.Global.ANIMATOR_DURATION_SCALE);
+ } catch (Settings.SettingNotFoundException e) {
+ sAnimatorDurationScale = 1f;
+ }
+
+ AnimatorScaleObserver obs = new AnimatorScaleObserver(new Handler());
+ getContentResolver().registerContentObserver(Settings.Global.CONTENT_URI, true, obs);
}
public void restoreCustomContentMode() {
diff --git a/src/com/android/launcher3/LauncherAnimUtils.java b/src/com/android/launcher3/LauncherAnimUtils.java
index e6c220b..0f58e0c 100644
--- a/src/com/android/launcher3/LauncherAnimUtils.java
+++ b/src/com/android/launcher3/LauncherAnimUtils.java
@@ -103,7 +103,12 @@ public class LauncherAnimUtils {
anim.setPropertyName(propertyName);
anim.setFloatValues(values);
cancelOnDestroyActivity(anim);
- new FirstFrameAnimatorHelper(anim, target);
+ // If the animation scale is less than 1f the FirstFrameAnimatorHelper sometimes causes
+ // the animation to not finish (e.g. opening a Folder will result in the Folder View's
+ // alpha being stuck somewhere between 0-1f.
+ if (Launcher.isAnimatorScaleSafe()) {
+ new FirstFrameAnimatorHelper(anim, target);
+ }
return anim;
}
@@ -113,7 +118,12 @@ public class LauncherAnimUtils {
anim.setTarget(target);
anim.setValues(values);
cancelOnDestroyActivity(anim);
- new FirstFrameAnimatorHelper(anim, target);
+ // If the animation scale is less than 1f the FirstFrameAnimatorHelper sometimes causes
+ // the animation to not finish (e.g. opening a Folder will result in the Folder View's
+ // alpha being stuck somewhere between 0-1f.
+ if (Launcher.isAnimatorScaleSafe()) {
+ new FirstFrameAnimatorHelper(anim, target);
+ }
return anim;
}
@@ -123,7 +133,12 @@ public class LauncherAnimUtils {
anim.setTarget(target);
anim.setValues(values);
cancelOnDestroyActivity(anim);
- new FirstFrameAnimatorHelper(anim, view);
+ // If the animation scale is less than 1f the FirstFrameAnimatorHelper sometimes causes
+ // the animation to not finish (e.g. opening a Folder will result in the Folder View's
+ // alpha being stuck somewhere between 0-1f.
+ if (Launcher.isAnimatorScaleSafe()) {
+ new FirstFrameAnimatorHelper(anim, view);
+ }
return anim;
}
}
diff --git a/src/com/android/launcher3/LauncherViewPropertyAnimator.java b/src/com/android/launcher3/LauncherViewPropertyAnimator.java
index 4cafbbf..63b87be 100644
--- a/src/com/android/launcher3/LauncherViewPropertyAnimator.java
+++ b/src/com/android/launcher3/LauncherViewPropertyAnimator.java
@@ -127,7 +127,9 @@ public class LauncherViewPropertyAnimator extends Animator implements AnimatorLi
public void onAnimationStart(Animator animation) {
// This is the first time we get a handle to the internal ValueAnimator
// used by the ViewPropertyAnimator.
- mFirstFrameHelper.onAnimationStart(animation);
+ if (mFirstFrameHelper != null) {
+ mFirstFrameHelper.onAnimationStart(animation);
+ }
for (int i = 0; i < mListeners.size(); i++) {
Animator.AnimatorListener listener = mListeners.get(i);
@@ -195,7 +197,12 @@ public class LauncherViewPropertyAnimator extends Animator implements AnimatorLi
// FirstFrameAnimatorHelper hooks itself up to the updates on the animator,
// and then adjusts the play time to keep the first two frames jank-free
- mFirstFrameHelper = new FirstFrameAnimatorHelper(mViewPropertyAnimator, mTarget);
+ // HOWEVER, If the animation scale is less than 1f the FirstFrameAnimatorHelper sometimes
+ // causes the animation to not finish (e.g. opening a Folder will result in the Folder
+ // View's alpha being stuck somewhere between 0-1f.
+ if (Launcher.isAnimatorScaleSafe()) {
+ mFirstFrameHelper = new FirstFrameAnimatorHelper(mViewPropertyAnimator, mTarget);
+ }
if (mPropertiesToSet.contains(Properties.TRANSLATION_X)) {
mViewPropertyAnimator.translationX(mTranslationX);