mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-19 16:19:33 +01:00
Fix note to self media delete options.
This commit is contained in:
committed by
Alex Hart
parent
6910ba6d2e
commit
47947b85c7
@@ -56,6 +56,7 @@ import org.thoughtcrime.securesms.conversation.mutiselect.forward.MultiselectFor
|
||||
import org.thoughtcrime.securesms.database.DatabaseObserver
|
||||
import org.thoughtcrime.securesms.database.MediaTable
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase
|
||||
import org.thoughtcrime.securesms.database.model.MessageRecord
|
||||
import org.thoughtcrime.securesms.databinding.FragmentMediaPreviewV2Binding
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||
import org.thoughtcrime.securesms.mediapreview.caption.ExpandingCaptionView
|
||||
@@ -613,13 +614,23 @@ class MediaPreviewV2Fragment :
|
||||
return
|
||||
}
|
||||
|
||||
val messageRecord = SignalDatabase.messages.getMessageRecord(attachment.mmsId)
|
||||
val isNoteToSelf = messageRecord.isOutgoing && messageRecord.toRecipient.isSelf
|
||||
|
||||
MaterialAlertDialogBuilder(requireContext()).apply {
|
||||
setIcon(R.drawable.symbol_error_triangle_fill_24)
|
||||
setTitle(R.string.MediaPreviewActivity_media_delete_confirmation_title)
|
||||
setMessage(R.string.MediaPreviewActivity_media_delete_confirmation_message)
|
||||
setCancelable(true)
|
||||
setNegativeButton(android.R.string.cancel, null)
|
||||
setPositiveButton(R.string.ConversationFragment_delete_for_me) { _, _ ->
|
||||
|
||||
val deleteButtonLabel = if (isNoteToSelf) {
|
||||
R.string.ConversationFragment_delete
|
||||
} else {
|
||||
R.string.ConversationFragment_delete_for_me
|
||||
}
|
||||
|
||||
setPositiveButton(deleteButtonLabel) { _, _ ->
|
||||
lifecycleDisposable += viewModel.localDelete(requireContext(), attachment)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeBy(
|
||||
@@ -634,7 +645,7 @@ class MediaPreviewV2Fragment :
|
||||
)
|
||||
}
|
||||
|
||||
if (canRemotelyDelete(attachment)) {
|
||||
if (canRemotelyDelete(attachment, messageRecord) && !isNoteToSelf) {
|
||||
setNeutralButton(R.string.ConversationFragment_delete_for_everyone) { _, _ ->
|
||||
lifecycleDisposable += viewModel.remoteDelete(attachment)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
@@ -653,10 +664,10 @@ class MediaPreviewV2Fragment :
|
||||
}.show()
|
||||
}
|
||||
|
||||
private fun canRemotelyDelete(attachment: DatabaseAttachment): Boolean {
|
||||
private fun canRemotelyDelete(attachment: DatabaseAttachment, messageRecord: MessageRecord): Boolean {
|
||||
val mmsId = attachment.mmsId
|
||||
val attachmentCount = SignalDatabase.attachments.getAttachmentsForMessage(mmsId).size
|
||||
return attachmentCount <= 1 && MessageConstraintsUtil.isValidRemoteDeleteSend(listOf(SignalDatabase.messages.getMessageRecord(mmsId)), System.currentTimeMillis())
|
||||
return attachmentCount <= 1 && MessageConstraintsUtil.isValidRemoteDeleteSend(listOf(messageRecord), System.currentTimeMillis())
|
||||
}
|
||||
|
||||
private fun editMediaItem(currentItem: MediaTable.MediaRecord) {
|
||||
|
||||
Reference in New Issue
Block a user