Skip to content
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

Merged
merged 12 commits into from
Aug 21, 2024
Merged

Conversation

grzesiek2010
Copy link
Member

@grzesiek2010 grzesiek2010 commented Aug 5, 2024

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:

  • 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 marked this pull request as ready for review August 5, 2024 15:02
@alyblenkin
Copy link
Collaborator

Looking good! A few notes:

  • I think it should start at zero so that it's more obvious that this is a counter
  • The number text should be slightly bigger so it's easier to see. I could be wrong but it looks a lot smaller than they other text inputs. I'd imagine people will be looking up counting something and then referencing down every once and a while. Haptic feedback would be a cool addition later on!
  • It looks like there is a thicker line on the inside of the buttons
    Screenshot 2024-08-06 at 9 22 33 AM

Button contrast

  • Dark theme: are the buttons the same colour as the main menu buttons?
  • Light theme: the grey I used is too light. The colour you have for the outside border has better contrast, so we can use that for the fill as well. Hopefully shades of grey will be easier once we update the colour palette.

Screenshot 2024-08-06 at 9 25 55 AM

@grzesiek2010
Copy link
Member Author

grzesiek2010 commented Aug 6, 2024

I think it should start at zero so that it's more obvious that this is a counter

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.

The number text should be slightly bigger so it's easier to see. I could be wrong but it looks a lot smaller than they other text inputs. I'd imagine people will be looking up counting something and then referencing down every once and a while. Haptic feedback would be a cool addition later on!

Ok, I will try to increase the size.

It looks like there is a thicker line on the inside of the buttons

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.

Dark theme: are the buttons the same colour as the main menu buttons?

It's the same (colorSurfaceContainerLow) in both light and dark themes.

Light theme: the grey I used is too light. The colour you have for the outside border has better contrast, so we can use that for the fill as well. Hopefully shades of grey will be easier once we update the colour palette.

You mean I should use the same color for the fill and the border?

@alyblenkin
Copy link
Collaborator

alyblenkin commented Aug 6, 2024

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.

Ah interesting point. My thinking was zero could be considered no-answer, but zero could be an answer.

It's the same (colorSurfaceContainerLow) in both light and dark themes.

ah okay!

You mean I should use the same color for the fill and the border?

yup, I think we should see if that helps with the contrast.

@grzesiek2010
Copy link
Member Author

@alyblenkin

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.

Copy link
Collaborator

@alyblenkin alyblenkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great

@grzesiek2010 grzesiek2010 requested a review from seadowg August 8, 2024 17:10
Copy link
Member

@seadowg seadowg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#6306 (comment)

Just that at the moment, but I'll have a proper last look later.

@grzesiek2010 grzesiek2010 requested a review from seadowg August 14, 2024 14:51
android:layout_height="0dp"
android:gravity="center"
android:background="@drawable/counter_value_background"
android:textSize="25sp"
Copy link
Member

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.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good.

Copy link
Member Author

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"
Copy link
Member

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?

Copy link
Collaborator

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.

Copy link
Member Author

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.

Copy link
Collaborator

@alyblenkin alyblenkin left a 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 :)

@seadowg seadowg merged commit 6d2e872 into getodk:master Aug 21, 2024
6 checks passed
@dbemke
Copy link

dbemke commented Aug 22, 2024

Tested with Success!

Verified on a device with Android 10

Verified Cases:

  • counter in dark and light mode
  • counter with don't keep activities enabled (minimizing the app, rotating)
  • removing answers
  • counters on a field-list
  • counter and last saved
  • landscape and portrait view
  • RTL

@WKobus
Copy link

WKobus commented Aug 22, 2024

Tested with Success

Verified on device with Android 14

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.

Add +/- buttons to integer question type
5 participants