Apply ValueAnimator scale factor immediately in WM.
Normally the ValueAnimator scale factor is applied the first time a ViewRootImpl window session is created but that may be too late for animators created by system services that start early in the boot process. So set the scale factor immediately whenever the setting changes. Also make ValueAnimator.getDurationScale() accessible (but @hide) for custom animators that want to apply the same scale to their animations. Change-Id: I0f5a750ab5b014f63848445435d8dca86f2a7ada
This commit is contained in:
@@ -231,6 +231,13 @@ public class ValueAnimator extends Animator {
|
||||
sDurationScale = durationScale;
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
public static float getDurationScale() {
|
||||
return sDurationScale;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new ValueAnimator object. This default constructor is primarily for
|
||||
* use internally; the factory methods which take parameters are more generally
|
||||
|
||||
@@ -57,6 +57,7 @@ import android.app.ActivityOptions;
|
||||
import android.app.IActivityManager;
|
||||
import android.app.StatusBarManager;
|
||||
import android.app.admin.DevicePolicyManager;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -900,8 +901,8 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
Settings.System.WINDOW_ANIMATION_SCALE, mWindowAnimationScale);
|
||||
mTransitionAnimationScale = Settings.System.getFloat(context.getContentResolver(),
|
||||
Settings.System.TRANSITION_ANIMATION_SCALE, mTransitionAnimationScale);
|
||||
mAnimatorDurationScale = Settings.System.getFloat(context.getContentResolver(),
|
||||
Settings.System.ANIMATOR_DURATION_SCALE, mTransitionAnimationScale);
|
||||
setAnimatorDurationScale(Settings.System.getFloat(context.getContentResolver(),
|
||||
Settings.System.ANIMATOR_DURATION_SCALE, mTransitionAnimationScale));
|
||||
|
||||
// Track changes to DevicePolicyManager state so we can enable/disable keyguard.
|
||||
IntentFilter filter = new IntentFilter();
|
||||
@@ -5160,7 +5161,7 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
mTransitionAnimationScale = fixScale(scales[1]);
|
||||
}
|
||||
if (scales.length >= 3) {
|
||||
mAnimatorDurationScale = fixScale(scales[2]);
|
||||
setAnimatorDurationScale(fixScale(scales[2]));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5168,6 +5169,11 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
mH.obtainMessage(H.PERSIST_ANIMATION_SCALE).sendToTarget();
|
||||
}
|
||||
|
||||
private void setAnimatorDurationScale(float scale) {
|
||||
mAnimatorDurationScale = scale;
|
||||
ValueAnimator.setDurationScale(scale);
|
||||
}
|
||||
|
||||
public float getAnimationScale(int which) {
|
||||
switch (which) {
|
||||
case 0: return mWindowAnimationScale;
|
||||
|
||||
Reference in New Issue
Block a user