Skip to content

Commit

Permalink
Customize export label for file sharing #470
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin-Salazar-itcr committed Dec 10, 2024
1 parent 9488714 commit 167a902
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions app/src/main/java/net/osmtracker/OSMTracker.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class OSMTracker {
public static final class Preferences {
// Property names
public final static String KEY_STORAGE_DIR = "logging.storage.dir";
public final static String KEY_EXPORT_LABEL = "gpx.export.label";
public final static String KEY_VOICEREC_DURATION = "voicerec.duration";
public final static String KEY_UI_THEME = "ui.theme";
public final static String KEY_GPS_OSSETTINGS = "gps.ossettings";
Expand Down Expand Up @@ -52,6 +53,7 @@ public static final class Preferences {

// Default values
public final static String VAL_STORAGE_DIR = "/osmtracker";
public final static String VAL_EXPORT_LABEL = "_OSMTracker";
public final static String VAL_VOICEREC_DURATION = "2";
public final static String VAL_UI_THEME = "net.osmtracker:style/DefaultTheme";
public final static boolean VAL_GPS_CHECKSTARTUP = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import android.content.Context;
import android.database.Cursor;
import android.preference.PreferenceManager;
import android.util.Log;

import net.osmtracker.OSMTracker;
import net.osmtracker.db.DataHelper;
import net.osmtracker.exception.ExportTrackException;

Expand All @@ -26,7 +28,12 @@ public abstract class ExportToTempFileTask extends ExportTrackTask {
public ExportToTempFileTask(Context context, long trackId) {
super(context, trackId);
try {
tmpFile = new File(context.getCacheDir(), new DataHelper(context).getTrackById(trackId).getName()+"_OSMTracker.gpx");
String exportLabelName = PreferenceManager.getDefaultSharedPreferences(context).getString(
OSMTracker.Preferences.KEY_EXPORT_LABEL, OSMTracker.Preferences.VAL_EXPORT_LABEL);
String trackName = new DataHelper(context).getTrackById(trackId).getName();

// Create temporary file
tmpFile = new File(context.getCacheDir(), trackName + exportLabelName+".gpx");
Log.d(TAG, "Temporary file: " + tmpFile.getAbsolutePath());

} catch (Exception ioe) {
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings-preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@

<string name="prefs_output">GPX settings</string>
<string name="prefs_storage_dir">Storage folder in documents</string>
<string name="prefs_export_label">Export label for sharing files</string>
<string name="prefs_storage_dir_hint">Effective for the next track (not the current one)</string>
<string name="prefs_output_one_dir_per_track">One directory per track</string>
<string name="prefs_output_one_dir_per_track_summary">Save each track and associated files to its own directory</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
android:title="@string/prefs_output_one_dir_per_track"
android:summary="@string/prefs_output_one_dir_per_track_summary"
android:defaultValue="true" />
<EditTextPreference android:key="gpx.export.label"
android:defaultValue="_OSMTracker" android:title="@string/prefs_export_label"/>
<ListPreference android:key="gpx.filename" android:defaultValue="name_date" android:summary="@string/prefs_output_filename_summary"
android:title="@string/prefs_output_filename" android:entryValues="@array/prefs_output_filename_values"
android:entries="@array/prefs_output_filename_keys" />
Expand Down

0 comments on commit 167a902

Please sign in to comment.