-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Make custom sync server preferences easier to understand #12367
Conversation
Message to maintainers, this PR contains strings changes.
Read more about updating strings on the wiki, |
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.
Overall I like it. It's a great improvement on this screen. Even being the least used screen, it's a nice progress for the app
AnkiDroid/src/main/java/com/ichi2/anki/preferences/HtmlHelpPreference.kt
Outdated
Show resolved
Hide resolved
AnkiDroid/src/main/java/com/ichi2/anki/preferences/VersatileTextPreference.kt
Outdated
Show resolved
Hide resolved
AnkiDroid/src/main/java/com/ichi2/anki/preferences/VersatileTextPreference.kt
Outdated
Show resolved
Hide resolved
AnkiDroid/src/main/java/com/ichi2/anki/preferences/VersatileTextWithASwitchPreference.kt
Outdated
Show resolved
Hide resolved
@@ -206,6 +206,9 @@ | |||
<string name="advanced_forecast_stats_mc_n_iterations_title" maxLength="41">Number of iterations of the simulation</string> | |||
<!-- Custom sync server settings --> | |||
<string name="custom_sync_server_title" maxLength="41">Custom sync server</string> | |||
<string name="custom_sync_server_summary_none_of_the_two_servers_used">Not used</string> | |||
<string name="custom_sync_server_summary_both_or_either_of_the_two_servers_used">Collection: %1$s\nMedia: %2$s</string> | |||
<string name="custom_sync_server_summary_placeholder_default">default</string> |
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.
Couldn't we use the AnkiWeb
string here? I think that it is more specific + would be one less string to translate
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 thought about that and while I don't have a strong preference I like “default” more. If you read Custom server? AnkiWeb!
it may sound a bit like maybe AnkiWeb is the name of a server application that you can install for yourself. “Default” also chimes a bit better with “Not used”, which I liked better than having “Default” if neither server is used. If you say “AnkiWeb” then “Not used” is a bit awkward... I guess in that case you'd also want to say “AnkiWeb” and that would be less ideal. Anyway, I'not a native so this is not a strong opinion.
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.
To me, it's more of a question that I have to think what default
means, while AnkiWeb
is straighthead, no thinking and no confusion. I'm not a native as well and I don't find having Not used
first and AnkiWeb
awkward at all. On my mind, their uses are distinct enough
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 think that in the context of custom x, it's rather clear that default x means not using the custom x. Or maybe not. Where are the natives when you need them? 😪
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 think the confusion can be minimised if we just mention that AnkiWeb is the default server with something like:
AnkiWeb (default)
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 still dislike AnkiWeb
, even with (default)
, for the reasons mentioned above. I am willing to give in to peer pressure, but I request more peers (or one very assertive peer).
77cc1e5
to
19792cf
Compare
AnkiDroid/src/main/java/com/ichi2/anki/preferences/CustomSyncServerSettingsFragment.kt
Outdated
Show resolved
Hide resolved
19792cf
to
4709427
Compare
Pending to me will be only
I'll leave the strings' texts to the natives. |
4709427
to
08fa835
Compare
Rebased onto v2.16alpha85 to resolve a conflict and to add |
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 like all of this except:
- I liked the language but tried to make it even more precise + prescriptive
- we must maintain URL flexibility without trashing translations, so that should be interpolated
And took a conflict during my current merge-fest, apologies. Probably an AlertDialog thing 🙈 |
08fa835
to
99943f6
Compare
Rebased on current main to resolve conflicts, also incorporated suggested wording changes into the first commit and added a commit extracting the URL into a separate string. Now if the tests would be so kind to pass... |
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.
The last changes LGTM.
Noticed only now, after reading HtmlHelpPreference
javadoc, that the new preferences are on com.ichi2.anki.preferences
, but all the other individual Preference
classes are on com.ichi2.preferences
, so they should be moved.
99943f6
to
e4ab1a2
Compare
Good catch! Rebased. (Rebasing with renaming is hell!) I put the helper methods into a new file |
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.
Renaming on a rebase is quite painful. My condolences
edit: There is a lint error. Good old missing copyright header
e4ab1a2
to
5574dc2
Compare
and a conflict, just for extra fun 🙈 |
5574dc2
to
0292199
Compare
Done, and rebased on current main to resolve conflict. |
Great - running through |
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.
Well...that's weird, on the very first commit ./gradlew ktlintFormat
fails with:
/home/mike/work/AnkiDroid/Anki-Android-Upstream/AnkiDroid/src/main/java/com/ichi2/preferences/PreferenceUtil.kt
interface DialogFragmentProvider should be declared in a file named DialogFragmentProvider.kt
...but....it works on the other 5 commits (!?)
Something about the extra sauce added in the following commit: d0e1209 makes ktlint okay with the interface in file not named after the interface 🤔
Could either dig deep and learn a bunch of things that may never be needed again to fix it, or just squash those two commits and be done, or squash them all 😆
Let me know what you think
HtmlHelpPreference is a preference that only provides help. It does not need a key and it is not selectable. It treats its summary text as HTML an renders it as such--including links. This commit implements it and adds it to the top of Custom sync server preference screen.
DialogFragmentProvider is an interface that slightly simplifies finding relations between the preferences that display dialogs on click, and the dialogs themselves.
At the time being, it serves two purposes: * It supports changing input type via android:inputType XML attribute, which can help the keyboard app with choosing a more suitable keyboard layout. * If continuousValidator is set, it is used to prevent the user from entering invalid data. On each text change, the validator is run; if it throws, the Ok button gets disabled. It was designed as a drop-in replacement of EditTextPreference with the extra functionality disabled by default. Additional functionality can be added as needed.
VersatileTextWithASwitchPreference is a combination of a TextPreference and a SwitchPreference. It mostly looks like a SwitchPreference, but the switch and the title can be clicked separately. The behavior is a bit special, see the javadoc for explanation.
Before, Custom sync server preferences were a bit confusing. There was a master switch for both of them, but you could actually disable either of the custom servers, or both of them, by not specifying the URL. This is an attempt to resolve the confusion by removing the master switch, and adding individual switches to the two custom server preferences. Also, the parent preference, that is the one that you click to get to Custom sync server preferences, now shows the status of both child preferences in its summary. Hopefully this is less confusing. Additionally, instead of showing an error dialog in the case of invalid URL, the edit text dialog doesn't allow accepting such an URL by disabling the Ok button. Allowing the user to okay bad input means it is going to be discarded, and that's pretty awful. What if user's custom sync URL is 420 characters long? Note that the URLs are now validated using OkHttp, which is more strict. Preference migration follows in the next commit.
Use custom sync server preference was the master switch for both collection and media custom sync servers. These preferences now have individual switches; this migration applies the old master switch to both individual switches, as long as the custom sync URLs are set.
0292199
to
84ce399
Compare
I assume this rule is supposed to catch typos, like when you have a class (Why squash though? I'm not exactly sure why one of commits failing lint is an issue. As long as you don't merge with I'd even go so far to say there's not much value in ensuring every commit builds. If something breaks you can still use |
will re-check... |
|
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.
/bin/nice -n 19 ./tools/test-commits.sh 0746ab0b4b08a74b6b7f609703d2628c496e8c35
clean
merge commit is not currently enabled for the repo, I've got squash or rebase - this is "rebase clean" now, so I'm going with that - will do the strings sync after |
Hi there @oakkitten! This is the OpenCollective Notice for PRs merged from 2022-10-01 through 2022-10-31 If you are interested in compensation for this work, the process with details is here: https://github.com/ankidroid/Anki-Android/wiki/OpenCollective-Payment-Process#how-to-get-paid We only post one comment per person per month to avoid spamming you, regardless of the number of PRs merged, but this note applies to all PRs merged for this month Please note that GSoC contributions are okay for this process. Our philosophy is that our users have donated to AnkiDroid for all contributions. The only PRs that will not go through the OpenCollective process are ones directly related to am accepted GSoC project from a selected participant, since those receive a stipend from GSoC itself. Please understand that our monthly budget is never guaranteed to cover all claims - the cap on payments-per-person may be lower, but we try to make our process as fair and transparent as possible, we just need your understanding. Thanks! |
This implements my own suggestion from the point 2 in Remaining issues in #12112 nearly verbatim, except I added a note about Sync url preference expecting the full URL as discussed in #12269. @dobefore What do you think?
device-2022-09-08-015053.mp4
As usual, please see the commits for individual changes.
Note that in the first commit there's a link to the fragment https://docs.ankidroid.org/#_custom_sync_server which doesn't exist yet. I suppose the docs will have to be amended for the new release, and this section could be added later.
Also note that Accessibility scanner complains about two things; not sure if this is actionable.
Edit: The test pass in my repo.
How Has This Been Tested?
Manually tested on my Xiaomi Mi A2 (Android 11) and Motorola Moto G 1st Gen (Android 6).
Added a unit test for preference migration.
Checklist