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 234ee65c3c..a4e50fb6c6 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 @@ -1170,6 +1170,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe } override fun deleteMessages(messages: Set) { + val allSentByCurrentUser = messages.all { it.isOutgoing } if (thread.isOpenGroupRecipient) { val messageCount = messages.size val builder = AlertDialog.Builder(this) @@ -1187,7 +1188,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe endActionMode() } builder.show() - } else { + } else if (allSentByCurrentUser) { val bottomSheet = DeleteOptionsBottomSheet() bottomSheet.recipient = thread bottomSheet.onDeleteForMeTapped = { @@ -1209,6 +1210,23 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe endActionMode() } bottomSheet.show(supportFragmentManager, bottomSheet.tag) + } else { + val messageCount = messages.size + val builder = AlertDialog.Builder(this) + builder.setTitle(resources.getQuantityString(R.plurals.ConversationFragment_delete_selected_messages, messageCount, messageCount)) + builder.setMessage(resources.getQuantityString(R.plurals.ConversationFragment_this_will_permanently_delete_all_n_selected_messages, messageCount, messageCount)) + builder.setCancelable(true) + builder.setPositiveButton(R.string.delete) { _, _ -> + for (message in messages) { + this.deleteLocally(message) + } + endActionMode() + } + builder.setNegativeButton(android.R.string.cancel) { dialog, _ -> + dialog.dismiss() + endActionMode() + } + builder.show() } } 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 2372657751..e1bde23e44 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 @@ -34,8 +34,9 @@ class ConversationActionModeCallback(private val adapter: ConversationAdapter, p val thread = DatabaseFactory.getThreadDatabase(context).getRecipientForThreadId(threadID)!! val userPublicKey = TextSecurePreferences.getLocalNumber(context)!! fun userCanDeleteSelectedItems(): Boolean { - if (openGroup == null) { return true } val allSentByCurrentUser = selectedItems.all { it.isOutgoing } + val allReceivedByByCurrentUser = selectedItems.all { !it.isOutgoing } + if (openGroup == null) { return allSentByCurrentUser || allReceivedByByCurrentUser } if (allSentByCurrentUser) { return true } return OpenGroupAPIV2.isUserModerator(userPublicKey, openGroup.room, openGroup.server) } diff --git a/app/src/main/java/org/thoughtcrime/securesms/database/MmsSmsDatabase.java b/app/src/main/java/org/thoughtcrime/securesms/database/MmsSmsDatabase.java index 6ba77ce83f..86b5231643 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/database/MmsSmsDatabase.java +++ b/app/src/main/java/org/thoughtcrime/securesms/database/MmsSmsDatabase.java @@ -128,7 +128,7 @@ public class MmsSmsDatabase extends Database { public Cursor getConversationSnippet(long threadId) { String order = MmsSmsColumns.NORMALIZED_DATE_RECEIVED + " DESC"; String selection = MmsSmsColumns.THREAD_ID + " = " + threadId; - + return queryTables(PROJECTION, selection, order, null); }