#15 Choose the map layers in settings

This commit is contained in:
jannis 2019-09-10 18:23:50 +02:00
parent c21214fba9
commit e2e0efea32
8 changed files with 123 additions and 19 deletions

View File

@ -22,7 +22,6 @@ package de.tadris.fitness.activity;
import android.Manifest;
import android.app.ActionBar;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
@ -44,7 +43,6 @@ import android.widget.NumberPicker;
import androidx.annotation.StringRes;
import androidx.core.app.ActivityCompat;
import androidx.core.app.NavUtils;
import androidx.core.content.FileProvider;
import java.io.BufferedInputStream;
@ -53,7 +51,6 @@ import java.io.FileNotFoundException;
import de.tadris.fitness.R;
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.view.ProgressDialogController;
@ -160,6 +157,7 @@ public class SettingsActivity extends PreferenceActivity {
addPreferencesFromResource(R.xml.preferences_main);
bindPreferenceSummaryToValue(findPreference("unitSystem"));
bindPreferenceSummaryToValue(findPreference("mapStyle"));
findPreference("weight").setOnPreferenceClickListener(preference -> showWeightPicker());
findPreference("import").setOnPreferenceClickListener(preference -> showImportDialog());

View File

@ -19,6 +19,8 @@
package de.tadris.fitness.map;
import android.preference.PreferenceManager;
import org.mapsforge.core.model.LatLong;
import org.mapsforge.map.android.graphics.AndroidGraphicFactory;
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 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.ThunderforestTileSource;
import de.tadris.fitness.map.tilesource.TileSources;
public class MapManager {
public static TileDownloadLayer setupMap(MapView mapView, TileSources.Purpose purpose){
FitoTrackTileSource tileSource;
switch (purpose){
/*case OUTDOOR: tileSource= ThunderforestTileSource.OUTDOORS; break;
case CYCLING: tileSource= ThunderforestTileSource.CYLE_MAP; break;*/
case DEFAULT:
default:
tileSource= MapnikTileSource.INSTANCE; break;
String chosenTileLayer= PreferenceManager.getDefaultSharedPreferences(mapView.getContext()).getString("mapStyle", "osm.mapnik");
switch (chosenTileLayer){
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");

View 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>

View File

@ -94,4 +94,6 @@
<string name="noGpsMessage">Bitte aktiviere GPS, damit dein Workout aufgezeichnet werden kann.</string>
<string name="workoutAscent">Aufstieg</string>
<string name="workoutDescent">Abstieg</string>
<string name="data">Daten</string>
<string name="mapStyle">Kartenstil</string>
</resources>

View 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>

View File

@ -112,4 +112,6 @@
<string name="importBackup">Import Data Backup</string>
<string name="importBackupSummary">Restore a taken backup</string>
<string name="gps">GPS</string>
<string name="data">Data</string>
<string name="mapStyle">Map Style</string>
</resources>

View File

@ -22,7 +22,7 @@
<string-array name="pref_unit_systems">
<item>Metric</item>
<item>Metric Physical (m/s)</item>
<item>Metric with m/s</item>
<item>Imperial</item>
<item>Imperial with meters</item>
</string-array>

View File

@ -1,11 +1,31 @@
<?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">
<ListPreference
android:entries="@array/pref_unit_systems"
android:entryValues="@array/pref_unit_system_values"
android:key="unitSystem"
android:title="@string/pref_unit_system" />
android:title="@string/pref_unit_system"
android:defaultValue="1" />
<Preference
android:key="weight"
@ -14,14 +34,25 @@
android:summary="@string/pref_weight_summary"
android:title="@string/pref_weight" />
<Preference
android:key="import"
android:summary="@string/importBackupSummary"
android:title="@string/importBackup" />
<Preference
android:key="export"
android:summary="@string/exportDataSummary"
android:title="@string/exportData" />
<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
android:key="import"
android:summary="@string/importBackupSummary"
android:title="@string/importBackup" />
<Preference
android:key="export"
android:summary="@string/exportDataSummary"
android:title="@string/exportData" />
</PreferenceCategory>
</PreferenceScreen>