support ?roster;ibr=y xmpp uris

This commit is contained in:
Daniel Gultsch 2020-01-09 15:49:49 +01:00
parent d039c4870f
commit 6205574bcb
5 changed files with 24 additions and 17 deletions

View File

@ -20,10 +20,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;
}

View File

@ -95,11 +95,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();

View File

@ -857,7 +857,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) {
@ -1279,7 +1280,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);
}
}
@ -1287,17 +1289,14 @@ 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);
}

View File

@ -89,17 +89,24 @@ public class UriHandlerActivity extends AppCompatActivity {
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 (xmppUri.isAction(XmppUri.ACTION_REGISTER)) {
if (jid.isDomainJid()) {
intent = SignupUtils.getTokenRegistrationIntent(this, jid.getDomain(), preauth);
startActivity(intent);
return;
}
Log.d(Config.LOGTAG,"attempting to register on "+jid+" with preauth="+preauth);
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;
}
}
if (accounts.size() == 0) {
if (xmppUri.isJidValid()) {

View File

@ -29,6 +29,7 @@ public class XmppUri {
public static final String ACTION_JOIN = "join";
public static final String ACTION_MESSAGE = "message";
public static final String ACTION_REGISTER = "register";
public static final String ACTION_ROSTER = "roster";
public XmppUri(String uri) {
try {