Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ff7e6ef4 authored by Jeff Brown's avatar Jeff Brown
Browse files

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
parent 109025d7
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -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
+9 −3
Original line number Diff line number Diff line
@@ -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;