aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--app/src/main/AndroidManifest.xml17
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java16
-rw-r--r--app/src/main/res/values/strings.xml3
3 files changed, 33 insertions, 3 deletions
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index a90f689f..26fd8b3f 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -215,21 +215,24 @@
<activity
android:name=".activities.ShareDataResolverActivity"
android:exported="true">
- <intent-filter>
+ <intent-filter
+ android:label="@string/submit_post">
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
- <intent-filter>
+ <intent-filter
+ android:label="@string/submit_post">
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="video/*" />
</intent-filter>
- <intent-filter>
+ <intent-filter
+ android:label="@string/submit_post">
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
@@ -275,6 +278,14 @@
<activity
android:name=".activities.LinkResolverActivity"
android:exported="true">
+ <intent-filter
+ android:label="@string/handle_link">
+ <action android:name="android.intent.action.SEND" />
+
+ <category android:name="android.intent.category.DEFAULT" />
+
+ <data android:mimeType="text/plain" />
+ </intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java
index d1589c18..79904bbc 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java
@@ -7,6 +7,7 @@ import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.os.Bundle;
+import android.webkit.URLUtil;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
@@ -74,6 +75,21 @@ public class LinkResolverActivity extends AppCompatActivity {
((Infinity) getApplication()).getAppComponent().inject(this);
Uri uri = getIntent().getData();
+ if (uri == null) {
+ String url = getIntent().getStringExtra(Intent.EXTRA_TEXT);
+ if (!URLUtil.isValidUrl(url)) {
+ Toast.makeText(this, R.string.invalid_link, Toast.LENGTH_SHORT).show();
+ finish();
+ return;
+ }
+ try {
+ uri = Uri.parse(url);
+ } catch (NullPointerException e) {
+ Toast.makeText(this, R.string.invalid_link, Toast.LENGTH_SHORT).show();
+ finish();
+ return;
+ }
+ }
if (uri.getScheme() == null && uri.getHost() == null) {
handleUri(getRedditUriByPath(uri.toString()));
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index e70184cd..8ed74ced 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1292,4 +1292,7 @@
<string name="awarder_karma">Awarder Karma:</string>
<string name="awardee_karma">Awardee Karma:</string>
+ <string name="handle_link">Handle Link</string>
+ <string name="invalid_link">Invalid link</string>
+
</resources>