Enhance Add Note Type dialog styling and validation#20512
Enhance Add Note Type dialog styling and validation#20512lukstbit merged 1 commit intoankidroid:mainfrom
Conversation
|
Important Maintainers: This PR contains Strings changes
|
|
It's up to the maintainers to decide which PR to merge, but please read my comment here #20479 (comment) and additionally, reduce the vertical padding in the dialog. |
|
@david-allison Lint issue resolved |
david-allison
left a comment
There was a problem hiding this comment.
Thanks!!!!!
The padding of the dialog doesn't match the spec: https://m3.material.io/components/dialogs/specs
Please note my review comments on: #20479, s there may be additional useful context
All minor issues, should be good to get this in 👍
| <string name="model_field_editor_reposition_menu">Reposition field</string> | ||
| <string name="model_field_editor_changing">Updating fields</string> | ||
| <string name="model_field_editor_sort_field">Sort by this field</string> | ||
| <string name="model_editor_name">Name</string> |
There was a problem hiding this comment.
make this generic, move it out the file and use name="name_prompt"
david-allison
left a comment
There was a problem hiding this comment.
Whoops, forgot to submit this.
A before/after screenshot would be great! Last round 🤞.
I'll get it over the finish line if it needs more, it's ALMOST done 👍
|
Last one I think! |
| // Previously used inconsistent padding (32/64dp) that didn't follow the spec. | ||
| // See: https://m3.material.io/components/dialogs/specs |
There was a problem hiding this comment.
I thought the issue was that the padding wasn't applied?
If it's just inconsistent, it's best to fix it in the code, so the layout would work with other screen types
There was a problem hiding this comment.
@david-allison Yeah true as well, The padding wasn't applied - I changed the value multiple times and it wasn't reflecting on the UI
There was a problem hiding this comment.
Could you fix the comment, future devs would be confused if it remained.
| <string name="model_field_editor_reposition_menu">Reposition field</string> | ||
| <string name="model_field_editor_changing">Updating fields</string> | ||
| <string name="model_field_editor_sort_field">Sort by this field</string> | ||
| <string name="model_editor_name">Name</string> |
|
@lukstbit fixed merge conflict |
|
Please rebase/squash next time, rather than adding in a merge commit. We rebase all commits to |
david-allison
left a comment
There was a problem hiding this comment.
Caught a potential issue while looking into this
| setTitle(TR.notetypesAddNoteType()) | ||
| customView(binding.root) | ||
| positiveButton(R.string.menu_add) { _ -> | ||
| val newName = binding.notetypeNewName.text.toString() |
There was a problem hiding this comment.
This no longer trims the input, why?
Please add a @NeedsTest annotation to the method if this was a bug
There was a problem hiding this comment.
Oh, that didn't come from my end though — it came from the merge conflict, I had to make a balance between the merged code and my code or else I did continue getting a merge conflict
There was a problem hiding this comment.
But you reverted the merged code, which was correct
There was a problem hiding this comment.
I will work on it and tag you once I made a push then
ui: enhance Add Note Type dialog styling and validation|
@david-allison Pls review |
david-allison
left a comment
There was a problem hiding this comment.
Cheers! Very minor fixup needed
|
@david-allison Pls review |
There was a problem hiding this comment.
I approved previously, but the code is great, congrats!!
Can't merge it yet due to conflicts. Please modify the git history (rebase + force push) so:
- Merge commits are removed
- Either:
- commits are split out into rebaseable changes
- there is 1 squashed commit
- commits have a good title and description
Changes: - improve dialog appearance by using a Material 3 outlined input box - displays a visual error when a name that already exists is entered by the user - implements a sentence case for TR.notetypesAddNoteType() backend string
|
Maintainers: Please Sync Translations to produce a commit with only the automated changes from this PR. Read more about updating strings on the wiki, |
|
@david-allison Thank you for the constant reviews and patiently pointing out mistakes i made - it was really rewarding and i gained alot from this little interaction between us @lukstbit Thanks for the review and final merge - I will check the issues you fixed Its really great working with you both, Hoping to contribute more to ankidroid, Cheers🥂 |





Purpose / Description
This PR modernizes the Add Note Type dialog by replacing outdated UI components with Material Design elements and introducing real-time validation. These changes provide immediate feedback to the user and align the dialog with modern Android design standards.
Fixes
Approach
Changes
(i) Material Components: Replaced the standard EditText with TextInputLayout using the OutlinedBox style. This adds a professional border and a floating "Name" label.
(ii) Copy Updates: Changed dialog title from "Type" to "Add note type".
· Updated confirmation button from "OK" to "Add" for better intent clarity.
(i)Real-time Detection: Implemented an addTextChangedListener to compare user input against existing note type names.
(ii)Error Handling: Utilized TextInputLayout.setError() to trigger a red border and a "This note name already exists" message when a duplicate is detected.
(iii)State Management: The "Add" button is now dynamically disabled while a validation error is present.
How Has This Been Tested?
Device: Techno spark 30
Test Steps:
Navigate to the Manage Note Types screen.
Tap the + button to open the new dialog.
Verification: Confirmed the title displays "Add note type".
Duplicate Test: Entered an existing name (e.g., "Basic").
· Result: Border turned red; error message appeared; "Add" button disabled.
Unique Test: Entered a new, unique name.
· Result: Error cleared; "Add" button enabled.