Skip to content

Commit

Permalink
android scope storage change 29->30
Browse files Browse the repository at this point in the history
  • Loading branch information
lwj1994 committed Apr 25, 2023
1 parent e3c5ba6 commit 73d2a42
Showing 1 changed file with 19 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ class ImageGallerySaverPlugin : FlutterPlugin, MethodCallHandler {
val quality = call.argument<Int>("quality") ?: return
val name = call.argument<String>("name")
val folder = call.argument<String>("folder")
if (Build.VERSION.SDK_INT >= 29) {
if (Build.VERSION.SDK_INT >= 30) {
result.success(
saveImageToGallery29(
saveImageToGallery30(
applicationContext!!,
BitmapFactory.decodeByteArray(image, 0, image.size),
name ?: "",
Expand All @@ -59,14 +59,15 @@ class ImageGallerySaverPlugin : FlutterPlugin, MethodCallHandler {
)
}
}

call.method == "saveFileToGallery" -> {
val path = call.argument<String>("file") ?: return
val name = call.argument<String>("name")
val folder = call.argument<String>("folder")

if (Build.VERSION.SDK_INT >= 29) {
if (Build.VERSION.SDK_INT >= 30) {
result.success(
saveFileToGallery29(
saveFileToGallery30(
applicationContext!!,
path,
name ?: "",
Expand All @@ -77,6 +78,7 @@ class ImageGallerySaverPlugin : FlutterPlugin, MethodCallHandler {
result.success(saveFileToGallery(path, name))
}
}

else -> result.notImplemented()
}
}
Expand Down Expand Up @@ -152,7 +154,7 @@ class ImageGallerySaverPlugin : FlutterPlugin, MethodCallHandler {
* android 10 以上版本
*/
@TargetApi(Build.VERSION_CODES.Q)
fun saveImageToGallery29(
fun saveImageToGallery30(
context: Context,
image: Bitmap,
name: String?,
Expand Down Expand Up @@ -206,7 +208,7 @@ class ImageGallerySaverPlugin : FlutterPlugin, MethodCallHandler {
}

@TargetApi(Build.VERSION_CODES.Q)
private fun saveFileToGallery29(
private fun saveFileToGallery30(
context: Context,
filePath: String,
name: String,
Expand All @@ -220,17 +222,17 @@ class ImageGallerySaverPlugin : FlutterPlugin, MethodCallHandler {
if (fileName.contains(".")) {
type = fileName.substringAfterLast(".")
}
val isImage = type.equals("png", ignoreCase = true) ||
type.equals("webp", ignoreCase = true) ||
type.equals("jpg", ignoreCase = true) ||
type.equals("jpeg", ignoreCase = true) ||
type.equals("heic", ignoreCase = true)
type.equals("gif", ignoreCase = true)
type.equals("apng", ignoreCase = true)
type.equals("raw", ignoreCase = true)
type.equals("svg", ignoreCase = true)
type.equals("bmp", ignoreCase = true)
type.equals("tif", ignoreCase = true)
val isImage = type.equals("png", ignoreCase = true)
|| type.equals("webp", ignoreCase = true)
|| type.equals("jpg", ignoreCase = true)
|| type.equals("jpeg", ignoreCase = true)
|| type.equals("heic", ignoreCase = true)
|| type.equals("gif", ignoreCase = true)
|| type.equals("apng", ignoreCase = true)
|| type.equals("raw", ignoreCase = true)
|| type.equals("svg", ignoreCase = true)
|| type.equals("bmp", ignoreCase = true)
|| type.equals("tif", ignoreCase = true)

filePath.substringAfterLast(".")
val currentTime: Long = System.currentTimeMillis()
Expand Down

0 comments on commit 73d2a42

Please sign in to comment.