Skip to content

Commit 9c68e63

Browse files
AndyporrasKevin-Salazar-itcrBinnette
authored
Update GPX export path to Documents folder for user accessibility (#458)
* SDK and MinSKD update * Change GPX export to user-accessible location Modifies the GPX export path to save files in a user-accessible location. Previously, files were exported to a default location that was not visible to the user, making access difficult. Exports are now saved in the Downloads folder. The solution works up to the latest version, Android 14. Co-Authored-By: Kevin Salazar <[email protected]> * Update strings-preferences.xml Changed the GPX export location to the Documents folder for better organization and user accessibility, as per feedback. Adjusted related strings and resolved conflicts with PR #451 * Update GPX export logic * Update GpsStatusRecord.java * Update About.java * Update ExportToStorageTask.java * Update strings-preferences.xml * Update ExportToStorageTask.java * Update ExportToStorageTask.java * Update AndroidManifest.xml --------- Co-authored-by: Kevin Salazar <[email protected]> Co-authored-by: Binnette <[email protected]>
1 parent 7f262c5 commit 9c68e63

File tree

4 files changed

+11
-16
lines changed

4 files changed

+11
-16
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@
1717
<uses-permission android:name="android.permission.INTERNET" />
1818
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
1919
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
20-
21-
<!-- External storage permissions -->
22-
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
23-
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
24-
2520
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
2621

2722
<application
@@ -129,4 +124,4 @@
129124

130125
</application>
131126

132-
</manifest>
127+
</manifest>

app/src/main/java/net/osmtracker/activity/About.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ protected void onCreate(Bundle savedInstanceState) {
4848
} catch (NameNotFoundException nnfe) {
4949
// Should not occur
5050
}
51-
51+
5252
findViewById(R.id.about_debug_info_button).setOnClickListener(
5353
new OnClickListener() {
5454

app/src/main/java/net/osmtracker/gpx/ExportToStorageTask.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ protected File getExportDirectory(Date startDate) throws ExportTrackException {
4141
String trackName = getSanitizedTrackNameByStartDate(startDate);
4242
boolean shouldCreateDirectoryPerTrack = shouldCreateDirectoryPerTrack(preferences);
4343
File finalExportDirectory = getBaseExportDirectory(preferences);
44+
Log.d(TAG, "absolute dir: " + finalExportDirectory.getAbsolutePath().toString());
4445

4546
if( shouldCreateDirectoryPerTrack && trackName.length() >= 1){
4647
String uniqueFolderName = getUniqueChildNameFor(finalExportDirectory, trackName, "");
@@ -86,32 +87,31 @@ private boolean isExternalStorageWritable() {
8687
}
8788

8889
// Create before returning if not exists
89-
public File getBaseExportDirectory(SharedPreferences prefs) throws ExportTrackException {
90+
public File getBaseExportDirectory(SharedPreferences prefs) throws ExportTrackException {
9091

9192
if (!isExternalStorageWritable()) {
9293
throw new ExportTrackException(
9394
context.getResources().getString(R.string.error_externalstorage_not_writable));
9495
}
95-
9696
String exportDirectoryNameInPreferences = prefs.getString(
9797
OSMTracker.Preferences.KEY_STORAGE_DIR, OSMTracker.Preferences.VAL_STORAGE_DIR);
9898
Log.d(TAG,"exportDirectoryNameInPreferences: " + exportDirectoryNameInPreferences);
9999

100100
File baseExportDirectory = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS),
101101
exportDirectoryNameInPreferences);
102-
103-
if(! baseExportDirectory.exists()){
102+
103+
// if folder not exists, create it
104+
if (!baseExportDirectory.exists()) {
104105
boolean ok = baseExportDirectory.mkdirs();
105106
if (!ok) {
106107
throw new ExportTrackException(
107-
context.getResources().getString(
108-
R.string.error_externalstorage_not_writable));
108+
context.getResources().getString(R.string.error_externalstorage_not_writable));
109109
}
110110
}
111111

112-
Log.d(TAG, "BaseExportDirectory: " + baseExportDirectory);
112+
Log.d(TAG, "BaseExportDirectory: " + baseExportDirectory.getAbsolutePath());
113113
return baseExportDirectory;
114-
}
114+
}
115115

116116
@Override
117117
protected boolean exportMediaFiles() {

app/src/main/res/values/strings-preferences.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
<string name="prefs_displaytrack_osm_summary_ask">Always display OpenStreetMap background? Requires a data connection</string>
7474

7575
<string name="prefs_output">GPX settings</string>
76-
<string name="prefs_storage_dir">External storage (SD) directory</string>
76+
<string name="prefs_storage_dir">Storage folder in documents</string>
7777
<string name="prefs_storage_dir_hint">Effective for the next track (not the current one)</string>
7878
<string name="prefs_output_one_dir_per_track">One directory per track</string>
7979
<string name="prefs_output_one_dir_per_track_summary">Save each track and associated files to its own directory</string>

0 commit comments

Comments
 (0)