From 6ecb56409866d6586c3cae4fe4bd2f68a15c2344 Mon Sep 17 00:00:00 2001 From: denbond7 Date: Tue, 11 Feb 2025 15:43:16 +0200 Subject: [PATCH 01/12] wip --- .../email/providers/EmbeddedAttachmentsProvider.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/providers/EmbeddedAttachmentsProvider.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/providers/EmbeddedAttachmentsProvider.kt index 50389a5ed2..35af0ac35d 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/providers/EmbeddedAttachmentsProvider.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/providers/EmbeddedAttachmentsProvider.kt @@ -59,6 +59,12 @@ class EmbeddedAttachmentsProvider : DocumentsProvider() { return getFileDescriptor(getBytesForDocumentId(documentId)) } + override fun getDocumentType(documentId: String?): String { + return documentId?.let { + Cache.getInstance().get(documentId)?.type ?: super.getDocumentType(documentId) + } ?: super.getDocumentType(documentId) + } + private fun getBytesForDocumentId(documentId: String): ByteArray { val attachmentInfo = Cache.getInstance().get(documentId) return requireNotNull(attachmentInfo?.rawData) From b3e83e145ac9078b934e2c6b1fdcaf2393f6fe17 Mon Sep 17 00:00:00 2001 From: denbond7 Date: Tue, 11 Feb 2025 16:47:47 +0200 Subject: [PATCH 02/12] wip --- .../fragment/ThreadDetailsFragment.kt | 52 +++++++++++++++++-- .../email/util/FileAndDirectoryUtils.kt | 19 ++++++- FlowCrypt/src/main/res/values-ru/strings.xml | 1 + FlowCrypt/src/main/res/values-uk/strings.xml | 1 + FlowCrypt/src/main/res/values/strings.xml | 1 + 5 files changed, 70 insertions(+), 4 deletions(-) diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/ThreadDetailsFragment.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/ThreadDetailsFragment.kt index 7ce51bb9e3..7bbcf46b38 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/ThreadDetailsFragment.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/ThreadDetailsFragment.kt @@ -93,6 +93,7 @@ import com.flowcrypt.email.ui.activity.fragment.dialog.TwoWayDialogFragment import com.flowcrypt.email.ui.adapter.GmailApiLabelsListAdapter import com.flowcrypt.email.ui.adapter.MessagesInThreadListAdapter import com.flowcrypt.email.ui.adapter.recyclerview.itemdecoration.SkipFirstAndLastDividerItemDecoration +import com.flowcrypt.email.util.FileAndDirectoryUtils import com.flowcrypt.email.util.GeneralUtil import com.flowcrypt.email.util.exception.ThreadNotFoundException import com.google.api.client.googleapis.json.GoogleJsonResponseException @@ -593,6 +594,21 @@ class ThreadDetailsFragment : BaseFragment(), Prog } } + REQUEST_CODE_DOWNLOAD_FILE_AGAIN -> { + if (result == TwoWayDialogFragment.RESULT_OK) { + bundle.getBundle(TwoWayDialogFragment.KEY_REQUEST_INCOMING_BUNDLE) + ?.let { + processActionForMessageAndAttachmentBasedOnIncomingBundle(it) { attachmentInfo, message -> + processDownloadAttachment( + attachmentInfo = attachmentInfo, + message = message, + forcedDownload = true + ) + } + } + } + } + REQUEST_CODE_SHOW_TWO_WAY_DIALOG_FOR_DELETING_DRAFT -> if (result == TwoWayDialogFragment.RESULT_OK) { bundle.getBundle(TwoWayDialogFragment.KEY_REQUEST_INCOMING_BUNDLE)?.let { @@ -1303,7 +1319,8 @@ class ThreadDetailsFragment : BaseFragment(), Prog private fun processDownloadAttachment( attachmentInfo: AttachmentInfo, - message: MessagesInThreadListAdapter.Message + message: MessagesInThreadListAdapter.Message, + forcedDownload: Boolean = false ) { if ( checkAndShowNeedPassphraseDialogIfNeeded( @@ -1313,15 +1330,43 @@ class ThreadDetailsFragment : BaseFragment(), Prog ) ) return - downloadAttachment(attachmentInfo, message) + downloadAttachment( + attachmentInfo = attachmentInfo, + message = message, + forcedDownload = forcedDownload + ) } private fun downloadAttachment( attachmentInfo: AttachmentInfo, - message: MessagesInThreadListAdapter.Message + message: MessagesInThreadListAdapter.Message, + forcedDownload: Boolean = false ) { val documentId = EmbeddedAttachmentsProvider.Cache.getInstance().getDocumentId(attachmentInfo) + if (!forcedDownload && FileAndDirectoryUtils.Downloads.isFileAlreadyExist( + context = requireContext(), + fileName = attachmentInfo.getSafeName() + ) + ) { + showTwoWayDialog( + requestKey = REQUEST_KEY_TWO_WAY_DIALOG_BASE + args.messageEntityId.toString(), + requestCode = REQUEST_CODE_DOWNLOAD_FILE_AGAIN, + dialogTitle = "", + dialogMsg = getString( + R.string.file_already_exists_in_download, + attachmentInfo.getSafeName() + ), + positiveButtonTitle = getString(R.string.download), + negativeButtonTitle = getString(android.R.string.cancel), + bundle = Bundle().apply { + putLong(KEY_EXTRA_MESSAGE_ID, message.id) + putString(KEY_EXTRA_ATTACHMENT_ID, attachmentInfo.uniqueStringId) + } + ) + return + } + when { attachmentInfo.uri != null && documentId != null -> { requireContext().startService( @@ -1541,6 +1586,7 @@ class ThreadDetailsFragment : BaseFragment(), Prog private const val REQUEST_CODE_PROCESS_AND_REPLY = 1014 private const val REQUEST_CODE_PROCESS_AND_REPLY_ALL = 1015 private const val REQUEST_CODE_PROCESS_AND_FORWARD = 1016 + private const val REQUEST_CODE_DOWNLOAD_FILE_AGAIN = 1017 private const val CONTENT_MAX_ALLOWED_LENGTH = 50000 } diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/util/FileAndDirectoryUtils.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/util/FileAndDirectoryUtils.kt index 8feadc797a..0e9a9ef05e 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/util/FileAndDirectoryUtils.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/util/FileAndDirectoryUtils.kt @@ -1,10 +1,12 @@ /* * © 2016-present FlowCrypt a.s. Limitations apply. Contact human@flowcrypt.com - * Contributors: DenBond7 + * Contributors: denbond7 */ package com.flowcrypt.email.util +import android.content.Context +import android.provider.MediaStore import org.apache.commons.io.FilenameUtils import java.io.File import java.io.IOException @@ -17,6 +19,21 @@ import java.util.regex.Pattern * @author Denys Bondarenko */ class FileAndDirectoryUtils { + object Downloads { + fun isFileAlreadyExist(context: Context, fileName: String): Boolean { + return context.contentResolver.query( + MediaStore.Downloads.EXTERNAL_CONTENT_URI, + arrayOf( + MediaStore.Files.FileColumns._ID, + MediaStore.Files.FileColumns.DISPLAY_NAME + ), + MediaStore.Downloads.DISPLAY_NAME + " = ?", + arrayOf(fileName), + null + )?.use { it.moveToNext() } ?: false + } + } + companion object { /** * Cleans an input directory. diff --git a/FlowCrypt/src/main/res/values-ru/strings.xml b/FlowCrypt/src/main/res/values-ru/strings.xml index e594cfd6f1..76aae37547 100644 --- a/FlowCrypt/src/main/res/values-ru/strings.xml +++ b/FlowCrypt/src/main/res/values-ru/strings.xml @@ -643,6 +643,7 @@ Черновик Удалить черновик? Переписка удалена или перемещена + \'%1$s\' уже существует Download. Хотите загрузить его снова? Черновик Черновики(%1$d) diff --git a/FlowCrypt/src/main/res/values-uk/strings.xml b/FlowCrypt/src/main/res/values-uk/strings.xml index 0bf836de2d..3153972588 100644 --- a/FlowCrypt/src/main/res/values-uk/strings.xml +++ b/FlowCrypt/src/main/res/values-uk/strings.xml @@ -644,6 +644,7 @@ Чорновик Видалити чернетку? Бесіду видалено або переміщено + \'%1$s\' уже існує в Download. Бажаєте завантажити його знову? Чорновик Чорновики(%1$d) diff --git a/FlowCrypt/src/main/res/values/strings.xml b/FlowCrypt/src/main/res/values/strings.xml index 846d2b6893..8fba418bc9 100644 --- a/FlowCrypt/src/main/res/values/strings.xml +++ b/FlowCrypt/src/main/res/values/strings.xml @@ -653,6 +653,7 @@ Draft Delete draft? The thread was deleted or moved + \'%1$s\' already exists in Download. Would you like to download it again? Draft Drafts(%1$d) From 369c56c0bd828964a68c37dd2b3758fe059bacaa Mon Sep 17 00:00:00 2001 From: denbond7 Date: Tue, 11 Feb 2025 17:28:54 +0200 Subject: [PATCH 03/12] wip --- .../AttachmentDownloadManagerService.kt | 38 ++++++++++--------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/service/attachment/AttachmentDownloadManagerService.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/service/attachment/AttachmentDownloadManagerService.kt index d464d09bfd..de2059867c 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/service/attachment/AttachmentDownloadManagerService.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/service/attachment/AttachmentDownloadManagerService.kt @@ -623,23 +623,6 @@ class AttachmentDownloadManagerService : LifecycleService() { val fileUri = resolver.insert(MediaStore.Downloads.EXTERNAL_CONTENT_URI, contentValues) requireNotNull(fileUri) - - //we should check maybe a file is already exist. Then we will use the file name from the system - val cursor = - resolver.query(fileUri, arrayOf(MediaStore.DownloadColumns.DISPLAY_NAME), null, null, null) - cursor?.let { - if (it.moveToFirst()) { - val nameIndex = it.getColumnIndex(MediaStore.DownloadColumns.DISPLAY_NAME) - if (nameIndex != -1) { - val nameFromSystem = it.getString(nameIndex) - if (nameFromSystem != finalFileName) { - finalFileName = nameFromSystem - } - } - } - } - cursor?.close() - val srcInputStream = attFile.inputStream() val destOutputStream = resolver.openOutputStream(fileUri) ?: throw IllegalArgumentException("provided URI could not be opened") @@ -652,6 +635,27 @@ class AttachmentDownloadManagerService : LifecycleService() { put(MediaStore.Downloads.IS_PENDING, 0) }, null, null) + resolver.query( + fileUri, + arrayOf(MediaStore.DownloadColumns.DISPLAY_NAME), + null, + null, + null + ) + ?.use { cursor -> + //we should check maybe a file is already exist. + //Then we will use the file name from the system. + if (cursor.moveToFirst()) { + val nameIndex = cursor.getColumnIndex(MediaStore.DownloadColumns.DISPLAY_NAME) + if (nameIndex != -1) { + val nameFromSystem = cursor.getString(nameIndex) + if (nameFromSystem != finalFileName) { + finalFileName = nameFromSystem + } + } + } + } + return fileUri } From ccaae2981d1dabfd3556f4d65b54b121a46b7c0c Mon Sep 17 00:00:00 2001 From: denbond7 Date: Wed, 12 Feb 2025 09:39:46 +0200 Subject: [PATCH 04/12] wip --- FlowCrypt/src/main/res/values-ru/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FlowCrypt/src/main/res/values-ru/strings.xml b/FlowCrypt/src/main/res/values-ru/strings.xml index 76aae37547..bd543f23d0 100644 --- a/FlowCrypt/src/main/res/values-ru/strings.xml +++ b/FlowCrypt/src/main/res/values-ru/strings.xml @@ -643,7 +643,7 @@ Черновик Удалить черновик? Переписка удалена или перемещена - \'%1$s\' уже существует Download. Хотите загрузить его снова? + \'%1$s\' уже существует в Download. Хотите загрузить его снова? Черновик Черновики(%1$d) From e1c96ee50c5600b836effc702b26de0ab451d5fa Mon Sep 17 00:00:00 2001 From: denbond7 Date: Wed, 12 Feb 2025 11:01:53 +0200 Subject: [PATCH 05/12] wip --- .../email/ui/activity/fragment/CreateMessageFragment.kt | 4 ---- .../email/ui/activity/fragment/MessageDetailsFragment.kt | 4 ---- .../email/ui/adapter/AttachmentsRecyclerViewAdapter.kt | 7 +------ .../email/ui/adapter/MessagesInThreadListAdapter.kt | 2 -- FlowCrypt/src/main/res/drawable/bg_att.xml | 5 +++-- FlowCrypt/src/main/res/drawable/bg_att_decrypted.xml | 4 ++-- 6 files changed, 6 insertions(+), 20 deletions(-) diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/CreateMessageFragment.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/CreateMessageFragment.kt index 1650de257b..8f2f403954 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/CreateMessageFragment.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/CreateMessageFragment.kt @@ -253,10 +253,6 @@ class CreateMessageFragment : BaseFragment(), attachmentActionListener = object : AttachmentsRecyclerViewAdapter.AttachmentActionListener { override fun onDownloadClick(attachmentInfo: AttachmentInfo) {} - override fun onAttachmentClick(attachmentInfo: AttachmentInfo) { - onPreviewClick(attachmentInfo) - } - override fun onPreviewClick(attachmentInfo: AttachmentInfo) { if (attachmentInfo.uri != null) { val intent = GeneralUtil.genViewAttachmentIntent(attachmentInfo.uri, attachmentInfo) diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/MessageDetailsFragment.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/MessageDetailsFragment.kt index 95247d2101..2472c0a86b 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/MessageDetailsFragment.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/MessageDetailsFragment.kt @@ -201,10 +201,6 @@ class MessageDetailsFragment : BaseFragment(), Pr } } - override fun onAttachmentClick(attachmentInfo: AttachmentInfo) { - onPreviewClick(attachmentInfo) - } - override fun onPreviewClick(attachmentInfo: AttachmentInfo) { if (attachmentInfo.uri != null) { if (attachmentInfo.isPossiblyEncrypted) { diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/ui/adapter/AttachmentsRecyclerViewAdapter.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/ui/adapter/AttachmentsRecyclerViewAdapter.kt index 17a5fb57e1..14f0761f89 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/ui/adapter/AttachmentsRecyclerViewAdapter.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/ui/adapter/AttachmentsRecyclerViewAdapter.kt @@ -1,6 +1,6 @@ /* * © 2016-present FlowCrypt a.s. Limitations apply. Contact human@flowcrypt.com - * Contributors: DenBond7 + * Contributors: denbond7 */ package com.flowcrypt.email.ui.adapter @@ -76,10 +76,6 @@ class AttachmentsRecyclerViewAdapter( attachmentActionListener.onDeleteClick(attachmentInfo) } - itemView.setOnClickListener { - attachmentActionListener.onAttachmentClick(attachmentInfo) - } - val value = progressMap[attachmentInfo.uniqueStringId] if (value?.progressInPercentage in 0..99) { imageViewAttIcon.setImageResource(R.drawable.stat_sys_download_blue) @@ -103,7 +99,6 @@ class AttachmentsRecyclerViewAdapter( interface AttachmentActionListener { fun onDownloadClick(attachmentInfo: AttachmentInfo) - fun onAttachmentClick(attachmentInfo: AttachmentInfo) fun onPreviewClick(attachmentInfo: AttachmentInfo) fun onDeleteClick(attachmentInfo: AttachmentInfo) } diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/ui/adapter/MessagesInThreadListAdapter.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/ui/adapter/MessagesInThreadListAdapter.kt index 1e798405a1..c4cd513abc 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/ui/adapter/MessagesInThreadListAdapter.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/ui/adapter/MessagesInThreadListAdapter.kt @@ -418,8 +418,6 @@ class MessagesInThreadListAdapter( onMessageActionsListener.onAttachmentDownloadClick(attachmentInfo, message) } - override fun onAttachmentClick(attachmentInfo: AttachmentInfo) {} - override fun onPreviewClick(attachmentInfo: AttachmentInfo) { onMessageActionsListener.onAttachmentPreviewClick(attachmentInfo, message) } diff --git a/FlowCrypt/src/main/res/drawable/bg_att.xml b/FlowCrypt/src/main/res/drawable/bg_att.xml index 0f5250bced..a8383ce8ba 100644 --- a/FlowCrypt/src/main/res/drawable/bg_att.xml +++ b/FlowCrypt/src/main/res/drawable/bg_att.xml @@ -1,10 +1,11 @@ - + + diff --git a/FlowCrypt/src/main/res/drawable/bg_att_decrypted.xml b/FlowCrypt/src/main/res/drawable/bg_att_decrypted.xml index e2cbd22a2d..48c1bdd450 100644 --- a/FlowCrypt/src/main/res/drawable/bg_att_decrypted.xml +++ b/FlowCrypt/src/main/res/drawable/bg_att_decrypted.xml @@ -1,11 +1,11 @@ - + From f7bbc4c40bd706b7a5b3336bee4260bf1972a72c Mon Sep 17 00:00:00 2001 From: denbond7 Date: Thu, 13 Feb 2025 12:37:58 +0200 Subject: [PATCH 06/12] wip --- .../main/java/com/flowcrypt/email/util/GeneralUtil.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/util/GeneralUtil.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/util/GeneralUtil.kt index 94423cc7c3..c84346e772 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/util/GeneralUtil.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/util/GeneralUtil.kt @@ -470,12 +470,14 @@ class GeneralUtil { } } - fun genViewAttachmentIntent(uri: Uri, attachmentInfo: AttachmentInfo) = - Intent() + fun genViewAttachmentIntent(uri: Uri, attachmentInfo: AttachmentInfo): Intent = + Intent.createChooser( + Intent() .setAction(Intent.ACTION_VIEW) - .setDataAndType(uri, Intent.normalizeMimeType(attachmentInfo.type)) + .setDataAndType(uri, "*/*") .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK) - .addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) + .addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION), null + ) suspend fun getGoogleIdTokenSilently( context: Context, From 59bbd7a4dcbdc65995349924e24e21445728cbe9 Mon Sep 17 00:00:00 2001 From: denbond7 Date: Thu, 13 Feb 2025 15:38:24 +0200 Subject: [PATCH 07/12] wip --- .../email/ui/activity/fragment/ThreadDetailsFragment.kt | 7 +++++++ .../src/main/java/com/flowcrypt/email/util/GeneralUtil.kt | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/ThreadDetailsFragment.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/ThreadDetailsFragment.kt index 7bbcf46b38..78d92e0f7a 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/ThreadDetailsFragment.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/ThreadDetailsFragment.kt @@ -1292,6 +1292,13 @@ class ThreadDetailsFragment : BaseFragment(), Prog private fun previewAttachment(attachmentInfo: AttachmentInfo) { val intent = if (attachmentInfo.uri != null) { + toast( + "Debug: Original = ${attachmentInfo.type}, final = ${ + Intent.normalizeMimeType( + attachmentInfo.type + ) + }" + ) GeneralUtil.genViewAttachmentIntent(requireNotNull(attachmentInfo.uri), attachmentInfo) } else { toast(getString(R.string.preview_is_not_available)) diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/util/GeneralUtil.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/util/GeneralUtil.kt index c84346e772..7a761275ff 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/util/GeneralUtil.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/util/GeneralUtil.kt @@ -474,7 +474,7 @@ class GeneralUtil { Intent.createChooser( Intent() .setAction(Intent.ACTION_VIEW) - .setDataAndType(uri, "*/*") + .setDataAndType(uri, "image/jpg") .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK) .addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION), null ) From 6ff5b5841407a6dae089885d40fee2d0a317a271 Mon Sep 17 00:00:00 2001 From: denbond7 Date: Mon, 17 Feb 2025 15:36:03 +0200 Subject: [PATCH 08/12] wip --- .../java/com/flowcrypt/email/Constants.kt | 3 ++ .../fragment/CreateMessageFragment.kt | 12 +++++++- .../activity/fragment/MainSettingsFragment.kt | 18 +++++++++--- .../fragment/MessageDetailsFragment.kt | 12 +++++++- .../fragment/ThreadDetailsFragment.kt | 17 ++++++----- .../preferences/GeneralSettingsFragment.kt | 28 +++++++++++++++++++ .../com/flowcrypt/email/util/GeneralUtil.kt | 22 +++++++++++---- .../src/main/res/navigation/nav_graph.xml | 8 ++++++ FlowCrypt/src/main/res/values-ru/strings.xml | 2 ++ FlowCrypt/src/main/res/values-uk/strings.xml | 2 ++ FlowCrypt/src/main/res/values/preferences.xml | 4 ++- FlowCrypt/src/main/res/values/strings.xml | 2 ++ .../res/xml/preferences_general_settings.xml | 19 +++++++++++++ .../res/xml/preferences_main_settings.xml | 8 +++++- 14 files changed, 137 insertions(+), 20 deletions(-) create mode 100644 FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/preferences/GeneralSettingsFragment.kt create mode 100644 FlowCrypt/src/main/res/xml/preferences_general_settings.xml diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/Constants.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/Constants.kt index 0a6e0136c2..c1b13b5c94 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/Constants.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/Constants.kt @@ -55,11 +55,14 @@ class Constants { const val PREF_KEY_MESSAGES_NOTIFICATION_FILTER = "preferences_key_messages_notification_filter" const val PREF_KEY_MANAGE_NOTIFICATIONS = "preferences_key_manage_notifications" const val PREF_KEY_SECURITY_CHANGE_PASS_PHRASE = "preferences_key_security_change_pass_phrase" + const val PREFERENCES_KEY_ATTACHMENTS_DISABLE_SMART_MODE_FOR_PREVIEW = + "preferences_key_attachments_disable_smart_mode_for_preview" const val PREF_KEY_LAST_ATT_ORDER_ID = "preferences_key_last_att_order_id" const val PREF_KEY_IS_CHECK_KEYS_NEEDED = "preferences_key_is_check_keys_needed" const val PREF_KEY_BACKUPS = "pref_key_backups" const val PREF_KEY_INSTALL_VERSION = "pref_key_install_version" const val PREF_KEY_SERVER_SETTINGS = "pref_key_server_settings" + const val PREF_KEY_GENERAL = "pref_key_general" /** * The max total size off all attachment which can be send via the app. diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/CreateMessageFragment.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/CreateMessageFragment.kt index 8f2f403954..fa5cb62476 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/CreateMessageFragment.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/CreateMessageFragment.kt @@ -39,6 +39,7 @@ import androidx.lifecycle.Lifecycle import androidx.lifecycle.ViewModel import androidx.navigation.NavDirections import androidx.navigation.fragment.navArgs +import androidx.preference.PreferenceManager import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import com.flowcrypt.email.Constants @@ -109,6 +110,7 @@ import com.flowcrypt.email.ui.adapter.recyclerview.itemdecoration.MarginItemDeco import com.flowcrypt.email.util.FileAndDirectoryUtils import com.flowcrypt.email.util.GeneralUtil import com.flowcrypt.email.util.LogsUtil +import com.flowcrypt.email.util.SharedPreferencesHelper import com.flowcrypt.email.util.UIUtil import com.flowcrypt.email.util.exception.DecryptionException import com.flowcrypt.email.util.exception.ExceptionUtil @@ -255,7 +257,15 @@ class CreateMessageFragment : BaseFragment(), override fun onPreviewClick(attachmentInfo: AttachmentInfo) { if (attachmentInfo.uri != null) { - val intent = GeneralUtil.genViewAttachmentIntent(attachmentInfo.uri, attachmentInfo) + val intent = GeneralUtil.genViewAttachmentIntent( + uri = attachmentInfo.uri, + attachmentInfo = attachmentInfo, + useCommonPattern = SharedPreferencesHelper.getBoolean( + sharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireContext()), + key = Constants.PREFERENCES_KEY_ATTACHMENTS_DISABLE_SMART_MODE_FOR_PREVIEW, + defaultValue = false + ) + ) try { startActivity(intent) } catch (e: ActivityNotFoundException) { diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/MainSettingsFragment.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/MainSettingsFragment.kt index 10e72e9d42..3cc315ab78 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/MainSettingsFragment.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/MainSettingsFragment.kt @@ -1,6 +1,6 @@ /* * © 2016-present FlowCrypt a.s. Limitations apply. Contact human@flowcrypt.com - * Contributors: DenBond7 + * Contributors: denbond7 */ package com.flowcrypt.email.ui.activity.fragment @@ -95,6 +95,14 @@ class MainSettingsFragment : BasePreferenceFragment() { true } + findPreference(getString(R.string.pref_key_general)) + ?.setOnPreferenceClickListener { + navController?.navigate( + MainSettingsFragmentDirections.actionMainSettingsFragmentToGeneralSettingsFragment() + ) + true + } + findPreference(getString(R.string.pref_key_experimental)) ?.setOnPreferenceClickListener { navController?.navigate( @@ -110,8 +118,10 @@ class MainSettingsFragment : BasePreferenceFragment() { !(accountEntity?.hasClientConfigurationProperty(ClientConfiguration.ConfigurationProperty.NO_PRV_BACKUP) ?: false) - if (accountEntity?.useAPI == false) { - findPreference(Constants.PREF_KEY_SERVER_SETTINGS)?.isVisible = true - } + findPreference(Constants.PREF_KEY_SERVER_SETTINGS)?.isVisible = + accountEntity?.useAPI == false + + findPreference(Constants.PREF_KEY_GENERAL)?.isVisible = + accountEntity?.isHandlingAttachmentRestricted() == false } } diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/MessageDetailsFragment.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/MessageDetailsFragment.kt index 2472c0a86b..0e28553066 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/MessageDetailsFragment.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/MessageDetailsFragment.kt @@ -42,6 +42,7 @@ import androidx.lifecycle.ViewModel import androidx.lifecycle.lifecycleScope import androidx.navigation.NavDirections import androidx.navigation.fragment.navArgs +import androidx.preference.PreferenceManager import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import com.flowcrypt.email.Constants @@ -131,6 +132,7 @@ import com.flowcrypt.email.ui.widget.EmailWebView import com.flowcrypt.email.ui.widget.TileDrawable import com.flowcrypt.email.util.DateTimeUtil import com.flowcrypt.email.util.GeneralUtil +import com.flowcrypt.email.util.SharedPreferencesHelper import com.flowcrypt.email.util.UIUtil import com.flowcrypt.email.util.exception.CommonConnectionException import com.flowcrypt.email.util.exception.GmailAPIException @@ -1824,7 +1826,15 @@ class MessageDetailsFragment : BaseFragment(), Pr useContentApp: Boolean = false ) { val intent = if (attachmentInfo.uri != null) { - GeneralUtil.genViewAttachmentIntent(requireNotNull(attachmentInfo.uri), attachmentInfo) + GeneralUtil.genViewAttachmentIntent( + uri = requireNotNull(attachmentInfo.uri), + attachmentInfo = attachmentInfo, + useCommonPattern = SharedPreferencesHelper.getBoolean( + sharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireContext()), + key = Constants.PREFERENCES_KEY_ATTACHMENTS_DISABLE_SMART_MODE_FOR_PREVIEW, + defaultValue = false + ) + ) } else { toast(getString(R.string.preview_is_not_available)) return diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/ThreadDetailsFragment.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/ThreadDetailsFragment.kt index 78d92e0f7a..47cd28c4ee 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/ThreadDetailsFragment.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/ThreadDetailsFragment.kt @@ -25,6 +25,7 @@ import androidx.lifecycle.Lifecycle import androidx.lifecycle.ViewModel import androidx.navigation.NavDirections import androidx.navigation.fragment.navArgs +import androidx.preference.PreferenceManager import androidx.recyclerview.widget.LinearLayoutManager import androidx.work.WorkManager import com.flowcrypt.email.Constants @@ -95,6 +96,7 @@ import com.flowcrypt.email.ui.adapter.MessagesInThreadListAdapter import com.flowcrypt.email.ui.adapter.recyclerview.itemdecoration.SkipFirstAndLastDividerItemDecoration import com.flowcrypt.email.util.FileAndDirectoryUtils import com.flowcrypt.email.util.GeneralUtil +import com.flowcrypt.email.util.SharedPreferencesHelper import com.flowcrypt.email.util.exception.ThreadNotFoundException import com.google.api.client.googleapis.json.GoogleJsonResponseException import org.apache.commons.io.FilenameUtils @@ -1292,14 +1294,15 @@ class ThreadDetailsFragment : BaseFragment(), Prog private fun previewAttachment(attachmentInfo: AttachmentInfo) { val intent = if (attachmentInfo.uri != null) { - toast( - "Debug: Original = ${attachmentInfo.type}, final = ${ - Intent.normalizeMimeType( - attachmentInfo.type - ) - }" + GeneralUtil.genViewAttachmentIntent( + uri = requireNotNull(attachmentInfo.uri), + attachmentInfo = attachmentInfo, + useCommonPattern = SharedPreferencesHelper.getBoolean( + sharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireContext()), + key = Constants.PREFERENCES_KEY_ATTACHMENTS_DISABLE_SMART_MODE_FOR_PREVIEW, + defaultValue = false + ) ) - GeneralUtil.genViewAttachmentIntent(requireNotNull(attachmentInfo.uri), attachmentInfo) } else { toast(getString(R.string.preview_is_not_available)) return diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/preferences/GeneralSettingsFragment.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/preferences/GeneralSettingsFragment.kt new file mode 100644 index 0000000000..438c34c300 --- /dev/null +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/preferences/GeneralSettingsFragment.kt @@ -0,0 +1,28 @@ +/* + * © 2016-present FlowCrypt a.s. Limitations apply. Contact human@flowcrypt.com + * Contributors: denbond7 + */ + +package com.flowcrypt.email.ui.activity.fragment.preferences + +import android.os.Bundle +import android.view.View +import com.flowcrypt.email.R +import com.flowcrypt.email.extensions.androidx.fragment.app.supportActionBar +import com.flowcrypt.email.ui.activity.fragment.base.BasePreferenceFragment + +/** + * This class describes general settings. + * + * @author Denys Bondarenko + */ +open class GeneralSettingsFragment : BasePreferenceFragment() { + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + supportActionBar?.title = getString(R.string.general) + } + + override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { + setPreferencesFromResource(R.xml.preferences_general_settings, rootKey) + } +} diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/util/GeneralUtil.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/util/GeneralUtil.kt index 7a761275ff..14ac170e4f 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/util/GeneralUtil.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/util/GeneralUtil.kt @@ -470,14 +470,26 @@ class GeneralUtil { } } - fun genViewAttachmentIntent(uri: Uri, attachmentInfo: AttachmentInfo): Intent = - Intent.createChooser( + fun genViewAttachmentIntent( + uri: Uri, + attachmentInfo: AttachmentInfo, + useCommonPattern: Boolean = false + ): Intent { + return Intent.createChooser( Intent() - .setAction(Intent.ACTION_VIEW) - .setDataAndType(uri, "image/jpg") - .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK) + .setAction(Intent.ACTION_VIEW) + .setDataAndType( + uri, + if (useCommonPattern) { + "*/*" + } else { + Intent.normalizeMimeType(attachmentInfo.type) + } + ) + .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK) .addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION), null ) + } suspend fun getGoogleIdTokenSilently( context: Context, diff --git a/FlowCrypt/src/main/res/navigation/nav_graph.xml b/FlowCrypt/src/main/res/navigation/nav_graph.xml index 4257b24760..0ff33271e7 100644 --- a/FlowCrypt/src/main/res/navigation/nav_graph.xml +++ b/FlowCrypt/src/main/res/navigation/nav_graph.xml @@ -145,6 +145,9 @@ + + + Удалить черновик? Переписка удалена или перемещена \'%1$s\' уже существует в Download. Хотите загрузить его снова? + Общиe + Отключить интеллектуальный режим для предварительного просмотра вложений Черновик Черновики(%1$d) diff --git a/FlowCrypt/src/main/res/values-uk/strings.xml b/FlowCrypt/src/main/res/values-uk/strings.xml index 3153972588..d4c9af51fa 100644 --- a/FlowCrypt/src/main/res/values-uk/strings.xml +++ b/FlowCrypt/src/main/res/values-uk/strings.xml @@ -645,6 +645,8 @@ Видалити чернетку? Бесіду видалено або переміщено \'%1$s\' уже існує в Download. Бажаєте завантажити його знову? + Загальні + Вимкнути розумний режим для попереднього перегляду вкладень Чорновик Чорновики(%1$d) diff --git a/FlowCrypt/src/main/res/values/preferences.xml b/FlowCrypt/src/main/res/values/preferences.xml index fbe9270602..749c5c8cab 100644 --- a/FlowCrypt/src/main/res/values/preferences.xml +++ b/FlowCrypt/src/main/res/values/preferences.xml @@ -1,13 +1,15 @@ preferences_key_messages_notification_filter preferences_key_manage_notifications preferences_key_security_change_pass_phrase + preferences_key_attachments_disable_smart_mode_for_preview pref_key_backups + pref_key_general pref_key_server_settings pref_key_attester pref_key_legal diff --git a/FlowCrypt/src/main/res/values/strings.xml b/FlowCrypt/src/main/res/values/strings.xml index 8fba418bc9..246e7ef2d6 100644 --- a/FlowCrypt/src/main/res/values/strings.xml +++ b/FlowCrypt/src/main/res/values/strings.xml @@ -654,6 +654,8 @@ Delete draft? The thread was deleted or moved \'%1$s\' already exists in Download. Would you like to download it again? + General + Disable smart mode for attachments preview Draft Drafts(%1$d) diff --git a/FlowCrypt/src/main/res/xml/preferences_general_settings.xml b/FlowCrypt/src/main/res/xml/preferences_general_settings.xml new file mode 100644 index 0000000000..5ad8f30e8e --- /dev/null +++ b/FlowCrypt/src/main/res/xml/preferences_general_settings.xml @@ -0,0 +1,19 @@ + + + + + + + + + + diff --git a/FlowCrypt/src/main/res/xml/preferences_main_settings.xml b/FlowCrypt/src/main/res/xml/preferences_main_settings.xml index cb89f03f39..75b0e640f2 100644 --- a/FlowCrypt/src/main/res/xml/preferences_main_settings.xml +++ b/FlowCrypt/src/main/res/xml/preferences_main_settings.xml @@ -1,6 +1,6 @@ + + Date: Tue, 18 Feb 2025 15:56:36 +0200 Subject: [PATCH 09/12] wip --- .../MainSettingsFragmentEnterpriseFlowTest.kt | 86 +++++++++++++++++++ ...ingsFragmentNavigationToSubMenuFlowTest.kt | 20 ++++- 2 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/fragment/MainSettingsFragmentEnterpriseFlowTest.kt diff --git a/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/fragment/MainSettingsFragmentEnterpriseFlowTest.kt b/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/fragment/MainSettingsFragmentEnterpriseFlowTest.kt new file mode 100644 index 0000000000..f479a8cf5e --- /dev/null +++ b/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/fragment/MainSettingsFragmentEnterpriseFlowTest.kt @@ -0,0 +1,86 @@ +/* + * © 2016-present FlowCrypt a.s. Limitations apply. Contact human@flowcrypt.com + * Contributors: denbond7 + */ + +package com.flowcrypt.email.ui.fragment + +import androidx.test.espresso.Espresso.onView +import androidx.test.espresso.assertion.ViewAssertions.doesNotExist +import androidx.test.espresso.assertion.ViewAssertions.matches +import androidx.test.espresso.matcher.ViewMatchers.isDisplayed +import androidx.test.espresso.matcher.ViewMatchers.withText +import androidx.test.ext.junit.rules.activityScenarioRule +import androidx.test.ext.junit.runners.AndroidJUnit4 +import androidx.test.filters.MediumTest +import com.flowcrypt.email.R +import com.flowcrypt.email.TestConstants +import com.flowcrypt.email.junit.annotations.FlowCryptTestSettings +import com.flowcrypt.email.rules.ClearAppSettingsRule +import com.flowcrypt.email.rules.FlowCryptMockWebServerRule +import com.flowcrypt.email.rules.GrantPermissionRuleChooser +import com.flowcrypt.email.rules.RetryRule +import com.flowcrypt.email.rules.ScreenshotTestRule +import com.flowcrypt.email.ui.activity.MainActivity +import com.flowcrypt.email.ui.base.BaseGmailApiTest +import com.flowcrypt.email.util.TestGeneralUtil +import okhttp3.mockwebserver.Dispatcher +import okhttp3.mockwebserver.MockResponse +import okhttp3.mockwebserver.RecordedRequest +import org.junit.Rule +import org.junit.Test +import org.junit.rules.RuleChain +import org.junit.rules.TestRule +import org.junit.runner.RunWith + +/** + * @author Denys Bondarenko + */ +@MediumTest +@RunWith(AndroidJUnit4::class) +@FlowCryptTestSettings(useCommonIdling = false) +class MainSettingsFragmentEnterpriseFlowTest : + BaseGmailApiTest(BASE_ACCOUNT_ENTITY.copy(useConversationMode = true)) { + override val activityScenarioRule = activityScenarioRule( + TestGeneralUtil.genIntentForNavigationComponent( + destinationId = R.id.mainSettingsFragment + ) + ) + + override val mockWebServerRule = + FlowCryptMockWebServerRule(TestConstants.MOCK_WEB_SERVER_PORT, object : Dispatcher() { + override fun dispatch(request: RecordedRequest): MockResponse { + return when { + else -> handleCommonAPICalls(request) + } + } + }) + + @get:Rule + var ruleChain: TestRule = RuleChain + .outerRule(RetryRule.DEFAULT) + .around(ClearAppSettingsRule()) + .around(GrantPermissionRuleChooser.grant(android.Manifest.permission.POST_NOTIFICATIONS)) + .around(addAccountToDatabaseRule) + .around(addPrivateKeyToDatabaseRule) + .around(activityScenarioRule) + .around(ScreenshotTestRule()) + + @Test + fun testHiddenOrVisibleItems() { + onView(withText(getResString(R.string.backups))) + .check(doesNotExist()) + onView(withText(getResString(R.string.security_and_privacy))) + .check(matches(isDisplayed())) + onView(withText(getResString(R.string.contacts))) + .check(matches(isDisplayed())) + onView(withText(getResString(R.string.keys))) + .check(matches(isDisplayed())) + onView(withText(getResString(R.string.attester))) + .check(matches(isDisplayed())) + onView(withText(getResString(R.string.general))) + .check(doesNotExist()) + onView(withText(getResString(R.string.experimental))) + .check(matches(isDisplayed())) + } +} diff --git a/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/fragment/MainSettingsFragmentNavigationToSubMenuFlowTest.kt b/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/fragment/MainSettingsFragmentNavigationToSubMenuFlowTest.kt index 5e8dcf74ed..bf08b10cff 100644 --- a/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/fragment/MainSettingsFragmentNavigationToSubMenuFlowTest.kt +++ b/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/fragment/MainSettingsFragmentNavigationToSubMenuFlowTest.kt @@ -1,6 +1,6 @@ /* * © 2016-present FlowCrypt a.s. Limitations apply. Contact human@flowcrypt.com - * Contributors: DenBond7 + * Contributors: denbond7 */ package com.flowcrypt.email.ui.fragment @@ -89,6 +89,24 @@ class MainSettingsFragmentNavigationToSubMenuFlowTest : BaseTest() { ) } + @Test + fun testHiddenOrVisibleItems() { + onView(withText(getResString(R.string.backups))) + .check(matches(isDisplayed())) + onView(withText(getResString(R.string.security_and_privacy))) + .check(matches(isDisplayed())) + onView(withText(getResString(R.string.contacts))) + .check(matches(isDisplayed())) + onView(withText(getResString(R.string.keys))) + .check(matches(isDisplayed())) + onView(withText(getResString(R.string.attester))) + .check(matches(isDisplayed())) + onView(withText(getResString(R.string.general))) + .check(matches(isDisplayed())) + onView(withText(getResString(R.string.experimental))) + .check(matches(isDisplayed())) + } + private fun checkIsScreenDisplaying(screenName: String) { checkIsScreenDisplaying(screenName, screenName) } From ba1c23dc6112b9429be0437d0b8bc75e403a1c37 Mon Sep 17 00:00:00 2001 From: denbond7 Date: Tue, 18 Feb 2025 16:02:55 +0200 Subject: [PATCH 10/12] wip --- .../ui/fragment/MainSettingsFragmentEnterpriseFlowTest.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/fragment/MainSettingsFragmentEnterpriseFlowTest.kt b/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/fragment/MainSettingsFragmentEnterpriseFlowTest.kt index f479a8cf5e..c7a955de0b 100644 --- a/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/fragment/MainSettingsFragmentEnterpriseFlowTest.kt +++ b/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/fragment/MainSettingsFragmentEnterpriseFlowTest.kt @@ -68,8 +68,14 @@ class MainSettingsFragmentEnterpriseFlowTest : @Test fun testHiddenOrVisibleItems() { + //should be hidden as we have NO_PRV_BACKUP onView(withText(getResString(R.string.backups))) .check(doesNotExist()) + //should be hidden as we have RESTRICT_ANDROID_ATTACHMENT_HANDLING + onView(withText(getResString(R.string.general))) + .check(doesNotExist()) + + //should be visible onView(withText(getResString(R.string.security_and_privacy))) .check(matches(isDisplayed())) onView(withText(getResString(R.string.contacts))) @@ -78,8 +84,6 @@ class MainSettingsFragmentEnterpriseFlowTest : .check(matches(isDisplayed())) onView(withText(getResString(R.string.attester))) .check(matches(isDisplayed())) - onView(withText(getResString(R.string.general))) - .check(doesNotExist()) onView(withText(getResString(R.string.experimental))) .check(matches(isDisplayed())) } From 7ea8610f545a3e5f5bf3d6e32ff2b16a7356f2c0 Mon Sep 17 00:00:00 2001 From: denbond7 Date: Tue, 18 Feb 2025 16:07:10 +0200 Subject: [PATCH 11/12] wip --- FlowCrypt/src/main/res/drawable/bg_att.xml | 2 -- FlowCrypt/src/main/res/drawable/bg_att_decrypted.xml | 2 -- 2 files changed, 4 deletions(-) diff --git a/FlowCrypt/src/main/res/drawable/bg_att.xml b/FlowCrypt/src/main/res/drawable/bg_att.xml index a8383ce8ba..7f837c60d9 100644 --- a/FlowCrypt/src/main/res/drawable/bg_att.xml +++ b/FlowCrypt/src/main/res/drawable/bg_att.xml @@ -5,8 +5,6 @@ - - - - From 72bed77e441a0e55644956165527e51d6ac8393d Mon Sep 17 00:00:00 2001 From: denbond7 Date: Wed, 19 Feb 2025 09:42:02 +0200 Subject: [PATCH 12/12] Refactored code. --- .../attachment/AttachmentDownloadManagerService.kt | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/service/attachment/AttachmentDownloadManagerService.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/service/attachment/AttachmentDownloadManagerService.kt index de2059867c..a83ac90ffb 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/service/attachment/AttachmentDownloadManagerService.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/service/attachment/AttachmentDownloadManagerService.kt @@ -646,13 +646,9 @@ class AttachmentDownloadManagerService : LifecycleService() { //we should check maybe a file is already exist. //Then we will use the file name from the system. if (cursor.moveToFirst()) { - val nameIndex = cursor.getColumnIndex(MediaStore.DownloadColumns.DISPLAY_NAME) - if (nameIndex != -1) { - val nameFromSystem = cursor.getString(nameIndex) - if (nameFromSystem != finalFileName) { - finalFileName = nameFromSystem - } - } + finalFileName = cursor.getString( + cursor.getColumnIndexOrThrow(MediaStore.DownloadColumns.DISPLAY_NAME) + ) } }