mirror of
https://github.com/oxen-io/session-android.git
synced 2025-12-05 07:52:30 +00:00
Implemented task SS-79 to only provide a save attachment menu option when the attachment download is complete
This commit is contained in:
@@ -2146,9 +2146,11 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
||||
override fun saveAttachment(messages: Set<MessageRecord>) {
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user