mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-19 13:03:36 +00:00
[android] Add custom map download URL setting
Signed-off-by: NoelClick <dev@noel.click>
This commit is contained in:
@@ -8,6 +8,7 @@ import android.os.Bundle;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.preference.EditTextPreference;
|
||||||
import androidx.preference.ListPreference;
|
import androidx.preference.ListPreference;
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
import androidx.preference.PreferenceCategory;
|
import androidx.preference.PreferenceCategory;
|
||||||
@@ -73,6 +74,7 @@ public class SettingsPrefsFragment extends BaseXmlSettingsFragment implements La
|
|||||||
initScreenSleepEnabledPrefsCallbacks();
|
initScreenSleepEnabledPrefsCallbacks();
|
||||||
initShowOnLockScreenPrefsCallbacks();
|
initShowOnLockScreenPrefsCallbacks();
|
||||||
initLeftButtonPrefs();
|
initLeftButtonPrefs();
|
||||||
|
initCustomMapDownloadUrlPrefsCallbacks();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initLeftButtonPrefs()
|
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)
|
private void removePreference(@NonNull String categoryKey, @NonNull Preference preference)
|
||||||
{
|
{
|
||||||
final PreferenceCategory category = getPreference(categoryKey);
|
final PreferenceCategory category = getPreference(categoryKey);
|
||||||
|
|||||||
@@ -966,4 +966,11 @@
|
|||||||
<string name="offline_explanation_title">Offline Maps</string>
|
<string name="offline_explanation_title">Offline Maps</string>
|
||||||
<string name="offline_explanation_text">A map needs to be downloaded to view and navigate the area.\nDownload maps for areas you want to travel.</string>
|
<string name="offline_explanation_text">A map needs to be downloaded to view and navigate the area.\nDownload maps for areas you want to travel.</string>
|
||||||
<string name="list_description_empty">Edit the list to add a description</string>
|
<string name="list_description_empty">Edit the list to add a description</string>
|
||||||
|
<!-- Custom Download URL -->
|
||||||
|
<string name="pref_custom_map_download_url_title">Custom map server</string>
|
||||||
|
<string name="pref_custom_map_download_url_summary">Leave empty to use the default CoMaps servers. Example: https://example.org/servers</string>
|
||||||
|
<string name="download_resources_advanced">Advanced…</string>
|
||||||
|
<string name="download_resources_custom_url_title">Custom map server</string>
|
||||||
|
<string name="download_resources_custom_url_message">Override the default map download server used for map downloads. Leave empty to use CoMaps default server.</string>
|
||||||
|
<string name="download_resources_custom_url_hint">https://comaps.app/servers/</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -212,5 +212,14 @@
|
|||||||
android:defaultValue="true"
|
android:defaultValue="true"
|
||||||
android:widgetLayout="@layout/preference_switch"
|
android:widgetLayout="@layout/preference_switch"
|
||||||
android:order="2"/>
|
android:order="2"/>
|
||||||
|
<EditTextPreference
|
||||||
|
android:key="@string/pref_custom_map_download_url"
|
||||||
|
android:title="@string/pref_custom_map_download_url_title"
|
||||||
|
android:summary="@string/pref_custom_map_download_url_summary"
|
||||||
|
android:inputType="textUri"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:defaultValue=""
|
||||||
|
android:order="3"/>
|
||||||
|
|
||||||
</androidx.preference.PreferenceCategory>
|
</androidx.preference.PreferenceCategory>
|
||||||
</androidx.preference.PreferenceScreen>
|
</androidx.preference.PreferenceScreen>
|
||||||
|
|||||||
Reference in New Issue
Block a user