aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Schink <xmpp-dev@marcschink.de>2017-12-08 15:55:36 +0100
committerAndroid Development <you@example.com>2017-12-09 12:32:21 +0100
commitc44dd4b06b206e7cf1d9d0696c9ca578d1a2f85b (patch)
tree7f6ee8c0bb507757d21a4c532b27bb1b77fbdd2f
parent26f85d73c9aa472207a9b19b9e08f27d2014f229 (diff)
StartConversationActivity: Handle 'message action' xmpp URIuri_message2
-rw-r--r--src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java46
1 files changed, 34 insertions, 12 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java
index e8bd498..6575e8c 100644
--- a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java
@@ -689,10 +689,8 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
Invite invite = new Invite(data);
if (xmppConnectionServiceBound) {
invite.invite();
- } else if (invite.getJid() != null) {
- this.mPendingInvite = invite;
} else {
- this.mPendingInvite = null;
+ this.mPendingInvite = invite;
}
}
} else if (resultCode == RESULT_OK) {
@@ -866,7 +864,12 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
}
private boolean handleJid(Invite invite) {
- Account account = xmppConnectionService.findAccountByJid(invite.getJid());
+ Account account = null;
+
+ if (invite.getJid() != null) {
+ account = xmppConnectionService.findAccountByJid(invite.getJid());
+ }
+
if (account != null && account.isEnabled()) {
if (invite.hasFingerprints() && xmppConnectionService.verifyFingerprints(account,invite.getFingerprints())) {
Toast.makeText(this,R.string.verified_fingerprints,Toast.LENGTH_SHORT).show();
@@ -885,6 +888,32 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
showJoinConferenceDialog(invite.getJid().toBareJid().toString());
return false;
}
+ } else if (invite.isMessage()) {
+ final Intent intent;
+ final int numAccounts = xmppConnectionService.getAccounts().size();
+ final String body = invite.getBody();
+ final Jid jid = invite.getJid();
+
+ if (jid != null && numAccounts == 0) {
+ Toast.makeText(this, R.string.no_accounts, Toast.LENGTH_SHORT).show();
+ return false;
+ } else if (jid != null && numAccounts == 1) {
+ Conversation conversation = xmppConnectionService.findOrCreateConversation(
+ xmppConnectionService.getAccounts().get(0), jid, false, false);
+ switchToConversation(conversation, body, false);
+ } else if (jid != null) {
+ intent = new Intent(getApplicationContext(), ShareViaAccountActivity.class);
+ intent.putExtra(ShareViaAccountActivity.EXTRA_CONTACT, jid.toString());
+ intent.putExtra(ShareViaAccountActivity.EXTRA_BODY, body);
+ startActivity(intent);
+ } else {
+ intent = new Intent(getApplicationContext(), ShareWithActivity.class);
+ intent.setAction(Intent.ACTION_SEND);
+ intent.setType("text/plain");
+ intent.putExtra(Intent.EXTRA_TEXT, body);
+ startActivity(intent);
+ }
+ return true;
} else if (contacts.size() == 0) {
showCreateContactDialog(invite.getJid().toString(), invite);
return false;
@@ -1193,14 +1222,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
public String account;
boolean invite() {
- if (!isJidValid()) {
- Toast.makeText(StartConversationActivity.this,R.string.invalid_jid,Toast.LENGTH_SHORT).show();
- return false;
- }
- if (getJid() != null) {
- return handleJid(this);
- }
- return false;
+ return handleJid(this);
}
public boolean isMuc() {