Commit Graph

236 Commits

Author SHA1 Message Date
Andrey Kulikov
6ee8379dc0 Made View.setLeftTopRightBottom() public
It will allow to call this method in AndroidX Transition without reflection.
ChangeBounds#BOTTOM_RIGHT_ONLY_PROPERTY,POSITION_PROPERTY are restricted now as well as developers can just use setLeftTopRightBottom method instead (it was used as a performance optimization in third-party transitions backport)

Bug: 117521189
Bug: 117521197
Bug: 117521053
Test: new test added for the method
Change-Id: I0a29bc8cf0b3357e49f6be14270993a21a6dfeee
2018-11-29 14:44:29 +00:00
Andrey Kulikov
b37dcbc2ab Restrict unsupported API usage to Scene#mEnterAction/mExitAction/setCurrentScene
They were used via reflection in older versions of support transitions.
Starting from 26.0.0 it is not in use and there is no need to allow this usages.
Developers should update to the newer version of support libraries/androidx

Bug: 117521462
Bug: 117521646
Test: none
Change-Id: Ia1d5516a58c0deec68091d719065621fc588591b
2018-11-29 11:18:19 +00:00
TreeHugger Robot
bf4deb273b Merge "Make transitions Scene.getCurrentScene() public" 2018-11-01 14:34:08 +00:00
Andrey Kulikov
a4ae81857a Make transitions Scene.getCurrentScene() public
I pretty sure the getter method Scene.getCurrentScene() should be promoted to be public. This method is the only option for developers to understand is the sceneRoot already in the scene they need. Otherwise they have to introduce their own states and sync it with all scene changes which is more error-prone. To make it simpler to developers we can just make the method public. As an example of usage:

void displayMessages(List<Message> messages) {
    if (!messages.isEmpty()) {
        if (Scene.getCurrentScene(root) != messagesScene) {
            TransitionManager.go(messagesScene);
            MyAnalytics.trackDisplayMessages();
            (... more initialization ... )
        }
        messagesView.display(messages);
    }
}

Test: added a cts test for getCurrentScene
Change in AndroidX: aosp/807055
Bug: 118720709
Change-Id: Ic90e3576a82b5ab9a88e38e396efd49875968011
2018-11-01 12:33:53 +00:00
Andrey Kulikov
c5dede2bca Improve platform TransitionSet behavior
1) Allow override values for a children of TransitionSet. For example for usages like this:
TransitionSet set = new TransitionSet().setDuration(300);
Fade fade = new Fade();
set.addTransition(fade);
fade.setDuration(100);
The result duration applied for fade transition is still 300. And it breaks all the flexibility of configuring sets.
The reason of it is clone() method which will be executed in beginDelayedTransition. And as part of clone() implementation of TransitionSet the children will be re-added to the new cloned set and set's duration will be re-applied again. To fix it I changed how we add transitions into set in clone().
2) Recently we had a bug about TransitionSet will crash during inflation if we provide duration for it via xml. I fixed similar issue for applying a path motion.

Test: added new tests for both issues
Change in AndroidX: aosp/803493
Bug: 64644617

Change-Id: If205845a83e29d49f8cced8a53d9f56a4ad740aa
2018-10-31 14:32:26 +00:00
TreeHugger Robot
7cc7662d6f Merge "Reuse overlay view between two Visibility transitions" 2018-10-29 21:28:04 +00:00
Andrey Kulikov
b80db0b799 Remove transition listener in MultiListener and FragmentTransition
Found two places where we forgot to remove TransitionListener in onTransitionEnd. I think it is important to clear it as if you reuse a transition object it will be leaked together with some views

Test: n/a
Bug: 64643817
Fixes in AndroidX: aosp/793641, aosp/795753

Change-Id: Iae0a9945a4158776f1a75c806c1f29efc049f96b
2018-10-22 10:11:28 +00:00
Andrey Kulikov
d4376badb4 Reuse overlay view between two Visibility transitions
Bug: 31362791

Instead of creating a new screenshot of the view every time previous visibility transition already did it or just added our startView to the overlay we can cache it and apply the animation to the same reused view. So the behaviour is the same(and expected) like in the case when no overlay is used.

Test: test added in VisibilityTest
Fix in AndroidX: aosp/772713
Change-Id: Iba4ab168722595eb19b9c681649a976462a5532b
2018-10-18 14:59:52 +01:00
Andrey Kulikov
d2d5cdff44 Fix crash in RecyclerView if it's view is animated by Transitions
When it is happening:
a) Disappear Visibility transition is applied to the recyclerview(and it's children)
b) Transition added the View to the ViewOverlay for an animation
c) Transition is first paused before being canceled (for example when the new reversed transition wants to start after user click)
d) In Visibility.onPause() we call suppressLayout(false) for RecyclerView
e) RecyclerView starts layouting and tries to use our view, but it is currently added to the overlay
f) So it crashes on attempt to call addView

Fix: Detach a view from overlay in Visibility transition while it is paused. Attach it back in onTransitionResume if the view is still not used by someone else like RecyclerView.

Bug: 33609996
Fix in AndroidX: I18d8327b338be442ec30b15fe53a99d1a2974888
Test: cts tests for Transitions
Change-Id: I74f138617c8afbac9f6efa4ee9a1f4e961306c9e
2018-10-15 10:24:07 +00:00
TreeHugger Robot
db63cbe7f7 Merge "Fix ChangeImageTransform for drawables without intrinsic size" 2018-09-28 21:08:33 +00:00
Andrey Kulikov
72be97465a Fix ChangeImageTransform for drawables without intrinsic size
Bug: 68489306

If we use a drawable like ColorDrawable for an ImageView it has intrinsicWidth and intrinsicHeight == -1.

1) Simplified matrix calculation in ChangeImageTransform.captureValues. It makes no sense to return null as a matrix because later in createAnimator it will be considered as the identity matrix. For cases when drawableSize == -1 instead we can just use view.getImageMatrix() which would be the identity matrix.
2) There is an additional check in createAnimator() to start an empty animation if the drawable width or height is 0. But actually it worth to use it also for cases when width or height is -1, as if it goes into else branch matrix transformations will try to incorrectly change the bounds of the drawable to (0, 0, -1, -1).
3) And also actually there is a bug in createNullAnimator() method, we can't provide nulls as values for ObjectAnimator.ofObject, as later it will crash on PropertyValuesHolder.setObjectValues(Object... values) because of "values[0].getClass()". So I changed it to provide some nonnull values like Matrix.IDENTITY_MATRIX. It is not important what to provide here as NULL_MATRIX_EVALUATOR will not use the values anyway.
4) Also I found a bug in ImageView.animateTransform(). If we provide null matrix if will try to update the drawable bounds to the view size but will not take into account paddings(in the same way like configureBounds()).

Test: Tested manually on the sample app from the bug and added new tests for both cases: with view bounds change and without it
Change-Id: I0750de56f4a011e06b340ed342884b59896d92dc
2018-09-28 19:40:22 +00:00
Andrey Kulikov
0cf6e6f0a4 Keep scene change code in framework transitions in sync with AndroidX
Bug: 65536124
Test: cts/TransitionManagerTest
Change-Id: I976f07899c7d6ef68acbcc207ddb07ae5ac7f28f
2018-09-28 19:39:58 +00:00
Andrey Kulikov
0a6085e87a Call Scene's exit action when use TransitionManager.go() with null transition
Bug: 65536124

When we pass null for TransitionManager.go() there is a special logic where we forgot to call previousScene.exit(), only newscene.enter() is called.

Test: added unit tests and tested manually
Change-Id: Ibd4d5a2cc17bbfe4aaa586357446da28d4b355af
2018-09-27 00:42:49 +01:00
Andrey Kulikov
275ca2a651 Fix IntDef's usages in the platform Transitions
Bug: 68490704

1) Add annotation in some places where it was missed: constructors of Fade and Slide
2) Add Fade.IN and Fade.OUT into a set of allowed values for Visibility.MODE IntDef. Without it Lint will false alarm on this line:
new Fade().setMode(Fade.IN);
It should be allowed as Fade.IN is just a proxy value for Visibility.MODE_IN.

Test: n/a
Change-Id: I56d8ba5f49b1cf8f6a61357f58ac76312e7cf037
2018-09-07 16:54:45 +00:00
Mathew Inwood
98e9ad1645 Add @UnsupportedAppUsage annotations
For all remaining unannotated code.

This is an automatically generated CL. See go/UnsupportedAppUsage
for more details.

Exempted-From-Owner-Approval: Mechanical changes to the codebase
which have been approved by Android API council and announced on
android-eng@

Bug: 110868826
Test: m
Change-Id: I67c8b71ea535ebffb10bf577948bd4ccb8ca069d
2018-08-30 13:38:42 +01:00
Mathew Inwood
a16013513d Merge "Code reformatting for upcoming automated code changes." am: 3b2cd9244d am: 0c875607f0
am: 6b9e65bea3

Change-Id: I5ca0de51793f574d7dc54b16e5427673bc5950f9
2018-08-21 08:54:59 -07:00
Mathew Inwood
c8f812ae10 Code reformatting for upcoming automated code changes.
Adding annotations to individual fields cannot be easily done when there
are two fields defined in a single statement. Put each definition in a
statement of its own.

See go/UnsupportedAppUsage for more context.

Bug: 110868826
Test: m
Change-Id: I34e163d0984fcb666c1ea8788791f5a7740c8892
2018-08-17 14:26:58 +01:00
Aurimas Liutikas
e701dc1799 Fix broken links in @see tags in framework docs.
doclava was accidentally suppressing all these broken links
in @see tags. This CL fixes issues so we can start enfocing
checks for broken @see links.

Test: make docs
Change-Id: If7830ece85f8d1f27c991eae282230814726e115
Exempt-From-Owner-Approval: Fixing @see javadoc link issues that are currently completely broken
2018-06-04 10:15:22 -07:00
Yuichi Araki
7c10e1e56c Fix race condition with GC in TransitionManager
Test: Built
Change-Id: I605b32dc7f86b63ba6ce539fcd13174558feb125
2018-05-02 13:42:14 +09:00
Evan Rosky
cd5719fde4 Merge "Don't clear focus during transition animations" into pi-dev am: 09ba7e0bae
am: 13f13935ea

Change-Id: Id5e4345720f6307c1809cc0e36a144f1ddf8365b
2018-05-01 15:15:43 -07:00
Evan Rosky
8cd89cddc1 Don't clear focus during transition animations
If a view is suppressing layout, it is probably part of a
transition animation. In this case, we don't want to defocus
a focused view which may eventually have a size.

Bug: 78302781
Test: issue in bug is resolved. Transition CTS tests still pass
Change-Id: I983f41bcd68056d2150d4db29c781b63a2c321c2
2018-04-23 13:58:16 -07:00
George Mount
a69609e124 Transfer Interpolator from TransitionSet to child Transitions
Bug: 74831546

TransitionSet interpolator was never being used in child
transitions. This transfers the interpolator by setting the
interpolator of the children as they are added or when the
interpolator is set. It also works for other settings:
epicenter, path motion, and propagation.

Test: Ie8ce23fe15e6193fdb2909606e442bd2912a4c5a
Change-Id: Ia9e35639f025d14c6497fa30abf75252ff3b1423
2018-03-16 16:30:04 -07:00
John Reck
519ad488a5 Switch to public API version
Use the public API version of the same thing that the private API
access was doing. No behavior change.

Test: built
Change-Id: I4a9032cfb1d4e699f72df3b079ef363d308419e8
2018-02-12 17:30:02 -08:00
TreeHugger Robot
a20833c06d Merge "Fix bug in calculating path in ArcMotion" 2018-02-08 15:43:50 +00:00
George Mount
575ffb856e Fix bug in calculating path in ArcMotion
Bug: 73077523

When the path is perfectly horizontal, ArcMotion
was calculating a Path that had NaN values. This
corrects that problem by special casing horizontal
and vertical paths.

Test: manual with app that discovered the problem
Test: manual with test app
Test: I30d51206194e3c68ea145d3a81e05a461c4e0ca8
Change-Id: Ic1a70b79290847726fc7994d1224fd77024e0610
2018-02-07 12:44:55 -08:00
George Mount
283897b327 Avoid improperly removing views during transitions
Bug: 65715616

There are two places where views were being removed improperly
during transitions. The first was when making a copy of a view.
Because of hardware bitmaps, views were being moved to the overlay
so that the image could be copied. This CL moves the view back
into its parent after copying the image.

The second location is where the view was being considered an
overlay. When a view is in the starting scene and the view in
the end scene cannot be used, the starting scene view was being
moved to the overlay. This is only valid when the view is alowed
to be removed. Instead, a bitmap copy of the view is moved to
the overlay.

Test: manual testing
Test: I0456d8a699525b08b044236c558b2d84b48c29a6
Change-Id: Ieb32b146cf65e3ff4ed6d7bb8325e74763dbd2d5
2018-02-02 15:10:22 -08:00
Jeff Sharkey
ce8db99114 Add more IntDef prefixes for auto-documenting.
Test: builds, boots
Bug: 70177949
Exempt-From-Owner-Approval: annotation-only changes
Change-Id: I76dde6054e06f52240bd4b1a0f196dcb74623608
2017-12-13 20:05:36 -07:00
George Mount
3884b03b98 Fix Transition test failure.
Bug: 67049319

TransitionUtils was returning null when the View wasn't attached,
but Visibility transitions can do that intentionally. This CL
temporarily adds detached views to the view hierarchy as part of
an overlay while creating the hardware bitmap representation.

Test: ran transition CTS tests
Change-Id: Ie335619953653dce0224514f0d5c9c8eb00ee1a9
2017-09-29 15:03:47 -07:00
Doris Liu
a3acf73c3e Merge "Associate RenderNodes created for hw bitmap w/ views" into oc-mr1-dev 2017-09-28 02:33:48 +00:00
Doris Liu
d4c5ab8b8c Associate RenderNodes created for hw bitmap w/ views
In transition animations, in order to capture the content of a view
or a drawable in a hw bitmap, a RenderNode needs to be created. The
RenderNode was previously setup with no owning view. As a result,
in cases where RenderNode animations are triggered by the draw calls
in displaylist recording, these animations would fail for lack of a
view to animate on.

This CL ensures that when RenderNodes are created for the purpose of
populating content in a hw bitmap in transitions, there's always a
view associated with each RenderNode.

BUG: 65160121
Test: Force to repro crash by changing press state during hw bitmap
creation, which triggers a ripple animation that led to the
otherwise timing dependent and hard to repro crash.

Change-Id: I2b4ba95cad25a94d50b3904e775606f737e960e3
2017-09-27 16:53:05 -07:00
Doris Liu
4dc1ec754c Fix crash when creating a HW Bitmap on a detached view
BUG: 65160121
Test: Unable to repro the crash before or after the fix

Change-Id: I84fa28557c67a6672b8d82443d4da7be4f28a50d
2017-09-25 17:21:48 -07:00
George Mount
3f81c33a35 Use hardware bitmap for shared element snapshots.
Bug: 64851247

Drawing to software bitmaps does not support many
features, most especially hardware bitmaps. This
changes the implementation to using hardware bitmaps
for View snapshots.

Also fixed broken TransitionTest discovered while
testing.

Test: I4ede02db67e578ea4a25069b683f1989c611e06c
Change-Id: I185bbfe1f789055c9efdba5297a74e481607afaf
2017-08-23 20:51:13 +00:00
George Mount
dc93620115 Fix ChangeClipBounds to set final clip to null.
Bug 35227753

ChangeClipBounds wasn't setting the final clip to null after its
transition if the end clip was supposed to be null.

Test: I9089e0c84718d219cfda266a99fd3dffdbae8512

Change-Id: If928454b30807ccc6b34ed4dfbb14857d99d43be
2017-04-20 09:12:20 -07:00
George Mount
f31efa38f8 Ensure bounds are updated together.
Bug 37156683

The animator was setting the value twice on the first run, so
the bounds was being set improperly as the top/left was being
set from a different frame than the bottom/right.

Test: I534cc4d7534cff1206ea8c2b222e0c0852fc0e9c
Change-Id: I6fb047d2fa4d0ed0db3b44107f9815a65f1f2676
2017-04-07 12:43:28 -07:00
George Mount
f85b3d48d6 Excluded Views don't go through Transition.
Bug 35832096

When entering or exiting Views were excluded, they were still
being set to INVISIBLE during the exit transition. This made
them disappear instantly. Instead, I've reverted back to the
original implementation by not affecting excluded Views during
the transition.

This CL walks the transition and removes excluded Views from
the enter/exit from being affected.

Test: I5b1b75dd12a3914e35c1d0fb641850981a19f9c3
Change-Id: I2b00ba95575420bae690b1cd8d4894c98401da79
2017-03-13 14:09:58 -07:00
Yuichi Araki
fb6ed353a6 Recycle TypedArrays in Fade and TransitionInflater
Test: Builds
Change-Id: I91e214eafc87850dca6986af2054e5edca46e724
2017-02-10 13:47:36 +09:00
Yuichi Araki
fd62c58ede Merge "Fix doc for setReparentWithOverlay" 2017-02-07 07:35:48 +00:00
Ben Weiss
995f4b5721 Merge "Extract and unhide TransitionListenerAdapter" 2017-02-06 10:16:50 +00:00
Yuichi Araki
3f23b30c63 Fix doc for setReparentWithOverlay
Test: Doc fix only
Change-Id: I8d89be7c87cf95fd2c7799fdd8286acc13102e46
2017-02-03 15:15:13 +09:00
Ben Weiss
5de23c5eb4 Make ArcMotion material spec compliant
Upwards and downwards paths are
now curved in the same direction,
applying "gravity" to objects as they move around.

Test: CTS I40a5df051711fd719806cd88d87eeed68565d73d

Change-Id: I9e5323655dc7901393f90bb1ea2f393ca64b77ff
2017-01-05 11:43:04 +00:00
Ben Weiss
e0c37bdea3 Extract and unhide TransitionListenerAdapter
Test: CTS tested

Change-Id: I8db99d5f212b15db70ee5a6d6debf25d7ad7922d
2016-11-17 10:50:34 +00:00
George Mount
f0b46b9540 Use safe access to OnPreDrawListener.
Bug 32472451

It is important to remove an OnPreDrawListener from the correct
ViewTreeObserver. When a View is added to the view hierarchy, the
initial ViewTreeObserver is not active. The listener must then be
removed from the current OnPreDrawListener. When a View has been
removed from the hierarchy, it is important to remove the listener
from the orignal ViewTreeObserver.

Test: cts-tradefed run singleCommand cts -d --skip-preconditions
--skip-connectivity-check -m CtsUsageStatsTestCases
Test: cts-tradefed run singleCommand cts -d --skip-preconditions
--skip-connectivity-check -m CtsFragmentTestCases

Change-Id: I735f71d2d9c84e86ef846aab0088a8651300fbe8
2016-11-15 15:00:53 -08:00
Aurimas Liutikas
67e2ae8639 Fix import statement in view|transition|animation packages.
This change also remove trailing whitespace.

Test: code still compiles
Change-Id: I7eff4546320d67d2bae58d31bad0625ea0791b8f
2016-10-12 09:09:52 -07:00
George Mount
d0549f2e90 Fix TransitionManager.go with null Transition.
Bug: 31529500

Test: I8e5a3285bc5e2b34a1eb32afd67e3184c6d8897e
Change-Id: Ibf273d5acab4e32420093adc395034b2246bd530
2016-09-20 15:19:03 -07:00
TreeHugger Robot
50b2c2444c Merge "Return proper values from ChangeScroll.getTransitionProperties" 2016-06-27 18:39:14 +00:00
George Mount
ae61b85cb5 Return proper values from ChangeScroll.getTransitionProperties
Bug 29644621

Change-Id: I9035e94582d05889a00df61f84de46d782baea17
2016-06-24 17:29:21 -07:00
George Mount
f239f99113 Make getTransition a @TestApi for CTS tests.
Bug 29570647

Change-Id: I85b2b215fbad2ca72e67b17a29cc9b122ae5945e
2016-06-24 11:53:42 -07:00
George Mount
25f98a4c01 Remove TransitionListener after transition completes.
Bug 22232371

Change-Id: I1ba6f8742792ff00996b7fdaa892d5e1388ef61c
2016-06-14 14:11:28 -07:00
George Mount
e6b23b6ab9 Merge \\"Re-add Internal API for cross-task Activity used by assistant.\\" into nyc-mr1-dev am: 174e41b1fd
am: dff1fa4bb9

Change-Id: I76afa8d89b2ac1624a36b3114bd3891c9c734cee
2016-06-08 20:39:54 +00:00
George Mount
413739e8c6 Re-add Internal API for cross-task Activity used by assistant.
Bug: 29091742

This reverts commit 563df3b328.

This also fixes the problems experienced by b/29128683.

Change-Id: I8e3d485cb818ea9e03ca475cba88934f6f903f11
2016-06-08 07:13:37 -07:00