Merge pull request #4012 from njohnston/gpx_monthly_directories

Optionally store recorded GPX tracks in monthly directories
This commit is contained in:
vshcherb 2017-07-03 18:38:22 +03:00 committed by GitHub
commit 21687914c3
4 changed files with 21 additions and 0 deletions

View file

@ -9,6 +9,8 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
-->
<string name="store_tracks_in_monthly_directories">Store recorded tracks in monthly directories</string>
<string name="store_tracks_in_monthly_directories_descrp">Store recorded tracks in directories based on the month that the track was recorded in, for example 2017-01 for January 2017.</string>
<string name="shared_string_reset">Reset</string>
<string name="shared_string_reload">Reload</string>
<string name="mapillary_menu_descr_tile_cache">Reload tiles to see up to date data.</string>

View file

@ -1028,6 +1028,8 @@ public class OsmandSettings {
public final CommonPreference<Boolean> DISABLE_RECORDING_ONCE_APP_KILLED = new BooleanPreference("disable_recording_once_app_killed", false).makeGlobal();
public final CommonPreference<Boolean> STORE_TRACKS_IN_MONTHLY_DIRECTORIES = new BooleanPreference("store_tracks_in_monthly_directories", false).makeGlobal();
// this value string is synchronized with settings_pref.xml preference name
public final OsmandPreference<Boolean> FAST_ROUTE_MODE = new BooleanPreference("fast_route_mode", true).makeProfile();
// temporarily for new version

View file

@ -32,6 +32,7 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;
public class SavingTrackHelper extends SQLiteOpenHelper {
@ -198,6 +199,20 @@ 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();
if (ctx.getSettings().STORE_TRACKS_IN_MONTHLY_DIRECTORIES.get()) {
SimpleDateFormat dateDirFormat = new SimpleDateFormat("yyyy-MM");
dateDirFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
String dateDirName = dateDirFormat.format(new Date(pt.time));
File dateDir = new File(dir, dateDirName);
dateDir.mkdirs();
if (dateDir.exists()) {
dir = dateDir;
}
}
String fileName = f + "_" + new SimpleDateFormat("HH-mm_EEE", Locale.US).format(new Date(pt.time)); //$NON-NLS-1$
fout = new File(dir, fileName + ".gpx"); //$NON-NLS-1$
int ind = 1;

View file

@ -118,6 +118,8 @@ public class SettingsMonitoringActivity extends SettingsBaseActivity {
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));
}