From da843443ef80424941310283a0180935ef8346e4 Mon Sep 17 00:00:00 2001 From: ericdecanini Date: Thu, 14 Apr 2022 11:28:14 +0200 Subject: [PATCH] Convert MediaFileUtils to a non-object --- .../im/vector/lib/multipicker/CameraPicker.kt | 6 ++-- .../lib/multipicker/utils/MediaFileUtils.kt | 33 +++++++++---------- 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/library/multipicker/src/main/java/im/vector/lib/multipicker/CameraPicker.kt b/library/multipicker/src/main/java/im/vector/lib/multipicker/CameraPicker.kt index 4b10a7ceae..785b9fae43 100644 --- a/library/multipicker/src/main/java/im/vector/lib/multipicker/CameraPicker.kt +++ b/library/multipicker/src/main/java/im/vector/lib/multipicker/CameraPicker.kt @@ -23,8 +23,8 @@ import android.provider.MediaStore import androidx.activity.result.ActivityResultLauncher import androidx.core.content.FileProvider import im.vector.lib.multipicker.entity.MultiPickerImageType -import im.vector.lib.multipicker.utils.MediaFileUtils.MediaType.IMAGE -import im.vector.lib.multipicker.utils.MediaFileUtils.createTemporaryMediaFile +import im.vector.lib.multipicker.utils.MediaType +import im.vector.lib.multipicker.utils.createTemporaryMediaFile import im.vector.lib.multipicker.utils.toMultiPickerImageType /** @@ -61,7 +61,7 @@ class CameraPicker { companion object { fun createPhotoUri(context: Context): Uri { - val file = createTemporaryMediaFile(context, IMAGE) + val file = createTemporaryMediaFile(context, MediaType.IMAGE) val authority = context.packageName + ".multipicker.fileprovider" return FileProvider.getUriForFile(context, authority, file) } diff --git a/library/multipicker/src/main/java/im/vector/lib/multipicker/utils/MediaFileUtils.kt b/library/multipicker/src/main/java/im/vector/lib/multipicker/utils/MediaFileUtils.kt index f1dbfbbb33..33cdab3ac2 100644 --- a/library/multipicker/src/main/java/im/vector/lib/multipicker/utils/MediaFileUtils.kt +++ b/library/multipicker/src/main/java/im/vector/lib/multipicker/utils/MediaFileUtils.kt @@ -22,24 +22,21 @@ import java.text.SimpleDateFormat import java.util.Date import java.util.Locale -object MediaFileUtils { - - fun createTemporaryMediaFile(context: Context, mediaType: MediaType): File { - val timeStamp: String = SimpleDateFormat("yyyyMMdd_HHmmss", Locale.getDefault()).format(Date()) - val storageDir: File = context.filesDir.also { it.mkdirs() } - val fileSuffix = when (mediaType) { - MediaType.IMAGE -> ".jpg" - MediaType.VIDEO -> ".mp4" - } - - return File.createTempFile( - "${timeStamp}_", - fileSuffix, - storageDir - ) +fun createTemporaryMediaFile(context: Context, mediaType: MediaType): File { + val timeStamp: String = SimpleDateFormat("yyyyMMdd_HHmmss", Locale.getDefault()).format(Date()) + val storageDir: File = context.filesDir.also { it.mkdirs() } + val fileSuffix = when (mediaType) { + MediaType.IMAGE -> ".jpg" + MediaType.VIDEO -> ".mp4" } - enum class MediaType { - IMAGE, VIDEO - } + return File.createTempFile( + "${timeStamp}_", + fileSuffix, + storageDir + ) +} + +enum class MediaType { + IMAGE, VIDEO }