mirror of
https://codeberg.org/OpenTracksApp/OpenTracks.git
synced 2026-10-02 17:43:06 +02:00
Prepend MyTracks to photo folder
This commit is contained in:
@@ -404,8 +404,7 @@ public class TrackDetailActivity extends AbstractSendToGoogleActivity
|
||||
return false;
|
||||
}
|
||||
|
||||
File dir = new File(
|
||||
FileUtils.getPath(FileUtils.PICTURES_DIR, Long.toString(trackId)));
|
||||
File dir = FileUtils.getPhotoDir(trackId);
|
||||
FileUtils.ensureDirectoryExists(dir);
|
||||
|
||||
String fileName = SimpleDateFormat.getDateTimeInstance().format(new Date());
|
||||
|
||||
+3
-3
@@ -472,9 +472,9 @@ abstract class AbstractFileTrackImporter extends DefaultHandler implements Track
|
||||
if (importTrackId == -1L) {
|
||||
return null;
|
||||
}
|
||||
String path = FileUtils.getPath(
|
||||
FileUtils.PICTURES_DIR, Long.toString(importTrackId), fileName);
|
||||
return Uri.fromFile(new File(path)).toString();
|
||||
File dir = FileUtils.getPhotoDir(importTrackId);
|
||||
File file = new File(dir, fileName);
|
||||
return Uri.fromFile(file).toString();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+2
-4
@@ -115,8 +115,7 @@ public class KmzTrackImporter implements TrackImporter {
|
||||
}
|
||||
|
||||
if (importTrackId != -1L) {
|
||||
File dir = new File(
|
||||
FileUtils.getPath(FileUtils.PICTURES_DIR, Long.toString(importTrackId)));
|
||||
File dir = FileUtils.getPhotoDir(importTrackId);
|
||||
if (FileUtils.isDirectory(dir)) {
|
||||
for (File file : dir.listFiles()) {
|
||||
file.delete();
|
||||
@@ -182,8 +181,7 @@ public class KmzTrackImporter implements TrackImporter {
|
||||
if (fileName.equals("")) {
|
||||
return;
|
||||
}
|
||||
File dir = new File(
|
||||
FileUtils.getPath(FileUtils.PICTURES_DIR, Long.toString(importTrackId)));
|
||||
File dir = FileUtils.getPhotoDir(importTrackId);
|
||||
FileUtils.ensureDirectoryExists(dir);
|
||||
|
||||
fileOutputStream = new FileOutputStream(new File(dir, fileName));
|
||||
|
||||
+3
-6
@@ -183,7 +183,7 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
||||
// Delete tracks last since it triggers a database vaccum call
|
||||
contentResolver.delete(TracksColumns.CONTENT_URI, null, null);
|
||||
|
||||
File dir = new File(FileUtils.getPath(FileUtils.PICTURES_DIR));
|
||||
File dir = FileUtils.getPhotoDir();
|
||||
deleteDirectoryRecurse(dir);
|
||||
}
|
||||
|
||||
@@ -212,11 +212,8 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
||||
contentResolver.delete(TrackPointsColumns.CONTENT_URI, where, selectionArgs);
|
||||
}
|
||||
contentResolver.delete(WaypointsColumns.CONTENT_URI, WaypointsColumns.TRACKID + "=?",
|
||||
new String[] { Long.toString(trackId) });
|
||||
|
||||
File dir = new File(
|
||||
FileUtils.getPath(FileUtils.PICTURES_DIR, Long.toString(trackId)));
|
||||
deleteDirectoryRecurse(dir);
|
||||
new String[] { Long.toString(trackId) });
|
||||
deleteDirectoryRecurse(FileUtils.getPhotoDir(trackId));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,11 +33,6 @@ public class FileUtils {
|
||||
*/
|
||||
public static final String BACKUPS_DIR = "backups";
|
||||
|
||||
/**
|
||||
* The pictures directory under the My Tracks external storage directory.
|
||||
*/
|
||||
public static final String PICTURES_DIR = "pictures";
|
||||
|
||||
/**
|
||||
* The My Tracks external storage directory.
|
||||
*/
|
||||
@@ -53,12 +48,17 @@ public class FileUtils {
|
||||
* The play tracks directory under the My Tracks cache directory.
|
||||
*/
|
||||
public static final String PLAY_TRACKS_DIR = "temp";
|
||||
|
||||
|
||||
/**
|
||||
* The temp files directory under the My Tracks cache directory.
|
||||
*/
|
||||
public static final String TEMP_FILES_DIR = "temp_files";
|
||||
|
||||
public static final String TEMP_FILES_DIR = "temp_files";
|
||||
|
||||
/**
|
||||
* The pictures directory under the My Tracks external storage directory.
|
||||
*/
|
||||
private static final String PICTURES_DIR = "pictures";
|
||||
|
||||
/**
|
||||
* Returns true if the external storage is available.
|
||||
*/
|
||||
@@ -98,6 +98,14 @@ public class FileUtils {
|
||||
return dir.mkdirs();
|
||||
}
|
||||
|
||||
public static File getPhotoDir() {
|
||||
return new File(getPath(PICTURES_DIR));
|
||||
}
|
||||
|
||||
public static File getPhotoDir(long trackId) {
|
||||
return new File(getPath(PICTURES_DIR, "MyTracks" + Long.toString(trackId)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the display name for a path on the external storage.
|
||||
*
|
||||
@@ -150,9 +158,9 @@ public class FileUtils {
|
||||
if (index == -1) {
|
||||
return fileName;
|
||||
}
|
||||
return fileName.substring(0, index);
|
||||
return fileName.substring(0, index);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the extension from a file name. Returns null if there is no extension.
|
||||
*
|
||||
@@ -164,8 +172,8 @@ public class FileUtils {
|
||||
return null;
|
||||
}
|
||||
return fileName.substring(index + 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a filename with the given base and the given extension, possibly
|
||||
* adding a suffix to ensure the file doesn't exist.
|
||||
|
||||
Reference in New Issue
Block a user