Status Update
Comments
ae...@google.com <ae...@google.com>
ke...@google.com <ke...@google.com>
ap...@google.com <ap...@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
na...@google.com <na...@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
lo...@gmail.com <lo...@gmail.com> #4
Unfortunately, this fix is not sufficient. We got the first crash with the updated version:
java.lang.IllegalArgumentException: start(3467.0002) must be <= endInclusive(3467.0)
Note that our slider usually has to take care of 4 to 5 digit numbers (prices). I think there will probably always be a case where the selected tolerance is not large enough if you increase the slider value range accordingly.
ty...@gmail.com <ty...@gmail.com> #5
I am encountering this crash as well. In our case we use the range slider for a min and max year selector. When sliding the min or max to be equal to the other then it crashes. This is what our slider code looks like.
Column(modifier = Modifier.padding(horizontal = 16.dp)) {
var sliderRange = (state.minYear.toFloat())..state.maxYear.toFloat()
var cachedMin by remember { mutableIntStateOf(YearEstablishedFilterState.MIN_YEAR) }
var cachedMax by remember { mutableIntStateOf(Year.now().value) }
RangeSlider(
value = sliderRange,
valueRange = YearEstablishedFilterState.MIN_YEAR.toFloat()..Year.now().value.toFloat(),
steps = Year.now().value - YearEstablishedFilterState.MIN_YEAR,
colors = SliderDefaults.colors(
thumbColor = ExtendedTheme.colors.secondaryText,
activeTrackColor = ExtendedTheme.colors.secondaryText,
inactiveTrackColor = ExtendedTheme.colors.divider,
activeTickColor = ExtendedTheme.colors.secondaryText,
inactiveTickColor = ExtendedTheme.colors.divider
),
onValueChange = { range ->
sliderRange = range
val minYear = range.start.roundToInt()
val maxYear = range.endInclusive.roundToInt()
if (minYear != cachedMin || maxYear != cachedMax) {
haptic.performHapticFeedback(HapticFeedbackType.TextHandleMove)
cachedMin = minYear
cachedMax = maxYear
}
onRangeChanged(
minYear,
maxYear
)
}
)
}
lo...@gmail.com <lo...@gmail.com> #6
I already created a follow up ticket:
Description
Jetpack Compose version: 2024.01.00
Jetpack Compose component(s) used:
RangeSlider
Android Studio Build: Build #AI-231.9392.1.2311.11330709, built on January 19, 2024
Kotlin version: 1.9.22
Material 3 version : 1.2.0-beta02
Steps to Reproduce or Code Sample to Reproduce:
RangeSlider
SliderRange
is failing therequire(isUnspecified || start <= endInclusive )
check on line 2120 due to rounding error as can be seen in the first line of the stack trace, wherestart
is only 0.00005 of a pixel greater than theendInclusive
Suggestion of a solution to fix this error
It is a known issue that floating point calculation is inherently imprecise in a sense that the resulting value is correct up to a specific decimal position. I suspect that the same is happening here when the start point and end point coordinates are being calculated. The
start
point may have gotten593.6667500000000000000000...
rounded to593.66675
andendInclusive
may have gotten593.66674999999999999999....
rounded to593.6667
.When doing floating point calculations for UI it is imperative to have a consistent cut off strategy for how many decimal places should be considered system-wise for rendering. In my experience 2 decimal places are ample for pixel-related arithmetics; anything beyond makes no visual difference.
So trim pixel values to only carry 2 decimal positions and discard everything from 3rd decimal position onwards. (Do NOT round the values!)
Following the strategy above system-wide for UI pixel-related arithmetics, will make sure that elusive errors like this do not happen.
Stack trace: