mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-27 19:38:22 +01:00
Share a link to Infinity so that you can open reddit links in this app.
This commit is contained in:
parent
b65e28b593
commit
3218ff10f1
@ -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" />
|
||||
|
||||
|
@ -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()));
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user