diff --git a/app/src/main/java/com/infomaniak/mail/data/api/ApiRepository.kt b/app/src/main/java/com/infomaniak/mail/data/api/ApiRepository.kt index 96556eba96..f48356e309 100644 --- a/app/src/main/java/com/infomaniak/mail/data/api/ApiRepository.kt +++ b/app/src/main/java/com/infomaniak/mail/data/api/ApiRepository.kt @@ -435,7 +435,7 @@ object ApiRepository : ApiRepositoryCore() { return callApi(url = ApiRoutes.shareLink(mailboxUuid, folderId, mailId), method = POST) } - fun getDownloadedAttachment(mailboxUuid: String, folderId: String, shortUid: Int): Response { + fun getDownloadedMessage(mailboxUuid: String, folderId: String, shortUid: Int): Response { val request = Request.Builder().url(ApiRoutes.downloadMessage(mailboxUuid, folderId, shortUid)) .headers(HttpUtils.getHeaders(null)) .get() diff --git a/app/src/main/java/com/infomaniak/mail/ui/MainViewModel.kt b/app/src/main/java/com/infomaniak/mail/ui/MainViewModel.kt index ab0e3c312b..1c9cebcfa0 100644 --- a/app/src/main/java/com/infomaniak/mail/ui/MainViewModel.kt +++ b/app/src/main/java/com/infomaniak/mail/ui/MainViewModel.kt @@ -923,7 +923,7 @@ class MainViewModel @Inject constructor( val message = messageController.getMessage(messageUid) ?: return@launch val mailbox = currentMailbox.value ?: return@launch - val response = ApiRepository.getDownloadedAttachment(mailbox.uuid, message.folderId, message.shortUid) + val response = ApiRepository.getDownloadedMessage(mailbox.uuid, message.folderId, message.shortUid) if (!response.isSuccessful || response.body == null) { reportDisplayProblemTrigger.postValue(Unit) @@ -1213,7 +1213,6 @@ class MainViewModel @Inject constructor( private val DEFAULT_SELECTED_FOLDER = FolderRole.INBOX private const val REFRESH_DELAY = 2_000L // We add this delay because `etop` isn't always big enough. private const val MAX_REFRESH_DELAY = 6_000L - private const val EML_CONTENT_TYPE = "message/rfc822" } } diff --git a/app/src/main/java/com/infomaniak/mail/ui/main/folder/TwoPaneFragment.kt b/app/src/main/java/com/infomaniak/mail/ui/main/folder/TwoPaneFragment.kt index 48bf4d3edb..2f46055afc 100644 --- a/app/src/main/java/com/infomaniak/mail/ui/main/folder/TwoPaneFragment.kt +++ b/app/src/main/java/com/infomaniak/mail/ui/main/folder/TwoPaneFragment.kt @@ -41,7 +41,7 @@ import com.infomaniak.mail.ui.MainActivity import com.infomaniak.mail.ui.MainViewModel import com.infomaniak.mail.ui.main.search.SearchFragment import com.infomaniak.mail.ui.main.thread.ThreadFragment -import com.infomaniak.mail.ui.main.thread.actions.DownloadThreadsProgressDialog.Companion.DOWNLOAD_THREADS_RESULT +import com.infomaniak.mail.ui.main.thread.actions.DownloadMessagesProgressDialog import com.infomaniak.mail.utils.extensions.* import javax.inject.Inject @@ -121,7 +121,7 @@ abstract class TwoPaneFragment : Fragment() { private fun observeThreadNavigation() = with(twoPaneViewModel) { getBackNavigationResult(AttachmentExtensions.DOWNLOAD_ATTACHMENT_RESULT, ::startActivity) - getBackNavigationResult(DOWNLOAD_THREADS_RESULT, ::startActivity) + getBackNavigationResult(DownloadMessagesProgressDialog.DOWNLOAD_MESSAGES_RESULT, ::startActivity) newMessageArgs.observe(viewLifecycleOwner) { safeNavigateToNewMessageActivity(args = it.toBundle()) diff --git a/app/src/main/java/com/infomaniak/mail/ui/main/thread/actions/DownloadThreadsProgressDialog.kt b/app/src/main/java/com/infomaniak/mail/ui/main/thread/actions/DownloadMessagesProgressDialog.kt similarity index 88% rename from app/src/main/java/com/infomaniak/mail/ui/main/thread/actions/DownloadThreadsProgressDialog.kt rename to app/src/main/java/com/infomaniak/mail/ui/main/thread/actions/DownloadMessagesProgressDialog.kt index b13af290c2..30f0ad574f 100644 --- a/app/src/main/java/com/infomaniak/mail/ui/main/thread/actions/DownloadThreadsProgressDialog.kt +++ b/app/src/main/java/com/infomaniak/mail/ui/main/thread/actions/DownloadMessagesProgressDialog.kt @@ -33,9 +33,9 @@ import com.infomaniak.mail.utils.KDriveUtils.canSaveOnKDrive import dagger.hilt.android.AndroidEntryPoint @AndroidEntryPoint -class DownloadThreadsProgressDialog : DownloadProgressDialog() { - private val downloadThreadsViewModel: DownloadThreadsViewModel by viewModels() - private val navigationArgs: DownloadThreadsProgressDialogArgs by navArgs() +class DownloadMessagesProgressDialog : DownloadProgressDialog() { + private val downloadThreadsViewModel: DownloadMessagesViewModel by viewModels() + private val navigationArgs: DownloadMessagesProgressDialogArgs by navArgs() override val dialogTitle: String? by lazy { getDialogTitleFromArgs() } override val dialogIconDrawableRes: Int? by lazy { null } @@ -45,7 +45,7 @@ class DownloadThreadsProgressDialog : DownloadProgressDialog() { popBackStackWithError() } else { ArrayList(threadUris).openKDriveOrPlayStore(requireContext())?.let { openKDriveIntent -> - setBackNavigationResult(DOWNLOAD_THREADS_RESULT, openKDriveIntent) + setBackNavigationResult(DOWNLOAD_MESSAGES_RESULT, openKDriveIntent) } ?: run { findNavController().popBackStack() } } } @@ -75,6 +75,6 @@ class DownloadThreadsProgressDialog : DownloadProgressDialog() { } companion object { - const val DOWNLOAD_THREADS_RESULT = "download_threads_result" + const val DOWNLOAD_MESSAGES_RESULT = "download_messages_result" } } diff --git a/app/src/main/java/com/infomaniak/mail/ui/main/thread/actions/DownloadThreadsViewModel.kt b/app/src/main/java/com/infomaniak/mail/ui/main/thread/actions/DownloadMessagesViewModel.kt similarity index 95% rename from app/src/main/java/com/infomaniak/mail/ui/main/thread/actions/DownloadThreadsViewModel.kt rename to app/src/main/java/com/infomaniak/mail/ui/main/thread/actions/DownloadMessagesViewModel.kt index c3e04423d3..b87e6c8a96 100644 --- a/app/src/main/java/com/infomaniak/mail/ui/main/thread/actions/DownloadThreadsViewModel.kt +++ b/app/src/main/java/com/infomaniak/mail/ui/main/thread/actions/DownloadMessagesViewModel.kt @@ -38,7 +38,7 @@ import java.io.File import javax.inject.Inject @HiltViewModel -class DownloadThreadsViewModel @Inject constructor( +class DownloadMessagesViewModel @Inject constructor( application: Application, private val savedStateHandle: SavedStateHandle, private val messageController: MessageController, @@ -48,7 +48,7 @@ class DownloadThreadsViewModel @Inject constructor( private val ioCoroutineContext = viewModelScope.coroutineContext(ioDispatcher) private val messageLocalUids - inline get() = savedStateHandle.get>(DownloadThreadsProgressDialogArgs::messageUids.name)!! + inline get() = savedStateHandle.get>(DownloadMessagesProgressDialogArgs::messageUids.name)!! fun downloadThreads(currentMailbox: Mailbox?) = liveData(ioCoroutineContext) { val downloadedThreadUris: List? = runCatching { @@ -58,7 +58,7 @@ class DownloadThreadsViewModel @Inject constructor( messageLocalUids.forEach { messageUid -> val message = messageController.getMessage(messageUid) ?: return@runCatching null - val response = ApiRepository.getDownloadedAttachment(mailbox.uuid, message.folderId, message.shortUid) + val response = ApiRepository.getDownloadedMessage(mailbox.uuid, message.folderId, message.shortUid) if (!response.isSuccessful || response.body == null) return@runCatching null diff --git a/app/src/main/java/com/infomaniak/mail/ui/main/thread/actions/MessageActionsBottomSheetDialog.kt b/app/src/main/java/com/infomaniak/mail/ui/main/thread/actions/MessageActionsBottomSheetDialog.kt index ba522992c8..ba3eb5a302 100644 --- a/app/src/main/java/com/infomaniak/mail/ui/main/thread/actions/MessageActionsBottomSheetDialog.kt +++ b/app/src/main/java/com/infomaniak/mail/ui/main/thread/actions/MessageActionsBottomSheetDialog.kt @@ -177,7 +177,7 @@ class MessageActionsBottomSheetDialog : MailActionsBottomSheetDialog() { override fun onSaveKDrive() { trackBottomSheetThreadActionsEvent(ACTION_SAVE_KDRIVE_NAME) - navigateToDownloadThreadsProgressDialog( + navigateToDownloadMessagesProgressDialog( listOf(messageUid), mainViewModel.getSubject(threadUid), MessageActionsBottomSheetDialog::class.java.name diff --git a/app/src/main/java/com/infomaniak/mail/ui/main/thread/actions/MultiSelectBottomSheetDialog.kt b/app/src/main/java/com/infomaniak/mail/ui/main/thread/actions/MultiSelectBottomSheetDialog.kt index 311531ad51..5c2eb916ab 100644 --- a/app/src/main/java/com/infomaniak/mail/ui/main/thread/actions/MultiSelectBottomSheetDialog.kt +++ b/app/src/main/java/com/infomaniak/mail/ui/main/thread/actions/MultiSelectBottomSheetDialog.kt @@ -41,7 +41,7 @@ import com.infomaniak.mail.ui.main.folder.ThreadListMultiSelection import com.infomaniak.mail.ui.main.folder.ThreadListMultiSelection.Companion.getReadIconAndShortText import com.infomaniak.mail.utils.extensions.animatedNavigation import com.infomaniak.mail.utils.extensions.deleteWithConfirmationPopup -import com.infomaniak.mail.utils.extensions.navigateToDownloadThreadsProgressDialog +import com.infomaniak.mail.utils.extensions.navigateToDownloadMessagesProgressDialog import dagger.hilt.android.AndroidEntryPoint import javax.inject.Inject @@ -120,7 +120,7 @@ class MultiSelectBottomSheetDialog : ActionsBottomSheetDialog() { } binding.saveKDrive.setClosingOnClickListener(shouldCloseMultiSelection = true) { trackMultiSelectActionEvent(ACTION_SAVE_KDRIVE_NAME, selectedThreadsCount, isFromBottomSheet = true) - navigateToDownloadThreadsProgressDialog( + navigateToDownloadMessagesProgressDialog( messageUids = mainViewModel.getMessagesUidsFromThreadUids(selectedThreadsUids), nameFirstMessage = selectedThreads.firstOrNull()?.subject, MultiSelectBottomSheetDialog::class.java.name, diff --git a/app/src/main/java/com/infomaniak/mail/ui/main/thread/actions/ThreadActionsBottomSheetDialog.kt b/app/src/main/java/com/infomaniak/mail/ui/main/thread/actions/ThreadActionsBottomSheetDialog.kt index 8be61b14d5..1f2bd418d5 100644 --- a/app/src/main/java/com/infomaniak/mail/ui/main/thread/actions/ThreadActionsBottomSheetDialog.kt +++ b/app/src/main/java/com/infomaniak/mail/ui/main/thread/actions/ThreadActionsBottomSheetDialog.kt @@ -198,7 +198,7 @@ class ThreadActionsBottomSheetDialog : MailActionsBottomSheetDialog() { override fun onSaveKDrive() { trackBottomSheetThreadActionsEvent(ACTION_SAVE_KDRIVE_NAME) - navigateToDownloadThreadsProgressDialog( + navigateToDownloadMessagesProgressDialog( messageUids = thread.messages.map { it.uid }, nameFirstMessage = thread.subject, ThreadActionsBottomSheetDialog::class.java.name diff --git a/app/src/main/java/com/infomaniak/mail/utils/extensions/NavigationExtensions.kt b/app/src/main/java/com/infomaniak/mail/utils/extensions/NavigationExtensions.kt index 80b061a7e2..95659dd45b 100644 --- a/app/src/main/java/com/infomaniak/mail/utils/extensions/NavigationExtensions.kt +++ b/app/src/main/java/com/infomaniak/mail/utils/extensions/NavigationExtensions.kt @@ -36,7 +36,7 @@ import com.infomaniak.mail.ui.login.LoginActivity import com.infomaniak.mail.ui.login.LoginActivityArgs import com.infomaniak.mail.ui.login.NoMailboxActivity import com.infomaniak.mail.ui.main.thread.actions.AttachmentActionsBottomSheetDialog -import com.infomaniak.mail.ui.main.thread.actions.DownloadThreadsProgressDialogArgs +import com.infomaniak.mail.ui.main.thread.actions.DownloadMessagesProgressDialogArgs import com.infomaniak.mail.ui.newMessage.NewMessageActivityArgs import com.infomaniak.mail.ui.noValidMailboxes.NoValidMailboxesActivity import com.infomaniak.mail.utils.AccountUtils @@ -91,14 +91,14 @@ fun Fragment.navigateToDownloadProgressDialog( ) } -fun Fragment.navigateToDownloadThreadsProgressDialog( +fun Fragment.navigateToDownloadMessagesProgressDialog( messageUids: List, nameFirstMessage: String?, currentClassName: String ) { safeNavigate( - resId = R.id.downloadThreadsProgressDialog, - args = DownloadThreadsProgressDialogArgs( + resId = R.id.downloadMessagesProgressDialog, + args = DownloadMessagesProgressDialogArgs( messageUids = messageUids.toTypedArray(), nameFirstMessage = nameFirstMessage ).toBundle(), diff --git a/app/src/main/res/navigation/main_navigation.xml b/app/src/main/res/navigation/main_navigation.xml index e682da501d..a8a76ef0cf 100644 --- a/app/src/main/res/navigation/main_navigation.xml +++ b/app/src/main/res/navigation/main_navigation.xml @@ -574,9 +574,9 @@