From ba2d0275e448c59c6f60ec6a087eb5ad2f1eff46 Mon Sep 17 00:00:00 2001 From: alansley Date: Fri, 2 Aug 2024 12:15:42 +1000 Subject: [PATCH] Implemented task SS-79 to only provide a save attachment menu option when the attachment download is complete --- .../conversation/v2/ConversationActivityV2.kt | 6 ++++-- .../v2/ConversationReactionOverlay.kt | 15 ++++++++++++--- .../src/main/res/values/strings.xml | 2 +- libsession/src/main/res/values/strings.xml | 5 ----- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt index 6465fe35c9..8633da7d58 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt @@ -2146,9 +2146,11 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe override fun saveAttachment(messages: Set) { val message = messages.first() as MmsMessageRecord - // Do not allow the user to download a file attachment before it has finished downloading + // Note: The save option is only added to the menu in ConversationReactionOverlay.getMenuActionItems + // if the attachment has finished downloading, so we don't really have to check for message.isMediaPending + // here - but we'll do it anyway and bail should that be the case as a defensive programming strategy. if (message.isMediaPending) { - Toast.makeText(this, resources.getString(R.string.conversation_activity__wait_until_attachment_has_finished_downloading), Toast.LENGTH_LONG).show() + Log.w(TAG, "Somehow we were asked to download an attachment before it had finished downloading - aborting download.") return } diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationReactionOverlay.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationReactionOverlay.kt index 041d322567..56cb59f245 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationReactionOverlay.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationReactionOverlay.kt @@ -39,6 +39,7 @@ import org.session.libsession.snode.SnodeAPI import org.session.libsession.utilities.StringSubstitutionConstants.TIME_LARGE_KEY import org.session.libsession.utilities.TextSecurePreferences.Companion.getLocalNumber import org.session.libsession.utilities.ThemeUtil +import org.session.libsignal.utilities.Log import org.thoughtcrime.securesms.components.emoji.EmojiImageView import org.thoughtcrime.securesms.components.emoji.RecentEmojiPageModel import org.thoughtcrime.securesms.components.menu.ActionItem @@ -564,9 +565,17 @@ class ConversationReactionOverlay : FrameLayout { if (message.isSyncFailed) { items += ActionItem(R.attr.menu_reply_icon, R.string.resync, { handleActionItemClicked(Action.RESYNC) }) } - // Save media - if (message.isMms && (message as MediaMmsMessageRecord).containsMediaSlide()) { - items += ActionItem(R.attr.menu_save_icon, R.string.save, { handleActionItemClicked(Action.DOWNLOAD) }, R.string.AccessibilityId_save_attachment) + // Save media.. + if (message.isMms) { + // ..but only provide the save option if the there is a media attachment which has finished downloading. + val mmsMessage = message as MediaMmsMessageRecord + if (mmsMessage.containsMediaSlide() && !mmsMessage.isMediaPending) { + items += ActionItem(R.attr.menu_save_icon, + R.string.save, + { handleActionItemClicked(Action.DOWNLOAD) }, + R.string.AccessibilityId_save_attachment + ) + } } backgroundView.visibility = VISIBLE foregroundView.visibility = VISIBLE diff --git a/content-descriptions/src/main/res/values/strings.xml b/content-descriptions/src/main/res/values/strings.xml index e5499dd410..ab47da53cb 100644 --- a/content-descriptions/src/main/res/values/strings.xml +++ b/content-descriptions/src/main/res/values/strings.xml @@ -15,7 +15,6 @@ Recovery password container Recovery password menu item View QR code - Multimedia message Fast mode notifications button Slow mode notifications button Loading animation @@ -188,4 +187,5 @@ Original version of disappearing messages. Expand + Media message \ No newline at end of file diff --git a/libsession/src/main/res/values/strings.xml b/libsession/src/main/res/values/strings.xml index ff40df4f64..68957383b0 100644 --- a/libsession/src/main/res/values/strings.xml +++ b/libsession/src/main/res/values/strings.xml @@ -70,11 +70,6 @@ --> Gallery - - Please wait until attachment has finished downloading -