support ?roster;ibr=y xmpp uris
This commit is contained in:
parent
6d74698aec
commit
e71bfaa48d
5 changed files with 25 additions and 20 deletions
|
@ -4,7 +4,6 @@ import android.content.Intent;
|
|||
import android.graphics.Bitmap;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import androidx.annotation.StringRes;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.View.OnLongClickListener;
|
||||
|
@ -13,6 +12,8 @@ import android.widget.ImageView;
|
|||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.StringRes;
|
||||
|
||||
import com.theartofdev.edmodo.cropper.CropImage;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
@ -95,11 +96,11 @@ public class PublishProfilePictureActivity extends XmppActivity implements XmppC
|
|||
});
|
||||
this.cancelButton.setOnClickListener(v -> {
|
||||
if (mInitialAccountSetup) {
|
||||
Intent intent = new Intent(getApplicationContext(), StartConversationActivity.class);
|
||||
final Intent intent = new Intent(getApplicationContext(), StartConversationActivity.class);
|
||||
if (xmppConnectionService != null && xmppConnectionService.getAccounts().size() == 1) {
|
||||
StartConversationActivity.addInviteUri(intent, getIntent());
|
||||
intent.putExtra("init", true);
|
||||
}
|
||||
StartConversationActivity.addInviteUri(intent, getIntent());
|
||||
startActivity(intent);
|
||||
}
|
||||
finish();
|
||||
|
|
|
@ -830,7 +830,8 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
|
|||
showJoinConferenceDialog(invite.getJid().asBareJid().toString());
|
||||
return false;
|
||||
}
|
||||
} else if (contacts.size() == 0) {
|
||||
} else if (contacts.size() == 0) { //TODO or init mode
|
||||
//TODO if init mode; prefill dialog with account jid
|
||||
showCreateContactDialog(invite.getJid().toString(), invite);
|
||||
return false;
|
||||
} else if (contacts.size() == 1) {
|
||||
|
@ -1232,7 +1233,8 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
|
|||
|
||||
public static void addInviteUri(Intent to, Intent from) {
|
||||
if (from != null && from.hasExtra(EXTRA_INVITE_URI)) {
|
||||
to.putExtra(EXTRA_INVITE_URI, from.getStringExtra(EXTRA_INVITE_URI));
|
||||
final String invite = from.getStringExtra(EXTRA_INVITE_URI);
|
||||
to.putExtra(EXTRA_INVITE_URI, invite);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1240,17 +1242,13 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
|
|||
|
||||
public String account;
|
||||
|
||||
public boolean forceDialog = false;
|
||||
boolean forceDialog = false;
|
||||
|
||||
public Invite(final Uri uri) {
|
||||
Invite(final String uri) {
|
||||
super(uri);
|
||||
}
|
||||
|
||||
public Invite(final String uri) {
|
||||
super(uri);
|
||||
}
|
||||
|
||||
public Invite(Uri uri, boolean safeSource) {
|
||||
Invite(Uri uri, boolean safeSource) {
|
||||
super(uri, safeSource);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ import android.content.pm.PackageManager;
|
|||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
@ -17,7 +16,6 @@ import java.util.List;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import de.pixart.messenger.Config;
|
||||
import de.pixart.messenger.R;
|
||||
import de.pixart.messenger.persistance.DatabaseBackend;
|
||||
import de.pixart.messenger.utils.SignupUtils;
|
||||
|
@ -88,16 +86,23 @@ public class UriHandlerActivity extends AppCompatActivity {
|
|||
final Intent intent;
|
||||
final XmppUri xmppUri = new XmppUri(uri);
|
||||
final List<Jid> accounts = DatabaseBackend.getInstance(this).getAccountJids(true);
|
||||
if (SignupUtils.isSupportTokenRegistry() && xmppUri.isJidValid() && xmppUri.isAction(XmppUri.ACTION_REGISTER)) {
|
||||
if (SignupUtils.isSupportTokenRegistry() && xmppUri.isJidValid()) {
|
||||
final String preauth = xmppUri.getParamater("preauth");
|
||||
final Jid jid = xmppUri.getJid();
|
||||
if (jid.isDomainJid()) {
|
||||
if (xmppUri.isAction(XmppUri.ACTION_REGISTER)) {
|
||||
if (jid.isDomainJid()) {
|
||||
intent = SignupUtils.getTokenRegistrationIntent(this, jid.getDomain(), preauth);
|
||||
startActivity(intent);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (xmppUri.isAction(XmppUri.ACTION_ROSTER) && "y".equals(xmppUri.getParamater("ibr"))) {
|
||||
intent = SignupUtils.getTokenRegistrationIntent(this, jid.getDomain(), preauth);
|
||||
intent.putExtra(StartConversationActivity.EXTRA_INVITE_URI, xmppUri.toString());
|
||||
startActivity(intent);
|
||||
return;
|
||||
}
|
||||
Log.d(Config.LOGTAG, "attempting to register on " + jid + " with preauth=" + preauth);
|
||||
return;
|
||||
}
|
||||
if (accounts.size() == 0) {
|
||||
if (xmppUri.isJidValid()) {
|
||||
|
|
|
@ -19,10 +19,10 @@ public class SignupUtils {
|
|||
return true;
|
||||
}
|
||||
|
||||
public static Intent getTokenRegistrationIntent(final Activity activity, String domain, String preauth) {
|
||||
public static Intent getTokenRegistrationIntent(final Activity activity, String domain, String preAuth) {
|
||||
final Intent intent = new Intent(activity, MagicCreateActivity.class);
|
||||
intent.putExtra(MagicCreateActivity.EXTRA_DOMAIN, domain);
|
||||
intent.putExtra(MagicCreateActivity.EXTRA_PRE_AUTH, preauth);
|
||||
intent.putExtra(MagicCreateActivity.EXTRA_PRE_AUTH, preAuth);
|
||||
return intent;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ public class XmppUri {
|
|||
|
||||
public static final String ACTION_MESSAGE = "message";
|
||||
public static final String ACTION_REGISTER = "register";
|
||||
public static final String ACTION_ROSTER = "roster";
|
||||
|
||||
public static Pattern XMPP_URI = Patterns.XMPP_PATTERN;
|
||||
|
||||
|
|
Reference in a new issue