This should help #11460. Since there is exactly two occurrences, most of the
time, arrays obfuscate instead of improving readability. I believe this version
is more readable.
When either of the settings is unset, AnkiWeb sync server is used. But
if you change any of these settings, you can't clear them.
This allows clearing the settings by inputting empty string.
This will save a string, not a null; however,
CustomSyncServer.getCollectionSyncUrlIfSetAndEnabledOrNull() will
return null for an empty string as well as for a null.
Currently the preference Custom sync server -> Sync url must be
specified without the full endpoint path, e.g. http://foo:8080,
not http://foo:8080/sync/. The /sync/ path is hardcoded.
This is not optimal as:
* It's inconsistent with the preference Media sync url below;
* Anki uses the full URL in its --syncserver output, and expect the
full URL in SYNC_ENDPOINT;
* Power users may want to use something other than /sync/ for security
or other reasons.
This changes the preference to take arbitrary path, and migrates the
old preference.
In HttpSyncer.kt and RemoteMediaServer.kt I opted for creating
overridable methods getDefaultSyncUrl() and getCustomSyncUrlOrNull()
instead of putting everything into syncURL(). This is a tad un-pretty,
but it allows solving a slight issue with parseUrl() in a simple way.
parseUrl() used to called the now deleted isUsingCustomSyncServer()
to determine whether a custom URL was used; this was incorrect.
The latter would yield the state of the Use custom sync server switch
preference, however, even if the switch is on, the custom sync server--
collection or media--is not used if it is not set; instead, the default
AnkiWeb URL is used instead. This is confusing both in the code and
in the UI, and I hope it is eventually simplified.
46c4f4d501 changed a single doProgress()
call to multiple ones. I suspect the speed improvements in that PR
came from checking cancellation at the top, and the other change was
not necessary.
Things got worse with the introduction of #11849, as the progress listener
is called it a hot loop, and it invokes colIsOpen() each time.
This change puts performance back on par with the legacy path; further
improvements should be possible in the future by switching to a recycler
view and another backend method: https://github.com/ankidroid/Anki-Android/issues/11889
The sync check when adding a card should be the same as the sync check when removing a card. Therefore factor the code to fix the differences (and prevent future ones).
In this PR:
- removed code related to rate menu item for help menu(this menu item is not shown in this dialog!)
- fix the rate menu visibility in the support help menu
- fix and improve tests related to the help/support menus
- add a test to check if the rate option is shown when device has app that can handle it