Skip to content

Improve custom server sync dialogs#20619

Merged
david-allison merged 1 commit intoankidroid:mainfrom
manocormen:improve-custom-sync-and-dir-dialogs
Apr 9, 2026
Merged

Improve custom server sync dialogs#20619
david-allison merged 1 commit intoankidroid:mainfrom
manocormen:improve-custom-sync-and-dir-dialogs

Conversation

@manocormen
Copy link
Copy Markdown
Contributor

@manocormen manocormen commented Mar 28, 2026

Purpose / Description

In this PR, I updated the "Sync URL" and "Custom root certificate", and "AnkiDroid directory" [scope update 1] dialogs to:

  • Style them consistently most notably, make their titles the same size [scope update 2].
  • Add a dialog hint: i.e. a floating label on the input border.
  • Rename the positive button from "OK" to "Save".

Additionally, I capitalized "url" in "Sync URL".

custom-stylings-removed

Fixes

Approach

To enforce consistency across dialogs, I identified the shared classes: "Sync URL" and "Custom root certificate" use VersatileTextPreference/VersatileTextPreferenceDialogFragment; I updated "AnkiDroid directory" to use it too.

Then, I wired a dialogHint attribute, and I made shared layout display the hint and have a "Save" button. The dialog styling update follows the same approach as the already-merged #20520.

How Has This Been Tested?

I did some manual tests across the two dialogs on my physical device:

  • Checked hint, title size, and "Save" button.
  • Tried valid and invalid inputs.

I ran the following commands:

./gradlew jacocoUnitTestReport                      
./gradlew lintRelease ktlintCheck

Learning

Lessons learned:

  • Understanding the preference/dialog class hierarchy helped identify the right shared implementation point.
  • Reviewing sibling PRs under the same parent issue helped confirm the preferred dialog pattern to use.
  • Favor view binding over findViewById (ref) and use extensions (ref) when possible.
  • Favor default styles over custom (ref), unless there's a strong reason not to.

Checklist

  • 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

@github-actions
Copy link
Copy Markdown
Contributor

Important

Maintainers: This PR contains Strings changes

  1. Sync Translations before merging this PR and wait for the action to complete
  2. Review and merge the auto-generated PR in order to sync all user-submitted translations
  3. Sync Translations again and merge the PR so the huge automated string changes caused by merging this PR are by themselves and easy to review

@manocormen manocormen marked this pull request as ready for review March 28, 2026 20:21
@ZornHadNoChoice
Copy link
Copy Markdown
Collaborator

Thanks, but the text fields shouldn't be rounded.

@david-allison david-allison added the Needs Author Reply Waiting for a reply from the original author label Mar 29, 2026
@manocormen manocormen force-pushed the improve-custom-sync-and-dir-dialogs branch from 0f8b280 to 3e673c2 Compare March 29, 2026 12:54
@manocormen
Copy link
Copy Markdown
Contributor Author

Thanks, but the text fields shouldn't be rounded.

Corner radius removed and screenshots updated. I'd carried them over from dialog_incrementer_preference.xml, but I've dropped the overrides here.

@manocormen manocormen force-pushed the improve-custom-sync-and-dir-dialogs branch from 3e673c2 to 9746532 Compare March 29, 2026 13:30
@manocormen
Copy link
Copy Markdown
Contributor Author

A couple of comments for whenever you get a chance to review this:

  • This PR is chunkier than my previous ones. I had it locally as three commits but squashed before pushing, assuming that's what you'd want. But now I'm double-guessing myself on whether you'd prefer to review them separately first. If I should wait for the go-ahead to squash next time, let me know.

  • I mention this in the description, but in case it goes unnoticed: the PR is largely based on the already-merged feat(preferences): improve timeout/backup number dialogs #20520. Hopefully that facilitates review.

@david-allison
Copy link
Copy Markdown
Member

Please revert the AnkiDroid Directory changes, this screen will be improved in

@manocormen manocormen force-pushed the improve-custom-sync-and-dir-dialogs branch from 9746532 to 3c1d5c4 Compare April 6, 2026 15:03
@manocormen manocormen changed the title Improve dialogs: custom sync & AnkiDroid directory Improve custom server sync dialogs Apr 6, 2026
@manocormen
Copy link
Copy Markdown
Contributor Author

@david-allison Done: removed the AnkiDroid Directory changes and updated the PR description accordingly.

Copy link
Copy Markdown
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.

LGTM, with optional improvements, thanks!!!

For a new issue: consider validating the URL as it's typed

Comment thread AnkiDroid/src/main/java/com/ichi2/preferences/VersatileTextPreference.kt Outdated
Comment thread AnkiDroid/src/main/java/com/ichi2/preferences/VersatileTextPreference.kt Outdated
@david-allison david-allison 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 Apr 6, 2026
Comment on lines +85 to +87
// Use a custom MaterialTextView to match the title text appearance and padding,
// as seen in other dialogs (e.g. "Create deck"). The default TextView renders
// the title too small and inconsistent with Material dialog standards.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm not sure why we aren't using the default style of Material dialogs.

Is the name size issue related to the string size?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Is the name size issue related to the string size?

Yes, with default styles, beyond a certain length, the title gets shrunk:

default-styles

So I enforced custom styles like here. If it gets too long, the title wraps to a newline:

custom-styles

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd go with whatever Material does

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done: removed the custom styles and updated the PR description accordingly.

@manocormen manocormen force-pushed the improve-custom-sync-and-dir-dialogs branch from 3c1d5c4 to 41bc157 Compare April 7, 2026 15:52
@manocormen manocormen force-pushed the improve-custom-sync-and-dir-dialogs branch from 41bc157 to b2ef5fd Compare April 7, 2026 20:03
@BrayanDSO BrayanDSO 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 Apr 8, 2026
@david-allison david-allison added this pull request to the merge queue Apr 9, 2026
Merged via the queue into ankidroid:main with commit 0c19c86 Apr 9, 2026
15 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

Maintainers: Please Sync Translations to produce a commit with only the automated changes from this PR.

Read more about updating strings on the wiki,

@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 Apr 9, 2026
@github-actions github-actions bot added this to the 2.24 release milestone Apr 9, 2026
@manocormen manocormen deleted the improve-custom-sync-and-dir-dialogs branch April 9, 2026 07:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve the custom sync server and AnkiDroid directory dialogs

4 participants