Skip to content

Comments

fix(preferences): Improve UI of IncrementerNumberRangePreferenceCompat#20271

Merged
david-allison merged 1 commit intoankidroid:mainfrom
Akira2206:fix/incrementer-ui
Jan 31, 2026
Merged

fix(preferences): Improve UI of IncrementerNumberRangePreferenceCompat#20271
david-allison merged 1 commit intoankidroid:mainfrom
Akira2206:fix/incrementer-ui

Conversation

@Akira2206
Copy link
Contributor

Purpose / Description

Updates the UI of IncrementerNumberRangePreferenceCompat to use Material Design components and fixes visibility issues across different themes.

Fixes

Approach

  • Replaced Button with MaterialButton (Elevated button) and EditText with TextInputLayout
  • Added custom attributes (incrementerButtonBackground, incrementerInputBackground, incrementerIconColor) to attrs.xml and defined specific colors for light, plain, dark, and black themes
  • Verified that disabled buttons fade out correctly (alpha 0.38). For enabled buttons, I aimed for a 3:1 contrast ratio. This was achieved in most cases, with exceptions to maintain visual hierarchy:

How Has This Been Tested?

WhatsApp.Video.2026-01-31.at.18.24.19.mp4

Enabled buttons:

Error text and disabled buttons:

Checklist

Please, go through these checks before submitting the PR.

  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • UI Changes: You have tested your change using the Google Accessibility Scanner

Copy link
Member

@BrayanDSO BrayanDSO left a comment

Choose a reason for hiding this comment

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

image

As shown in your screenshots, the - and + buttons aren't aligned with the text input if the Invalid value warning is shown.


The rest looks great!

@BrayanDSO BrayanDSO added Needs Author Reply Waiting for a reply from the original author and removed Needs Review labels Jan 31, 2026
@Akira2206
Copy link
Contributor Author

I'll fix the alignment, but @ZornHadNoChoice just suggested removing the buttons entirely here: #20005 (comment)

What should be done?

@david-allison
Copy link
Member

Keep the buttons, this looks great to me aside from Brayan's comment

Copy link
Member

@david-allison david-allison left a comment

Choose a reason for hiding this comment

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

This is AWESOME, thank you!!

Could you post 3 variants of the "light" theme with a different, (IMO: darker, still blue) colour for the icon colour, and the original

That's the only one which I mildly feel we can do better on, the rest are perfect

@Akira2206
Copy link
Contributor Author

Akira2206 commented Jan 31, 2026

Fixed alignment of the buttons with text input:

In the original light theme, the icon color used is material_light_blue_500 (contrast: 2.37)
3 variants of the same color along with their contrast ratios:

material_light_blue_600 (2.81:1)

material_light_blue_700 (3.43:1)

material_light_blue_800 (4.31:1)

I prefer 600 because it matches the other dialog buttons, though 700 is safer for accessibility

@BrayanDSO BrayanDSO added Needs Second Approval Has one approval, one more approval to merge and removed Needs Author Reply Waiting for a reply from the original author labels Jan 31, 2026
Copy link
Member

@david-allison david-allison left a comment

Choose a reason for hiding this comment

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

Mild preference for material_light_blue_700

Implementer's choice - let us know what you decide on and we'll merge

Thanks!!

Comment on lines +53 to +54
private var bindingRef: DialogIncrementerPreferenceBinding? = null
private val binding get() = bindingRef!!
Copy link
Member

Choose a reason for hiding this comment

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

why not lateinit?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since the fragment lives longer than the view we need to make bindingRef = null in onDestroyView(), and lateinit variables cannot be set to null

Copy link
Member

Choose a reason for hiding this comment

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

by viewBinding(DialogIncrementerPreferenceBinding::bind) won't work in this circumstance?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I looked into it. Because we are creating the view from scratch in onCreateDialogView (inflating it manually to return binding.root), the ::bind method which expects an existing view won't work here it seems, so we have to handle the lifecycle manually

Copy link
Member

Choose a reason for hiding this comment

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

Preferences are weird, cheers

@david-allison david-allison added this pull request to the merge queue Jan 31, 2026
@david-allison david-allison added Pending Merge Things with approval that are waiting future merge (e.g. targets a future release, CI wait, etc) and removed Needs Second Approval Has one approval, one more approval to merge labels Jan 31, 2026
Merged via the queue into ankidroid:main with commit bc78d4a Jan 31, 2026
15 checks passed
@github-actions github-actions bot added this to the 2.24 release milestone Jan 31, 2026
@github-actions github-actions bot removed the Pending Merge Things with approval that are waiting future merge (e.g. targets a future release, CI wait, etc) label Jan 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve UI of IncrementerNumberRangePreferenceCompat

3 participants