aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Schink <xmpp-dev@marcschink.de>2017-12-07 22:13:24 +0100
committerAndroid Development <you@example.com>2017-12-10 14:57:28 +0100
commitcf3159e5aff2b0516ade21d00be7f564f7b0f07e (patch)
treee9072f4596f05aae4100280dc9ab968802cc96a6
parent7aedb6fbabe298595364723d68419562f724e6e2 (diff)
UriHandlerActivity: Handle 'message action' xmpp URI
-rw-r--r--src/main/java/eu/siacs/conversations/ui/UriHandlerActivity.java38
1 files changed, 32 insertions, 6 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/UriHandlerActivity.java b/src/main/java/eu/siacs/conversations/ui/UriHandlerActivity.java
index f96faf3..7f7e0b3 100644
--- a/src/main/java/eu/siacs/conversations/ui/UriHandlerActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/UriHandlerActivity.java
@@ -2,6 +2,10 @@ package eu.siacs.conversations.ui;
import android.app.Activity;
import android.content.Intent;
+import android.net.Uri;
+
+import eu.siacs.conversations.utils.XmppUri;
+import eu.siacs.conversations.xmpp.jid.Jid;
public class UriHandlerActivity extends Activity {
@@ -16,6 +20,33 @@ public class UriHandlerActivity extends Activity {
handleIntent(intent);
}
+ private void handleUri(Uri uri) {
+ final Intent intent;
+ final XmppUri xmppUri = new XmppUri(uri);
+
+ if (xmppUri.isMessage()) {
+ final Jid jid = xmppUri.getJid();
+ final String body = xmppUri.getBody();
+
+ if (jid != null) {
+ intent = new Intent(getApplicationContext(), ShareViaAccountActivity.class);
+ intent.putExtra(ShareViaAccountActivity.EXTRA_CONTACT, jid.toString());
+ intent.putExtra(ShareViaAccountActivity.EXTRA_BODY, body);
+ } else {
+ intent = new Intent(getApplicationContext(), ShareWithActivity.class);
+ intent.setAction(Intent.ACTION_SEND);
+ intent.setType("text/plain");
+ intent.putExtra(Intent.EXTRA_TEXT, body);
+ }
+ } else {
+ intent = new Intent(getApplicationContext(), StartConversationActivity.class);
+ intent.setAction(Intent.ACTION_VIEW);
+ intent.setData(uri);
+ }
+
+ startActivity(intent);
+ }
+
private void handleIntent(Intent data) {
if (data == null) {
finish();
@@ -25,12 +56,7 @@ public class UriHandlerActivity extends Activity {
switch (data.getAction()) {
case Intent.ACTION_VIEW:
case Intent.ACTION_SENDTO:
- final Intent intent = new Intent(getApplicationContext(),
- StartConversationActivity.class);
- intent.setAction(data.getAction());
- intent.setData(data.getData());
- intent.setAction(data.getAction());
- startActivity(intent);
+ handleUri(data.getData());
}
finish();