allow to start secret chat on roster page

This commit is contained in:
kosyak 2024-10-29 17:28:33 +07:00
parent b18f042b8b
commit e72b866fce
2 changed files with 25 additions and 0 deletions

View file

@ -1310,6 +1310,21 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
}
}
protected void startOtrChat() {
int position = contact_context_id;
Contact contact = (Contact) contacts.get(position);
Conversation conversation = xmppConnectionService.findOrCreateConversation(contact.getAccount(), contact.getJid(), null, false, false, false, null);
selectPresence(conversation,
() -> {
Conversation c = xmppConnectionService.findOrCreateConversation(contact.getAccount(), contact.getJid(), null, false, false, false, conversation.getNextCounterpart());
conversation.setNextCounterpart(null);
if (c != null) {
switchToConversation(c);
}
});
}
private void setRefreshing(boolean refreshing) {
MyListFragment fragment = (MyListFragment) mListPagerAdapter.getItem(0);
@ -1451,9 +1466,12 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
final MenuItem blockUnblockItem = menu.findItem(R.id.context_contact_block_unblock);
final MenuItem showContactDetailsItem = menu.findItem(R.id.context_contact_details);
final MenuItem deleteContactMenuItem = menu.findItem(R.id.context_delete_contact);
final MenuItem startSecrectChat = menu.findItem(R.id.context_contact_start_secrect_chat);
if (contact.isSelf()) {
showContactDetailsItem.setVisible(false);
startSecrectChat.setVisible(false);
}
deleteContactMenuItem.setVisible(contact.showInRoster() && !contact.getOption(Contact.Options.SYNCED_VIA_OTHER));
final XmppConnection xmpp = contact.getAccount().getXmppConnection();
if (xmpp != null && xmpp.getFeatures().blocking() && !contact.isSelf()) {
@ -1492,6 +1510,8 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
break;
case R.id.context_delete_conference:
activity.deleteConference();
case R.id.context_contact_start_secrect_chat:
activity.startOtrChat();
}
return true;
}

View file

@ -4,6 +4,11 @@
<item
android:id="@+id/context_contact_details"
android:title="@string/view_contact_details"/>
<item
android:id="@+id/context_contact_start_secrect_chat"
android:title="@string/action_start_secret_chat"/>
<item
android:id="@+id/context_show_qr"
android:title="@string/show_qr_code"/>