-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implemented the new counter widget #6306
Conversation
collect_app/src/main/java/org/odk/collect/android/widgets/CounterWidget.kt
Outdated
Show resolved
Hide resolved
collect_app/src/main/java/org/odk/collect/android/widgets/CounterWidget.kt
Outdated
Show resolved
Hide resolved
collect_app/src/test/java/org/odk/collect/android/widgets/CounterWidgetTest.kt
Show resolved
Hide resolved
collect_app/src/test/java/org/odk/collect/android/widgets/CounterWidgetTest.kt
Show resolved
Hide resolved
This would be the only question type that does not support no-answers. We support no-answers even in range widgets, and the reason we display some question types using dialogs (like dates, ranking etc.) was also to allow leaving such a question unanswered. I think it's important to make it consistent with other question types.
Ok, I will try to increase the size.
Yes, this happens because every element in that layout (the minus button, the plus button, and the value text) has its own border, resulting in doubled adjacent lines. I didn't think it would be noticeable, but I can try to improve it.
It's the same (
You mean I should use the same color for the fill and the border? |
Ah interesting point. My thinking was zero could be considered no-answer, but zero could be an answer.
ah okay!
yup, I think we should see if that helps with the contrast. |
Done. I've also increased the font size from 20sp to 25sp. Please let me know if it looks better. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great
collect_app/src/main/java/org/odk/collect/android/widgets/CounterWidget.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just that at the moment, but I'll have a proper last look later.
android:layout_height="0dp" | ||
android:gravity="center" | ||
android:background="@drawable/counter_value_background" | ||
android:textSize="25sp" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@grzesiek2010 @alyblenkin let's work out a Material 3 text appearance for this to use instead of a custom text size. If there isn't one that feels right, we can tweak one of the appearances to suit us better.
Use disparate text sizes like this will cause us problems down the line when we change themes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
textAppearanceHeadlineSmall
looks nice.
<item> | ||
<shape android:shape="rectangle"> | ||
<corners | ||
android:topLeftRadius="10dp" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this and the plus button, is there a shape appearance theme attribute we could use instead of a hardcoded one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what would work best but the extended FAB or segmented buttons have a similar design.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dialogCornerRadius
looks like a good fit here.
57de8e2
to
7997eb1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! I hope we add haptic feedback one day :)
Tested with Success! Verified on a device with Android 10 Verified Cases:
|
Tested with Success Verified on device with Android 14 |
Closes #6137
Why is this the best possible solution? Were any other approaches considered?
The new widget is implemented in the same way as the existing widgets, so there is nothing significant to discuss here. The only additional consideration while working on this issue was the potential use of Jetpack Compose. To implement the layout for this new widget using XML, I had to create the layout file and three separate background XML files. This example highlights the complexity of using XML for layouts. Although I am not an expert in Jetpack Compose, I believe it would simplify the process considerably.
However, I propose we create a separate issue to discuss adopting Jetpack Compose and setting it up, as it might require more detailed consideration.
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?
This adds a new question type. It's an isolated change so we can focus on that new question type. The existing question types should not be at risk.
Do we need any specific form for testing your changes? If so, please attach one.
I used this one: counter.xlsx
Does this change require updates to documentation? If so, please file an issue here and include the link below.
Yes: getodk/docs#1843
Before submitting this PR, please make sure you have:
./gradlew connectedAndroidTest
(or./gradlew testLab
) and confirmed all checks still passDateFormatsTest