diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
index 60cef8bfd..ce21492c0 100644
--- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
+++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
@@ -2705,6 +2705,16 @@ public class XmppConnectionService extends Service {
archiveConversation(conversation, true);
}
+ public void destroyConversation(Conversation conversation) {
+ archiveConversation(conversation);
+ final Runnable runnable = () -> {
+ if (!databaseBackend.deleteConversation(conversation.getAccount(), conversation.getContactJid().asBareJid(), conversation.getNextCounterpart())) {
+ Log.d(Config.LOGTAG, conversation.getJid().asBareJid() + ": unable to delete conversation");
+ }
+ };
+ mDatabaseWriterExecutor.execute(runnable);
+ }
+
private void archiveConversation(Conversation conversation, final boolean maySynchronizeWithBookmarks) {
getNotificationService().clear(conversation);
conversation.setStatus(Conversation.STATUS_ARCHIVED);
@@ -2733,6 +2743,7 @@ public class XmppConnectionService extends Service {
stopPresenceUpdatesTo(conversation.getContact());
}
}
+ conversation.endOtrIfNeeded();
updateConversation(conversation);
this.conversations.remove(conversation);
updateConversationUi();
diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
index 9e427412e..c1b5de697 100644
--- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
+++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
@@ -1408,12 +1408,15 @@ public class ConversationFragment extends XmppFragment
final MenuItem menuTogglePinned = menu.findItem(R.id.action_toggle_pinned);
final MenuItem deleteCustomBg = menu.findItem(R.id.action_delete_custom_bg);
final MenuItem startSecretChat = menu.findItem(R.id.action_start_secret_chat);
+ final MenuItem destroySecretChat = menu.findItem(R.id.action_destroy_secret_chat);
final MenuItem encryption = menu.findItem(R.id.action_security);
if (conversation != null) {
boolean considerAsSecretChat = conversation.getMode() == Conversational.MODE_SINGLE &&
conversation.getNextCounterpart() != null && conversation.hasPermanentCounterpart();
+
+ destroySecretChat.setVisible(false);
if (conversation.getMode() == Conversation.MODE_MULTI) {
menuContactDetails.setVisible(false);
menuInviteContact.setVisible(conversation.getMucOptions().canInvite() && conversation.getNextCounterpart() == null);
@@ -1427,6 +1430,7 @@ public class ConversationFragment extends XmppFragment
} else {
if (considerAsSecretChat) {
startSecretChat.setVisible(false);
+ destroySecretChat.setVisible(true);
}
menuMucParticipants.setVisible(false);
final XmppConnectionService service =
@@ -2065,6 +2069,9 @@ public class ConversationFragment extends XmppFragment
case R.id.action_start_secret_chat:
startOtrChat();
break;
+ case R.id.action_destroy_secret_chat:
+ destroySecrectChat();
+ break;
case R.id.action_contact_details:
activity.switchToContactDetails(conversation.getContact());
break;
@@ -4013,6 +4020,12 @@ public class ConversationFragment extends XmppFragment
});
}
+ private void destroySecrectChat() {
+ conversation.endOtrIfNeeded();
+ activity.xmppConnectionService.destroyConversation(conversation);
+ activity.onBackPressed();
+ }
+
protected void sendPgpMessage(final Message message) {
final XmppConnectionService xmppService = activity.xmppConnectionService;
final Contact contact = message.getConversation().getContact();
diff --git a/src/main/res/menu/fragment_conversation.xml b/src/main/res/menu/fragment_conversation.xml
index ef3f8e792..a1a2ee847 100644
--- a/src/main/res/menu/fragment_conversation.xml
+++ b/src/main/res/menu/fragment_conversation.xml
@@ -126,6 +126,12 @@
android:orderInCategory="65"
android:title="@string/action_start_secret_chat"
app:showAsAction="never" />
+
+
-
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index bf8767b6e..15ddea99f 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -7,6 +7,7 @@
Manage account
Close conversation
Start secret chat
+ Destroy secret chat
Contact details
Group chat details
Channel details