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

Commit a00f3865 authored by Chet Haase's avatar Chet Haase
Browse files

Add ViewPropertyAnimator for easy animation of View properties

Change-Id: I2bc52ca16507d8d20004d2d6823e587791272aac
parent 11f4ae76
Loading
Loading
Loading
Loading
+331 −1
Original line number Diff line number Diff line
@@ -21153,6 +21153,17 @@
<parameter name="listener" type="android.animation.ValueAnimator.AnimatorUpdateListener">
</parameter>
</method>
<method name="getAnimatedFraction"
 return="float"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="getAnimatedValue"
 return="java.lang.Object"
 abstract="false"
@@ -220391,6 +220402,17 @@
<parameter name="views" type="java.util.ArrayList&lt;android.view.View&gt;">
</parameter>
</method>
<method name="animate"
 return="android.view.ViewPropertyAnimator"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="awakenScrollBars"
 return="boolean"
 abstract="false"
@@ -228642,6 +228664,314 @@
</parameter>
</method>
</interface>
<class name="ViewPropertyAnimator"
 extends="java.lang.Object"
 abstract="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<method name="alpha"
 return="android.view.ViewPropertyAnimator"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="value" type="float">
</parameter>
</method>
<method name="alphaBy"
 return="android.view.ViewPropertyAnimator"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="value" type="float">
</parameter>
</method>
<method name="rotation"
 return="android.view.ViewPropertyAnimator"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="value" type="float">
</parameter>
</method>
<method name="rotationBy"
 return="android.view.ViewPropertyAnimator"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="value" type="float">
</parameter>
</method>
<method name="rotationX"
 return="android.view.ViewPropertyAnimator"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="value" type="float">
</parameter>
</method>
<method name="rotationXBy"
 return="android.view.ViewPropertyAnimator"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="value" type="float">
</parameter>
</method>
<method name="rotationY"
 return="android.view.ViewPropertyAnimator"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="value" type="float">
</parameter>
</method>
<method name="rotationYBy"
 return="android.view.ViewPropertyAnimator"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="value" type="float">
</parameter>
</method>
<method name="scaleX"
 return="android.view.ViewPropertyAnimator"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="value" type="float">
</parameter>
</method>
<method name="scaleXBy"
 return="android.view.ViewPropertyAnimator"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="value" type="float">
</parameter>
</method>
<method name="scaleY"
 return="android.view.ViewPropertyAnimator"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="value" type="float">
</parameter>
</method>
<method name="scaleYBy"
 return="android.view.ViewPropertyAnimator"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="value" type="float">
</parameter>
</method>
<method name="setDuration"
 return="android.view.ViewPropertyAnimator"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="duration" type="long">
</parameter>
</method>
<method name="setInterpolator"
 return="android.view.ViewPropertyAnimator"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="interpolator" type="android.animation.TimeInterpolator">
</parameter>
</method>
<method name="setListener"
 return="android.view.ViewPropertyAnimator"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="listener" type="android.animation.Animator.AnimatorListener">
</parameter>
</method>
<method name="translationX"
 return="android.view.ViewPropertyAnimator"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="value" type="float">
</parameter>
</method>
<method name="translationXBy"
 return="android.view.ViewPropertyAnimator"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="value" type="float">
</parameter>
</method>
<method name="translationY"
 return="android.view.ViewPropertyAnimator"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="value" type="float">
</parameter>
</method>
<method name="translationYBy"
 return="android.view.ViewPropertyAnimator"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="value" type="float">
</parameter>
</method>
<method name="x"
 return="android.view.ViewPropertyAnimator"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="value" type="float">
</parameter>
</method>
<method name="xBy"
 return="android.view.ViewPropertyAnimator"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="value" type="float">
</parameter>
</method>
<method name="y"
 return="android.view.ViewPropertyAnimator"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="value" type="float">
</parameter>
</method>
<method name="yBy"
 return="android.view.ViewPropertyAnimator"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="value" type="float">
</parameter>
</method>
</class>
<class name="ViewStub"
 extends="android.view.View"
 abstract="false"
@@ -266083,7 +266413,7 @@
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="arg0" type="T">
<parameter name="t" type="T">
</parameter>
</method>
</interface>
+16 −0
Original line number Diff line number Diff line
@@ -159,6 +159,11 @@ public class ValueAnimator extends Animator {
     */
    private int mCurrentIteration = 0;

    /**
     * Tracks current elapsed/eased fraction, for querying in getAnimatedFraction().
     */
    private float mCurrentFraction = 0f;

    /**
     * Tracks whether a startDelay'd animation has begun playing through the startDelay.
     */
@@ -1110,6 +1115,16 @@ public class ValueAnimator extends Animator {
        return done;
    }

    /**
     * Returns the current animation fraction, which is the elapsed/interpolated fraction used in
     * the most recent frame update on the animation.
     *
     * @return Elapsed/interpolated fraction of the animation.
     */
    public float getAnimatedFraction() {
        return mCurrentFraction;
    }

    /**
     * This method is called with the elapsed fraction of the animation during every
     * animation frame. This function turns the elapsed fraction into an interpolated fraction
@@ -1124,6 +1139,7 @@ public class ValueAnimator extends Animator {
     */
    void animateValue(float fraction) {
        fraction = mInterpolator.getInterpolation(fraction);
        mCurrentFraction = fraction;
        int numValues = mValues.length;
        for (int i = 0; i < numValues; ++i) {
            mValues[i].calculateValue(fraction);
+49 −11
Original line number Diff line number Diff line
@@ -1866,7 +1866,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
     * transform matrix, based on whether the rotation or scaleX/Y properties
     * have changed since the matrix was last calculated.
     */
    private boolean mMatrixDirty = false;
    boolean mMatrixDirty = false;

    /**
     * An internal variable that tracks whether we need to recalculate the
@@ -1914,66 +1914,66 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
     * The degrees rotation around the vertical axis through the pivot point.
     */
    @ViewDebug.ExportedProperty
    private float mRotationY = 0f;
    float mRotationY = 0f;

    /**
     * The degrees rotation around the horizontal axis through the pivot point.
     */
    @ViewDebug.ExportedProperty
    private float mRotationX = 0f;
    float mRotationX = 0f;

    /**
     * The degrees rotation around the pivot point.
     */
    @ViewDebug.ExportedProperty
    private float mRotation = 0f;
    float mRotation = 0f;

    /**
     * The amount of translation of the object away from its left property (post-layout).
     */
    @ViewDebug.ExportedProperty
    private float mTranslationX = 0f;
    float mTranslationX = 0f;

    /**
     * The amount of translation of the object away from its top property (post-layout).
     */
    @ViewDebug.ExportedProperty
    private float mTranslationY = 0f;
    float mTranslationY = 0f;

    /**
     * The amount of scale in the x direction around the pivot point. A
     * value of 1 means no scaling is applied.
     */
    @ViewDebug.ExportedProperty
    private float mScaleX = 1f;
    float mScaleX = 1f;

    /**
     * The amount of scale in the y direction around the pivot point. A
     * value of 1 means no scaling is applied.
     */
    @ViewDebug.ExportedProperty
    private float mScaleY = 1f;
    float mScaleY = 1f;

    /**
     * The amount of scale in the x direction around the pivot point. A
     * value of 1 means no scaling is applied.
     */
    @ViewDebug.ExportedProperty
    private float mPivotX = 0f;
    float mPivotX = 0f;

    /**
     * The amount of scale in the y direction around the pivot point. A
     * value of 1 means no scaling is applied.
     */
    @ViewDebug.ExportedProperty
    private float mPivotY = 0f;
    float mPivotY = 0f;

    /**
     * The opacity of the View. This is a value from 0 to 1, where 0 means
     * completely transparent and 1 means completely opaque.
     */
    @ViewDebug.ExportedProperty
    private float mAlpha = 1f;
    float mAlpha = 1f;

    /**
     * The distance in pixels from the left edge of this view's parent
@@ -2236,6 +2236,11 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
     */
    private int mTouchSlop;

    /**
     * Object that handles automatic animation of view properties.
     */
    private ViewPropertyAnimator mAnimator = null;

    /**
     * Cache drag/drop state
     *
@@ -6156,6 +6161,26 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
        }
    }

    /**
     * Faster version of setAlpha() which performs the same steps except there are
     * no calls to invalidate(). The caller of this function should perform proper invalidation
     * on the parent and this object. The return value indicates whether the subclass handles
     * alpha (the return value for onSetAlpha()).
     *
     * @param alpha The new value for the alpha property
     * @return true if the View subclass handles alpha (the return value for onSetAlpha())
     */
    boolean setAlphaNoInvalidation(float alpha) {
        mAlpha = alpha;
        boolean subclassHandlesAlpha = onSetAlpha((int) (alpha * 255));
        if (subclassHandlesAlpha) {
            mPrivateFlags |= ALPHA_SET;
        } else {
            mPrivateFlags &= ~ALPHA_SET;
        }
        return subclassHandlesAlpha;
    }

    /**
     * Top position of this view relative to its parent.
     *
@@ -11784,6 +11809,19 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
        mAttachInfo.mTurnOffWindowResizeAnim = off;
    }

    /**
     * This method returns a ViewPropertyAnimator object, which can be used to animate
     * specific properties on this View.
     *
     * @return ViewPropertyAnimator The ViewPropertyAnimator associated with this View.
     */
    public ViewPropertyAnimator animate() {
        if (mAnimator == null) {
            mAnimator = new ViewPropertyAnimator(this);
        }
        return mAnimator;
    }

    /**
     * Interface definition for a callback to be invoked when a key event is
     * dispatched to this view. The callback will be invoked before the key
+745 −0

File added.

Preview size limit exceeded, changes collapsed.