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 7b9c3629f9..fc6fb03e1e 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 @@ -1251,6 +1251,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe // `position` is the adapter position; not the visual position private fun handleSwipeToReply(message: MessageRecord) { + if (message.isOpenGroupInvitation) return val recipient = viewModel.recipient ?: return binding?.inputBar?.draftQuote(recipient, message, glide) } 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 d336c5fcce..af754a300a 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 @@ -532,7 +532,7 @@ class ConversationReactionOverlay : FrameLayout { items += ActionItem(R.attr.menu_select_icon, R.string.conversation_context__menu_select, { handleActionItemClicked(Action.SELECT) }, R.string.AccessibilityId_select) // Reply val canWrite = openGroup == null || openGroup.canWrite - if (canWrite && !message.isPending && !message.isFailed) { + if (canWrite && !message.isPending && !message.isFailed && !message.isOpenGroupInvitation) { items += ActionItem(R.attr.menu_reply_icon, R.string.conversation_context__menu_reply, { handleActionItemClicked(Action.REPLY) }, R.string.AccessibilityId_reply_message) } // Copy message text diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/MessageDetailActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/MessageDetailActivity.kt index 61732827f3..d5e28fb936 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/MessageDetailActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/MessageDetailActivity.kt @@ -123,7 +123,7 @@ class MessageDetailActivity : PassphraseRequiredActionBarActivity() { AppTheme { MessageDetails( state = state, - onReply = { setResultAndFinish(ON_REPLY) }, + onReply = if (state.canReply) { { setResultAndFinish(ON_REPLY) } } else null, onResend = state.error?.let { { setResultAndFinish(ON_RESEND) } }, onDelete = { setResultAndFinish(ON_DELETE) }, onClickImage = { viewModel.onClickImage(it) }, @@ -145,7 +145,7 @@ class MessageDetailActivity : PassphraseRequiredActionBarActivity() { @Composable fun MessageDetails( state: MessageDetailsState, - onReply: () -> Unit = {}, + onReply: (() -> Unit)? = null, onResend: (() -> Unit)? = null, onDelete: () -> Unit = {}, onClickImage: (Int) -> Unit = {}, @@ -214,18 +214,20 @@ fun CellMetadata( @Composable fun CellButtons( - onReply: () -> Unit = {}, + onReply: (() -> Unit)? = null, onResend: (() -> Unit)? = null, onDelete: () -> Unit = {}, ) { Cell { Column { - ItemButton( - stringResource(R.string.reply), - R.drawable.ic_message_details__reply, - onClick = onReply - ) - Divider() + onReply?.let { + ItemButton( + stringResource(R.string.reply), + R.drawable.ic_message_details__reply, + onClick = it + ) + Divider() + } onResend?.let { ItemButton( stringResource(R.string.resend), diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/MessageDetailsViewModel.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/MessageDetailsViewModel.kt index 4ebc1f27b3..ba153a6b36 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/MessageDetailsViewModel.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/MessageDetailsViewModel.kt @@ -117,7 +117,7 @@ class MessageDetailsViewModel @Inject constructor( Attachment(slide.details, slide.fileName.orNull(), slide.uri, slide is ImageSlide) fun onClickImage(index: Int) { - val state = state.value ?: return + val state = state.value val mmsRecord = state.mmsRecord ?: return val slide = mmsRecord.slideDeck.slides[index] ?: return // only open to downloaded images @@ -158,6 +158,7 @@ data class MessageDetailsState( val thread: Recipient? = null, ) { val fromTitle = GetString(R.string.message_details_header__from) + val canReply = record?.isOpenGroupInvitation != true } data class Attachment( diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/menus/ConversationActionModeCallback.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/menus/ConversationActionModeCallback.kt index 2788d35dd2..21398c71aa 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/menus/ConversationActionModeCallback.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/menus/ConversationActionModeCallback.kt @@ -77,7 +77,7 @@ class ConversationActionModeCallback(private val adapter: ConversationAdapter, p && firstMessage.isMms && (firstMessage as MediaMmsMessageRecord).containsMediaSlide()) // Reply menu.findItem(R.id.menu_context_reply).isVisible = - (selectedItems.size == 1 && !firstMessage.isPending && !firstMessage.isFailed) + (selectedItems.size == 1 && !firstMessage.isPending && !firstMessage.isFailed && !firstMessage.isOpenGroupInvitation) } override fun onPrepareActionMode(mode: ActionMode?, menu: Menu): Boolean { diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageView.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageView.kt index f22de40c10..4e8a079024 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageView.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageView.kt @@ -66,6 +66,7 @@ private const val TAG = "VisibleMessageView" @AndroidEntryPoint class VisibleMessageView : LinearLayout { + private var replyDisabled: Boolean = false @Inject lateinit var threadDb: ThreadDatabase @Inject lateinit var lokiThreadDb: LokiThreadDatabase @Inject lateinit var lokiApiDb: LokiAPIDatabase @@ -136,6 +137,7 @@ class VisibleMessageView : LinearLayout { onAttachmentNeedsDownload: (Long, Long) -> Unit, lastSentMessageId: Long ) { + replyDisabled = message.isOpenGroupInvitation val threadID = message.threadId val thread = threadDb.getRecipientForThreadId(threadID) ?: return val isGroupThread = thread.isGroupRecipient @@ -474,6 +476,7 @@ class VisibleMessageView : LinearLayout { } else { longPressCallback?.let { gestureHandler.removeCallbacks(it) } } + if (replyDisabled) return if (translationX > 0) { return } // Only allow swipes to the left // The idea here is to asymptotically approach a maximum drag distance val damping = 50.0f