Fixed
Status Update
Comments
an...@google.com <an...@google.com>
ap...@google.com <ap...@google.com> #2
Project: platform/frameworks/support
Branch: androidx-master-dev
commit fba994d3ea12cf9f6dfe5ae6a365891ad770d07e
Author: Andrey Kulikov <andreykulikov@google.com>
Date: Tue Jan 22 18:08:16 2019
Fix ChangeImageTransform wrong matrix applied on API < 21 bug
There was a logic to store the current scaleType and the matrix before the animation and restore it after the animation for pre-lollipop. It works fine until we start an another concurrent transition while the previous one is still in progress. Example steps:
1) The user scheduled the new transition and changed the scaleType to the value they wants
2) The old animation canceled and the end listener is called.
3) In this listener we apply our stored scaleType and overrides the value the user provided.
4) We start a new animation and now store the wrong value - our just restored, but not the final value provided by the user
5) After the animation we restore a wrong scaleType.
To prevent this for happening we should not save and restore but reimplement the ImageView.animateTransform() method logic for API's below 21. We have to use reflection here (only before 21) to change the value of ImageView.mDrawMatrix to apply a transient matrix for a view, it will only be applied for the next drawing and not clear the user provided matrix.
Bug: 123226255
Test: added a test for this case, fixed the test to correctly obtain a drawMatrix before 4.3
Change-Id: Id9870adc59ba815bfb37cedc42426cb6921d11df
M transition/src/androidTest/java/androidx/transition/ChangeImageTransformTest.java
M transition/src/main/java/androidx/transition/ChangeImageTransform.java
M transition/src/main/java/androidx/transition/ImageViewUtils.java
M transition/src/main/res/values/ids.xml
https://android-review.googlesource.com/880597
https://goto.google.com/android-sha1/fba994d3ea12cf9f6dfe5ae6a365891ad770d07e
Branch: androidx-master-dev
commit fba994d3ea12cf9f6dfe5ae6a365891ad770d07e
Author: Andrey Kulikov <andreykulikov@google.com>
Date: Tue Jan 22 18:08:16 2019
Fix ChangeImageTransform wrong matrix applied on API < 21 bug
There was a logic to store the current scaleType and the matrix before the animation and restore it after the animation for pre-lollipop. It works fine until we start an another concurrent transition while the previous one is still in progress. Example steps:
1) The user scheduled the new transition and changed the scaleType to the value they wants
2) The old animation canceled and the end listener is called.
3) In this listener we apply our stored scaleType and overrides the value the user provided.
4) We start a new animation and now store the wrong value - our just restored, but not the final value provided by the user
5) After the animation we restore a wrong scaleType.
To prevent this for happening we should not save and restore but reimplement the ImageView.animateTransform() method logic for API's below 21. We have to use reflection here (only before 21) to change the value of ImageView.mDrawMatrix to apply a transient matrix for a view, it will only be applied for the next drawing and not clear the user provided matrix.
Bug: 123226255
Test: added a test for this case, fixed the test to correctly obtain a drawMatrix before 4.3
Change-Id: Id9870adc59ba815bfb37cedc42426cb6921d11df
M transition/src/androidTest/java/androidx/transition/ChangeImageTransformTest.java
M transition/src/main/java/androidx/transition/ChangeImageTransform.java
M transition/src/main/java/androidx/transition/ImageViewUtils.java
M transition/src/main/res/values/ids.xml
Description
Steps:
1) Setup the image view with scaletype center
2) Start delayedTransition and apply fit-end scaletype
3) While transition is in progress again start delayedTransition and apply center scaletype
ER:
Transition back to center scaletype without visual bugs.
AR:
It starts animation to center, but in the end the image jumps to a position which represents fit-end scaletype. Works fine starting from 21 API