Skip to content

Commit

Permalink
#141 - Show only the folder name instead of the complete uri path
Browse files Browse the repository at this point in the history
  • Loading branch information
GrazianoCapelli committed Nov 21, 2021
1 parent ad6316e commit 6d33d8b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -357,11 +357,13 @@ else if (evList.size() == 1)
pGPXVersion.setSummary(pGPXVersion.getEntry());
pShowTrackStatsType.setSummary(pShowTrackStatsType.getEntry());
pShowDirections.setSummary(pShowDirections.getEntry());
if (GPSApplication.getInstance().isExportFolderWritable())
pExportFolder.setSummary(prefs.getString("prefExportFolder", "").replace("%3A","/").replace("%20"," "));
else
pExportFolder.setSummary(getString(R.string.pref_not_set));
//pViewTracksWith.setSummary(pViewTracksWith.getEntry());

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
if (GPSApplication.getInstance().isExportFolderWritable())
pExportFolder.setSummary(GPSApplication.getInstance().extractFolderNameFromEncodedUri(prefs.getString("prefExportFolder", "")));
else
pExportFolder.setSummary(getString(R.string.pref_not_set));
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ public void onEvent(Short msg) {
@Override
public void run() {
Toast toast = Toast.makeText(gpsApp.getApplicationContext(),
gpsApp.getString(R.string.toast_track_exported, gpsApp.getPrefExportFolder()), Toast.LENGTH_LONG);
gpsApp.getString(R.string.toast_track_exported, gpsApp.extractFolderNameFromEncodedUri(gpsApp.getPrefExportFolder())), Toast.LENGTH_LONG);
toast.setGravity(Gravity.BOTTOM, 0, TOAST_VERTICAL_OFFSET);
toast.show();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,20 @@ public String getFileName(Track track) {
return track.getName() + " - " + stringToDescFileName(track.getDescription());
}

/**
* Extracts the folder name starting from the encoded uri.
*
* @param uriPath The encoded URI path
* @return the path of the folder
*/
public String extractFolderNameFromEncodedUri(String uriPath) {
String spath = Uri.decode(uriPath);
if (spath.contains(":")) {
String[] spathParts = spath.split(":");
return spathParts[spathParts.length - 1];
} else return spath;
}

// ---------------------------------------------------------------------- Preferences Excluded from Backup
// These are Boolean SharedPreferences that are excluded by automatic Backups

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
<!-- Main menu -->
<string name="menu_settings">Settings</string>
<string name="toast_track_saved_into_tracklist">Track saved into the Tracklist</string>
<string name="toast_track_exported">Tracks exported in %1$s</string>
<string name="toast_track_exported">Tracks exported in \"%1$s\"</string>
<string name="menu_about">About</string>
<string name="menu_online_help">Online help</string>
<string name="menu_shutdown">Shutdown</string>
Expand Down

0 comments on commit 6d33d8b

Please sign in to comment.