From 852fc8d7fcb598f0f9ba9a12f5f0a1981fd45dc3 Mon Sep 17 00:00:00 2001 From: Nicolas Bourdin Date: Mon, 16 Dec 2024 15:26:49 +0100 Subject: [PATCH] refractor: Remove 'EXPOSED_EML_PATH' from 'build.gradle' --- app/build.gradle | 2 -- .../mail/ui/main/thread/actions/DownloadMessagesViewModel.kt | 5 +++-- .../main/java/com/infomaniak/mail/utils/LocalStorageUtils.kt | 3 +++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index b75d63e61d..135e2f17f7 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -49,8 +49,6 @@ android { resValue 'string', 'EML_AUTHORITY', 'com.infomaniak.mail.eml' resValue 'string', 'FILES_AUTHORITY', 'com.infomaniak.mail.attachments;com.infomaniak.mail.eml' - resValue 'string', 'EXPOSED_EML_PATH', 'eml_export' - resourceConfigurations += ["en", "de", "es", "fr", "it"] } diff --git a/app/src/main/java/com/infomaniak/mail/ui/main/thread/actions/DownloadMessagesViewModel.kt b/app/src/main/java/com/infomaniak/mail/ui/main/thread/actions/DownloadMessagesViewModel.kt index 387d69a204..f1a09e3d72 100644 --- a/app/src/main/java/com/infomaniak/mail/ui/main/thread/actions/DownloadMessagesViewModel.kt +++ b/app/src/main/java/com/infomaniak/mail/ui/main/thread/actions/DownloadMessagesViewModel.kt @@ -31,6 +31,7 @@ import com.infomaniak.mail.data.api.ApiRepository import com.infomaniak.mail.data.cache.mailboxContent.MessageController import com.infomaniak.mail.data.models.mailbox.Mailbox import com.infomaniak.mail.di.IoDispatcher +import com.infomaniak.mail.utils.LocalStorageUtils.getEmlCacheDir import com.infomaniak.mail.utils.coroutineContext import com.infomaniak.mail.utils.extensions.appContext import dagger.hilt.android.lifecycle.HiltViewModel @@ -90,14 +91,14 @@ class DownloadMessagesViewModel @Inject constructor( } private fun getAllFileNameInExportEmlDir(context: Context): List { - val fileDir = File(context.cacheDir, context.getString(R.string.EXPOSED_EML_PATH)) + val fileDir = getEmlCacheDir(context) if (!fileDir.exists()) fileDir.mkdirs() return fileDir.listFiles()?.map { it.name.removeSuffix(".eml") } ?: emptyList() } private fun saveEmlToFile(context: Context, emlByteArray: ByteArray, fileName: String): Uri? { val fileNameWithExtension = "${fileName.removeIllegalFileNameCharacter()}.eml" - val fileDir = File(context.cacheDir, context.getString(R.string.EXPOSED_EML_PATH)) + val fileDir = getEmlCacheDir(context) if (!fileDir.exists()) fileDir.mkdirs() diff --git a/app/src/main/java/com/infomaniak/mail/utils/LocalStorageUtils.kt b/app/src/main/java/com/infomaniak/mail/utils/LocalStorageUtils.kt index d682a8d95f..d47a927040 100644 --- a/app/src/main/java/com/infomaniak/mail/utils/LocalStorageUtils.kt +++ b/app/src/main/java/com/infomaniak/mail/utils/LocalStorageUtils.kt @@ -36,11 +36,14 @@ object LocalStorageUtils { private const val ATTACHMENTS_UPLOAD_DIR = "attachments_upload" private const val HIDDEN_FILE_NAME = "HIDDEN_FILE_NAME" private const val NAME_TOO_LONG_EXCEPTION = "ENAMETOOLONG" + private const val EML_CACHE_DIR = "eml_export" private inline val Context.attachmentsCacheRootDir get() = File(cacheDir, ATTACHMENTS_CACHE_DIR) private inline val Context.attachmentsUploadRootDir get() = File(filesDir, ATTACHMENTS_UPLOAD_DIR) //region Cache + fun getEmlCacheDir(context: Context): File = File(context.cacheDir, EML_CACHE_DIR) + fun getAttachmentsCacheDir( context: Context, attachmentPath: String,