diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f801657..3ea5ec76 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,8 @@ To know more about breaking changes, see the [Migration Guide][]. ### Fixes - Do not use `privateFileURL` on iOS 18+. +- Fixes saving MP4 videos will result in 3GP on Android API 30-. +- Fixes nullable result returned when saving images and videos on Android. ## 3.5.2 diff --git a/android/src/main/kotlin/com/fluttercandies/photo_manager/core/PhotoManagerPlugin.kt b/android/src/main/kotlin/com/fluttercandies/photo_manager/core/PhotoManagerPlugin.kt index 23998203..82bb2334 100644 --- a/android/src/main/kotlin/com/fluttercandies/photo_manager/core/PhotoManagerPlugin.kt +++ b/android/src/main/kotlin/com/fluttercandies/photo_manager/core/PhotoManagerPlugin.kt @@ -493,7 +493,7 @@ class PhotoManagerPlugin( resultHandler.reply(map) } catch (e: Exception) { LogUtils.error("save image error", e) - resultHandler.reply(null) + resultHandler.replyError(call.method, message = null, obj = e) } } @@ -515,7 +515,7 @@ class PhotoManagerPlugin( resultHandler.reply(map) } catch (e: Exception) { LogUtils.error("save image error", e) - resultHandler.reply(null) + resultHandler.replyError(call.method, message = null, obj = e) } } @@ -537,7 +537,7 @@ class PhotoManagerPlugin( resultHandler.reply(map) } catch (e: Exception) { LogUtils.error("save video error", e) - resultHandler.reply(null) + resultHandler.replyError(call.method, message = null, obj = e) } } diff --git a/android/src/main/kotlin/com/fluttercandies/photo_manager/core/utils/IDBUtils.kt b/android/src/main/kotlin/com/fluttercandies/photo_manager/core/utils/IDBUtils.kt index aefd1225..ba9875e6 100644 --- a/android/src/main/kotlin/com/fluttercandies/photo_manager/core/utils/IDBUtils.kt +++ b/android/src/main/kotlin/com/fluttercandies/photo_manager/core/utils/IDBUtils.kt @@ -452,6 +452,18 @@ interface IDBUtils { if (relativePath.isNotBlank()) { put(RELATIVE_PATH, relativePath) } + } else { + val albumDir = File( + Environment.getExternalStorageDirectory().path, + Environment.DIRECTORY_MOVIES + ) + // Check if the directory exist. + File(albumDir, title).path.checkDirs() + // Using a duplicate file name that already exists on the device will cause + // inserts to fail on Android API 29-. + val basename = System.currentTimeMillis().toString() + val newFilePath = File(albumDir, "$basename.${file.extension}").absolutePath + put(DATA, newFilePath) } if (latLong != null) { put(MediaStore.Video.VideoColumns.LATITUDE, latLong.first())