aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDocile-Alligator <chineseperson5@gmail.com>2022-05-30 15:20:44 +0000
committerDocile-Alligator <chineseperson5@gmail.com>2022-05-30 15:20:44 +0000
commit3218ff10f1b27942615fa1dd0d0ea5347a5ea64e (patch)
treeb9eab59a992a535a5292691dfe70734c021ccc43 /app
parentb65e28b593c9cd24f2759cee96660e472b00edfe (diff)
downloadinfinity-for-reddit-3218ff10f1b27942615fa1dd0d0ea5347a5ea64e.tar
infinity-for-reddit-3218ff10f1b27942615fa1dd0d0ea5347a5ea64e.tar.gz
infinity-for-reddit-3218ff10f1b27942615fa1dd0d0ea5347a5ea64e.tar.bz2
infinity-for-reddit-3218ff10f1b27942615fa1dd0d0ea5347a5ea64e.tar.lz
infinity-for-reddit-3218ff10f1b27942615fa1dd0d0ea5347a5ea64e.tar.xz
infinity-for-reddit-3218ff10f1b27942615fa1dd0d0ea5347a5ea64e.tar.zst
infinity-for-reddit-3218ff10f1b27942615fa1dd0d0ea5347a5ea64e.zip
Share a link to Infinity so that you can open reddit links in this app.
Diffstat (limited to 'app')
-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>