Skip to content

Commit

Permalink
Fix error on putVideo to album in android 29
Browse files Browse the repository at this point in the history
  • Loading branch information
natsuk4ze committed Aug 9, 2023
1 parent 0cc1f3e commit d534c7c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions android/src/main/java/studio/midoridesign/gal/GalPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class GalPlugin implements FlutterPlugin, MethodCallHandler, ActivityAwar
private static final Uri IMAGE_URI = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
private static final Uri VIDEO_URI = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
private static final int PERMISSION_REQUEST_CODE = 1317298; // Anything unique in the app.
private static final boolean USE_EXTERNAL_STORAGE = Build.VERSION.SDK_INT < 29;
private static final boolean USE_EXTERNAL_STORAGE = Build.VERSION.SDK_INT <= 29;
private static final boolean HAS_ACCESS_BY_DEFAULT =
Build.VERSION.SDK_INT < 23 || Build.VERSION.SDK_INT >= 29;

Expand Down Expand Up @@ -140,8 +140,9 @@ private void writeData(Context context, InputStream in, boolean isImage, String
String album) throws IOException, SecurityException, FileNotFoundException {
ContentResolver resolver = context.getContentResolver();
ContentValues values = new ContentValues();
String dirPath = isImage || album != null ? "Pictures" : "Movies";

String dirPath = isImage || album != null ? Environment.DIRECTORY_PICTURES
: Environment.DIRECTORY_MOVIES;

if (USE_EXTERNAL_STORAGE) {
File dir = new File(Environment.getExternalStoragePublicDirectory(dirPath),
album != null ? album : "");
Expand Down

0 comments on commit d534c7c

Please sign in to comment.