aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/AndroidManifest.xml31
-rw-r--r--src/main/java/eu/siacs/conversations/ui/UriHandlerActivity.java38
2 files changed, 57 insertions, 12 deletions
diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml
index 228b6c1..af011e0 100644
--- a/src/main/AndroidManifest.xml
+++ b/src/main/AndroidManifest.xml
@@ -58,18 +58,11 @@
</intent-filter>
</activity>
<activity
- android:name=".ui.StartConversationActivity"
- android:label="@string/title_activity_start_conversation"
+ android:name=".ui.UriHandlerActivity"
+ android:label="foobar"
+ android:theme="@android:style/Theme.NoDisplay"
android:launchMode="singleTop">
<intent-filter>
- <action android:name="android.intent.action.SENDTO" />
-
- <category android:name="android.intent.category.DEFAULT" />
-
- <data android:scheme="imto" />
- <data android:host="jabber" />
- </intent-filter>
- <intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
@@ -78,11 +71,12 @@
<data android:scheme="xmpp" />
</intent-filter>
<intent-filter>
- <action android:name="android.nfc.action.NDEF_DISCOVERED" />
+ <action android:name="android.intent.action.SENDTO" />
<category android:name="android.intent.category.DEFAULT" />
- <data android:scheme="xmpp" />
+ <data android:scheme="imto" />
+ <data android:host="jabber" />
</intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
@@ -95,6 +89,19 @@
<data android:pathPrefix="/i/" />
<data android:pathPrefix="/j/" />
</intent-filter>
+ </activity>
+ <activity
+ android:name=".ui.StartConversationActivity"
+ android:label="@string/title_activity_start_conversation"
+ android:launchMode="singleTop">
+ <intent-filter>
+ <action android:name="android.nfc.action.NDEF_DISCOVERED" />
+
+ <category android:name="android.intent.category.DEFAULT" />
+
+ <data android:scheme="imto" />
+ <data android:host="jabber" />
+ </intent-filter>
</activity>
<activity
diff --git a/src/main/java/eu/siacs/conversations/ui/UriHandlerActivity.java b/src/main/java/eu/siacs/conversations/ui/UriHandlerActivity.java
new file mode 100644
index 0000000..f96faf3
--- /dev/null
+++ b/src/main/java/eu/siacs/conversations/ui/UriHandlerActivity.java
@@ -0,0 +1,38 @@
+package eu.siacs.conversations.ui;
+
+import android.app.Activity;
+import android.content.Intent;
+
+public class UriHandlerActivity extends Activity {
+
+ @Override
+ public void onStart() {
+ super.onStart();
+ handleIntent(getIntent());
+ }
+
+ @Override
+ public void onNewIntent(Intent intent) {
+ handleIntent(intent);
+ }
+
+ private void handleIntent(Intent data) {
+ if (data == null) {
+ finish();
+ return;
+ }
+
+ 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);
+ }
+
+ finish();
+ }
+}