Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3690)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/compositor/layouts/ChromeAnimation.java

Issue 2743403006: [Android] Respect animation multiplier from Developer Options. (Closed)
Patch Set: x Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/compositor/layouts/ChromeAnimation.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/compositor/layouts/ChromeAnimation.java b/chrome/android/java/src/org/chromium/chrome/browser/compositor/layouts/ChromeAnimation.java
index 5933a66a8e46883d77b32d6ee32565aec3c7377a..be825b1363c00e843ea2f97b8b588c39289225e8 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/compositor/layouts/ChromeAnimation.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/compositor/layouts/ChromeAnimation.java
@@ -4,12 +4,17 @@
package org.chromium.chrome.browser.compositor.layouts;
+import android.annotation.TargetApi;
+import android.os.Build;
import android.os.SystemClock;
+import android.provider.Settings;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
import android.view.animation.LinearInterpolator;
+import org.chromium.base.ContextUtils;
+
import java.util.ArrayList;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -31,9 +36,10 @@ public class ChromeAnimation<T> {
private static final int FIRST_FRAME_OFFSET_MS = 1000 / 60;
/**
- * Can be used to slow down created animations for debugging purposes.
+ * Multiplier for animation durations for debugging. Can be set in Developer Options and cached
+ * here.
*/
- private static final int ANIMATION_MULTIPLIER = 1;
+ private static Float sAnimationMultiplier;
mdjones 2017/03/15 20:50:38 I'm guessing this can't be final because it is set
Bernhard Bauer 2017/03/15 21:21:58 It's static, so it would have to be set when the c
mdjones 2017/03/15 22:13:12 Ah right. I think what you have is fine.
private final AtomicBoolean mFinishCalled = new AtomicBoolean();
private final ArrayList<Animation<T>> mAnimations = new ArrayList<Animation<T>>();
@@ -256,11 +262,26 @@ public class ChromeAnimation<T> {
mAnimatedObject = t;
mStart = start;
mEnd = end;
- mDuration = duration * ANIMATION_MULTIPLIER;
- mStartDelay = startTime * ANIMATION_MULTIPLIER;
+ float animationMultiplier = getAnimationMultiplier();
+ mDuration = (long) (duration * animationMultiplier);
+ mStartDelay = (long) (startTime * animationMultiplier);
mCurrentTime = 0;
}
+ @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
+ private float getAnimationMultiplier() {
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) return 1f;
+
+ synchronized (sLock) {
+ if (sAnimationMultiplier == null) {
+ sAnimationMultiplier = Settings.Global.getFloat(
+ ContextUtils.getApplicationContext().getContentResolver(),
+ Settings.Global.ANIMATOR_DURATION_SCALE, 1f);
+ }
+ return sAnimationMultiplier;
+ }
+ }
+
/**
* Returns the object being animated.
*/
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698