Skip to content

Commit

Permalink
Allow unsetting Sync url & Media sync url
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
oakkitten authored and mikehardy committed Aug 24, 2022
1 parent 08cc851 commit f9fb22f
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class CustomSyncServerSettingsFragment : SettingsFragment() {
// Sync url
requirePreference<Preference>(R.string.custom_sync_server_collection_url_key).setOnPreferenceChangeListener { _, newValue: Any ->
val newUrl = newValue.toString()
if (!URLUtil.isValidUrl(newUrl)) {
if (newUrl.isNotEmpty() && !URLUtil.isValidUrl(newUrl)) {
AlertDialog.Builder(requireContext())
.setTitle(R.string.custom_sync_server_base_url_invalid)
.setPositiveButton(R.string.dialog_ok, null)
Expand All @@ -49,7 +49,7 @@ class CustomSyncServerSettingsFragment : SettingsFragment() {
// Media url
requirePreference<Preference>(R.string.custom_sync_server_media_url_key).setOnPreferenceChangeListener { _, newValue: Any ->
val newUrl = newValue.toString()
if (!URLUtil.isValidUrl(newUrl)) {
if (newUrl.isNotEmpty() && !URLUtil.isValidUrl(newUrl)) {
AlertDialog.Builder(requireContext())
.setTitle(R.string.custom_sync_server_media_url_invalid)
.setPositiveButton(R.string.dialog_ok, null)
Expand Down

0 comments on commit f9fb22f

Please sign in to comment.