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 dcf7f11cf6..53562d09a1 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 @@ -989,7 +989,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe Log.e("Loki", "Failed to show emoji picker", e) return } - ViewUtil.hideKeyboard(this, visibleMessageView); + ViewUtil.hideKeyboard(this, visibleMessageView) binding?.reactionsShade?.isVisible = true showOrHidScrollToBottomButton(false) binding?.conversationRecyclerView?.suppressLayout(true) @@ -1020,7 +1020,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe message.isOutgoing, visibleMessageView.messageContentView ) - reactionDelegate.show(this, message, selectedConversationModel) + reactionDelegate.show(this, message, selectedConversationModel, viewModel.blindedPublicKey) } override fun dispatchTouchEvent(ev: MotionEvent): Boolean { @@ -1802,6 +1802,8 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe ConversationReactionOverlay.Action.VIEW_INFO -> showMessageDetail(selectedItems) ConversationReactionOverlay.Action.SELECT -> selectMessages(selectedItems) ConversationReactionOverlay.Action.DELETE -> deleteMessages(selectedItems) + ConversationReactionOverlay.Action.BAN_AND_DELETE_ALL -> banAndDeleteAll(selectedItems) + ConversationReactionOverlay.Action.BAN_USER -> banUser(selectedItems) } } } diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationReactionDelegate.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationReactionDelegate.kt index a090462c46..fd77a3bf0f 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationReactionDelegate.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationReactionDelegate.kt @@ -27,13 +27,15 @@ internal class ConversationReactionDelegate(private val overlayStub: Stub handleActionItemClicked(Action.COPY_SESSION_ID))); } // Delete message - if (ConversationMenuItemHelper.userCanDeleteSelectedItems(getContext(), message, openGroup, userPublicKey)) { + if (ConversationMenuItemHelper.userCanDeleteSelectedItems(getContext(), message, openGroup, userPublicKey, blindedPublicKey)) { items.add(new ActionItem(R.attr.menu_trash_icon, getContext().getResources().getString(R.string.delete), () -> handleActionItemClicked(Action.DELETE))); } // Ban user - if (ConversationMenuItemHelper.userCanBanSelectedUsers(getContext(), message, openGroup, userPublicKey)) { - items.add(new ActionItem(0, getContext().getResources().getString(R.string.conversation_context__menu_ban_user), () -> handleActionItemClicked(Action.BAN_USER))); + if (ConversationMenuItemHelper.userCanBanSelectedUsers(getContext(), message, openGroup, userPublicKey, blindedPublicKey)) { + items.add(new ActionItem(R.attr.menu_block_icon, getContext().getResources().getString(R.string.conversation_context__menu_ban_user), () -> handleActionItemClicked(Action.BAN_USER))); } // Ban and delete all - if (ConversationMenuItemHelper.userCanBanSelectedUsers(getContext(), message, openGroup, userPublicKey)) { - items.add(new ActionItem(0, getContext().getResources().getString(R.string.conversation_context__menu_ban_and_delete_all), () -> handleActionItemClicked(Action.BAN_AND_DELETE_ALL))); + if (ConversationMenuItemHelper.userCanBanSelectedUsers(getContext(), message, openGroup, userPublicKey, blindedPublicKey)) { + items.add(new ActionItem(R.attr.menu_trash_icon, getContext().getResources().getString(R.string.conversation_context__menu_ban_and_delete_all), () -> handleActionItemClicked(Action.BAN_AND_DELETE_ALL))); } // Message detail if (message.isFailed()) { diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/menus/ConversationMenuItemHelper.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/menus/ConversationMenuItemHelper.kt index a72ae848fa..ffc36fddf6 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/menus/ConversationMenuItemHelper.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/menus/ConversationMenuItemHelper.kt @@ -8,17 +8,17 @@ import org.thoughtcrime.securesms.groups.OpenGroupManager object ConversationMenuItemHelper { @JvmStatic - fun userCanDeleteSelectedItems(context: Context, message: MessageRecord, openGroup: OpenGroup?, userPublicKey: String): Boolean { + fun userCanDeleteSelectedItems(context: Context, message: MessageRecord, openGroup: OpenGroup?, userPublicKey: String, blindedPublicKey: String?): Boolean { if (openGroup == null) return message.isOutgoing || !message.isOutgoing if (message.isOutgoing) return true - return OpenGroupManager.isUserModerator(context, openGroup.groupId, userPublicKey) + return OpenGroupManager.isUserModerator(context, openGroup.groupId, userPublicKey, blindedPublicKey) } @JvmStatic - fun userCanBanSelectedUsers(context: Context, message: MessageRecord, openGroup: OpenGroup?, userPublicKey: String): Boolean { + fun userCanBanSelectedUsers(context: Context, message: MessageRecord, openGroup: OpenGroup?, userPublicKey: String, blindedPublicKey: String?): Boolean { if (openGroup == null) return false if (message.isOutgoing) return false // Users can't ban themselves - return OpenGroupManager.isUserModerator(context, openGroup.groupId, userPublicKey) + return OpenGroupManager.isUserModerator(context, openGroup.groupId, userPublicKey, blindedPublicKey) } }