forked from upstream-mirrors/OpenTracks
BREAKING CHANGE: pictures are now stored in getExternalFilesDir(); no migration takes place!
This commit is contained in:
@@ -72,11 +72,6 @@ public class ExportActivity extends FragmentActivity implements FileTypeDialogFr
|
||||
super.onActivityResult(requestCode, resultCode, resultData);
|
||||
if (requestCode == EXTERNAL_STORAGE_PERMISSION_REQUEST_CODE) {
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
// final int takeFlags = resultData.getFlags()
|
||||
// & (Intent.FLAG_GRANT_READ_URI_PERMISSION
|
||||
// | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
|
||||
//// Check for the freshest data.
|
||||
// getContentResolver().takePersistableUriPermission(uri, takeFlags);
|
||||
directoryUri = resultData.getData();
|
||||
fileTypeDialogStart();
|
||||
} else {
|
||||
@@ -93,9 +88,9 @@ public class ExportActivity extends FragmentActivity implements FileTypeDialogFr
|
||||
@Override
|
||||
public void onFileTypeDone(TrackFileFormat trackFileFormat) {
|
||||
DocumentFile pickedDirectory = DocumentFile.fromTreeUri(this, directoryUri);
|
||||
DocumentFile exportDirectory = pickedDirectory.findFile(FileUtils.SDCARD_TOP_DIR);
|
||||
DocumentFile exportDirectory = pickedDirectory.findFile(FileUtils.EXPORT_DIR);
|
||||
if (exportDirectory == null) {
|
||||
exportDirectory = pickedDirectory.createDirectory(FileUtils.SDCARD_TOP_DIR);
|
||||
exportDirectory = pickedDirectory.createDirectory(FileUtils.EXPORT_DIR);
|
||||
}
|
||||
|
||||
directoryDisplayName = FileUtils.getPathDisplayName(trackFileFormat.getExtension());
|
||||
|
||||
+1
-1
@@ -377,7 +377,7 @@ abstract class AbstractFileTrackImporter extends DefaultHandler implements Track
|
||||
if (importTrackId == -1L) {
|
||||
return null;
|
||||
}
|
||||
File dir = FileUtils.getPhotoDir(importTrackId);
|
||||
File dir = FileUtils.getPhotoDir(context, importTrackId);
|
||||
File file = new File(dir, fileName);
|
||||
return Uri.fromFile(file).toString();
|
||||
}
|
||||
|
||||
@@ -73,11 +73,6 @@ public class ImportActivity extends FragmentActivity implements FileTypeDialogFr
|
||||
super.onActivityResult(requestCode, resultCode, resultData);
|
||||
if (requestCode == EXTERNAL_STORAGE_PERMISSION_REQUEST_CODE) {
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
// final int takeFlags = resultData.getFlags()
|
||||
// & (Intent.FLAG_GRANT_READ_URI_PERMISSION
|
||||
// | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
|
||||
//// Check for the freshest data.
|
||||
// getContentResolver().takePersistableUriPermission(uri, takeFlags);
|
||||
directoryUri = resultData.getData();
|
||||
fileTypeDialogStart();
|
||||
} else {
|
||||
|
||||
@@ -68,7 +68,7 @@ public class KmzTrackImporter implements TrackImporter {
|
||||
while ((zipEntry = zipInputStream.getNextEntry()) != null) {
|
||||
if (Thread.interrupted()) {
|
||||
Log.d(TAG, "Thread interrupted");
|
||||
cleanImport(trackId);
|
||||
cleanImport(context, trackId);
|
||||
return -1L;
|
||||
}
|
||||
String fileName = zipEntry.getName();
|
||||
@@ -76,7 +76,7 @@ public class KmzTrackImporter implements TrackImporter {
|
||||
trackId = parseKml(zipInputStream);
|
||||
if (trackId == -1L) {
|
||||
Log.d(TAG, "Unable to parse kml in kmz");
|
||||
cleanImport(trackId);
|
||||
cleanImport(context, trackId);
|
||||
return -1L;
|
||||
}
|
||||
} else {
|
||||
@@ -90,7 +90,7 @@ public class KmzTrackImporter implements TrackImporter {
|
||||
return trackId;
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "Unable to import file", e);
|
||||
cleanImport(trackId);
|
||||
cleanImport(context, trackId);
|
||||
return -1L;
|
||||
}
|
||||
}
|
||||
@@ -100,15 +100,15 @@ public class KmzTrackImporter implements TrackImporter {
|
||||
*
|
||||
* @param trackId the trackId
|
||||
*/
|
||||
private void cleanImport(long trackId) {
|
||||
private void cleanImport(Context context, long trackId) {
|
||||
if (PreferencesUtils.isRecording(trackId)) {
|
||||
ContentProviderUtils contentProviderUtils = new ContentProviderUtils(context);
|
||||
contentProviderUtils.deleteTrack(context, trackId);
|
||||
}
|
||||
|
||||
if (importTrackId != -1L) {
|
||||
File dir = FileUtils.getPhotoDir(importTrackId);
|
||||
if (FileUtils.isDirectory(dir)) {
|
||||
File dir = FileUtils.getPhotoDir(context, importTrackId);
|
||||
if (dir.exists() && dir.isDirectory()) {
|
||||
for (File file : dir.listFiles()) {
|
||||
file.delete();
|
||||
}
|
||||
@@ -159,8 +159,7 @@ public class KmzTrackImporter implements TrackImporter {
|
||||
return;
|
||||
}
|
||||
|
||||
File dir = FileUtils.getPhotoDir(importTrackId);
|
||||
FileUtils.ensureDirectoryExists(dir);
|
||||
File dir = FileUtils.getPhotoDir(context, importTrackId);
|
||||
File file = new File(dir, fileName);
|
||||
|
||||
try (FileOutputStream fileOutputStream = new FileOutputStream(file)) {
|
||||
|
||||
Reference in New Issue
Block a user