Status Update
Comments
st...@google.com <st...@google.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
fe...@gmail.com <fe...@gmail.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
st...@google.com <st...@google.com>
st...@google.com <st...@google.com>
ss...@google.com <ss...@google.com> #4
We have a simple reproducition involving only the HorizontalPager & focus, trying to find out the root cause.
fe...@gmail.com <fe...@gmail.com> #5
st...@google.com <st...@google.com> #6
I'll have a look in this sprint, sorry for the slow response.
st...@google.com <st...@google.com> #7
I wrote a simple repro of this:
A couple of observations:
- it occurs with Pager + LazyColumn as well as Pager + ScalingLazyColumn (so isn't Wear specific)
- if you delay clicking/scrolling, then the UI does respond to the clicks first time. Could be that there's a Pager animation running on the main thread that's blocking the gestures.
@OptIn(ExperimentalFoundationApi::class)
@Composable
fun PagerWithIndicator(swipeState: SwipeToDismissBoxState) {
val pagesCount = 3
val pagerState = rememberPagerState { pagesCount }
var background by remember { mutableStateOf(Color.Black) }
var selectedPage by remember { mutableIntStateOf(0) }
val animatedSelectedPage by animateFloatAsState(
targetValue = pagerState.targetPage.toFloat(), label = "page-indicator",
) {
selectedPage = it.toInt()
}
val pageIndicatorState: PageIndicatorState = remember {
object : PageIndicatorState {
override val pageOffset: Float
get() = animatedSelectedPage - selectedPage
override val selectedPage: Int
get() = selectedPage
override val pageCount: Int
get() = pagesCount
}
}
Box(modifier = Modifier.background(background)) {
HorizontalPager(
modifier = Modifier.fillMaxSize().edgeSwipeToDismiss(swipeState),
state = pagerState,
) {page ->
val scrollState = rememberScalingLazyListState()
ScalingLazyColumn(
// val scrollState = rememberLazyListState()
// LazyColumn(
state = scrollState,
modifier = Modifier.fillMaxWidth()
) {
item {
ListHeader { Text("Page $page") }
}
items(4) {
Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.Center) {
Chip(
onClick = {
background =
if (background == Color.Black) Color.DarkGray else Color.Black
},
label = {
Text(text = "Click", color = Color.Black)
}
)
}
}
}
}
HorizontalPageIndicator(
pageIndicatorState = pageIndicatorState,
)
}
}
st...@google.com <st...@google.com> #8
As a workaround, it's possible to use pagerState.isScrollInProgress to determine whether the UI is ready to receive clicks. In my repro, I disabled the buttons until the scroll was complete:
Alternatively, you could experiment with the fling behavior, as the defaults do seem to take longer to settle that I'd expect -
For example, I've just tried setting HorizontalPager(state = pagerState, flingBehavior = PagerDefaults.flingBehavior(pagerState, snapAnimationSpec = tween(150, 0)))
and that eliminates the wait in my demo between the scroll visibly finishing and the buttons being re-enabled.
You could also try Horologists HorizontalPagerDefaults.flingBehavior, but I think that still takes a little too long for the scroll to finish.
st...@google.com <st...@google.com> #9
From discussions,
Meanwhile, please try the workaround to reduce the duration of the fling animation spec suggested in
st...@google.com <st...@google.com> #10
This is a screencast with PagerDefaults.flingBehavior(pagerState, snapAnimationSpec = tween(150, 0))
ys...@google.com <ys...@google.com> #11
Does this have some noticeable impact in some edge cases? Does it look jarring if you cross the snap threshold but the page is in the middle?
Basically, what's the down side?
Overall, this looks great to me.
st...@google.com <st...@google.com> #12
Thanks Yuri - here's a screencast of edge-case snapping, still looks ok IMO:
pe...@google.com <pe...@google.com> #13
would be great to test this on device, do we have an apk?
ap...@google.com <ap...@google.com> #14
Branch: androidx-main
commit f7ffa0cda0ccd10700ab00ac30ef57003077173a
Author: stevebower <stevebower@google.com>
Date: Tue Dec 12 12:33:58 2023
Update HorizontalPager demo to show ScalingLazyColumn with custom animation spec
Test: N/A
Bug: 303807950
Relnote: N/A
Change-Id: I9dc060b0cc5120dbff11b4d68f94375ed5430a35
M wear/compose/integration-tests/demos/src/main/java/androidx/wear/compose/integration/demos/HorizontalPageIndicatorDemo.kt
M wear/compose/integration-tests/demos/src/main/java/androidx/wear/compose/integration/demos/MaterialDemos.kt
pe...@google.com <pe...@google.com> #15
Tested on device and looks good from UX side
st...@google.com <st...@google.com> #16
Made an update to horologist to recommend PagerDefaults.flingBehavior(pagerState, snapAnimationSpec = tween(150, 0))
in
fe...@gmail.com <fe...@gmail.com> #17
fe...@gmail.com <fe...@gmail.com> #18
ref:
st...@google.com <st...@google.com> #19
Nothing seems obviously wrong. This is our demo, which definitely allows the user to tap first time:
@Composable
fun PagerWithIndicator(swipeState: SwipeToDismissBoxState) {
val pagesCount = 3
val pagerState = rememberPagerState { pagesCount }
var background by remember { mutableStateOf(Color.Black) }
var selectedPage by remember { mutableIntStateOf(0) }
val animatedSelectedPage by animateFloatAsState(
targetValue = pagerState.targetPage.toFloat(), label = "page-indicator",
) {
selectedPage = it.toInt()
}
val pageIndicatorState: PageIndicatorState = remember {
object : PageIndicatorState {
override val pageOffset: Float
get() = animatedSelectedPage - selectedPage
override val selectedPage: Int
get() = selectedPage
override val pageCount: Int
get() = pagesCount
}
}
Box(modifier = Modifier.background(background)) {
HorizontalPager(
modifier = Modifier.fillMaxSize().edgeSwipeToDismiss(swipeState),
state = pagerState,
flingBehavior =
PagerDefaults.flingBehavior(
pagerState,
snapAnimationSpec = tween(150, 0),
)
) { page ->
val scrollState = rememberScalingLazyListState()
ScalingLazyColumn(
state = scrollState,
modifier = Modifier.fillMaxWidth()
) {
item {
ListHeader { Text("Page $page") }
}
items(4) {
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.Center
) {
Chip(
onClick = {
background =
if (background == Color.Black) Color.DarkGray else Color.Black
},
label = {
Text(text = "Click", color = Color.Black)
},
enabled = !pagerState.isScrollInProgress
)
}
}
}
}
HorizontalPageIndicator(
pageIndicatorState = pageIndicatorState,
)
}
}
fe...@gmail.com <fe...@gmail.com> #20
I tried your code, but it keeps crashing after a swipe (to change page).
FATAL EXCEPTION: main
Process: com.feduss.horizontalpagerbug, PID: 6215
java.lang.IllegalStateException: The offset was read before being initialized. Did you access the offset in a phase before layout, like effects or composition?
at androidx.wear.compose.foundation.SwipeableV2State.requireOffset(SwipeableV2.kt:299)
at androidx.wear.compose.foundation.SwipeableV2State.settle(SwipeableV2.kt:457)
at androidx.wear.compose.foundation.SwipeToDismissBoxState$Companion$edgeNestedScrollConnection$1.onPostFling-RZ2iAVY(BasicSwipeToDismissBox.kt:380)
at androidx.compose.ui.input.nestedscroll.NestedScrollNode.onPostFling-RZ2iAVY(NestedScrollNode.kt:105)
at androidx.compose.ui.input.nestedscroll.NestedScrollDispatcher.dispatchPostFling-RZ2iAVY(NestedScrollModifier.kt:221)
at androidx.compose.foundation.gestures.ScrollingLogic$onDragStopped$performFling$1.invokeSuspend(Scrollable.kt:810)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.internal.ScopeCoroutine.afterResume(Scopes.kt:32)
at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:102)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
at kotlinx.coroutines.internal.ScopeCoroutine.afterResume(Scopes.kt:32)
at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:102)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
at kotlinx.coroutines.UndispatchedCoroutine.afterResume(CoroutineContext.kt:270)
at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:102)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at androidx.compose.ui.platform.AndroidUiDispatcher.performTrampolineDispatch(AndroidUiDispatcher.android.kt:81)
at androidx.compose.ui.platform.AndroidUiDispatcher.access$performTrampolineDispatch(AndroidUiDispatcher.android.kt:41)
at androidx.compose.ui.platform.AndroidUiDispatcher$dispatchCallback$1.run(AndroidUiDispatcher.android.kt:57)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7898)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [androidx.compose.ui.platform.MotionDurationScaleImpl@133984, androidx.compose.runtime.BroadcastFrameClock@3cde56d, StandaloneCoroutine{Cancelling}@9e015a2, AndroidUiDispatcher@84cc233]
---------------------------------
implementation ("androidx.wear.compose:compose-ui-tooling:1.3.0-beta02")
implementation("androidx.wear.compose:compose-foundation:1.3.0-beta02")
implementation("androidx.wear.compose:compose-material:1.3.0-beta02")
implementation("androidx.wear.compose:compose-navigation:1.3.0-beta02")
I also tested with latest stable version 1.2.1, and i got the same error.
st...@google.com <st...@google.com>
ag...@google.com <ag...@google.com>
st...@google.com <st...@google.com>
le...@google.com <le...@google.com> #21
Project: platform/frameworks/support Branch: androidx-main
commit 418f3a6588d2384e49d996cebcb2d5678ceeb3ea
Author: Levi Albuquerque
Click on moving list initial issue
Due to an early fix we were prioritizing continuing the scroll of nested lists in any direction when taping on a parent list. The actual intended behavior was to consider nested children that scroll -on the same direction- if the click happened on the said child. In this CL I'm reverting those changes as we will revisit the nested scrolling UX and there will be more benefits to having the original behavior without the issues the fix introduced.
Test: Added test to check behavior.
Relnote: N/A
Fixes: 293777304
Fixes: 289685606
Fixes: 296064317
Bug: 175010956
Bug: 179417109
Change-Id: Ia71ed02e06603c6c27ad4648cfc8e32587397d63
M compose/foundation/foundation/src/androidInstrumentedTest/kotlin/androidx/compose/foundation/ScrollableTest.kt M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/gestures/Scrollable.kt
le...@google.com <le...@google.com> #22
Hey @stevebower @pedrobatista could you verify if this fixes the issue for wear foundation? Thanks!
st...@google.com <st...@google.com> #23
Ok, I'll take a look at this.
st...@google.com <st...@google.com> #24
Still not fixed, if we remove our custom animation override, the pager takes a while to settle:
(edited to upload a gif for ease of reference)
st...@google.com <st...@google.com>
le...@google.com <le...@google.com> #25
Hi @stevebower just bringing the chat conversation we've had to this bug for visibility. In order to update the behavior in Foundation Pager with some good default spring animation (that also works for wear devices) we need wear compose to provide a good visibility threshold to be used here.
st...@google.com <st...@google.com>
ap...@google.com <ap...@google.com> #26
Branch: androidx-main
commit 1f395a390184dad8164957e44bfc1483ffe3f53e
Author: Levi Albuquerque <levima@google.com>
Date: Thu May 09 09:28:40 2024
Improve Pager default snapping animation.
Specifying a visibility threshold for Pager improves the alignment of the visual representation of the end of a snapping operation with the actual PagerState interpretation of a scrolling Pager. It takes now twice less time between the time the Pager "looks settled" with the indication that it stopped scrolling "isScrollInProgress=false" which should signal to the user that they can interact with the screen.
Test: Previous tests should pass.
Fixes: 338710348
Bug: 303807950
Relnote: N/A
Change-Id: I9627a48d53604a0919951fa4dbb74717ba30bd28
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/pager/Pager.kt
ak...@google.com <ak...@google.com>
ap...@google.com <ap...@google.com> #27
Project: platform/frameworks/support
Branch: androidx-main
Author: Aman Khosa <
Link:
Change Wear Compose foundation pager snapAnimationSpec
Expand for full commit details
Change Wear Compose foundation pager snapAnimationSpec
Currently the snapAnimationSpec is set to a tween with a duration
of 150ms. This was set to ensure the Pager settles quickly so that
contents are focused and clickable, see b/345191109.
However a tween animation causes an ugly double jump when flinging
fast to the top or bottom of a SLC inside of a VerticalPager, see
b/349781047.
Changing to a Spring animation with no bounciness and high
stiffness achieves the same behaviour of settling quickly, and
avoids the double jump. Added a test to ensure this is the case.
Bug: 303807950
Bug: 345191109
Bug: 350466286
Bug: 349781047
Test: Added test case to PagerTest.kt
Change-Id: I9bfefca9998e856279d63d2595f3bed0d67639bb
Files:
- M
wear/compose/compose-foundation/src/androidTest/kotlin/androidx/wear/compose/foundation/PagerTest.kt
- M
wear/compose/compose-foundation/src/main/java/androidx/wear/compose/foundation/pager/Pager.kt
Hash: 335faecba455a29d7a21c5e369b7c95ee4a5c1ce
Date: Thu Oct 24 12:42:02 2024
ak...@google.com <ak...@google.com> #28
Please use the Wear HorizontalPager component which settles with a faster animation than the default Compose Foundation HorizontalPager.
gr...@google.com <gr...@google.com> #29
ap...@google.com <ap...@google.com> #30
Project: platform/frameworks/support
Branch: androidx-main
Author: Aman Khosa <
Link:
Change Wear foundation pager snapAnimationSpec
Expand for full commit details
Change Wear foundation pager snapAnimationSpec
Currently the snapAnimationSpec is set to a tween with a duration
of 150ms. This was set to ensure the Pager settles quickly so that
contents are focused and clickable, see b/345191109.
However a tween animation causes an ugly double jump when flinging
fast to the top or bottom of a SLC inside of a VerticalPager, see
b/349781047.
Changing to a Spring animation with no bounciness and high
stiffness achieves the same behaviour of settling quickly, and
avoids the double jump. Added a test to ensure this is the case.
Test to ensure the Pager settles quickly can be ran locally.
Bug: 303807950
Bug: 345191109
Bug: 350466286
Bug: 349781047
Test: Added test case to PagerTest.kt
Relnote: "Change pager snapAnimationSpec from Tween to Spring"
Change-Id: I10d0275b7f3b957af279893d2ed52d63e42b8115
Files:
- M
wear/compose/compose-foundation/api/current.txt
- M
wear/compose/compose-foundation/api/restricted_current.txt
- M
wear/compose/compose-foundation/src/androidTest/kotlin/androidx/wear/compose/foundation/PagerTest.kt
- M
wear/compose/compose-foundation/src/main/java/androidx/wear/compose/foundation/pager/Pager.kt
Hash: 2850a0327fe61851a8f53f70add7b5a0e3b11228
Date: Thu Oct 24 12:42:02 2024
gr...@google.com <gr...@google.com> #31
na...@google.com <na...@google.com> #32
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.wear.compose:compose-foundation:1.5.0-alpha06
Description
Version used: horologist 0.5.7 (Wear Compose 1.3 alpha)...the bug is compose 1.2 stable (horologist v.0.4.x)
Devices/Android versions reproduced on: wear os emulator (sdk 26, 30 and 33)
If this is a bug in the library, we would appreciate if you could attach:
- Sample project to trigger the issue. -->
- A screenrecord or screenshots showing the issue (if UI related). --> See the attachment
Description:
I have a pagerscreen with 4 pages, 3 of those have a scaling lazy column.
I manually implemented 3 differents column state to maintain the scroll state, but i have a focus problem.
In particular, when i switch page with an horizontal swipe, the elements in the page are tappable only after a vertical scroll instead of with the first tap on screen.