From 3bc88c19f10ce8af901a1acc19cdc3101f455567 Mon Sep 17 00:00:00 2001 From: m1ga Date: Sat, 14 Oct 2023 11:14:20 +0200 Subject: [PATCH 1/4] feat(android): make rotation animatable --- .../appcelerator/titanium/util/TiAnimationBuilder.java | 8 +++++++- apidoc/Titanium/UI/Animation.yml | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/android/titanium/src/java/org/appcelerator/titanium/util/TiAnimationBuilder.java b/android/titanium/src/java/org/appcelerator/titanium/util/TiAnimationBuilder.java index 32ed3fc6957..30d04b61a4f 100644 --- a/android/titanium/src/java/org/appcelerator/titanium/util/TiAnimationBuilder.java +++ b/android/titanium/src/java/org/appcelerator/titanium/util/TiAnimationBuilder.java @@ -117,7 +117,7 @@ public class TiAnimationBuilder protected String width = null, height = null; protected Integer backgroundColor = null; protected Integer color = null; - protected float rotationY, rotationX = -1; + protected float rotationY, rotationX, rotation = -1; protected TiAnimationCurve curve = TiAnimationBuilder.DEFAULT_CURVE; protected TiAnimation animationProxy; @@ -251,6 +251,9 @@ public void applyOptions(HashMap options) if (options.containsKey(TiC.PROPERTY_ROTATION_X)) { rotationX = TiConvert.toFloat(options, TiC.PROPERTY_ROTATION_X, -1); } + if (options.containsKey(TiC.PROPERTY_ROTATION)) { + rotation = TiConvert.toFloat(options, TiC.PROPERTY_ROTATION, -1); + } this.options = options; } @@ -319,6 +322,9 @@ private AnimatorSet buildPropertyAnimators(int x, int y, int w, int h, int paren if (rotationX >= 0) { addAnimator(animators, ObjectAnimator.ofFloat(view, "rotationX", rotationX)); } + if (rotation >= 0) { + addAnimator(animators, ObjectAnimator.ofFloat(view, "rotation", rotation)); + } if (backgroundColor != null) { View bgView = view; diff --git a/apidoc/Titanium/UI/Animation.yml b/apidoc/Titanium/UI/Animation.yml index 5a4fbfcc10b..6b4b895ffb5 100644 --- a/apidoc/Titanium/UI/Animation.yml +++ b/apidoc/Titanium/UI/Animation.yml @@ -131,6 +131,12 @@ properties: summary: Duration of the animation, in milliseconds. type: Number + - name: rotation + summary: Value of the `rotation` property at the end of the animation. + type: Number + platforms: [android] + since: { android: "12.3.0" } + - name: rotationY summary: Value of the `rotationY` property at the end of the animation. type: Number From 795b3d270a39e6b0ba46bc48b5bc9d4a2746e8e2 Mon Sep 17 00:00:00 2001 From: m1ga Date: Sat, 14 Oct 2023 11:33:05 +0200 Subject: [PATCH 2/4] fix initial value --- .../titanium/util/TiAnimationBuilder.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/android/titanium/src/java/org/appcelerator/titanium/util/TiAnimationBuilder.java b/android/titanium/src/java/org/appcelerator/titanium/util/TiAnimationBuilder.java index 30d04b61a4f..c3d184aa0a7 100644 --- a/android/titanium/src/java/org/appcelerator/titanium/util/TiAnimationBuilder.java +++ b/android/titanium/src/java/org/appcelerator/titanium/util/TiAnimationBuilder.java @@ -117,7 +117,8 @@ public class TiAnimationBuilder protected String width = null, height = null; protected Integer backgroundColor = null; protected Integer color = null; - protected float rotationY, rotationX, rotation = -1; + private float INITIAL_ROTATION = 999999f; + protected float rotationY, rotationX, rotation = INITIAL_ROTATION; protected TiAnimationCurve curve = TiAnimationBuilder.DEFAULT_CURVE; protected TiAnimation animationProxy; @@ -245,14 +246,15 @@ public void applyOptions(HashMap options) } if (options.containsKey(TiC.PROPERTY_ROTATION_Y)) { - rotationY = TiConvert.toFloat(options, TiC.PROPERTY_ROTATION_Y, -1); + rotationY = TiConvert.toFloat(options, TiC.PROPERTY_ROTATION_Y, INITIAL_ROTATION); } if (options.containsKey(TiC.PROPERTY_ROTATION_X)) { - rotationX = TiConvert.toFloat(options, TiC.PROPERTY_ROTATION_X, -1); + rotationX = TiConvert.toFloat(options, TiC.PROPERTY_ROTATION_X, INITIAL_ROTATION); } + if (options.containsKey(TiC.PROPERTY_ROTATION)) { - rotation = TiConvert.toFloat(options, TiC.PROPERTY_ROTATION, -1); + rotation = TiConvert.toFloat(options, TiC.PROPERTY_ROTATION, INITIAL_ROTATION); } this.options = options; } @@ -316,13 +318,13 @@ private AnimatorSet buildPropertyAnimators(int x, int y, int w, int h, int paren addAnimator(animators, ObjectAnimator.ofFloat(view, "elevation", elevation)); } - if (rotationY >= 0) { + if (rotationY != INITIAL_ROTATION) { addAnimator(animators, ObjectAnimator.ofFloat(view, "rotationY", rotationY)); } - if (rotationX >= 0) { + if (rotationX != INITIAL_ROTATION) { addAnimator(animators, ObjectAnimator.ofFloat(view, "rotationX", rotationX)); } - if (rotation >= 0) { + if (rotation != INITIAL_ROTATION) { addAnimator(animators, ObjectAnimator.ofFloat(view, "rotation", rotation)); } From 28df6e977227266865fe82523adb2b66e22724ab Mon Sep 17 00:00:00 2001 From: Michael Gangolf Date: Fri, 12 Jul 2024 13:53:06 +0200 Subject: [PATCH 3/4] Update Animation.yml --- apidoc/Titanium/UI/Animation.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apidoc/Titanium/UI/Animation.yml b/apidoc/Titanium/UI/Animation.yml index 733362c60db..296d68d313e 100644 --- a/apidoc/Titanium/UI/Animation.yml +++ b/apidoc/Titanium/UI/Animation.yml @@ -135,7 +135,7 @@ properties: summary: Value of the `rotation` property at the end of the animation. type: Number platforms: [android] - since: { android: "12.3.0" } + since: { android: "12.5.0" } - name: rotationY summary: Value of the `rotationY` property at the end of the animation. From f92b21a76060f6bc5f3d1dbe962b0c097acdc784 Mon Sep 17 00:00:00 2001 From: Michael Gangolf Date: Sat, 19 Oct 2024 16:28:41 +0200 Subject: [PATCH 4/4] Update apidoc/Titanium/UI/Animation.yml --- apidoc/Titanium/UI/Animation.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apidoc/Titanium/UI/Animation.yml b/apidoc/Titanium/UI/Animation.yml index 296d68d313e..18a72ad7137 100644 --- a/apidoc/Titanium/UI/Animation.yml +++ b/apidoc/Titanium/UI/Animation.yml @@ -135,7 +135,7 @@ properties: summary: Value of the `rotation` property at the end of the animation. type: Number platforms: [android] - since: { android: "12.5.0" } + since: { android: "12.6.0" } - name: rotationY summary: Value of the `rotationY` property at the end of the animation.