Status Update
Comments
nu...@gmail.com <nu...@gmail.com> #2
Project: platform/frameworks/support
Branch: androidx-main
Author: Louis Pullen-Freilich <
Link:
Adds OverscrollEffect#withoutDrawing and OverscrollEffect#withoutEventHandling
Expand for full commit details
Adds OverscrollEffect#withoutDrawing and OverscrollEffect#withoutEventHandling
These APIs allow overscroll to have events dispatched to it by one component, and rendered in a separate component.
Fixes: b/266550551
Fixes: b/204650733
Fixes: b/255554340
Fixes: b/229537244
Test: OverscrollTest
Relnote: "Adds OverscrollEffect#withoutDrawing and OverscrollEffect#withoutEventHandling APIs - these APIs create a wrapped instance of the provided overscroll effect that doesn't draw / handle events respectively, which allows for rendering overscroll in a separate component from the component that is dispatching events. For example, disabling drawing the overscroll inside a lazy list, and then drawing the overscroll separately on top / elsewhere."
Change-Id: Idbb3d91546b49c1987a041f959bce4b2b09a9f61
Files:
- M
compose/foundation/foundation/api/current.txt
- M
compose/foundation/foundation/api/restricted_current.txt
- M
compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/OverscrollDemo.kt
- M
compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/OverscrollSample.kt
- M
compose/foundation/foundation/src/androidInstrumentedTest/kotlin/androidx/compose/foundation/OverscrollTest.kt
- M
compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/Overscroll.kt
Hash: f64e25b7a473c757d080521e7dd97b3f6670f60d
Date: Fri Nov 01 18:43:56 2024
kl...@google.com <kl...@google.com> #3
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.compose.foundation:foundation:1.8.0-alpha06
androidx.compose.foundation:foundation-android:1.8.0-alpha06
androidx.compose.foundation:foundation-jvmstubs:1.8.0-alpha06
androidx.compose.foundation:foundation-linuxx64stubs:1.8.0-alpha06
kl...@google.com <kl...@google.com> #4
Does this work as expected for you with Views? I was able to reproduce this bug with views as well – an EditText
inside a ScrollView
will not cause the view to scroll to keep the EditText
in view if the keyboard covers it.
kl...@google.com <kl...@google.com> #5
We've been taking a closer look at this bug and considered alternatives to fixing it, which require larger changes to the Compose keyboard controller and BringIntoView APIs.
Unfortunately since Compose 1.2 is already in beta, the API is effectively frozen. We could explore more hacky ways to fix it in 1.2, but considering this behaviour matches what happens with Views, we decided it was better to fix properly with more time as opposed to fix it with a hack, increasing the tech debt and potentially creating other bugs.
As a workaround, either don't call setDecorFitsSystemWindows(false)
for now, or if you do, use ViewCompat.setWindowInsetsAnimationCallback
BringIntoViewRequester
API.
kl...@google.com <kl...@google.com>
ap...@google.com <ap...@google.com> #6
Branch: androidx-main
commit d15475fecc931bf1044888b10eddd1a13db2e64c
Author: Zach Klippenstein <klippenstein@google.com>
Date: Mon May 23 15:17:11 2022
Improve WindowInsets.ime kdoc to include API 23.
The WindowInsets.ime value is actually supported on API 23+,
so I updated the kdoc to say that. However, it's only *animated* on 30+,
so I clarified that in the kdoc as well.
This change also adds a demo to the demo app that shows the actual
insets.
Bug:
Test: n/a, only a docs change
Relnote: "Clarified the documentation for `WindowInsets.ime` to state
that `ime` insets are reported as far back as API 23, but only
_animated_ on 30+."
Change-Id: Ia7fc002bde64074be7a176121483bff3017f24a8
A compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/WindowInsetsDemo.kt
M compose/foundation/foundation-layout/src/androidMain/kotlin/androidx/compose/foundation/layout/WindowInsets.android.kt
M compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/FoundationDemos.kt
ke...@gmail.com <ke...@gmail.com> #7
I'm trying the workaround, but the ViewCompat.setWindowInsetsAnimationCallback
is already set on the Compose side.
Is it okay to overwrite this?
ke...@gmail.com <ke...@gmail.com> #8
I realized that overwriting setWindowInsetsAnimationCallback
disables ime animation on all screens when using navigation-compose.
Below code is the workaround I tried.
var text by remember { mutableStateOf("") }
val view = LocalView.current
val bringIntoViewRequester = remember { BringIntoViewRequester() }
val coroutineScope = rememberCoroutineScope()
// Workaround: Call it first to overwrite the setWindowInsetsAnimationCallback set by Compose.
WindowInsets.ime
DisposableEffect(view) {
ViewCompat.setWindowInsetsAnimationCallback(
view,
object : WindowInsetsAnimationCompat.Callback(DISPATCH_MODE_STOP) {
override fun onProgress(
insets: WindowInsetsCompat,
runningAnimations: MutableList<WindowInsetsAnimationCompat>
): WindowInsetsCompat {
return WindowInsetsCompat.CONSUMED
}
override fun onEnd(animation: WindowInsetsAnimationCompat) {
val isImeVisible =
WindowInsetsCompat.toWindowInsetsCompat(view.rootWindowInsets)
.isVisible(WindowInsetsCompat.Type.ime())
if (isImeVisible) {
coroutineScope.launch {
bringIntoViewRequester.bringIntoView()
}
}
}
}
)
onDispose {
ViewCompat.setWindowInsetsAnimationCallback(view, null)
}
}
Column(
modifier = Modifier
.fillMaxSize()
.imePadding()
.verticalScroll(rememberScrollState())
) {
// ...
TextField(
value = text,
onValueChange = { text = it },
modifier = Modifier
.bringIntoViewRequester(bringIntoViewRequester)
)
}
It may be enough to just disable the setWindowInsetsAnimationCallback
set by Compose.
val view = LocalView.current
// Workaround: Call it first to overwrite the setWindowInsetsAnimationCallback set by Compose.
WindowInsets.ime
LaunchedEffect(Unit) {
ViewCompat.setWindowInsetsAnimationCallback(view, null)
}
ap...@google.com <ap...@google.com> #10
Branch: androidx-main
commit 787a2f8056da406e0631a6c27b3ea67252e05f46
Author: Zach Klippenstein <klippenstein@google.com>
Date: Thu Jun 23 15:15:48 2022
Update ScrollState's maxValue in measure, not place.
The old behavior, setting maxValue in the placement pass, prevented
Modifier.scrollable from dispatching scroll events in onRemeasured,
which is called after the measurement pass but before placement.
Test: ./gradlew :compose:f:f:cDAT
Bug:
Change-Id: I68ad542100438c8a6b4430827f28c2ccbfa6a037
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/Scroll.kt
M compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/ScrollTest.kt
ap...@google.com <ap...@google.com> #11
Branch: androidx-main
commit cb90e2addc50ff6f4e7f48df0dc0a03343898ccb
Author: Zach Klippenstein <klippenstein@google.com>
Date: Wed Jun 15 12:13:03 2022
Fix scrollable focused child tracking.
When calculating whether we need to scroll to keep the focused child
in-view after the scrollable viewport is resized, we were using the
bounds of the focused child to figure out if it was previously visible.
That was incorrect, because if the viewport is animating while the
scroll animation is running, it's possible for the viewport to shrink
fast enough that the focused child isn't actually visible, but would
have eventually became visible after the animation, so we need to
continue to animate.
This approach is documented as Option 0 in the design doc:
Note that while this fixes
end up in the correct final state, it makes
since it looks like the scroll animation doesn't start at all until the
viewport animation stops.
Fixes:
Test: Manually using the 'Foundation > Scrollable with focused child"
and "Text > Input fields > Inside scrollable" demos."
Test: ./gradlew :compose:f:f:cDAT
Relnote: "When a scrollable has a focused child, it will now correctly
scroll to keep the focused child in view when its size is decreased,
even when the size is animated."
Change-Id: I8086717b14174e566b299f2643f1dd6c0b250773
M compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/ScrollableFocusableInteractionTest.kt
M compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/ScrollableFocusedChildDemo.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/gestures/Scrollable.kt
ap...@google.com <ap...@google.com> #12
Branch: androidx-main
commit 7e77bb541331ce0d62cabad732e43eca41ac978a
Author: Zach Klippenstein <klippenstein@google.com>
Date: Wed Jul 06 11:42:21 2022
Move BringIntoView queueing into the scrollable implementation.
This change removes the over-complicated coroutine-based queuing of
bringIntoView requests in the BringIntoViewResponder, which now is only
responsible for dispatching the request to the actual responder
interface and propagating it up the modifier local chain.
This gives the actual responder implementation (i.e. in
Modifier.scrollable) all the information about conflicting
requests and manage the queue of ongoing requests with an actual,
explicit queue that is much more straightforward than the previous
coroutine job chaining mess. Each request is stored in an actual list
along with the continuation from the request, and requests are
explicitly resumed or cancelled when needed. This also makes debugging
easier, because there's an actual queue data structure we can inspect,
which contains all the actual information about each request.
It also completely changes how the scroll animation is performed.
On every frame, the scroll target is recomputed to account for
changes in the viewport size, the request size, or the set of active
requests since the last frame, while still keeping the animation
smooth. The animation logic is in its own class, which allows a single
suspend animation call to animate to a target value that can be updated
while the animation is running.
While this change is a valuable cleanup on its own, it also fixes
focused child tracking with an explicit API for keeping a thing in view.
Fixes:
Bug:
Bug:
Bug:
Bug:
Test: ScrollableFocusableInteractionTest
Test: androidx.compose.foundation.relocation.*
Test: RebasableAnimationStateTest
Test: BringIntoViewRequestPriorityQueueTest
Relnote: "Rewrote the way scrollables respond to
`bringIntoViewRequesters` and focusables to better model the
complexity of those operations and handle more edge cases."
Change-Id: I2e5fec8c8582a8fe1f191e37fd0f4f9165678664
M compose/foundation/foundation/api/current.txt
M compose/foundation/foundation/api/public_plus_experimental_current.txt
M compose/foundation/foundation/api/restricted_current.txt
M compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/FoundationDemos.kt
M compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/ScrollableFocusedChildDemo.kt
A compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/relocation/BringIntoViewResponderDemo.kt
M compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/relocation/BringRectangleIntoViewDemo.kt
M compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/BringIntoViewSamples.kt
M compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/ScrollableFocusableInteractionTest.kt
M compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/list/LazyListFocusMoveTest.kt
M compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/relocation/BringIntoViewResponderTest.kt
M compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/relocation/BringIntoViewScrollableInteractionTest.kt
A compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/gestures/BringIntoViewRequestPriorityQueue.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/gestures/ContentInViewModifier.kt
A compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/gestures/UpdatableAnimationState.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/relocation/BringIntoViewResponder.kt
A compose/foundation/foundation/src/test/kotlin/androidx/compose/foundation/gestures/BringIntoViewRequestPriorityQueueTest.kt
A compose/foundation/foundation/src/test/kotlin/androidx/compose/foundation/gestures/UpdatableAnimationStateTest.kt
na...@google.com <na...@google.com> #13
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.compose.foundation:foundation:1.4.0-alpha04
Description
Reported in https://b.corp.google.com/issues/192043120#comment81 .