Skip to content

Downgrade com.google.android.material to fix the cut-off slider#6987

Merged
seadowg merged 1 commit intogetodk:masterfrom
grzesiek2010:COLLECT-6974
Dec 9, 2025
Merged

Downgrade com.google.android.material to fix the cut-off slider#6987
seadowg merged 1 commit intogetodk:masterfrom
grzesiek2010:COLLECT-6974

Conversation

@grzesiek2010
Copy link
Member

@grzesiek2010 grzesiek2010 commented Dec 9, 2025

Closes #6974

Why is this the best possible solution? Were any other approaches considered?

The issue occurred after upgrading com.google.android.material at the beginning of the current release cycle. The problem is that the slider provided by that dependency does not support null values. There must always be a default value within the start–end range, but we want to support a no value state, just like in every other question type.

To achieve this, we created an extension of the slider class and tried to mimic that behavior by setting the value to the range’s start while hiding the thumb see https://github.com/getodk/collect/blob/f725a3bf4aa6da2b59079d8596dd3e25c42d587c/collect_app/src/main/java/org/odk/collect/android/views/TrackingTouchSlider.kt. It looks like in the newest version the way the slider is drawn has changed, and now the space behind the thumb is not drawn at all. As a result, when we hide it, a blank gap appears, making the slider look cut off.

Unfortunately, there’s no easy fix for this, so the best option for now seems to be downgrading to the version that worked for us previously.

I think we may need to consider building our own slider if we want to keep supporting no value states. The current solution with hiding the thumb is already a workaround, and even if we found a way to fill the blank space behind it, it would be convoluted. This might actually be a good moment to consider implementing our own slider entirely, especially since we’re also thinking about adding a new appearance for the range question type that supports translatable labels.

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?

It should simply fix the issue. We don't need to spend time testing the behavior of range question types, since the only change is reverting to the previously well-tested version of com.google.android.material.

Do we need any specific form for testing your changes? If so, please attach one.

No.

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:

  • added or modified tests for any new or changed behavior
  • run ./gradlew connectedAndroidTest (or ./gradlew testLab) and confirmed all checks still pass
  • added a comment above any new strings describing it for translators
  • added any new strings with date formatting to DateFormatsTest
  • verified that any code or assets from external sources are properly credited in comments and/or in the about file.
  • verified that any new UI elements use theme colors. UI Components Style guidelines

@grzesiek2010 grzesiek2010 requested a review from seadowg December 9, 2025 09:44
@seadowg seadowg merged commit 1b6a172 into getodk:master Dec 9, 2025
7 checks passed
@lognaturel
Copy link
Member

Filed upstream in case someone else has the requirement: material-components/material-components-android#4984

@lognaturel
Copy link
Member

lognaturel commented Dec 9, 2025

I bet we're going to need to do a custom implementation to support indicators at less frequent intervals (new requirement). Looks like the standard one snaps to the interval indicators: https://m3.material.io/components/sliders/guidelines#b0825f89-5029-43d5-a80c-f0520d0f1186

@WKobus
Copy link

WKobus commented Dec 11, 2025

Tested with success

Verified on Android 16, 10

Verified cases:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Left side of the axis is cut off in range widgets

4 participants