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

Commit fad1a881 authored by Jordan Demeulenaere's avatar Jordan Demeulenaere
Browse files

Allow DiP values in the translate XML animation (1/2)

Bug: 215679624
Bug: 217356408
Test: atest TranslateAnimationTest
Change-Id: Icbd6d9832a68f0327bdcd4735f2f597f927caaeb
parent aa45a654
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -1251,18 +1251,19 @@ public abstract class Animation implements Cloneable {
        public float value;

        /**
         * Size descriptions can appear inthree forms:
         * Size descriptions can appear in four forms:
         * <ol>
         * <li>An absolute size. This is represented by a number.</li>
         * <li>A size relative to the size of the object being animated. This
         * is represented by a number followed by "%".</li> *
         * is represented by a number followed by "%".</li>
         * <li>A size relative to the size of the parent of object being
         * animated. This is represented by a number followed by "%p".</li>
         * <li>(Starting from API 32) A complex number.</li>
         * </ol>
         * @param value The typed value to parse
         * @return The parsed version of the description
         */
        static Description parseValue(TypedValue value) {
        static Description parseValue(TypedValue value, Context context) {
            Description d = new Description();
            if (value == null) {
                d.type = ABSOLUTE;
@@ -1283,6 +1284,11 @@ public abstract class Animation implements Cloneable {
                    d.type = ABSOLUTE;
                    d.value = value.data;
                    return d;
                } else if (value.type == TypedValue.TYPE_DIMENSION) {
                    d.type = ABSOLUTE;
                    d.value = TypedValue.complexToDimension(value.data,
                            context.getResources().getDisplayMetrics());
                    return d;
                }
            }

+8 −9
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.util.DisplayMetrics;

/**
 * An animation that controls the clip of an object. See the
@@ -66,43 +65,43 @@ public class ClipRectAnimation extends Animation {
                com.android.internal.R.styleable.ClipRectAnimation);

        Description d = Description.parseValue(a.peekValue(
                com.android.internal.R.styleable.ClipRectAnimation_fromLeft));
                com.android.internal.R.styleable.ClipRectAnimation_fromLeft), context);
        mFromLeftType = d.type;
        mFromLeftValue = d.value;

        d = Description.parseValue(a.peekValue(
                com.android.internal.R.styleable.ClipRectAnimation_fromTop));
                com.android.internal.R.styleable.ClipRectAnimation_fromTop), context);
        mFromTopType = d.type;
        mFromTopValue = d.value;

        d = Description.parseValue(a.peekValue(
                com.android.internal.R.styleable.ClipRectAnimation_fromRight));
                com.android.internal.R.styleable.ClipRectAnimation_fromRight), context);
        mFromRightType = d.type;
        mFromRightValue = d.value;

        d = Description.parseValue(a.peekValue(
                com.android.internal.R.styleable.ClipRectAnimation_fromBottom));
                com.android.internal.R.styleable.ClipRectAnimation_fromBottom), context);
        mFromBottomType = d.type;
        mFromBottomValue = d.value;


        d = Description.parseValue(a.peekValue(
                com.android.internal.R.styleable.ClipRectAnimation_toLeft));
                com.android.internal.R.styleable.ClipRectAnimation_toLeft), context);
        mToLeftType = d.type;
        mToLeftValue = d.value;

        d = Description.parseValue(a.peekValue(
                com.android.internal.R.styleable.ClipRectAnimation_toTop));
                com.android.internal.R.styleable.ClipRectAnimation_toTop), context);
        mToTopType = d.type;
        mToTopValue = d.value;

        d = Description.parseValue(a.peekValue(
                com.android.internal.R.styleable.ClipRectAnimation_toRight));
                com.android.internal.R.styleable.ClipRectAnimation_toRight), context);
        mToRightType = d.type;
        mToRightValue = d.value;

        d = Description.parseValue(a.peekValue(
                com.android.internal.R.styleable.ClipRectAnimation_toBottom));
                com.android.internal.R.styleable.ClipRectAnimation_toBottom), context);
        mToBottomType = d.type;
        mToBottomValue = d.value;

+8 −8
Original line number Diff line number Diff line
@@ -63,43 +63,43 @@ public class ExtendAnimation extends Animation {
                com.android.internal.R.styleable.ExtendAnimation);

        Description d = Description.parseValue(a.peekValue(
                com.android.internal.R.styleable.ExtendAnimation_fromExtendLeft));
                com.android.internal.R.styleable.ExtendAnimation_fromExtendLeft), context);
        mFromLeftType = d.type;
        mFromLeftValue = d.value;

        d = Description.parseValue(a.peekValue(
                com.android.internal.R.styleable.ExtendAnimation_fromExtendTop));
                com.android.internal.R.styleable.ExtendAnimation_fromExtendTop), context);
        mFromTopType = d.type;
        mFromTopValue = d.value;

        d = Description.parseValue(a.peekValue(
                com.android.internal.R.styleable.ExtendAnimation_fromExtendRight));
                com.android.internal.R.styleable.ExtendAnimation_fromExtendRight), context);
        mFromRightType = d.type;
        mFromRightValue = d.value;

        d = Description.parseValue(a.peekValue(
                com.android.internal.R.styleable.ExtendAnimation_fromExtendBottom));
                com.android.internal.R.styleable.ExtendAnimation_fromExtendBottom), context);
        mFromBottomType = d.type;
        mFromBottomValue = d.value;


        d = Description.parseValue(a.peekValue(
                com.android.internal.R.styleable.ExtendAnimation_toExtendLeft));
                com.android.internal.R.styleable.ExtendAnimation_toExtendLeft), context);
        mToLeftType = d.type;
        mToLeftValue = d.value;

        d = Description.parseValue(a.peekValue(
                com.android.internal.R.styleable.ExtendAnimation_toExtendTop));
                com.android.internal.R.styleable.ExtendAnimation_toExtendTop), context);
        mToTopType = d.type;
        mToTopValue = d.value;

        d = Description.parseValue(a.peekValue(
                com.android.internal.R.styleable.ExtendAnimation_toExtendRight));
                com.android.internal.R.styleable.ExtendAnimation_toExtendRight), context);
        mToRightType = d.type;
        mToRightValue = d.value;

        d = Description.parseValue(a.peekValue(
                com.android.internal.R.styleable.ExtendAnimation_toExtendBottom));
                com.android.internal.R.styleable.ExtendAnimation_toExtendBottom), context);
        mToBottomType = d.type;
        mToBottomValue = d.value;

+4 −2
Original line number Diff line number Diff line
@@ -116,10 +116,12 @@ public class GridLayoutAnimationController extends LayoutAnimationController {
                com.android.internal.R.styleable.GridLayoutAnimation);

        Animation.Description d = Animation.Description.parseValue(
                a.peekValue(com.android.internal.R.styleable.GridLayoutAnimation_columnDelay));
                a.peekValue(com.android.internal.R.styleable.GridLayoutAnimation_columnDelay),
                context);
        mColumnDelay = d.value;
        d = Animation.Description.parseValue(
                a.peekValue(com.android.internal.R.styleable.GridLayoutAnimation_rowDelay));
                a.peekValue(com.android.internal.R.styleable.GridLayoutAnimation_rowDelay),
                context);
        mRowDelay = d.value;
        //noinspection PointlessBitwiseExpression
        mDirection = a.getInt(com.android.internal.R.styleable.GridLayoutAnimation_direction,
+1 −1
Original line number Diff line number Diff line
@@ -106,7 +106,7 @@ public class LayoutAnimationController {
        TypedArray a = context.obtainStyledAttributes(attrs, com.android.internal.R.styleable.LayoutAnimation);

        Animation.Description d = Animation.Description.parseValue(
                a.peekValue(com.android.internal.R.styleable.LayoutAnimation_delay));
                a.peekValue(com.android.internal.R.styleable.LayoutAnimation_delay), context);
        mDelay = d.value;

        mOrder = a.getInt(com.android.internal.R.styleable.LayoutAnimation_animationOrder, ORDER_NORMAL);
Loading