Marker Bugfixes: markers deletion didn't work and track import didn't include marker's photos. Fixes #514.

Marker edition bugfixed: orphan photos are deleted.
This commit is contained in:
Román Martínez
2020-11-13 18:30:28 +01:00
parent fd77e77bb9
commit 974baaf611
8 changed files with 92 additions and 61 deletions
@@ -20,6 +20,7 @@ import android.net.Uri;
import android.os.Environment;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.core.content.FileProvider;
import androidx.documentfile.provider.DocumentFile;
@@ -289,6 +290,30 @@ public class FileUtils {
return file;
}
/**
* Builds interval photo file object for fileNameUri Uri.
*
* @param context the Context.
* @param trackId the id of the Track.
* @param fileNameUri the file name uri.
* @return file object or null.
*/
public static File buildInternalPhotoFile(Context context, Track.Id trackId, @NonNull Uri fileNameUri) {
if (fileNameUri == null) {
Log.w(TAG, "URI object is null.");
return null;
}
String filename = fileNameUri.getLastPathSegment();
if (filename == null) {
Log.w(TAG, "External photo contains no filename.");
return null;
}
File dir = FileUtils.getPhotoDir(context, trackId);
return new File(dir, filename);
}
/**
* Delete the directory recursively.
*