diff options
9 files changed, 42 insertions, 35 deletions
diff --git a/core/java/android/view/animation/Animation.java b/core/java/android/view/animation/Animation.java index 3914a3c963b6..fadbdbbe8746 100644 --- a/core/java/android/view/animation/Animation.java +++ b/core/java/android/view/animation/Animation.java @@ -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; } } diff --git a/core/java/android/view/animation/ClipRectAnimation.java b/core/java/android/view/animation/ClipRectAnimation.java index 21509d3a1159..3f4b3e7b4c80 100644 --- a/core/java/android/view/animation/ClipRectAnimation.java +++ b/core/java/android/view/animation/ClipRectAnimation.java @@ -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; diff --git a/core/java/android/view/animation/ExtendAnimation.java b/core/java/android/view/animation/ExtendAnimation.java index fd627e50ab0e..210eb8a1ca9d 100644 --- a/core/java/android/view/animation/ExtendAnimation.java +++ b/core/java/android/view/animation/ExtendAnimation.java @@ -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; diff --git a/core/java/android/view/animation/GridLayoutAnimationController.java b/core/java/android/view/animation/GridLayoutAnimationController.java index 0f189ae98030..c77f54fa889e 100644 --- a/core/java/android/view/animation/GridLayoutAnimationController.java +++ b/core/java/android/view/animation/GridLayoutAnimationController.java @@ -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, diff --git a/core/java/android/view/animation/LayoutAnimationController.java b/core/java/android/view/animation/LayoutAnimationController.java index e2b7519b1912..1d56d293e7df 100644 --- a/core/java/android/view/animation/LayoutAnimationController.java +++ b/core/java/android/view/animation/LayoutAnimationController.java @@ -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); diff --git a/core/java/android/view/animation/RotateAnimation.java b/core/java/android/view/animation/RotateAnimation.java index 3c325d9b2aa9..0613cd2ea5ad 100644 --- a/core/java/android/view/animation/RotateAnimation.java +++ b/core/java/android/view/animation/RotateAnimation.java @@ -56,12 +56,12 @@ public class RotateAnimation extends Animation { mToDegrees = a.getFloat(com.android.internal.R.styleable.RotateAnimation_toDegrees, 0.0f); Description d = Description.parseValue(a.peekValue( - com.android.internal.R.styleable.RotateAnimation_pivotX)); + com.android.internal.R.styleable.RotateAnimation_pivotX), context); mPivotXType = d.type; mPivotXValue = d.value; d = Description.parseValue(a.peekValue( - com.android.internal.R.styleable.RotateAnimation_pivotY)); + com.android.internal.R.styleable.RotateAnimation_pivotY), context); mPivotYType = d.type; mPivotYValue = d.value; diff --git a/core/java/android/view/animation/ScaleAnimation.java b/core/java/android/view/animation/ScaleAnimation.java index e9a84364452c..533ef45e7fe5 100644 --- a/core/java/android/view/animation/ScaleAnimation.java +++ b/core/java/android/view/animation/ScaleAnimation.java @@ -118,12 +118,12 @@ public class ScaleAnimation extends Animation { } Description d = Description.parseValue(a.peekValue( - com.android.internal.R.styleable.ScaleAnimation_pivotX)); + com.android.internal.R.styleable.ScaleAnimation_pivotX), context); mPivotXType = d.type; mPivotXValue = d.value; d = Description.parseValue(a.peekValue( - com.android.internal.R.styleable.ScaleAnimation_pivotY)); + com.android.internal.R.styleable.ScaleAnimation_pivotY), context); mPivotYType = d.type; mPivotYValue = d.value; diff --git a/core/java/android/view/animation/TranslateAnimation.java b/core/java/android/view/animation/TranslateAnimation.java index 3365c70b5b34..e27469c0729a 100644 --- a/core/java/android/view/animation/TranslateAnimation.java +++ b/core/java/android/view/animation/TranslateAnimation.java @@ -73,22 +73,22 @@ public class TranslateAnimation extends Animation { com.android.internal.R.styleable.TranslateAnimation); Description d = Description.parseValue(a.peekValue( - com.android.internal.R.styleable.TranslateAnimation_fromXDelta)); + com.android.internal.R.styleable.TranslateAnimation_fromXDelta), context); mFromXType = d.type; mFromXValue = d.value; d = Description.parseValue(a.peekValue( - com.android.internal.R.styleable.TranslateAnimation_toXDelta)); + com.android.internal.R.styleable.TranslateAnimation_toXDelta), context); mToXType = d.type; mToXValue = d.value; d = Description.parseValue(a.peekValue( - com.android.internal.R.styleable.TranslateAnimation_fromYDelta)); + com.android.internal.R.styleable.TranslateAnimation_fromYDelta), context); mFromYType = d.type; mFromYValue = d.value; d = Description.parseValue(a.peekValue( - com.android.internal.R.styleable.TranslateAnimation_toYDelta)); + com.android.internal.R.styleable.TranslateAnimation_toYDelta), context); mToYType = d.type; mToYValue = d.value; diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index afe0f1bf0001..d774fd4e397a 100644 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -6953,10 +6953,10 @@ </declare-styleable> <declare-styleable name="TranslateAnimation"> - <attr name="fromXDelta" format="float|fraction" /> - <attr name="toXDelta" format="float|fraction" /> - <attr name="fromYDelta" format="float|fraction" /> - <attr name="toYDelta" format="float|fraction" /> + <attr name="fromXDelta" format="float|fraction|dimension" /> + <attr name="toXDelta" format="float|fraction|dimension" /> + <attr name="fromYDelta" format="float|fraction|dimension" /> + <attr name="toYDelta" format="float|fraction|dimension" /> </declare-styleable> <declare-styleable name="AlphaAnimation"> |