OSDN Git Service

Add entry animation to Settings Panels.
authorMatthew Fritze <mfritze@google.com>
Fri, 8 Mar 2019 16:15:00 +0000 (08:15 -0800)
committerLinda Tseng <lindatseng@google.com>
Tue, 16 Apr 2019 16:29:04 +0000 (16:29 +0000)
commitb6fdd25c23f3ba1f9e66a90269dbd42eef004986
tree7a50b5709334415d62c55ce61e5690f7e0f89ead
parent80584fe1f7cfa4f6124d27d4fe3d8fe85be85b61
Add entry animation to Settings Panels.

Settings Panels as a dialog have a default animation for entering the
screen, but Slices complicate the animation. While the dialog enters the
screen, Slices begin to bind, thus changing the height of the dialog as
it enters, causing perceived bounce / jank in the animation.

This CL is cherry-picked/based on ag/6671083 but do the following modification:
(See the original commit message for the whole concept)

When trying to load all the Slices, there are few possible situations:
1. Slice starts loading slowly, starting at state LOADED_NONE
2. Slice is loading in progress, having state LOADED_PARTIAL
3. Slice is loaded, but there's error return from the Slice data (We don't
need to show the Slice in this case)
4. Slice is loaded, progress to state LOADED_ALL
5. Slice starts from state LOADED_NONE, but never progress to the next state
because it crashes at setting backend.

Notice that there are two cases that the state will stay at LOADED_NONE and
we can't distinguish them.

Hence, we decide to do the following:

If Slice is with error (case 3) we remove the slice from the list and mark it
loaded.

If Slice is loaded with LOADED_ALL (case 4, which is the ideal case), we mark
it as loaded.

In the other cases, we fire a handler to mark the slice loaded anyway after
250ms timeout.

When all the slices are marked loaded (which should happen after 250ms timeout,
we will animate the panel out.  Although there might be slices which are still
partial loaded, we can still have the slice in the panel once it is ready.
The panel might bounce/jank in this case, but at least it will still showing
correctly, and should show up smoothly in most cases.

The solution to this problem is twofold:
1. Load all Slices first
2. Create a custom animation to draw the panel once the recyclerview has
been laid out.

Test: Manual/Visual inspection
Test: make -j40 RunSettingsRobotests
Bug: 123942159

Change-Id: I639a707aa4ba3f906bd6f9752c92727aaba28142
res/layout/panel_layout.xml
res/layout/settings_panel.xml
res/values/themes.xml
src/com/android/settings/panel/PanelFragment.java
src/com/android/settings/panel/PanelSlicesAdapter.java
src/com/android/settings/panel/PanelSlicesLoaderCountdownLatch.java [new file with mode: 0644]
tests/robotests/src/com/android/settings/panel/PanelFragmentTest.java
tests/robotests/src/com/android/settings/panel/PanelSlicesAdapterTest.java
tests/robotests/src/com/android/settings/panel/PanelSlicesLoaderCountdownLatchTest.java [new file with mode: 0644]