added possibility to store tracks in folders per day and changed options menu accordingly (#5)

This commit is contained in:
jensMF 2019-10-10 12:09:32 +02:00 committed by GitHub
parent 4a8803b341
commit db279b440e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 47 additions and 19 deletions

View file

@ -2460,8 +2460,13 @@ Abgedeckte Fläche: %1$s x %2$s</string>
<string name="max_min">max/min</string> <string name="max_min">max/min</string>
<string name="shared_string_reset">Zurücksetzen</string> <string name="shared_string_reset">Zurücksetzen</string>
<string name="ascent_descent">Aufstieg/Abstieg</string> <string name="ascent_descent">Aufstieg/Abstieg</string>
<string name="track_storage_directory">Track Speicherort</string>
<string name="track_storage_directory_descrp">Tracks können im Rec Ordner oder in Monats- bzw. Tagesordnern gespeichert werden.</string>
<string name="store_tracks_in_rec_directory">Aufgezeichnete Tracks im Rec Ordner speichern</string>
<string name="store_tracks_in_monthly_directories">Aufgezeichnete Tracks in Monatsordnern speichern</string> <string name="store_tracks_in_monthly_directories">Aufgezeichnete Tracks in Monatsordnern speichern</string>
<string name="store_tracks_in_monthly_directories_descrp">Aufgezeichnete Tracks in nach Aufzeichnungsmonat benannten Unterordnern speichern (z. B. 2018-01).</string> <string name="store_tracks_in_monthly_directories_descrp">Aufgezeichnete Tracks in nach Aufzeichnungsmonat benannten Unterordnern speichern (z. B. 2018-01).</string>
<string name="store_tracks_in_daily_directories">Aufgezeichnete Tracks in Tagesordnern speichern</string>
<string name="store_tracks_in_daily_directories_descrp">Aufgezeichnete Tracks in nach Aufzeichnungstag benannten Unterordnern speichern (z. B. 2018-01).</string>
<string name="map_widget_ruler_control">Zirkel</string> <string name="map_widget_ruler_control">Zirkel</string>
<string name="of">%1$d von %2$d</string> <string name="of">%1$d von %2$d</string>
<string name="moving_time">Zeit in Bewegung</string> <string name="moving_time">Zeit in Bewegung</string>

View file

@ -739,8 +739,13 @@
<string name="quick_action_show_navigation_finish_dialog">Show \'Navigation finished\' dialog</string> <string name="quick_action_show_navigation_finish_dialog">Show \'Navigation finished\' dialog</string>
<string name="quick_action_start_stop_navigation">Start/stop navigation</string> <string name="quick_action_start_stop_navigation">Start/stop navigation</string>
<string name="quick_action_start_stop_navigation_descr">Tap this button to start or end the navigation.</string> <string name="quick_action_start_stop_navigation_descr">Tap this button to start or end the navigation.</string>
<string name="track_storage_directory">Track Storage Directory</string>
<string name="track_storage_directory_descrp">Tracks can be stored in rec folder or in monthly or daily folders.</string>
<string name="store_tracks_in_rec_directory">Store recorded tracks in rec folder</string>
<string name="store_tracks_in_monthly_directories">Store recorded tracks in monthly folders</string> <string name="store_tracks_in_monthly_directories">Store recorded tracks in monthly folders</string>
<string name="store_tracks_in_monthly_directories_descrp">Store recorded tracks in sub-folders per recording month (like 2018-01).</string> <string name="store_tracks_in_monthly_directories_descrp">Store recorded tracks in sub-folders per recording month (like 2018-01).</string>
<string name="store_tracks_in_daily_directories">Store recorded tracks in daily folders</string>
<string name="store_tracks_in_daily_directories_descrp">Store recorded tracks in sub-folders per recording day (like 2018-01-01).</string>
<string name="shared_string_reset">Reset</string> <string name="shared_string_reset">Reset</string>
<string name="shared_string_reload">Reload</string> <string name="shared_string_reload">Reload</string>
<string name="mapillary_menu_descr_tile_cache">Reload tiles to see up to date data.</string> <string name="mapillary_menu_descr_tile_cache">Reload tiles to see up to date data.</string>

View file

@ -1505,9 +1505,13 @@ public class OsmandSettings {
SAVE_TRACK_TO_GPX.setModeDefaultValue(ApplicationMode.PEDESTRIAN, false); 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<Boolean> DISABLE_RECORDING_ONCE_APP_KILLED = new BooleanPreference("disable_recording_once_app_killed", false).makeGlobal(); 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(); public final CommonPreference<Integer> TRACK_STORAGE_DIRECTORY = new IntPreference("track_storage_directory", 0).makeGlobal();
// this value string is synchronized with settings_pref.xml preference name // 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(); public final OsmandPreference<Boolean> FAST_ROUTE_MODE = new BooleanPreference("fast_route_mode", true).makeProfile();

View file

@ -186,7 +186,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
return false; return false;
} }
/** /**
* @return warnings, filenames * @return warnings, filenames
*/ */
@ -205,8 +205,12 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
if (!data.get(f).isEmpty()) { if (!data.get(f).isEmpty()) {
WptPt pt = data.get(f).findPointToShow(); WptPt pt = data.get(f).findPointToShow();
String fileName = f + "_" + new SimpleDateFormat("HH-mm_EEE", Locale.US).format(new Date(pt.time)); //$NON-NLS-1$ 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"); 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)); String dateDirName = dateDirFormat.format(new Date(pt.time));
File dateDir = new File(dir, dateDirName); File dateDir = new File(dir, dateDirName);
dateDir.mkdirs(); dateDir.mkdirs();

View file

@ -42,7 +42,7 @@ public class OnSaveCurrentTrackFragment extends BottomSheetDialogFragment {
dismiss(); 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 boolean nightMode = !app.getSettings().isLightContent();
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme; final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
View mainView = View View mainView = View

View file

@ -16,17 +16,21 @@ import android.preference.PreferenceCategory;
import android.preference.PreferenceScreen; import android.preference.PreferenceScreen;
import android.view.Window; 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 { public class SettingsMonitoringActivity extends SettingsBaseActivity {
private CheckBoxPreference routeServiceEnabled; private CheckBoxPreference routeServiceEnabled;
private BroadcastReceiver broadcastReceiver; private BroadcastReceiver broadcastReceiver;
public static final int[] BG_SECONDS = new int[]{0, 30, 60, 90}; 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}; 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[] SECONDS = OsmandMonitoringPlugin.SECONDS;
private static final int[] MINUTES = OsmandMonitoringPlugin.MINUTES; private static final int[] MINUTES = OsmandMonitoringPlugin.MINUTES;
private static final int[] MAX_INTERVAL_TO_SEND_MINUTES = OsmandMonitoringPlugin.MAX_INTERVAL_TO_SEND_MINUTES; private static final int[] MAX_INTERVAL_TO_SEND_MINUTES = OsmandMonitoringPlugin.MAX_INTERVAL_TO_SEND_MINUTES;
public SettingsMonitoringActivity() { public SettingsMonitoringActivity() {
super(true); super(true);
} }
@ -39,7 +43,7 @@ public class SettingsMonitoringActivity extends SettingsBaseActivity {
setProgressVisibility(false); setProgressVisibility(false);
getToolbar().setTitle(R.string.monitoring_settings); getToolbar().setTitle(R.string.monitoring_settings);
PreferenceScreen grp = getPreferenceScreen(); PreferenceScreen grp = getPreferenceScreen();
createLoggingSection(grp); createLoggingSection(grp);
createLiveSection(grp); createLiveSection(grp);
createNotificationSection(grp); createNotificationSection(grp);
@ -87,15 +91,15 @@ public class SettingsMonitoringActivity extends SettingsBaseActivity {
R.string.save_track_to_gpx_descrp)); R.string.save_track_to_gpx_descrp));
cat.addPreference(createTimeListPreference(settings.SAVE_TRACK_INTERVAL, SECONDS, cat.addPreference(createTimeListPreference(settings.SAVE_TRACK_INTERVAL, SECONDS,
MINUTES, 1000, R.string.save_track_interval, R.string.save_track_interval_descr)); MINUTES, 1000, R.string.save_track_interval, R.string.save_track_interval_descr));
String[] names; String[] names;
Float[] floatValues; Float[] floatValues;
floatValues = new Float[] {0.f, 2.0f, 5.0f, 10.0f, 20.0f, 30.0f, 50.0f}; floatValues = new Float[] {0.f, 2.0f, 5.0f, 10.0f, 20.0f, 30.0f, 50.0f};
names = new String[floatValues.length]; names = new String[floatValues.length];
names[0] = getString(R.string.shared_string_not_selected); names[0] = getString(R.string.shared_string_not_selected);
for(int i = 1; i < floatValues.length; i++) { 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)); 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}; 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]; names = new String[floatValues.length];
@ -103,7 +107,7 @@ public class SettingsMonitoringActivity extends SettingsBaseActivity {
for(int i = 1; i < floatValues.length; i++) { 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) + ")"; 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)); 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}; 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]; names = new String[floatValues.length];
@ -113,14 +117,20 @@ public class SettingsMonitoringActivity extends SettingsBaseActivity {
names[i] = floatValues[i].intValue() + " " + getString(R.string.km_h); names[i] = floatValues[i].intValue() + " " + getString(R.string.km_h);
floatValues[i] = floatValues[i] / 3.6f; 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)); 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, cat.addPreference(createCheckBoxPreference(settings.AUTO_SPLIT_RECORDING, R.string.auto_split_recording_title,
R.string.auto_split_recording_descr)); R.string.auto_split_recording_descr));
cat.addPreference(createCheckBoxPreference(settings.DISABLE_RECORDING_ONCE_APP_KILLED, R.string.disable_recording_once_app_killed, cat.addPreference(createCheckBoxPreference(settings.DISABLE_RECORDING_ONCE_APP_KILLED, R.string.disable_recording_once_app_killed,
R.string.disable_recording_once_app_killed_descrp)); 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 = new PreferenceCategory(this);
cat.setTitle(R.string.live_monitoring_m); cat.setTitle(R.string.live_monitoring_m);
grp.addPreference(cat); grp.addPreference(cat);
cat.addPreference(createEditTextPreference(settings.LIVE_MONITORING_URL, R.string.live_monitoring_url, cat.addPreference(createEditTextPreference(settings.LIVE_MONITORING_URL, R.string.live_monitoring_url,
R.string.live_monitoring_url_descr)); R.string.live_monitoring_url_descr));
final CheckBoxPreference liveMonitoring = createCheckBoxPreference(settings.LIVE_MONITORING, R.string.live_monitoring_m, final CheckBoxPreference liveMonitoring = createCheckBoxPreference(settings.LIVE_MONITORING, R.string.live_monitoring_m,
@ -154,12 +164,12 @@ public class SettingsMonitoringActivity extends SettingsBaseActivity {
public void updateAllSettings() { public void updateAllSettings() {
super.updateAllSettings(); super.updateAllSettings();
if(routeServiceEnabled != null) { if(routeServiceEnabled != null) {
routeServiceEnabled.setChecked(getMyApplication().getNavigationService() != null); routeServiceEnabled.setChecked(getMyApplication().getNavigationService() != null);
} }
} }
private void saveCurrentTracks(final SavingTrackHelper helper) { private void saveCurrentTracks(final SavingTrackHelper helper) {
setProgressVisibility(true); setProgressVisibility(true);
getMyApplication().getTaskManager().runInBackground(new OsmAndTaskRunnable<Void, Void, Void>() { getMyApplication().getTaskManager().runInBackground(new OsmAndTaskRunnable<Void, Void, Void>() {
@ -178,7 +188,7 @@ public class SettingsMonitoringActivity extends SettingsBaseActivity {
}, (Void) null); }, (Void) null);
} }
@Override @Override
protected void onDestroy() { protected void onDestroy() {
super.onDestroy(); super.onDestroy();
@ -187,7 +197,7 @@ public class SettingsMonitoringActivity extends SettingsBaseActivity {
broadcastReceiver = null; broadcastReceiver = null;
} }
} }