Refactor range widgets to use a new Jetpack Compose slider#7077
Refactor range widgets to use a new Jetpack Compose slider#7077grzesiek2010 wants to merge 29 commits intogetodk:v2026.2.xfrom
Conversation
seadowg
left a comment
There was a problem hiding this comment.
Managed to have a read through the Compose code and so just leaving thoughts on that for now!
collect_app/src/main/java/org/odk/collect/android/widgets/range/RangeDecimalWidget.kt
Outdated
Show resolved
Hide resolved
collect_app/src/main/java/org/odk/collect/android/widgets/range/RangeSlider.kt
Show resolved
Hide resolved
collect_app/src/main/java/org/odk/collect/android/widgets/range/RangeSlider.kt
Show resolved
Hide resolved
collect_app/src/main/java/org/odk/collect/android/widgets/range/RangeSlider.kt
Show resolved
Hide resolved
collect_app/src/main/java/org/odk/collect/android/widgets/range/RangeSlider.kt
Outdated
Show resolved
Hide resolved
collect_app/src/main/java/org/odk/collect/android/widgets/range/RangeSlider.kt
Show resolved
Hide resolved
ff97f3c to
79c86d0
Compare
There was a problem hiding this comment.
@grzesiek2010 as we discussed, this should now target v2026.2.x instead of master
collect_app/src/main/java/org/odk/collect/android/widgets/range/Track.kt
Show resolved
Hide resolved
collect_app/src/main/java/org/odk/collect/android/widgets/range/RangeSliderFactory.kt
Outdated
Show resolved
Hide resolved
collect_app/src/main/java/org/odk/collect/android/widgets/range/RangeSlider.kt
Outdated
Show resolved
Hide resolved
8733672 to
d1489ac
Compare
d1489ac to
59cdc5c
Compare
collect_app/src/main/java/org/odk/collect/android/widgets/range/VerticalRangeSlider.kt
Outdated
Show resolved
Hide resolved
|
|
||
| @Composable | ||
| fun Thumb(value: Float?) { | ||
| val sliderThumbContentDescription = stringResource(org.odk.collect.strings.R.string.slider_thumb) |
There was a problem hiding this comment.
Is the main motivation for giving the individual slider items content descriptions for tests? I'm wondering whether that's the right approach. Looking at the accessibility guide for Sliders (https://m3.material.io/components/sliders/accessibility), it seems like the labelling (content description) should usually be related to the value being changed (which would be the question text in our widget case). Do you think we should switch to using other Semantics like Role for testing instead?
collect_app/src/test/java/org/odk/collect/android/widgets/range/RangeDecimalWidgetTest.kt
Outdated
Show resolved
Hide resolved
collect_app/src/test/java/org/odk/collect/android/widgets/range/RangeDecimalWidgetTest.kt
Outdated
Show resolved
Hide resolved
|
The issue #6424 changed a bit in the PR. Now step 0.5 in a range widget shows unexpected values (the 0.5 issue doesn't occur in the store version 2026.1.0). Step to reproduce:
|
Yes, there is a difference between sliders in Android MDC and Jetpack Compose. In Android MDC, the thumb had some margin and was not positioned exactly at the start or end of the slider. In Jetpack Compose, this behavior has changed, and the ticks should now be placed directly at the edges, without any padding. |
It seems it still occurs in some numbers.
|



Work toward #7013
Closes: #6424
Why is this the best possible solution? Were any other approaches considered?
With the classic View-based UI, building a range widget using the built-in slider has been challenging. We support a no-value state, which the slider itself does not allow, so we had to work around it by hiding the thumb and adjusting styles and colors. Issue #7013 requires even more customization, so the best approach is to first switch to Jetpack Compose, which gives us much greater flexibility in customizing the layout.
How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?
There may be some visual differences between the old and new implementations, but the behavior should remain unchanged. Please test both integer and decimal range questions carefully. Below is a list of issues we’ve encountered with these questions so far, which may be helpful:
Do we need any specific form for testing your changes? If so, please attach one.
Any form with range integer and decimal questions. You can find some of them linked in the issues mentioned above.
Does this change require updates to documentation? If so, please file an issue here and include the link below.
No.
Before submitting this PR, please make sure you have:
./gradlew connectedAndroidTest(or./gradlew testLab) and confirmed all checks still passDateFormatsTest