From 6c92264fb07481b900973d6a58263af366e454a2 Mon Sep 17 00:00:00 2001 From: NoelClick Date: Sat, 15 Nov 2025 19:34:17 -0800 Subject: [PATCH] [android] Add custom map download URL setting Signed-off-by: NoelClick --- .../settings/SettingsPrefsFragment.java | 16 ++++++++++++++++ android/app/src/main/res/values/strings.xml | 7 +++++++ android/app/src/main/res/xml/prefs_main.xml | 9 +++++++++ 3 files changed, 32 insertions(+) diff --git a/android/app/src/main/java/app/organicmaps/settings/SettingsPrefsFragment.java b/android/app/src/main/java/app/organicmaps/settings/SettingsPrefsFragment.java index 26eade991..8f3649f82 100644 --- a/android/app/src/main/java/app/organicmaps/settings/SettingsPrefsFragment.java +++ b/android/app/src/main/java/app/organicmaps/settings/SettingsPrefsFragment.java @@ -8,6 +8,7 @@ import android.os.Bundle; import android.view.View; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.preference.EditTextPreference; import androidx.preference.ListPreference; import androidx.preference.Preference; import androidx.preference.PreferenceCategory; @@ -73,6 +74,7 @@ public class SettingsPrefsFragment extends BaseXmlSettingsFragment implements La initScreenSleepEnabledPrefsCallbacks(); initShowOnLockScreenPrefsCallbacks(); initLeftButtonPrefs(); + initCustomMapDownloadUrlPrefsCallbacks(); } private void initLeftButtonPrefs() @@ -535,6 +537,20 @@ public class SettingsPrefsFragment extends BaseXmlSettingsFragment implements La }); } + private void initCustomMapDownloadUrlPrefsCallbacks() + { + EditTextPreference customUrlPref = getPreference(getString(R.string.pref_custom_map_download_url)); + customUrlPref.setOnPreferenceChangeListener((preference, newValue) -> { + String url = newValue != null ? ((String) newValue).trim() : ""; + Framework.applyCustomMapDownloadUrl(requireContext(), url); + return true; // save the value + }); + + // Ensure native side is updated when the screen opens + String current = customUrlPref.getText(); + Framework.applyCustomMapDownloadUrl(requireContext(), current != null ? current.trim() : ""); + } + private void removePreference(@NonNull String categoryKey, @NonNull Preference preference) { final PreferenceCategory category = getPreference(categoryKey); diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml index 3d4c9ae30..5a8a594ad 100644 --- a/android/app/src/main/res/values/strings.xml +++ b/android/app/src/main/res/values/strings.xml @@ -966,4 +966,11 @@ Offline Maps A map needs to be downloaded to view and navigate the area.\nDownload maps for areas you want to travel. Edit the list to add a description + + Custom map server + Leave empty to use the default CoMaps servers. Example: https://example.org/servers + Advanced… + Custom map server + Override the default map download server used for map downloads. Leave empty to use CoMaps default server. + https://comaps.app/servers/ diff --git a/android/app/src/main/res/xml/prefs_main.xml b/android/app/src/main/res/xml/prefs_main.xml index 7065ed1ca..f2f0a0d7c 100644 --- a/android/app/src/main/res/xml/prefs_main.xml +++ b/android/app/src/main/res/xml/prefs_main.xml @@ -212,5 +212,14 @@ android:defaultValue="true" android:widgetLayout="@layout/preference_switch" android:order="2"/> + +