From 4a8803b3416d87dc54207b1c1f850085aa543362 Mon Sep 17 00:00:00 2001 From: jensMF Date: Thu, 10 Oct 2019 11:03:46 +0200 Subject: [PATCH 1/3] changed saveDataToGpx so that it saves the dateDirectory in filenames, too --- .../net/osmand/plus/activities/SavingTrackHelper.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java b/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java index a8cce1df62..c1d1b65f5e 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java +++ b/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java @@ -204,23 +204,21 @@ public class SavingTrackHelper extends SQLiteOpenHelper { File fout = new File(dir, f + ".gpx"); //$NON-NLS-1$ if (!data.get(f).isEmpty()) { WptPt pt = data.get(f).findPointToShow(); - File targetDir = dir; + String fileName = f + "_" + new SimpleDateFormat("HH-mm_EEE", Locale.US).format(new Date(pt.time)); //$NON-NLS-1$ if (ctx.getSettings().STORE_TRACKS_IN_MONTHLY_DIRECTORIES.get()) { SimpleDateFormat dateDirFormat = new SimpleDateFormat("yyyy-MM"); String dateDirName = dateDirFormat.format(new Date(pt.time)); File dateDir = new File(dir, dateDirName); dateDir.mkdirs(); if (dateDir.exists()) { - targetDir = dateDir; + fileName = dateDirName + File.separator + fileName; } } - - String fileName = f + "_" + new SimpleDateFormat("HH-mm_EEE", Locale.US).format(new Date(pt.time)); //$NON-NLS-1$ filenames.add(fileName); - fout = new File(targetDir, fileName + ".gpx"); //$NON-NLS-1$ + fout = new File(dir, fileName + ".gpx"); //$NON-NLS-1$ int ind = 1; while (fout.exists()) { - fout = new File(targetDir, fileName + "_" + (++ind) + ".gpx"); //$NON-NLS-1$ //$NON-NLS-2$ + fout = new File(dir, fileName + "_" + (++ind) + ".gpx"); //$NON-NLS-1$ //$NON-NLS-2$ } } From db279b440e89a0705ae88912ea27f1e8dbfc77db Mon Sep 17 00:00:00 2001 From: jensMF Date: Thu, 10 Oct 2019 12:09:32 +0200 Subject: [PATCH 2/3] added possibility to store tracks in folders per day and changed options menu accordingly (#5) --- OsmAnd/res/values-de/strings.xml | 5 +++ OsmAnd/res/values/strings.xml | 5 +++ .../src/net/osmand/plus/OsmandSettings.java | 6 ++- .../plus/activities/SavingTrackHelper.java | 8 +++- .../OnSaveCurrentTrackFragment.java | 2 +- .../SettingsMonitoringActivity.java | 40 ++++++++++++------- 6 files changed, 47 insertions(+), 19 deletions(-) diff --git a/OsmAnd/res/values-de/strings.xml b/OsmAnd/res/values-de/strings.xml index e3bb0900e8..7d20dacd63 100644 --- a/OsmAnd/res/values-de/strings.xml +++ b/OsmAnd/res/values-de/strings.xml @@ -2460,8 +2460,13 @@ Abgedeckte Fläche: %1$s x %2$s max/min Zurücksetzen Aufstieg/Abstieg + Track Speicherort + Tracks können im Rec Ordner oder in Monats- bzw. Tagesordnern gespeichert werden. + Aufgezeichnete Tracks im Rec Ordner speichern Aufgezeichnete Tracks in Monatsordnern speichern Aufgezeichnete Tracks in nach Aufzeichnungsmonat benannten Unterordnern speichern (z. B. 2018-01). + Aufgezeichnete Tracks in Tagesordnern speichern + Aufgezeichnete Tracks in nach Aufzeichnungstag benannten Unterordnern speichern (z. B. 2018-01). Zirkel %1$d von %2$d Zeit in Bewegung diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index b7b9d29317..b1f8f701a1 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -739,8 +739,13 @@ Show \'Navigation finished\' dialog Start/stop navigation Tap this button to start or end the navigation. + Track Storage Directory + Tracks can be stored in rec folder or in monthly or daily folders. + Store recorded tracks in rec folder Store recorded tracks in monthly folders Store recorded tracks in sub-folders per recording month (like 2018-01). + Store recorded tracks in daily folders + Store recorded tracks in sub-folders per recording day (like 2018-01-01). Reset Reload Reload tiles to see up to date data. diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java index 8d67e643e7..623e9f13fe 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -1505,9 +1505,13 @@ public class OsmandSettings { SAVE_TRACK_TO_GPX.setModeDefaultValue(ApplicationMode.PEDESTRIAN, false); } + public static final Integer REC_DIRECTORY = 0; + public static final Integer MONTHLY_DIRECTORY = 1; + public static final Integer DAILY_DIRECTORY = 2; + public final CommonPreference DISABLE_RECORDING_ONCE_APP_KILLED = new BooleanPreference("disable_recording_once_app_killed", false).makeGlobal(); - public final CommonPreference STORE_TRACKS_IN_MONTHLY_DIRECTORIES = new BooleanPreference("store_tracks_in_monthly_directories", false).makeGlobal(); + public final CommonPreference TRACK_STORAGE_DIRECTORY = new IntPreference("track_storage_directory", 0).makeGlobal(); // this value string is synchronized with settings_pref.xml preference name public final OsmandPreference FAST_ROUTE_MODE = new BooleanPreference("fast_route_mode", true).makeProfile(); diff --git a/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java b/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java index c1d1b65f5e..90116408f9 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java +++ b/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java @@ -186,7 +186,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper { return false; } - + /** * @return warnings, filenames */ @@ -205,8 +205,12 @@ public class SavingTrackHelper extends SQLiteOpenHelper { if (!data.get(f).isEmpty()) { WptPt pt = data.get(f).findPointToShow(); String fileName = f + "_" + new SimpleDateFormat("HH-mm_EEE", Locale.US).format(new Date(pt.time)); //$NON-NLS-1$ - if (ctx.getSettings().STORE_TRACKS_IN_MONTHLY_DIRECTORIES.get()) { + Integer track_storage_directory = ctx.getSettings().TRACK_STORAGE_DIRECTORY.get(); + if (track_storage_directory != OsmandSettings.REC_DIRECTORY) { SimpleDateFormat dateDirFormat = new SimpleDateFormat("yyyy-MM"); + if (track_storage_directory == OsmandSettings.DAILY_DIRECTORY) { + dateDirFormat = new SimpleDateFormat("yyyy-MM-dd"); + } String dateDirName = dateDirFormat.format(new Date(pt.time)); File dateDir = new File(dir, dateDirName); dateDir.mkdirs(); diff --git a/OsmAnd/src/net/osmand/plus/monitoring/OnSaveCurrentTrackFragment.java b/OsmAnd/src/net/osmand/plus/monitoring/OnSaveCurrentTrackFragment.java index e7957ddc02..3704a780d8 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/OnSaveCurrentTrackFragment.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/OnSaveCurrentTrackFragment.java @@ -42,7 +42,7 @@ public class OnSaveCurrentTrackFragment extends BottomSheetDialogFragment { dismiss(); } - final File f = new File (app.getAppCustomization().getTracksDir() +"/"+ savedGpxName + ".gpx"); + final File f = new File (app.getAppCustomization().getTracksDir(), savedGpxName + ".gpx"); final boolean nightMode = !app.getSettings().isLightContent(); final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme; View mainView = View diff --git a/OsmAnd/src/net/osmand/plus/monitoring/SettingsMonitoringActivity.java b/OsmAnd/src/net/osmand/plus/monitoring/SettingsMonitoringActivity.java index 5a7cb43cd4..d65e21418e 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/SettingsMonitoringActivity.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/SettingsMonitoringActivity.java @@ -16,17 +16,21 @@ import android.preference.PreferenceCategory; import android.preference.PreferenceScreen; import android.view.Window; +import static net.osmand.plus.OsmandSettings.DAILY_DIRECTORY; +import static net.osmand.plus.OsmandSettings.MONTHLY_DIRECTORY; +import static net.osmand.plus.OsmandSettings.REC_DIRECTORY; + public class SettingsMonitoringActivity extends SettingsBaseActivity { private CheckBoxPreference routeServiceEnabled; private BroadcastReceiver broadcastReceiver; - + public static final int[] BG_SECONDS = new int[]{0, 30, 60, 90}; public static final int[] BG_MINUTES = new int[]{2, 3, 5, 10, 15, 30, 60, 90}; private static final int[] SECONDS = OsmandMonitoringPlugin.SECONDS; private static final int[] MINUTES = OsmandMonitoringPlugin.MINUTES; private static final int[] MAX_INTERVAL_TO_SEND_MINUTES = OsmandMonitoringPlugin.MAX_INTERVAL_TO_SEND_MINUTES; - + public SettingsMonitoringActivity() { super(true); } @@ -39,7 +43,7 @@ public class SettingsMonitoringActivity extends SettingsBaseActivity { setProgressVisibility(false); getToolbar().setTitle(R.string.monitoring_settings); PreferenceScreen grp = getPreferenceScreen(); - + createLoggingSection(grp); createLiveSection(grp); createNotificationSection(grp); @@ -87,15 +91,15 @@ public class SettingsMonitoringActivity extends SettingsBaseActivity { R.string.save_track_to_gpx_descrp)); cat.addPreference(createTimeListPreference(settings.SAVE_TRACK_INTERVAL, SECONDS, MINUTES, 1000, R.string.save_track_interval, R.string.save_track_interval_descr)); - String[] names; + String[] names; Float[] floatValues; floatValues = new Float[] {0.f, 2.0f, 5.0f, 10.0f, 20.0f, 30.0f, 50.0f}; names = new String[floatValues.length]; names[0] = getString(R.string.shared_string_not_selected); for(int i = 1; i < floatValues.length; i++) { - names[i] = floatValues[i].intValue() + " " + getString(R.string.m); + names[i] = floatValues[i].intValue() + " " + getString(R.string.m); } - cat.addPreference(createListPreference(settings.SAVE_TRACK_MIN_DISTANCE, names, floatValues, + cat.addPreference(createListPreference(settings.SAVE_TRACK_MIN_DISTANCE, names, floatValues, R.string.save_track_min_distance, R.string.save_track_min_distance_descr)); floatValues = new Float[] {0.f, 1.0f, 2.0f, 5.0f, 10.0f, 15.0f, 20.0f, 50.0f, 100.0f}; names = new String[floatValues.length]; @@ -103,7 +107,7 @@ public class SettingsMonitoringActivity extends SettingsBaseActivity { for(int i = 1; i < floatValues.length; i++) { names[i] = floatValues[i].intValue() + " " + getString(R.string.m) + " (" + Math.round(floatValues[i]/0.3048f) + " " + getString(R.string.foot) + ")"; } - cat.addPreference(createListPreference(settings.SAVE_TRACK_PRECISION, names, floatValues, + cat.addPreference(createListPreference(settings.SAVE_TRACK_PRECISION, names, floatValues, R.string.save_track_precision, R.string.save_track_precision_descr)); floatValues = new Float[] {0.f, 0.000001f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f}; names = new String[floatValues.length]; @@ -113,14 +117,20 @@ public class SettingsMonitoringActivity extends SettingsBaseActivity { names[i] = floatValues[i].intValue() + " " + getString(R.string.km_h); floatValues[i] = floatValues[i] / 3.6f; } - cat.addPreference(createListPreference(settings.SAVE_TRACK_MIN_SPEED, names, floatValues, + cat.addPreference(createListPreference(settings.SAVE_TRACK_MIN_SPEED, names, floatValues, R.string.save_track_min_speed, R.string.save_track_min_speed_descr)); cat.addPreference(createCheckBoxPreference(settings.AUTO_SPLIT_RECORDING, R.string.auto_split_recording_title, R.string.auto_split_recording_descr)); cat.addPreference(createCheckBoxPreference(settings.DISABLE_RECORDING_ONCE_APP_KILLED, R.string.disable_recording_once_app_killed, R.string.disable_recording_once_app_killed_descrp)); - cat.addPreference(createCheckBoxPreference(settings.STORE_TRACKS_IN_MONTHLY_DIRECTORIES, R.string.store_tracks_in_monthly_directories, - R.string.store_tracks_in_monthly_directories_descrp)); + + Integer[] intValues = new Integer[]{REC_DIRECTORY, MONTHLY_DIRECTORY, DAILY_DIRECTORY}; + names = new String[intValues.length]; + names[0] = getString(R.string.store_tracks_in_rec_directory); + names[1] = getString(R.string.store_tracks_in_monthly_directories); + names[2] = getString(R.string.store_tracks_in_daily_directories); + cat.addPreference(createListPreference(settings.TRACK_STORAGE_DIRECTORY, names, intValues, + R.string.track_storage_directory, R.string.track_storage_directory_descrp)); } @@ -129,7 +139,7 @@ public class SettingsMonitoringActivity extends SettingsBaseActivity { cat = new PreferenceCategory(this); cat.setTitle(R.string.live_monitoring_m); grp.addPreference(cat); - + cat.addPreference(createEditTextPreference(settings.LIVE_MONITORING_URL, R.string.live_monitoring_url, R.string.live_monitoring_url_descr)); final CheckBoxPreference liveMonitoring = createCheckBoxPreference(settings.LIVE_MONITORING, R.string.live_monitoring_m, @@ -154,12 +164,12 @@ public class SettingsMonitoringActivity extends SettingsBaseActivity { public void updateAllSettings() { super.updateAllSettings(); - + if(routeServiceEnabled != null) { routeServiceEnabled.setChecked(getMyApplication().getNavigationService() != null); } } - + private void saveCurrentTracks(final SavingTrackHelper helper) { setProgressVisibility(true); getMyApplication().getTaskManager().runInBackground(new OsmAndTaskRunnable() { @@ -178,7 +188,7 @@ public class SettingsMonitoringActivity extends SettingsBaseActivity { }, (Void) null); } - + @Override protected void onDestroy() { super.onDestroy(); @@ -187,7 +197,7 @@ public class SettingsMonitoringActivity extends SettingsBaseActivity { broadcastReceiver = null; } } - + From e82966d014f478b98032be620651561a7134fcf5 Mon Sep 17 00:00:00 2001 From: Denis Kolomiets Date: Mon, 21 Oct 2019 17:38:56 +0300 Subject: [PATCH 3/3] Update strings.xml --- OsmAnd/res/values/strings.xml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index b1f8f701a1..1e10b1152c 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -11,6 +11,11 @@ Thx - Hardy --> + Track Storage Directory + Tracks can be stored in rec folder or in monthly or daily folders. + Store recorded tracks in rec folder + Store recorded tracks in daily folders + Store recorded tracks in sub-folders per recording day (like 2018-01-01). Avoid certain routes and road types Move OsmAnd data files to the new destination?\n%1$s > %2$s %1$s • Used %2$s GB @@ -739,13 +744,8 @@ Show \'Navigation finished\' dialog Start/stop navigation Tap this button to start or end the navigation. - Track Storage Directory - Tracks can be stored in rec folder or in monthly or daily folders. - Store recorded tracks in rec folder Store recorded tracks in monthly folders Store recorded tracks in sub-folders per recording month (like 2018-01). - Store recorded tracks in daily folders - Store recorded tracks in sub-folders per recording day (like 2018-01-01). Reset Reload Reload tiles to see up to date data.