Pass invite XMPP URI along instead of JID

This commit is contained in:
Marc Schink 2018-02-14 16:55:45 +01:00
parent c7d2b65982
commit 3b7d9b39f7
6 changed files with 20 additions and 20 deletions

View File

@ -314,7 +314,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
&& xmppConnectionService.getAccounts().size() == 1) {
xmppConnectionService.deleteAccount(mAccount);
Intent intent = new Intent(EditAccountActivity.this, WelcomeActivity.class);
WelcomeActivity.addInvitee(intent, getIntent());
WelcomeActivity.addInviteUri(intent, getIntent());
startActivity(intent);
}
}
@ -388,7 +388,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
if (wasFirstAccount) {
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
}
WelcomeActivity.addInvitee(intent, getIntent());
WelcomeActivity.addInviteUri(intent, getIntent());
startActivity(intent);
finish();
});

View File

@ -80,7 +80,7 @@ public class MagicCreateActivity extends XmppActivity implements TextWatcher {
intent.putExtra("init", true);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
Toast.makeText(MagicCreateActivity.this, R.string.secure_password_generated, Toast.LENGTH_SHORT).show();
WelcomeActivity.addInvitee(intent, getIntent());
WelcomeActivity.addInviteUri(intent, getIntent());
startActivity(intent);
} catch (InvalidJidException e) {
mUsername.setError(getString(R.string.invalid_username));

View File

@ -62,7 +62,7 @@ public class PublishProfilePictureActivity extends XmppActivity implements XmppC
runOnUiThread(() -> {
if (mInitialAccountSetup) {
Intent intent = new Intent(getApplicationContext(), StartConversationActivity.class);
WelcomeActivity.addInvitee(intent, getIntent());
WelcomeActivity.addInviteUri(intent, getIntent());
intent.putExtra("init", true);
startActivity(intent);
}
@ -110,7 +110,7 @@ public class PublishProfilePictureActivity extends XmppActivity implements XmppC
if (mInitialAccountSetup) {
Intent intent = new Intent(getApplicationContext(), StartConversationActivity.class);
if (xmppConnectionService != null && xmppConnectionService.getAccounts().size() == 1) {
WelcomeActivity.addInvitee(intent, getIntent());
WelcomeActivity.addInviteUri(intent, getIntent());
intent.putExtra("init", true);
}
startActivity(intent);

View File

@ -269,7 +269,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
recreate();
} else {
Intent i = getIntent();
if (i == null || !i.hasExtra(WelcomeActivity.EXTRA_INVITEE)) {
if (i == null || !i.hasExtra(WelcomeActivity.EXTRA_INVITE_URI)) {
askForContactsPermissions();
}
}
@ -799,9 +799,9 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
if (intent == null) {
return false;
}
final String invitee = intent.getStringExtra(WelcomeActivity.EXTRA_INVITEE);
if (invitee != null) {
Invite invite = new Invite("xmpp:" + invitee);
final String inviteUri = intent.getStringExtra(WelcomeActivity.EXTRA_INVITE_URI);
if (inviteUri != null) {
Invite invite = new Invite(inviteUri);
if (invite.isJidValid()) {
return invite.invite();
}

View File

@ -36,7 +36,7 @@ public class UriHandlerActivity extends Activity {
if (accounts.size() == 0) {
intent = new Intent(getApplicationContext(), WelcomeActivity.class);
WelcomeActivity.addInvitee(intent, xmppUri);
WelcomeActivity.addInviteUri(intent, xmppUri);
startActivity(intent);
return;
}

View File

@ -15,7 +15,7 @@ import eu.siacs.conversations.utils.XmppUri;
public class WelcomeActivity extends XmppActivity {
public static final String EXTRA_INVITEE = "eu.siacs.conversations.invitee";
public static final String EXTRA_INVITE_URI = "eu.siacs.conversations.invite_uri";
@Override
protected void refreshUiReal() {
@ -59,7 +59,7 @@ public class WelcomeActivity extends XmppActivity {
createAccount.setOnClickListener(v -> {
final Intent intent = new Intent(WelcomeActivity.this, MagicCreateActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
addInvitee(intent);
addInviteUri(intent);
startActivity(intent);
});
final Button useOwnProvider = findViewById(R.id.use_own_provider);
@ -72,25 +72,25 @@ public class WelcomeActivity extends XmppActivity {
} else if (accounts.size() >= 1) {
intent = new Intent(WelcomeActivity.this, ManageAccountActivity.class);
}
addInvitee(intent);
addInviteUri(intent);
startActivity(intent);
});
}
public void addInvitee(Intent intent) {
addInvitee(intent, getIntent());
public void addInviteUri(Intent intent) {
addInviteUri(intent, getIntent());
}
public static void addInvitee(Intent intent, XmppUri uri) {
public static void addInviteUri(Intent intent, XmppUri uri) {
if (uri.isJidValid()) {
intent.putExtra(EXTRA_INVITEE, uri.getJid().toString());
intent.putExtra(EXTRA_INVITE_URI, uri.toString());
}
}
public static void addInvitee(Intent to, Intent from) {
if (from != null && from.hasExtra(EXTRA_INVITEE)) {
to.putExtra(EXTRA_INVITEE, from.getStringExtra(EXTRA_INVITEE));
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));
}
}