mirror of
https://github.com/russok/FitoTrack.git
synced 2025-10-29 08:42:12 -07:00
#15 Choose the map layers in settings
This commit is contained in:
parent
c21214fba9
commit
e2e0efea32
@ -22,7 +22,6 @@ package de.tadris.fitness.activity;
|
|||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
import android.app.ActionBar;
|
import android.app.ActionBar;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
@ -44,7 +43,6 @@ import android.widget.NumberPicker;
|
|||||||
|
|
||||||
import androidx.annotation.StringRes;
|
import androidx.annotation.StringRes;
|
||||||
import androidx.core.app.ActivityCompat;
|
import androidx.core.app.ActivityCompat;
|
||||||
import androidx.core.app.NavUtils;
|
|
||||||
import androidx.core.content.FileProvider;
|
import androidx.core.content.FileProvider;
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
@ -53,7 +51,6 @@ import java.io.FileNotFoundException;
|
|||||||
|
|
||||||
import de.tadris.fitness.R;
|
import de.tadris.fitness.R;
|
||||||
import de.tadris.fitness.util.export.Exporter;
|
import de.tadris.fitness.util.export.Exporter;
|
||||||
import de.tadris.fitness.util.gpx.GpxExporter;
|
|
||||||
import de.tadris.fitness.util.unit.UnitUtils;
|
import de.tadris.fitness.util.unit.UnitUtils;
|
||||||
import de.tadris.fitness.view.ProgressDialogController;
|
import de.tadris.fitness.view.ProgressDialogController;
|
||||||
|
|
||||||
@ -160,6 +157,7 @@ public class SettingsActivity extends PreferenceActivity {
|
|||||||
addPreferencesFromResource(R.xml.preferences_main);
|
addPreferencesFromResource(R.xml.preferences_main);
|
||||||
|
|
||||||
bindPreferenceSummaryToValue(findPreference("unitSystem"));
|
bindPreferenceSummaryToValue(findPreference("unitSystem"));
|
||||||
|
bindPreferenceSummaryToValue(findPreference("mapStyle"));
|
||||||
|
|
||||||
findPreference("weight").setOnPreferenceClickListener(preference -> showWeightPicker());
|
findPreference("weight").setOnPreferenceClickListener(preference -> showWeightPicker());
|
||||||
findPreference("import").setOnPreferenceClickListener(preference -> showImportDialog());
|
findPreference("import").setOnPreferenceClickListener(preference -> showImportDialog());
|
||||||
|
|||||||
@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
package de.tadris.fitness.map;
|
package de.tadris.fitness.map;
|
||||||
|
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
|
|
||||||
import org.mapsforge.core.model.LatLong;
|
import org.mapsforge.core.model.LatLong;
|
||||||
import org.mapsforge.map.android.graphics.AndroidGraphicFactory;
|
import org.mapsforge.map.android.graphics.AndroidGraphicFactory;
|
||||||
import org.mapsforge.map.android.util.AndroidUtil;
|
import org.mapsforge.map.android.util.AndroidUtil;
|
||||||
@ -27,20 +29,22 @@ import org.mapsforge.map.layer.cache.TileCache;
|
|||||||
import org.mapsforge.map.layer.download.TileDownloadLayer;
|
import org.mapsforge.map.layer.download.TileDownloadLayer;
|
||||||
|
|
||||||
import de.tadris.fitness.map.tilesource.FitoTrackTileSource;
|
import de.tadris.fitness.map.tilesource.FitoTrackTileSource;
|
||||||
|
import de.tadris.fitness.map.tilesource.HumanitarianTileSource;
|
||||||
import de.tadris.fitness.map.tilesource.MapnikTileSource;
|
import de.tadris.fitness.map.tilesource.MapnikTileSource;
|
||||||
|
import de.tadris.fitness.map.tilesource.ThunderforestTileSource;
|
||||||
import de.tadris.fitness.map.tilesource.TileSources;
|
import de.tadris.fitness.map.tilesource.TileSources;
|
||||||
|
|
||||||
public class MapManager {
|
public class MapManager {
|
||||||
|
|
||||||
public static TileDownloadLayer setupMap(MapView mapView, TileSources.Purpose purpose){
|
public static TileDownloadLayer setupMap(MapView mapView, TileSources.Purpose purpose){
|
||||||
FitoTrackTileSource tileSource;
|
FitoTrackTileSource tileSource;
|
||||||
switch (purpose){
|
|
||||||
/*case OUTDOOR: tileSource= ThunderforestTileSource.OUTDOORS; break;
|
|
||||||
case CYCLING: tileSource= ThunderforestTileSource.CYLE_MAP; break;*/
|
|
||||||
|
|
||||||
case DEFAULT:
|
String chosenTileLayer= PreferenceManager.getDefaultSharedPreferences(mapView.getContext()).getString("mapStyle", "osm.mapnik");
|
||||||
default:
|
switch (chosenTileLayer){
|
||||||
tileSource= MapnikTileSource.INSTANCE; break;
|
case "osm.humanitarian": tileSource= HumanitarianTileSource.INSTANCE; break;
|
||||||
|
case "thunderforest.outdoors": tileSource= ThunderforestTileSource.OUTDOORS; break;
|
||||||
|
case "thunderforest.cycle": tileSource= ThunderforestTileSource.CYLE_MAP; break;
|
||||||
|
default: tileSource= MapnikTileSource.INSTANCE; break; // Inclusive "osm.mapnik"
|
||||||
}
|
}
|
||||||
tileSource.setUserAgent("mapsforge-android");
|
tileSource.setUserAgent("mapsforge-android");
|
||||||
|
|
||||||
|
|||||||
30
app/src/main/res/values-de/map_layers.xml
Normal file
30
app/src/main/res/values-de/map_layers.xml
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
~ Copyright (c) 2019 Jannis Scheibe <jannis@tadris.de>
|
||||||
|
~
|
||||||
|
~ This file is part of FitoTrack
|
||||||
|
~
|
||||||
|
~ FitoTrack is free software: you can redistribute it and/or modify
|
||||||
|
~ it under the terms of the GNU General Public License as published by
|
||||||
|
~ the Free Software Foundation, either version 3 of the License, or
|
||||||
|
~ (at your option) any later version.
|
||||||
|
~
|
||||||
|
~ FitoTrack is distributed in the hope that it will be useful,
|
||||||
|
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
~ GNU General Public License for more details.
|
||||||
|
~
|
||||||
|
~ You should have received a copy of the GNU General Public License
|
||||||
|
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<resources>
|
||||||
|
|
||||||
|
<string-array name="pref_map_layers">
|
||||||
|
<item>Mapnik\nStandard OSM Kartenstil</item>
|
||||||
|
<item>Humanitarian\nSchöne Karte, aber manchmal nicht verfügbar</item>
|
||||||
|
<item>Outdoors\nLimitierter Zugriff</item>
|
||||||
|
<item>Cyclemap\nLimitierter Zugriff</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
</resources>
|
||||||
@ -94,4 +94,6 @@
|
|||||||
<string name="noGpsMessage">Bitte aktiviere GPS, damit dein Workout aufgezeichnet werden kann.</string>
|
<string name="noGpsMessage">Bitte aktiviere GPS, damit dein Workout aufgezeichnet werden kann.</string>
|
||||||
<string name="workoutAscent">Aufstieg</string>
|
<string name="workoutAscent">Aufstieg</string>
|
||||||
<string name="workoutDescent">Abstieg</string>
|
<string name="workoutDescent">Abstieg</string>
|
||||||
|
<string name="data">Daten</string>
|
||||||
|
<string name="mapStyle">Kartenstil</string>
|
||||||
</resources>
|
</resources>
|
||||||
37
app/src/main/res/values/map_layers.xml
Normal file
37
app/src/main/res/values/map_layers.xml
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
~ Copyright (c) 2019 Jannis Scheibe <jannis@tadris.de>
|
||||||
|
~
|
||||||
|
~ This file is part of FitoTrack
|
||||||
|
~
|
||||||
|
~ FitoTrack is free software: you can redistribute it and/or modify
|
||||||
|
~ it under the terms of the GNU General Public License as published by
|
||||||
|
~ the Free Software Foundation, either version 3 of the License, or
|
||||||
|
~ (at your option) any later version.
|
||||||
|
~
|
||||||
|
~ FitoTrack is distributed in the hope that it will be useful,
|
||||||
|
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
~ GNU General Public License for more details.
|
||||||
|
~
|
||||||
|
~ You should have received a copy of the GNU General Public License
|
||||||
|
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<resources>
|
||||||
|
|
||||||
|
<string-array name="pref_map_layers">
|
||||||
|
<item>Mapnik\nDefault OSM Mapstyle</item>
|
||||||
|
<item>Humanitarian\nClean map but sometimes not available</item>
|
||||||
|
<item>Outdoors\nLimited access</item>
|
||||||
|
<item>Cyclemap\nLimited access</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<string-array name="pref_map_layers_values">
|
||||||
|
<item>osm.mapnik</item>
|
||||||
|
<item>osm.humanitarian</item>
|
||||||
|
<item>thunderforest.outdoors</item>
|
||||||
|
<item>thunderforest.cycle</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
</resources>
|
||||||
@ -112,4 +112,6 @@
|
|||||||
<string name="importBackup">Import Data Backup</string>
|
<string name="importBackup">Import Data Backup</string>
|
||||||
<string name="importBackupSummary">Restore a taken backup</string>
|
<string name="importBackupSummary">Restore a taken backup</string>
|
||||||
<string name="gps">GPS</string>
|
<string name="gps">GPS</string>
|
||||||
|
<string name="data">Data</string>
|
||||||
|
<string name="mapStyle">Map Style</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
<string-array name="pref_unit_systems">
|
<string-array name="pref_unit_systems">
|
||||||
<item>Metric</item>
|
<item>Metric</item>
|
||||||
<item>Metric Physical (m/s)</item>
|
<item>Metric with m/s</item>
|
||||||
<item>Imperial</item>
|
<item>Imperial</item>
|
||||||
<item>Imperial with meters</item>
|
<item>Imperial with meters</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|||||||
@ -1,11 +1,31 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
~ Copyright (c) 2019 Jannis Scheibe <jannis@tadris.de>
|
||||||
|
~
|
||||||
|
~ This file is part of FitoTrack
|
||||||
|
~
|
||||||
|
~ FitoTrack is free software: you can redistribute it and/or modify
|
||||||
|
~ it under the terms of the GNU General Public License as published by
|
||||||
|
~ the Free Software Foundation, either version 3 of the License, or
|
||||||
|
~ (at your option) any later version.
|
||||||
|
~
|
||||||
|
~ FitoTrack is distributed in the hope that it will be useful,
|
||||||
|
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
~ GNU General Public License for more details.
|
||||||
|
~
|
||||||
|
~ You should have received a copy of the GNU General Public License
|
||||||
|
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
-->
|
||||||
|
|
||||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
<ListPreference
|
<ListPreference
|
||||||
android:entries="@array/pref_unit_systems"
|
android:entries="@array/pref_unit_systems"
|
||||||
android:entryValues="@array/pref_unit_system_values"
|
android:entryValues="@array/pref_unit_system_values"
|
||||||
android:key="unitSystem"
|
android:key="unitSystem"
|
||||||
android:title="@string/pref_unit_system" />
|
android:title="@string/pref_unit_system"
|
||||||
|
android:defaultValue="1" />
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="weight"
|
android:key="weight"
|
||||||
@ -14,6 +34,16 @@
|
|||||||
android:summary="@string/pref_weight_summary"
|
android:summary="@string/pref_weight_summary"
|
||||||
android:title="@string/pref_weight" />
|
android:title="@string/pref_weight" />
|
||||||
|
|
||||||
|
<ListPreference
|
||||||
|
android:defaultValue="osm.mapnik"
|
||||||
|
android:entries="@array/pref_map_layers"
|
||||||
|
android:entryValues="@array/pref_map_layers_values"
|
||||||
|
android:key="mapStyle"
|
||||||
|
android:title="@string/mapStyle" />
|
||||||
|
|
||||||
|
|
||||||
|
<PreferenceCategory android:title="@string/data">
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="import"
|
android:key="import"
|
||||||
android:summary="@string/importBackupSummary"
|
android:summary="@string/importBackupSummary"
|
||||||
@ -22,6 +52,7 @@
|
|||||||
android:key="export"
|
android:key="export"
|
||||||
android:summary="@string/exportDataSummary"
|
android:summary="@string/exportDataSummary"
|
||||||
android:title="@string/exportData" />
|
android:title="@string/exportData" />
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
Loading…
x
Reference in New Issue
Block a user