mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-25 17:27:45 +00:00
SES-2692 only save valid media in message details
This commit is contained in:
parent
4e2cef6346
commit
1761024911
@ -104,7 +104,6 @@ import org.session.libsignal.utilities.guava.Optional
|
||||
import org.session.libsignal.utilities.hexEncodedPrivateKey
|
||||
import org.thoughtcrime.securesms.ApplicationContext
|
||||
import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity
|
||||
import org.thoughtcrime.securesms.SessionDialogBuilder
|
||||
import org.thoughtcrime.securesms.attachments.ScreenshotObserver
|
||||
import org.thoughtcrime.securesms.audio.AudioRecorder
|
||||
import org.thoughtcrime.securesms.components.emoji.RecentEmojiPageModel
|
||||
@ -2208,7 +2207,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
||||
ON_DELETE -> deleteMessages(set)
|
||||
ON_COPY -> copyMessages(set)
|
||||
ON_SAVE -> {
|
||||
if(message is MmsMessageRecord) saveAttachments(message)
|
||||
if(message is MmsMessageRecord) saveAttachmentsIfPossible(setOf(message))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2244,7 +2243,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
||||
return result == PackageManager.PERMISSION_GRANTED
|
||||
}
|
||||
|
||||
override fun saveAttachment(messages: Set<MessageRecord>) {
|
||||
override fun saveAttachmentsIfPossible(messages: Set<MessageRecord>) {
|
||||
val message = messages.first() as MmsMessageRecord
|
||||
|
||||
// Note: The save option is only added to the menu in ConversationReactionOverlay.getMenuActionItems
|
||||
@ -2431,7 +2430,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
||||
ConversationReactionOverlay.Action.REPLY -> reply(selectedItems)
|
||||
ConversationReactionOverlay.Action.RESYNC -> resyncMessage(selectedItems)
|
||||
ConversationReactionOverlay.Action.RESEND -> resendMessage(selectedItems)
|
||||
ConversationReactionOverlay.Action.DOWNLOAD -> saveAttachment(selectedItems)
|
||||
ConversationReactionOverlay.Action.DOWNLOAD -> saveAttachmentsIfPossible(selectedItems)
|
||||
ConversationReactionOverlay.Action.COPY_MESSAGE -> copyMessages(selectedItems)
|
||||
ConversationReactionOverlay.Action.VIEW_INFO -> showMessageDetail(selectedItems)
|
||||
ConversationReactionOverlay.Action.SELECT -> selectMessages(selectedItems)
|
||||
|
@ -61,6 +61,7 @@ import org.session.libsession.messaging.sending_receiving.attachments.DatabaseAt
|
||||
import org.thoughtcrime.securesms.MediaPreviewActivity.getPreviewIntent
|
||||
import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity
|
||||
import org.thoughtcrime.securesms.database.Storage
|
||||
import org.thoughtcrime.securesms.database.model.MediaMmsMessageRecord
|
||||
import org.thoughtcrime.securesms.ui.Avatar
|
||||
import org.thoughtcrime.securesms.ui.CarouselNextButton
|
||||
import org.thoughtcrime.securesms.ui.CarouselPrevButton
|
||||
@ -126,11 +127,16 @@ class MessageDetailActivity : PassphraseRequiredActionBarActivity() {
|
||||
@Composable
|
||||
private fun MessageDetailsScreen() {
|
||||
val state by viewModel.stateFlow.collectAsState()
|
||||
|
||||
// can only save if the there is a media attachment which has finished downloading.
|
||||
val canSave = state.mmsRecord?.containsMediaSlide() == true
|
||||
&& state.mmsRecord?.isMediaPending == false
|
||||
|
||||
MessageDetails(
|
||||
state = state,
|
||||
onReply = if (state.canReply) { { setResultAndFinish(ON_REPLY) } } else null,
|
||||
onResend = state.error?.let { { setResultAndFinish(ON_RESEND) } },
|
||||
onSave = if(state.mmsRecord != null) { { setResultAndFinish(ON_SAVE) } } else null,
|
||||
onSave = if(canSave) { { setResultAndFinish(ON_SAVE) } } else null,
|
||||
onDelete = { setResultAndFinish(ON_DELETE) },
|
||||
onCopy = { setResultAndFinish(ON_COPY) },
|
||||
onClickImage = { viewModel.onClickImage(it) },
|
||||
|
@ -102,7 +102,7 @@ class ConversationActionModeCallback(private val adapter: ConversationAdapter, p
|
||||
R.id.menu_context_resync -> delegate?.resyncMessage(selectedItems)
|
||||
R.id.menu_context_resend -> delegate?.resendMessage(selectedItems)
|
||||
R.id.menu_message_details -> delegate?.showMessageDetail(selectedItems)
|
||||
R.id.menu_context_save_attachment -> delegate?.saveAttachment(selectedItems)
|
||||
R.id.menu_context_save_attachment -> delegate?.saveAttachmentsIfPossible(selectedItems)
|
||||
R.id.menu_context_reply -> delegate?.reply(selectedItems)
|
||||
}
|
||||
return true
|
||||
@ -126,7 +126,7 @@ interface ConversationActionModeCallbackDelegate {
|
||||
fun resyncMessage(messages: Set<MessageRecord>)
|
||||
fun resendMessage(messages: Set<MessageRecord>)
|
||||
fun showMessageDetail(messages: Set<MessageRecord>)
|
||||
fun saveAttachment(messages: Set<MessageRecord>)
|
||||
fun saveAttachmentsIfPossible(messages: Set<MessageRecord>)
|
||||
fun reply(messages: Set<MessageRecord>)
|
||||
fun destroyActionMode()
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user