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

Commit 7eaccbfb authored by Doris Liu's avatar Doris Liu
Browse files

Remove distance based animation duration API

Bug: 20500107

This reverts commit 0084e370.

Change-Id: I57f1f3a22c5adfefd966447050b100a50e7141b2
parent 3f3a2a87
Loading
Loading
Loading
Loading
+1 −6
Original line number Diff line number Diff line
@@ -505,7 +505,6 @@ package android {
    field public static final int dropDownWidth = 16843362; // 0x1010262
    field public static final int duplicateParentState = 16842985; // 0x10100e9
    field public static final int duration = 16843160; // 0x1010198
    field public static final int durationScaleHint = 16844014; // 0x10104ee
    field public static final int dynamicResources = 16844019; // 0x10104f3
    field public static final int editTextBackground = 16843602; // 0x1010352
    field public static final int editTextColor = 16843601; // 0x1010351
@@ -996,6 +995,7 @@ package android {
    field public static final int readPermission = 16842759; // 0x1010007
    field public static final int recognitionService = 16843932; // 0x101049c
    field public static final int relinquishTaskIdentity = 16843894; // 0x1010476
    field public static final int removeBeforeMRelease = 16844014; // 0x10104ee
    field public static final int reparent = 16843964; // 0x10104bc
    field public static final int reparentWithOverlay = 16843965; // 0x10104bd
    field public static final int repeatCount = 16843199; // 0x10101bf
@@ -2868,7 +2868,6 @@ package android.animation {
    method public void cancel();
    method public android.animation.Animator clone();
    method public void end();
    method public long getDistanceBasedDuration();
    method public abstract long getDuration();
    method public android.animation.TimeInterpolator getInterpolator();
    method public java.util.ArrayList<android.animation.Animator.AnimatorListener> getListeners();
@@ -2882,16 +2881,12 @@ package android.animation {
    method public void removePauseListener(android.animation.Animator.AnimatorPauseListener);
    method public void resume();
    method public abstract android.animation.Animator setDuration(long);
    method public void setDurationScaleHint(int, android.content.res.Resources);
    method public abstract void setInterpolator(android.animation.TimeInterpolator);
    method public abstract void setStartDelay(long);
    method public void setTarget(java.lang.Object);
    method public void setupEndValues();
    method public void setupStartValues();
    method public void start();
    field public static final int HINT_DISTANCE_DEFINED_IN_DP = 2; // 0x2
    field public static final int HINT_DISTANCE_PROPORTIONAL_TO_SCREEN_SIZE = 1; // 0x1
    field public static final int HINT_NO_SCALE = 0; // 0x0
  }
  public static abstract interface Animator.AnimatorListener {
+1 −6
Original line number Diff line number Diff line
@@ -578,7 +578,6 @@ package android {
    field public static final int dropDownWidth = 16843362; // 0x1010262
    field public static final int duplicateParentState = 16842985; // 0x10100e9
    field public static final int duration = 16843160; // 0x1010198
    field public static final int durationScaleHint = 16844014; // 0x10104ee
    field public static final int dynamicResources = 16844019; // 0x10104f3
    field public static final int editTextBackground = 16843602; // 0x1010352
    field public static final int editTextColor = 16843601; // 0x1010351
@@ -1069,6 +1068,7 @@ package android {
    field public static final int readPermission = 16842759; // 0x1010007
    field public static final int recognitionService = 16843932; // 0x101049c
    field public static final int relinquishTaskIdentity = 16843894; // 0x1010476
    field public static final int removeBeforeMRelease = 16844014; // 0x10104ee
    field public static final int reparent = 16843964; // 0x10104bc
    field public static final int reparentWithOverlay = 16843965; // 0x10104bd
    field public static final int repeatCount = 16843199; // 0x10101bf
@@ -2948,7 +2948,6 @@ package android.animation {
    method public void cancel();
    method public android.animation.Animator clone();
    method public void end();
    method public long getDistanceBasedDuration();
    method public abstract long getDuration();
    method public android.animation.TimeInterpolator getInterpolator();
    method public java.util.ArrayList<android.animation.Animator.AnimatorListener> getListeners();
@@ -2962,16 +2961,12 @@ package android.animation {
    method public void removePauseListener(android.animation.Animator.AnimatorPauseListener);
    method public void resume();
    method public abstract android.animation.Animator setDuration(long);
    method public void setDurationScaleHint(int, android.content.res.Resources);
    method public abstract void setInterpolator(android.animation.TimeInterpolator);
    method public abstract void setStartDelay(long);
    method public void setTarget(java.lang.Object);
    method public void setupEndValues();
    method public void setupStartValues();
    method public void start();
    field public static final int HINT_DISTANCE_DEFINED_IN_DP = 2; // 0x2
    field public static final int HINT_DISTANCE_PROPORTIONAL_TO_SCREEN_SIZE = 1; // 0x1
    field public static final int HINT_NO_SCALE = 0; // 0x0
  }
  public static abstract interface Animator.AnimatorListener {
+0 −118
Original line number Diff line number Diff line
@@ -16,12 +16,7 @@

package android.animation;

import android.content.res.Configuration;
import android.content.res.ConstantState;
import android.content.res.Resources;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.animation.AnimationUtils;

import java.util.ArrayList;

@@ -30,29 +25,6 @@ import java.util.ArrayList;
 * started, ended, and have <code>AnimatorListeners</code> added to them.
 */
public abstract class Animator implements Cloneable {
    /**
     * Set this hint when duration for the animation does not need to be scaled. By default, no
     * scaling is applied to the duration.
     */
    public static final int HINT_NO_SCALE = 0;

    /**
     * Set this scale hint (using {@link #setDurationScaleHint(int, Resources)} when the animation's
     * moving distance is proportional to the screen size. (e.g. a view coming in from the bottom of
     * the screen to top/center). With this scale hint set, the animation duration will be
     * automatically scaled based on screen size.
     */
    public static final int HINT_DISTANCE_PROPORTIONAL_TO_SCREEN_SIZE = 1;

    /**
     * Set this scale hint (using {@link #setDurationScaleHint(int, Resources)}) if the animation
     * has pre-defined moving distance in dp that does not vary from device to device. This is
     * extremely useful when the animation needs to run on both phones/tablets and TV, because TV
     * has inflated dp and therefore will have a longer visual arc for the same animation than on
     * the phone. This hint is used to calculate a scaling factor to compensate for different
     * visual arcs while maintaining the same angular velocity for the animation.
     */
    public static final int HINT_DISTANCE_DEFINED_IN_DP = 2;

    /**
     * The set of listeners to be sent events through the life of an animation.
@@ -82,24 +54,6 @@ public abstract class Animator implements Cloneable {
     */
    private AnimatorConstantState mConstantState;

    /**
     * Scaling factor for an animation that moves across the whole screen.
     */
    float mScreenSizeBasedDurationScale = 1.0f;

    /**
     * Scaling factor for an animation that is defined to move the same amount of dp across all
     * devices.
     */
    float mDpBasedDurationScale = 1.0f;

    /**
     * By default, the scaling assumes the animation moves across the entire screen.
     */
    int mDurationScaleHint = HINT_NO_SCALE;

    private final static boolean ANIM_DEBUG = false;

    /**
     * Starts this animation. If the animation has a nonzero startDelay, the animation will start
     * running after that delay elapses. A non-delayed animation will have its initial
@@ -229,78 +183,6 @@ public abstract class Animator implements Cloneable {
     */
    public abstract long getDuration();

    /**
     * Hints how duration scaling factor should be calculated. The duration will not be scaled when
     * hint is set to {@link #HINT_NO_SCALE}. Otherwise, the duration will be automatically scaled
     * per device to achieve the same look and feel across different devices. In order to do
     * that, the same angular velocity of the animation will be needed on different devices in
     * users' field of view. Therefore, the duration scale factor is determined by the ratio of the
     * angular movement on current devices to that on the baseline device (i.e. Nexus 5).
     *
     * @param hint an indicator on how the animation is defined. The hint could be
     *             {@link #HINT_NO_SCALE}, {@link #HINT_DISTANCE_PROPORTIONAL_TO_SCREEN_SIZE} or
     *             {@link #HINT_DISTANCE_DEFINED_IN_DP}.
     * @param res The resources {@see android.content.res.Resources} for getting display metrics
     */
    public void setDurationScaleHint(int hint, Resources res) {
        if (ANIM_DEBUG) {
            Log.d("ANIM_DEBUG", "distance based duration hint: " + hint);
        }
        if (hint == mDurationScaleHint) {
            return;
        }
        mDurationScaleHint = hint;
        if (hint != HINT_NO_SCALE) {
            int uiMode = res.getConfiguration().uiMode & Configuration.UI_MODE_TYPE_MASK;
            DisplayMetrics metrics = res.getDisplayMetrics();
            float width = metrics.widthPixels / metrics.xdpi;
            float height = metrics.heightPixels / metrics.ydpi;
            float viewingDistance = AnimationUtils.getViewingDistance(width, height, uiMode);
            if (ANIM_DEBUG) {
                Log.d("ANIM_DEBUG", "width, height, viewing distance, uimode: "
                        + width + ", " + height + ", " + viewingDistance + ", " + uiMode);
            }
            mScreenSizeBasedDurationScale = AnimationUtils
                    .getScreenSizeBasedDurationScale(width, height, viewingDistance);
            mDpBasedDurationScale = AnimationUtils.getDpBasedDurationScale(
                    metrics.density, metrics.xdpi, viewingDistance);
            if (ANIM_DEBUG) {
                Log.d("ANIM_DEBUG", "screen based scale, dp based scale: " +
                        mScreenSizeBasedDurationScale + ", " + mDpBasedDurationScale);
            }
        }
    }

    // Copies duration scale hint and scaling factors to the new animation.
    void copyDurationScaleInfoTo(Animator anim) {
        anim.mDurationScaleHint = mDurationScaleHint;
        anim.mScreenSizeBasedDurationScale = mScreenSizeBasedDurationScale;
        anim.mDpBasedDurationScale = mDpBasedDurationScale;
    }

    /**
     * @return The scaled duration calculated based on distance of movement (as defined by the
     * animation) and perceived velocity (derived from the duration set on the animation for
     * baseline device)
     */
    public long getDistanceBasedDuration() {
        return (long) (getDuration() * getDistanceBasedDurationScale());
    }

    /**
     * @return scaling factor of duration based on the duration scale hint. A scaling factor of 1
     * means no scaling will be applied to the duration.
     */
    float getDistanceBasedDurationScale() {
        if (mDurationScaleHint == HINT_DISTANCE_PROPORTIONAL_TO_SCREEN_SIZE) {
            return mScreenSizeBasedDurationScale;
        } else if (mDurationScaleHint == HINT_DISTANCE_DEFINED_IN_DP) {
            return mDpBasedDurationScale;
        } else {
            return 1f;
        }
    }

    /**
     * The time interpolator used in calculating the elapsed fraction of the
     * animation. The interpolator determines whether the animation runs with
+0 −13
Original line number Diff line number Diff line
@@ -70,13 +70,6 @@ public class AnimatorInflater {
    private static final int VALUE_TYPE_COLOR       = 3;
    private static final int VALUE_TYPE_UNDEFINED   = 4;

    /**
     * Enum values used in XML attributes to indicate the duration scale hint.
     */
    private static final int HINT_NO_SCALE                  = 0;
    private static final int HINT_PROPORTIONAL_TO_SCREEN    = 1;
    private static final int HINT_DEFINED_IN_DP             = 2;

    private static final boolean DBG_ANIMATOR_INFLATER = false;

    // used to calculate changing configs for resource references
@@ -698,9 +691,6 @@ public class AnimatorInflater {
                int ordering = a.getInt(R.styleable.AnimatorSet_ordering, TOGETHER);
                createAnimatorFromXml(res, theme, parser, attrs, (AnimatorSet) anim, ordering,
                        pixelSize);
                final int hint = a.getInt(R.styleable.AnimatorSet_durationScaleHint,
                        HINT_NO_SCALE);
                anim.setDurationScaleHint(hint, res);
                a.recycle();
            } else if (name.equals("propertyValuesHolder")) {
                PropertyValuesHolder[] values = loadValues(res, theme, parser,
@@ -1065,9 +1055,6 @@ public class AnimatorInflater {
            anim.setInterpolator(interpolator);
        }

        final int hint = arrayAnimator.getInt(R.styleable.Animator_durationScaleHint,
                HINT_NO_SCALE);
        anim.setDurationScaleHint(hint, res);
        arrayAnimator.recycle();
        if (arrayObjectAnimator != null) {
            arrayObjectAnimator.recycle();
+0 −1
Original line number Diff line number Diff line
@@ -519,7 +519,6 @@ public final class AnimatorSet extends Animator {

        for (Node node : mNodes) {
            node.animation.setAllowRunningAsynchronously(false);
            copyDurationScaleInfoTo(node.animation);
        }

        if (mDuration >= 0) {
Loading