forked from upstream-mirrors/OpenTracks
Prepend MyTracks to photo folder
This commit is contained in:
@@ -404,8 +404,7 @@ public class TrackDetailActivity extends AbstractSendToGoogleActivity
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
File dir = new File(
|
File dir = FileUtils.getPhotoDir(trackId);
|
||||||
FileUtils.getPath(FileUtils.PICTURES_DIR, Long.toString(trackId)));
|
|
||||||
FileUtils.ensureDirectoryExists(dir);
|
FileUtils.ensureDirectoryExists(dir);
|
||||||
|
|
||||||
String fileName = SimpleDateFormat.getDateTimeInstance().format(new Date());
|
String fileName = SimpleDateFormat.getDateTimeInstance().format(new Date());
|
||||||
|
|||||||
+3
-3
@@ -472,9 +472,9 @@ abstract class AbstractFileTrackImporter extends DefaultHandler implements Track
|
|||||||
if (importTrackId == -1L) {
|
if (importTrackId == -1L) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
String path = FileUtils.getPath(
|
File dir = FileUtils.getPhotoDir(importTrackId);
|
||||||
FileUtils.PICTURES_DIR, Long.toString(importTrackId), fileName);
|
File file = new File(dir, fileName);
|
||||||
return Uri.fromFile(new File(path)).toString();
|
return Uri.fromFile(file).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+2
-4
@@ -115,8 +115,7 @@ public class KmzTrackImporter implements TrackImporter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (importTrackId != -1L) {
|
if (importTrackId != -1L) {
|
||||||
File dir = new File(
|
File dir = FileUtils.getPhotoDir(importTrackId);
|
||||||
FileUtils.getPath(FileUtils.PICTURES_DIR, Long.toString(importTrackId)));
|
|
||||||
if (FileUtils.isDirectory(dir)) {
|
if (FileUtils.isDirectory(dir)) {
|
||||||
for (File file : dir.listFiles()) {
|
for (File file : dir.listFiles()) {
|
||||||
file.delete();
|
file.delete();
|
||||||
@@ -182,8 +181,7 @@ public class KmzTrackImporter implements TrackImporter {
|
|||||||
if (fileName.equals("")) {
|
if (fileName.equals("")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
File dir = new File(
|
File dir = FileUtils.getPhotoDir(importTrackId);
|
||||||
FileUtils.getPath(FileUtils.PICTURES_DIR, Long.toString(importTrackId)));
|
|
||||||
FileUtils.ensureDirectoryExists(dir);
|
FileUtils.ensureDirectoryExists(dir);
|
||||||
|
|
||||||
fileOutputStream = new FileOutputStream(new File(dir, fileName));
|
fileOutputStream = new FileOutputStream(new File(dir, fileName));
|
||||||
|
|||||||
+2
-5
@@ -183,7 +183,7 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
|||||||
// Delete tracks last since it triggers a database vaccum call
|
// Delete tracks last since it triggers a database vaccum call
|
||||||
contentResolver.delete(TracksColumns.CONTENT_URI, null, null);
|
contentResolver.delete(TracksColumns.CONTENT_URI, null, null);
|
||||||
|
|
||||||
File dir = new File(FileUtils.getPath(FileUtils.PICTURES_DIR));
|
File dir = FileUtils.getPhotoDir();
|
||||||
deleteDirectoryRecurse(dir);
|
deleteDirectoryRecurse(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,10 +213,7 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
|||||||
}
|
}
|
||||||
contentResolver.delete(WaypointsColumns.CONTENT_URI, WaypointsColumns.TRACKID + "=?",
|
contentResolver.delete(WaypointsColumns.CONTENT_URI, WaypointsColumns.TRACKID + "=?",
|
||||||
new String[] { Long.toString(trackId) });
|
new String[] { Long.toString(trackId) });
|
||||||
|
deleteDirectoryRecurse(FileUtils.getPhotoDir(trackId));
|
||||||
File dir = new File(
|
|
||||||
FileUtils.getPath(FileUtils.PICTURES_DIR, Long.toString(trackId)));
|
|
||||||
deleteDirectoryRecurse(dir);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -33,11 +33,6 @@ public class FileUtils {
|
|||||||
*/
|
*/
|
||||||
public static final String BACKUPS_DIR = "backups";
|
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.
|
* The My Tracks external storage directory.
|
||||||
*/
|
*/
|
||||||
@@ -59,6 +54,11 @@ public class FileUtils {
|
|||||||
*/
|
*/
|
||||||
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.
|
* Returns true if the external storage is available.
|
||||||
*/
|
*/
|
||||||
@@ -98,6 +98,14 @@ public class FileUtils {
|
|||||||
return dir.mkdirs();
|
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.
|
* Gets the display name for a path on the external storage.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user