diff options
author | Docile-Alligator <chineseperson5@gmail.com> | 2022-05-30 15:20:44 +0000 |
---|---|---|
committer | Docile-Alligator <chineseperson5@gmail.com> | 2022-05-30 15:20:44 +0000 |
commit | 3218ff10f1b27942615fa1dd0d0ea5347a5ea64e (patch) | |
tree | b9eab59a992a535a5292691dfe70734c021ccc43 /app/src/main/java | |
parent | b65e28b593c9cd24f2759cee96660e472b00edfe (diff) | |
download | infinity-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 '')
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java | 16 |
1 files changed, 16 insertions, 0 deletions
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())); |