mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-14 06:22:49 +01:00
Use the file extension from the ImageType enum (#6800)
* Use the file extension from the ImageType enum * Use the mime type from the ImageType enum - On Android 29+
This commit is contained in:
parent
da2b30268a
commit
cd07027192
@ -28,7 +28,7 @@ class ImageSaver(
|
|||||||
val data = image.data
|
val data = image.data
|
||||||
|
|
||||||
val type = ImageUtil.findImageType(data) ?: throw Exception("Not an image")
|
val type = ImageUtil.findImageType(data) ?: throw Exception("Not an image")
|
||||||
val filename = DiskUtil.buildValidFilename("${image.name}.$type")
|
val filename = DiskUtil.buildValidFilename("${image.name}.${type.extension}")
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
|
||||||
return save(data(), image.location.directory(context), filename)
|
return save(data(), image.location.directory(context), filename)
|
||||||
@ -43,6 +43,7 @@ class ImageSaver(
|
|||||||
|
|
||||||
val contentValues = ContentValues().apply {
|
val contentValues = ContentValues().apply {
|
||||||
put(MediaStore.Images.Media.DISPLAY_NAME, image.name)
|
put(MediaStore.Images.Media.DISPLAY_NAME, image.name)
|
||||||
|
put(MediaStore.Images.Media.MIME_TYPE, type.mime)
|
||||||
put(
|
put(
|
||||||
MediaStore.Images.Media.RELATIVE_PATH,
|
MediaStore.Images.Media.RELATIVE_PATH,
|
||||||
"${Environment.DIRECTORY_PICTURES}/${context.getString(R.string.app_name)}/" +
|
"${Environment.DIRECTORY_PICTURES}/${context.getString(R.string.app_name)}/" +
|
||||||
|
Loading…
Reference in New Issue
Block a user