Skip to content

Commit

Permalink
refractor: Remove 'EXPOSED_EML_PATH' from 'build.gradle'
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasBourdin88 committed Dec 16, 2024
1 parent be1e6a0 commit 852fc8d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 0 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -90,14 +91,14 @@ class DownloadMessagesViewModel @Inject constructor(
}

private fun getAllFileNameInExportEmlDir(context: Context): List<String> {
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()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 852fc8d

Please sign in to comment.