allow to destroy secret chat
This commit is contained in:
parent
e72b866fce
commit
82134599ef
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -126,6 +126,12 @@
|
|||
android:orderInCategory="65"
|
||||
android:title="@string/action_start_secret_chat"
|
||||
app:showAsAction="never" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_destroy_secret_chat"
|
||||
android:orderInCategory="66"
|
||||
android:title="@string/action_destroy_secret_chat"
|
||||
app:showAsAction="never" />
|
||||
<item
|
||||
android:orderInCategory="70"
|
||||
android:title="@string/more_options">
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
<string name="action_account">Manage account</string>
|
||||
<string name="action_end_conversation">Close conversation</string>
|
||||
<string name="action_start_secret_chat">Start secret chat</string>
|
||||
<string name="action_destroy_secret_chat">Destroy secret chat</string>
|
||||
<string name="action_contact_details">Contact details</string>
|
||||
<string name="action_muc_details">Group chat details</string>
|
||||
<string name="channel_details">Channel details</string>
|
||||
|
|
Loading…
Reference in a new issue