fix crash when using direct jingle init on offline contacts

This commit is contained in:
Daniel Gultsch 2024-01-18 13:16:14 +01:00
parent 1090b2edd3
commit bcc0c32af3
No known key found for this signature in database
GPG key ID: F43D18AD2A0982C2

View file

@ -32,6 +32,7 @@ package eu.siacs.conversations.ui.util;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.util.Pair; import android.util.Pair;
import android.widget.Toast;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AlertDialog;
@ -60,7 +61,9 @@ public class PresenceSelector {
public static void selectFullJidForDirectRtpConnection(final Activity activity, final Contact contact, final RtpCapability.Capability required, final OnFullJidSelected onFullJidSelected) { public static void selectFullJidForDirectRtpConnection(final Activity activity, final Contact contact, final RtpCapability.Capability required, final OnFullJidSelected onFullJidSelected) {
final String[] resources = RtpCapability.filterPresences(contact, required); final String[] resources = RtpCapability.filterPresences(contact, required);
if (resources.length == 1) { if (resources.length == 0) {
Toast.makeText(activity,R.string.rtp_state_contact_offline,Toast.LENGTH_LONG).show();
} else if (resources.length == 1) {
onFullJidSelected.onFullJidSelected(contact.getJid().withResource(resources[0])); onFullJidSelected.onFullJidSelected(contact.getJid().withResource(resources[0]));
} else { } else {
showPresenceSelectionDialog(activity, contact, resources, onFullJidSelected); showPresenceSelectionDialog(activity, contact, resources, onFullJidSelected);