Skip to content

Commit

Permalink
feat(android): custom gallery folder names
Browse files Browse the repository at this point in the history
  • Loading branch information
m1ga committed Jan 5, 2024
1 parent abdc7bf commit fbd9a55
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ public class MediaModule extends KrollModule implements Handler.Callback
private static String mediaType = MEDIA_TYPE_PHOTO;
private static ContentResolver contentResolver;
private boolean useCameraX = false;
private static String imageFolder = "";

public MediaModule()
{
Expand Down Expand Up @@ -697,6 +698,10 @@ public void showCamera(@SuppressWarnings("rawtypes") HashMap options)
useCameraX = cameraOptions.getBoolean("useCameraX");
}

if (cameraOptions.containsKeyAndNotNull("galleryFolder")) {
imageFolder = cameraOptions.getString("galleryFolder");
}

if ((overlay != null) && (overlay instanceof TiViewProxy)) {
if (useCameraX) {
Log.d(TAG, "Use CameraX");
Expand Down Expand Up @@ -1009,6 +1014,10 @@ private static Uri createExternalMediaContentUri(boolean isVideo, boolean isPubl
if (isVideo) {
contentUri = contentResolver.insert(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, contentValues);
} else {
if (!imageFolder.equals("")) {
contentValues.put(MediaStore.Images.Media.RELATIVE_PATH,
Environment.DIRECTORY_PICTURES + "/" + imageFolder);
}
contentUri = contentResolver.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, contentValues);
}
} else if (isVideo) {
Expand Down

0 comments on commit fbd9a55

Please sign in to comment.