aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Schink <xmpp-dev@marcschink.de>2017-12-06 08:38:01 +0100
committerAndroid Development <you@example.com>2017-12-07 17:34:48 +0100
commit676013935b82c221bce26a0f8c3338529f81e4b0 (patch)
tree70187c197842bac7ad37b5a6612a52be2477dec0
parent40d6baa2464becd766992159046651a294b6ab7c (diff)
Handle xmpp message action URI with JIDuri_message
-rw-r--r--src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java40
-rw-r--r--src/main/res/values-de/strings.xml1
-rw-r--r--src/main/res/values/strings.xml1
3 files changed, 42 insertions, 0 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java
index 9a5ec7f..f4af3a7 100644
--- a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java
@@ -101,6 +101,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
private AtomicBoolean mRequestedContactsPermission = new AtomicBoolean(false);
private final int REQUEST_SYNC_CONTACTS = 0x3b28cf;
private final int REQUEST_CREATE_CONFERENCE = 0x3b39da;
+ private final int REQUEST_CHOOSE_ACCOUNT = 0x3b39db;
private Dialog mCurrentDialog = null;
private MenuItem.OnActionExpandListener mOnActionExpandListener = new MenuItem.OnActionExpandListener() {
@@ -722,6 +723,19 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
mToast.show();
}
}
+ } else if (requestCode == REQUEST_CHOOSE_ACCOUNT) {
+ try {
+ final Jid accountJid = Jid.fromString(intent.getStringExtra(ChooseAccountActivity.EXTRA_SELECTED_ACCOUNT));
+ final Account account = xmppConnectionService.findAccountByJid(accountJid);
+ final Jid jid = Jid.fromString(intent.getStringExtra("contact"));
+ final String body = intent.getStringExtra("body");
+
+ Conversation conversation = xmppConnectionService.findOrCreateConversation(
+ account, jid, false, false);
+ switchToConversation(conversation, body, false);
+ } catch (InvalidJidException e) {
+ // ignore error
+ }
}
} else {
this.mPostponedActivityResult = new Pair<>(requestCode, intent);
@@ -892,6 +906,32 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
showJoinConferenceDialog(invite.getJid().toBareJid().toString());
return false;
}
+ } else if (invite.isMessage()) {
+ final int numAccounts = xmppConnectionService.getAccounts().size();
+
+ if (numAccounts == 0) {
+ /* TODO: Should we show a toast here? */
+ Toast.makeText(this, "No accounts available", Toast.LENGTH_SHORT).show();
+ } else if (numAccounts == 1) {
+ try {
+ final Jid jid = Jid.fromString(mActivatedAccounts.get(0));
+ final Account acc = xmppConnectionService.findAccountByJid(jid);
+ final Conversation conv = xmppConnectionService.findOrCreateConversation(acc,
+ invite.getJid(), false, false);
+ switchToConversation(conv, invite.getBody(), false);
+ } catch (InvalidJidException e) {
+ // ignore error
+ }
+ } else {
+ final Intent intent = new Intent(this, ChooseAccountActivity.class);
+ intent.putExtra(ChooseAccountActivity.EXTRA_TITLE_RES_ID,
+ R.string.title_activity_share_via_account);
+ intent.putExtra("body", invite.getBody());
+ intent.putExtra("contact", invite.getJid().toString());
+ startActivityForResult(intent, REQUEST_CHOOSE_ACCOUNT);
+ }
+
+ return true;
} else if (contacts.size() == 0) {
showCreateContactDialog(invite.getJid().toString(), invite);
return false;
diff --git a/src/main/res/values-de/strings.xml b/src/main/res/values-de/strings.xml
index cc2e66c..f3afef9 100644
--- a/src/main/res/values-de/strings.xml
+++ b/src/main/res/values-de/strings.xml
@@ -18,6 +18,7 @@
<string name="title_activity_manage_accounts">Konten verwalten</string>
<string name="title_activity_settings">Einstellungen</string>
<string name="title_activity_sharewith">Mit Unterhaltung teilen</string>
+ <string name="title_activity_share_via_account">Über Account teilen</string>
<string name="title_activity_start_conversation">Unterhaltung beginnen</string>
<string name="title_activity_choose_contact">Kontakt auswählen</string>
<string name="title_activity_block_list">Sperrliste</string>
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index e99c633..f44befb 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -19,6 +19,7 @@
<string name="title_activity_manage_accounts">Manage Accounts</string>
<string name="title_activity_settings">Settings</string>
<string name="title_activity_sharewith">Share with Conversation</string>
+ <string name="title_activity_share_via_account">Share via account</string>
<string name="title_activity_start_conversation">Start Conversation</string>
<string name="title_activity_choose_contact">Choose Contact</string>
<string name="title_activity_choose_account">Choose account</string>