Fixed
Status Update
Comments
ap...@google.com <ap...@google.com> #2
Project: platform/frameworks/support
Branch: androidx-master-dev
commit f27971d31a5947e0d0d38d40b99c96d3a76e2188
Author: Adam Powell <adamp@google.com>
Date: Fri Jan 10 13:25:52 2020
Integrate native fling spline into Compose UI
Extract the native Android fling spline from android.widget.Scroller
and move it into Compose UI foundation in such a way that it can be
driven via an external time source.
Future work will delegate to a similarly factored version of this
in AOSP frameworks/base for a future platform release for forward
compatibility with any future platform behavior changes.
Thanks to the nature of the source material, testing this port for
correct behavior will necessarily involve an instrumentation test and
comparing values over "real" time with the output of
android.widget.Scroller.
This commit also starts spreading a new-ish pattern of @Composable
factory functions that read default or configuration-specific values
from the composition. An interesting outcome of this is that the result
of such a factory may not be the content of a `remember {}` block - the
`remember` body is not itself `@Composable`. In order to preserve
expected object instance behavior as well as a reasonably usable caller
experience this means that such factories must internally `remember`
as needed.
This might be for the best. When this pattern is used for complex
hoisted state objects that require composition-based construction, it
removes the need for an explicit `remember {}` on behalf of the caller
and the right thing happens with simpler calling code. On the other
hand, this may end up being confusing for developers who may not easily
recognize when something needs to be `remember`ed.
Current builds of the Android Studio plugin highlight composable calls
in bright green and once an outstanding plugin bug is fixed, attempting
to memo the result of one will be a compiler error. This might be
enough. If not, we should explore other tooling (lint?) or conventions
(`rememberFoo` for such factories?) to help aid in understanding
and discoverability.
Relnote: Scrollers now exhibit native Android fling motion behavior.
Bug: 147493715
Test: existing; manual
Change-Id: I922af68261f3f1e81538a98a7575603e531fc035
M ui/integration-tests/test/src/main/java/androidx/ui/integration/test/foundation/NestedScrollerTestCase.kt
M ui/integration-tests/test/src/main/java/androidx/ui/integration/test/foundation/ScrollerTestCase.kt
M ui/ui-foundation/api/0.1.0-dev04.txt
M ui/ui-foundation/api/current.txt
M ui/ui-foundation/api/public_plus_experimental_0.1.0-dev04.txt
M ui/ui-foundation/api/public_plus_experimental_current.txt
M ui/ui-foundation/api/restricted_0.1.0-dev04.txt
M ui/ui-foundation/api/restricted_current.txt
M ui/ui-foundation/integration-tests/samples/src/main/java/androidx/ui/foundation/samples/ScrollerSamples.kt
M ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/ScrollerTest.kt
M ui/ui-foundation/src/main/java/androidx/ui/foundation/Scroller.kt
A ui/ui-foundation/src/main/java/androidx/ui/foundation/animation/AndroidFlingCalculator.kt
A ui/ui-foundation/src/main/java/androidx/ui/foundation/animation/AndroidFlingDecayAnimation.kt
A ui/ui-foundation/src/main/java/androidx/ui/foundation/animation/AndroidFlingSpline.kt
M ui/ui-foundation/src/main/java/androidx/ui/foundation/animation/FlingConfig.kt
M ui/ui-material/integration-tests/material-demos/src/main/java/androidx/ui/material/demos/DynamicThemeActivity.kt
M ui/ui-material/src/main/java/androidx/ui/material/Tab.kt
https://android-review.googlesource.com/1206049
Branch: androidx-master-dev
commit f27971d31a5947e0d0d38d40b99c96d3a76e2188
Author: Adam Powell <adamp@google.com>
Date: Fri Jan 10 13:25:52 2020
Integrate native fling spline into Compose UI
Extract the native Android fling spline from android.widget.Scroller
and move it into Compose UI foundation in such a way that it can be
driven via an external time source.
Future work will delegate to a similarly factored version of this
in AOSP frameworks/base for a future platform release for forward
compatibility with any future platform behavior changes.
Thanks to the nature of the source material, testing this port for
correct behavior will necessarily involve an instrumentation test and
comparing values over "real" time with the output of
android.widget.Scroller.
This commit also starts spreading a new-ish pattern of @Composable
factory functions that read default or configuration-specific values
from the composition. An interesting outcome of this is that the result
of such a factory may not be the content of a `remember {}` block - the
`remember` body is not itself `@Composable`. In order to preserve
expected object instance behavior as well as a reasonably usable caller
experience this means that such factories must internally `remember`
as needed.
This might be for the best. When this pattern is used for complex
hoisted state objects that require composition-based construction, it
removes the need for an explicit `remember {}` on behalf of the caller
and the right thing happens with simpler calling code. On the other
hand, this may end up being confusing for developers who may not easily
recognize when something needs to be `remember`ed.
Current builds of the Android Studio plugin highlight composable calls
in bright green and once an outstanding plugin bug is fixed, attempting
to memo the result of one will be a compiler error. This might be
enough. If not, we should explore other tooling (lint?) or conventions
(`rememberFoo` for such factories?) to help aid in understanding
and discoverability.
Relnote: Scrollers now exhibit native Android fling motion behavior.
Bug: 147493715
Test: existing; manual
Change-Id: I922af68261f3f1e81538a98a7575603e531fc035
M ui/integration-tests/test/src/main/java/androidx/ui/integration/test/foundation/NestedScrollerTestCase.kt
M ui/integration-tests/test/src/main/java/androidx/ui/integration/test/foundation/ScrollerTestCase.kt
M ui/ui-foundation/api/0.1.0-dev04.txt
M ui/ui-foundation/api/current.txt
M ui/ui-foundation/api/public_plus_experimental_0.1.0-dev04.txt
M ui/ui-foundation/api/public_plus_experimental_current.txt
M ui/ui-foundation/api/restricted_0.1.0-dev04.txt
M ui/ui-foundation/api/restricted_current.txt
M ui/ui-foundation/integration-tests/samples/src/main/java/androidx/ui/foundation/samples/ScrollerSamples.kt
M ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/ScrollerTest.kt
M ui/ui-foundation/src/main/java/androidx/ui/foundation/Scroller.kt
A ui/ui-foundation/src/main/java/androidx/ui/foundation/animation/AndroidFlingCalculator.kt
A ui/ui-foundation/src/main/java/androidx/ui/foundation/animation/AndroidFlingDecayAnimation.kt
A ui/ui-foundation/src/main/java/androidx/ui/foundation/animation/AndroidFlingSpline.kt
M ui/ui-foundation/src/main/java/androidx/ui/foundation/animation/FlingConfig.kt
M ui/ui-material/integration-tests/material-demos/src/main/java/androidx/ui/material/demos/DynamicThemeActivity.kt
M ui/ui-material/src/main/java/androidx/ui/material/Tab.kt
Description
Compose UI should match Android's native fling scrolling behavior, delegating to the platform for forward compatibility where possible.
Android's scrolling components,
android.widget.Scroller
andandroid.widget.OverScroller
internally use the static clock provided byAnimationUtils
, making it infeasible to use these components natively in Compose UI without changes.This work will proceed in several steps:
Scroller
such that it can be used in a testable, clock-agnostic manner.DecayAnimation
based on this extracted spline.VerticalScroller
and similar rather than the exponential decay animation.frameworks/base