Fix up empty OTR verification window

This commit is contained in:
Arne 2024-10-10 05:23:07 +02:00
parent 3187060698
commit f5daf84f44
3 changed files with 34 additions and 1 deletions

View file

@ -827,6 +827,10 @@ public class XmppConnectionService extends Service {
return find(getConversations(), account, jid);
}
public Conversation find(final Account account, final Jid jid, final Jid counterpart) {
return find(getConversations(), account, jid, counterpart);
}
public boolean isMuc(final Account account, final Jid jid) {
final Conversation c = find(account, jid);
return c != null && c.getMode() == Conversational.MODE_MULTI;
@ -2856,6 +2860,34 @@ public class XmppConnectionService extends Service {
return null;
}
private Conversation find(final Iterable<Conversation> haystack, final Account account, final Jid jid, final Jid counterpart) {
if (jid == null) {
return null;
}
if (counterpart != null) {
for (final Conversation conversation : haystack) {
if ((account == null || conversation.getAccount() == account)
&& (conversation.getJid().asBareJid().equals(jid.asBareJid()))
&& Objects.equal(conversation.getNextCounterpart(), counterpart)
) {
return conversation;
}
}
} else {
for (final Conversation conversation : haystack) {
if ((account == null || conversation.getAccount() == account)
&& (conversation.getJid().asBareJid().equals(jid.asBareJid()))
&& conversation.getNextCounterpart() == null
) {
return conversation;
}
}
}
return null;
}
public boolean isConversationsListEmpty(final Conversation ignore) {
synchronized (this.conversations) {
final int size = this.conversations.size();

View file

@ -1535,6 +1535,7 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
Intent intent = new Intent(ConversationsActivity.this, VerifyOTRActivity.class);
intent.setAction(VerifyOTRActivity.ACTION_VERIFY_CONTACT);
intent.putExtra("contact", conversation.getContact().getJid().asBareJid().toString());
intent.putExtra("counterpart", conversation.getNextCounterpart().toString());
intent.putExtra(EXTRA_ACCOUNT, conversation.getAccount().getJid().asBareJid().toString());
switch (menuItem.getItemId()) {
case R.id.ask_question:

View file

@ -200,7 +200,7 @@ public class VerifyOTRActivity extends XmppActivity implements XmppConnectionSer
return false;
}
try {
this.mConversation = this.xmppConnectionService.find(this.mAccount, Jid.of(intent.getStringExtra("contact")));
this.mConversation = this.xmppConnectionService.find(this.mAccount, Jid.of(intent.getExtras().getString("contact")), Jid.of(intent.getExtras().getString("counterpart")));
if (this.mConversation == null) {
return false;
}