Add buff.ly unshorten support
This commit is contained in:
parent
f0cc359d27
commit
c6460840f8
|
@ -34,10 +34,8 @@
|
||||||
<!-- t.co -->
|
<!-- t.co -->
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.VIEW" />
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
<category android:name="android.intent.category.BROWSABLE" />
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
|
|
||||||
<data
|
<data
|
||||||
android:host="t.co"
|
android:host="t.co"
|
||||||
android:pathPattern=".*"
|
android:pathPattern=".*"
|
||||||
|
@ -57,10 +55,8 @@
|
||||||
<!-- nyti.ms -->
|
<!-- nyti.ms -->
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.VIEW" />
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
<category android:name="android.intent.category.BROWSABLE" />
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
|
|
||||||
<data
|
<data
|
||||||
android:host="nyti.ms"
|
android:host="nyti.ms"
|
||||||
android:pathPattern=".*"
|
android:pathPattern=".*"
|
||||||
|
@ -80,10 +76,8 @@
|
||||||
<!-- bit.ly -->
|
<!-- bit.ly -->
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.VIEW" />
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
<category android:name="android.intent.category.BROWSABLE" />
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
|
|
||||||
<data
|
<data
|
||||||
android:host="bit.ly"
|
android:host="bit.ly"
|
||||||
android:pathPattern=".*"
|
android:pathPattern=".*"
|
||||||
|
@ -146,7 +140,6 @@
|
||||||
android:host="goo.gl"
|
android:host="goo.gl"
|
||||||
android:mimeType="text/plain" />
|
android:mimeType="text/plain" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
|
||||||
<!-- ow.ly -->
|
<!-- ow.ly -->
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.VIEW" />
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
@ -170,7 +163,6 @@
|
||||||
android:host="ow.ly"
|
android:host="ow.ly"
|
||||||
android:mimeType="text/plain" />
|
android:mimeType="text/plain" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
|
||||||
<!-- bl.ink -->
|
<!-- bl.ink -->
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.VIEW" />
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
@ -194,8 +186,6 @@
|
||||||
android:host="bl.ink"
|
android:host="bl.ink"
|
||||||
android:mimeType="text/plain" />
|
android:mimeType="text/plain" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
|
||||||
|
|
||||||
<!-- buff.ly -->
|
<!-- buff.ly -->
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.VIEW" />
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
@ -342,10 +332,8 @@
|
||||||
<!-- twitter.com -->
|
<!-- twitter.com -->
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.VIEW" />
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
<category android:name="android.intent.category.BROWSABLE" />
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
|
|
||||||
<data
|
<data
|
||||||
android:host="twitter.com"
|
android:host="twitter.com"
|
||||||
android:pathPattern=".*"
|
android:pathPattern=".*"
|
||||||
|
@ -495,6 +483,238 @@
|
||||||
android:mimeType="text/plain"
|
android:mimeType="text/plain"
|
||||||
android:pathPattern="/maps/place/.*" />
|
android:pathPattern="/maps/place/.*" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
|
||||||
|
<!-- INSTANCES FOR REDIRECT TO THE PREFERRED ONES -->
|
||||||
|
<!-- NITTER INSTANCES -->
|
||||||
|
<!-- nitter.net -->
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
|
<data
|
||||||
|
android:host="nitter.net"
|
||||||
|
android:pathPattern=".*"
|
||||||
|
android:scheme="https" />
|
||||||
|
<data
|
||||||
|
android:host="nitter.net"
|
||||||
|
android:pathPattern=".*"
|
||||||
|
android:scheme="http" />
|
||||||
|
</intent-filter>
|
||||||
|
<!-- nitter.snopyta.org -->
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
|
<data
|
||||||
|
android:host="nitter.snopyta.org"
|
||||||
|
android:pathPattern=".*"
|
||||||
|
android:scheme="https" />
|
||||||
|
<data
|
||||||
|
android:host="nitter.snopyta.org"
|
||||||
|
android:pathPattern=".*"
|
||||||
|
android:scheme="http" />
|
||||||
|
</intent-filter>
|
||||||
|
<!-- nitter.42l.fr -->
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
|
<data
|
||||||
|
android:host="nitter.42l.fr"
|
||||||
|
android:pathPattern=".*"
|
||||||
|
android:scheme="https" />
|
||||||
|
<data
|
||||||
|
android:host="nitter.42l.fr"
|
||||||
|
android:pathPattern=".*"
|
||||||
|
android:scheme="http" />
|
||||||
|
</intent-filter>
|
||||||
|
<!-- nitter.nixnet.services -->
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
|
<data
|
||||||
|
android:host="nitter.nixnet.services"
|
||||||
|
android:pathPattern=".*"
|
||||||
|
android:scheme="https" />
|
||||||
|
<data
|
||||||
|
android:host="nitter.nixnet.services"
|
||||||
|
android:pathPattern=".*"
|
||||||
|
android:scheme="http" />
|
||||||
|
</intent-filter>
|
||||||
|
<!-- nitter.13ad.de -->
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
|
<data
|
||||||
|
android:host="nitter.13ad.de"
|
||||||
|
android:pathPattern=".*"
|
||||||
|
android:scheme="https" />
|
||||||
|
<data
|
||||||
|
android:host="nitter.13ad.de"
|
||||||
|
android:pathPattern=".*"
|
||||||
|
android:scheme="http" />
|
||||||
|
</intent-filter>
|
||||||
|
<!-- tw.openalgeria.org -->
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
|
<data
|
||||||
|
android:host="tw.openalgeria.org"
|
||||||
|
android:pathPattern=".*"
|
||||||
|
android:scheme="https" />
|
||||||
|
<data
|
||||||
|
android:host="tw.openalgeria.org"
|
||||||
|
android:pathPattern=".*"
|
||||||
|
android:scheme="http" />
|
||||||
|
</intent-filter>
|
||||||
|
<!-- nitter.pussthecat.org -->
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
|
<data
|
||||||
|
android:host="nitter.pussthecat.org"
|
||||||
|
android:pathPattern=".*"
|
||||||
|
android:scheme="https" />
|
||||||
|
<data
|
||||||
|
android:host="nitter.pussthecat.org"
|
||||||
|
android:pathPattern=".*"
|
||||||
|
android:scheme="http" />
|
||||||
|
</intent-filter>
|
||||||
|
|
||||||
|
<!-- INVIDIOUS INSTANCES -->
|
||||||
|
<!-- invidio.us -->
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
|
<data
|
||||||
|
android:host="invidio.us"
|
||||||
|
android:pathPattern=".*"
|
||||||
|
android:scheme="https" />
|
||||||
|
<data
|
||||||
|
android:host="invidio.us"
|
||||||
|
android:pathPattern=".*"
|
||||||
|
android:scheme="http" />
|
||||||
|
</intent-filter>
|
||||||
|
<!-- invidious.snopyta.org -->
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
|
<data
|
||||||
|
android:host="invidious.snopyta.org"
|
||||||
|
android:pathPattern=".*"
|
||||||
|
android:scheme="https" />
|
||||||
|
<data
|
||||||
|
android:host="invidious.snopyta.org"
|
||||||
|
android:pathPattern=".*"
|
||||||
|
android:scheme="http" />
|
||||||
|
</intent-filter>
|
||||||
|
<!-- invidiou.sh -->
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
|
<data
|
||||||
|
android:host="invidiou.sh"
|
||||||
|
android:pathPattern=".*"
|
||||||
|
android:scheme="https" />
|
||||||
|
<data
|
||||||
|
android:host="invidiou.sh"
|
||||||
|
android:pathPattern=".*"
|
||||||
|
android:scheme="http" />
|
||||||
|
</intent-filter>
|
||||||
|
<!-- invidious.toot.koeln -->
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
|
<data
|
||||||
|
android:host="invidious.toot.koeln"
|
||||||
|
android:pathPattern=".*"
|
||||||
|
android:scheme="https" />
|
||||||
|
<data
|
||||||
|
android:host="invidious.toot.koeln"
|
||||||
|
android:pathPattern=".*"
|
||||||
|
android:scheme="http" />
|
||||||
|
</intent-filter>
|
||||||
|
<!-- invidious.ggc-project.de -->
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
|
<data
|
||||||
|
android:host="invidious.ggc-project.de"
|
||||||
|
android:pathPattern=".*"
|
||||||
|
android:scheme="https" />
|
||||||
|
<data
|
||||||
|
android:host="invidious.ggc-project.de"
|
||||||
|
android:pathPattern=".*"
|
||||||
|
android:scheme="http" />
|
||||||
|
</intent-filter>
|
||||||
|
|
||||||
|
<!-- BIBLIOGRAM INSTANCES -->
|
||||||
|
<!-- bibliogram.art -->
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
|
<data
|
||||||
|
android:host="bibliogram.art"
|
||||||
|
android:pathPattern=".*"
|
||||||
|
android:scheme="https" />
|
||||||
|
<data
|
||||||
|
android:host="bibliogram.art"
|
||||||
|
android:pathPattern=".*"
|
||||||
|
android:scheme="http" />
|
||||||
|
</intent-filter>
|
||||||
|
<!-- bibliogram.snopyta.org -->
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
|
<data
|
||||||
|
android:host="bibliogram.snopyta.org"
|
||||||
|
android:pathPattern=".*"
|
||||||
|
android:scheme="https" />
|
||||||
|
<data
|
||||||
|
android:host="bibliogram.snopyta.org"
|
||||||
|
android:pathPattern=".*"
|
||||||
|
android:scheme="http" />
|
||||||
|
</intent-filter>
|
||||||
|
<!-- bibliogram.dsrev.ru -->
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
|
<data
|
||||||
|
android:host="bibliogram.dsrev.ru"
|
||||||
|
android:pathPattern=".*"
|
||||||
|
android:scheme="https" />
|
||||||
|
<data
|
||||||
|
android:host="bibliogram.dsrev.ru"
|
||||||
|
android:pathPattern=".*"
|
||||||
|
android:scheme="http" />
|
||||||
|
</intent-filter>
|
||||||
|
<!-- bibliogram.pussthecat.org -->
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
|
<data
|
||||||
|
android:host="bibliogram.pussthecat.org"
|
||||||
|
android:pathPattern=".*"
|
||||||
|
android:scheme="https" />
|
||||||
|
<data
|
||||||
|
android:host="bibliogram.pussthecat.org"
|
||||||
|
android:pathPattern=".*"
|
||||||
|
android:scheme="http" />
|
||||||
|
</intent-filter>
|
||||||
|
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name="app.fedilab.nitterizeme.InstanceActivity"
|
android:name="app.fedilab.nitterizeme.InstanceActivity"
|
||||||
|
|
|
@ -91,6 +91,30 @@ public class MainActivity extends AppCompatActivity {
|
||||||
"bl.ink",
|
"bl.ink",
|
||||||
"buff.ly"
|
"buff.ly"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//Supported instances to redirect one instance to another faster for the user
|
||||||
|
public static String[] invidious_instances = {
|
||||||
|
"invidio.us",
|
||||||
|
"invidious.snopyta.org",
|
||||||
|
"invidiou.sh",
|
||||||
|
"invidious.toot.koeln",
|
||||||
|
"invidious.ggc-project.de"
|
||||||
|
};
|
||||||
|
public static String[] nitter_instances = {
|
||||||
|
"nitter.net",
|
||||||
|
"nitter.snopyta.org",
|
||||||
|
"nitter.42l.fr",
|
||||||
|
"nitter.13ad.de",
|
||||||
|
"tw.openalgeria.org",
|
||||||
|
"nitter.pussthecat.org"
|
||||||
|
};
|
||||||
|
public static String[] bibliogram_instances = {
|
||||||
|
"bibliogram.art",
|
||||||
|
"bibliogram.snopyta.org",
|
||||||
|
"bibliogram.dsrev.ru",
|
||||||
|
"bibliogram.pussthecat.org"
|
||||||
|
};
|
||||||
|
|
||||||
private AppInfoAdapter appInfoAdapter;
|
private AppInfoAdapter appInfoAdapter;
|
||||||
private RecyclerView list_apps;
|
private RecyclerView list_apps;
|
||||||
private String[] domains;
|
private String[] domains;
|
||||||
|
@ -109,7 +133,7 @@ public class MainActivity extends AppCompatActivity {
|
||||||
Objects.requireNonNull(getSupportActionBar()).setDisplayShowHomeEnabled(true);
|
Objects.requireNonNull(getSupportActionBar()).setDisplayShowHomeEnabled(true);
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
|
||||||
domains = new String[twitter_domains.length + youtube_domains.length + shortener_domains.length + instagram_domains.length];
|
domains = new String[twitter_domains.length + youtube_domains.length + shortener_domains.length + instagram_domains.length + invidious_instances.length + nitter_instances.length + bibliogram_instances.length];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (String host : twitter_domains) {
|
for (String host : twitter_domains) {
|
||||||
domains[i] = host;
|
domains[i] = host;
|
||||||
|
@ -127,6 +151,18 @@ public class MainActivity extends AppCompatActivity {
|
||||||
domains[i] = host;
|
domains[i] = host;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
for (String host : invidious_instances) {
|
||||||
|
domains[i] = host;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
for (String host : nitter_instances) {
|
||||||
|
domains[i] = host;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
for (String host : bibliogram_instances) {
|
||||||
|
domains[i] = host;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
SharedPreferences sharedpreferences = getSharedPreferences(APP_PREFS, Context.MODE_PRIVATE);
|
SharedPreferences sharedpreferences = getSharedPreferences(APP_PREFS, Context.MODE_PRIVATE);
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
@ -26,6 +27,7 @@ import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
import android.util.Log;
|
||||||
import android.util.Patterns;
|
import android.util.Patterns;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
@ -47,7 +49,10 @@ import java.util.regex.Pattern;
|
||||||
import static app.fedilab.nitterizeme.MainActivity.SET_BIBLIOGRAM_ENABLED;
|
import static app.fedilab.nitterizeme.MainActivity.SET_BIBLIOGRAM_ENABLED;
|
||||||
import static app.fedilab.nitterizeme.MainActivity.SET_INVIDIOUS_ENABLED;
|
import static app.fedilab.nitterizeme.MainActivity.SET_INVIDIOUS_ENABLED;
|
||||||
import static app.fedilab.nitterizeme.MainActivity.SET_NITTER_ENABLED;
|
import static app.fedilab.nitterizeme.MainActivity.SET_NITTER_ENABLED;
|
||||||
|
import static app.fedilab.nitterizeme.MainActivity.bibliogram_instances;
|
||||||
import static app.fedilab.nitterizeme.MainActivity.instagram_domains;
|
import static app.fedilab.nitterizeme.MainActivity.instagram_domains;
|
||||||
|
import static app.fedilab.nitterizeme.MainActivity.invidious_instances;
|
||||||
|
import static app.fedilab.nitterizeme.MainActivity.nitter_instances;
|
||||||
import static app.fedilab.nitterizeme.MainActivity.shortener_domains;
|
import static app.fedilab.nitterizeme.MainActivity.shortener_domains;
|
||||||
import static app.fedilab.nitterizeme.MainActivity.twitter_domains;
|
import static app.fedilab.nitterizeme.MainActivity.twitter_domains;
|
||||||
import static app.fedilab.nitterizeme.MainActivity.youtube_domains;
|
import static app.fedilab.nitterizeme.MainActivity.youtube_domains;
|
||||||
|
@ -70,6 +75,7 @@ public class TransformActivity extends Activity {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
SharedPreferences sharedpreferences = getSharedPreferences(MainActivity.APP_PREFS, Context.MODE_PRIVATE);
|
SharedPreferences sharedpreferences = getSharedPreferences(MainActivity.APP_PREFS, Context.MODE_PRIVATE);
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
|
Log.v(MainActivity.TAG,"intent: " + intent);
|
||||||
if (intent != null && intent.getStringExtra("nitterizeme") != null) {
|
if (intent != null && intent.getStringExtra("nitterizeme") != null) {
|
||||||
finish();
|
finish();
|
||||||
return;
|
return;
|
||||||
|
@ -77,9 +83,12 @@ public class TransformActivity extends Activity {
|
||||||
notShortnedURLDialog = new ArrayList<>();
|
notShortnedURLDialog = new ArrayList<>();
|
||||||
assert intent != null;
|
assert intent != null;
|
||||||
//Dealing with URLs
|
//Dealing with URLs
|
||||||
|
|
||||||
|
Log.v(MainActivity.TAG,"intent: " + intent);
|
||||||
if (Objects.requireNonNull(intent.getAction()).equals(Intent.ACTION_VIEW)) {
|
if (Objects.requireNonNull(intent.getAction()).equals(Intent.ACTION_VIEW)) {
|
||||||
|
|
||||||
String url = Objects.requireNonNull(intent.getData()).toString();
|
String url = Objects.requireNonNull(intent.getData()).toString();
|
||||||
|
Log.v(MainActivity.TAG,"url: " + url);
|
||||||
URL url_;
|
URL url_;
|
||||||
String host = null;
|
String host = null;
|
||||||
try {
|
try {
|
||||||
|
@ -220,9 +229,11 @@ public class TransformActivity extends Activity {
|
||||||
//Twitter URLs
|
//Twitter URLs
|
||||||
else if (Arrays.asList(twitter_domains).contains(host)) {
|
else if (Arrays.asList(twitter_domains).contains(host)) {
|
||||||
boolean nitter_enabled = sharedpreferences.getBoolean(SET_NITTER_ENABLED, true);
|
boolean nitter_enabled = sharedpreferences.getBoolean(SET_NITTER_ENABLED, true);
|
||||||
|
Log.v(MainActivity.TAG,"nitter_enabled: " + nitter_enabled);
|
||||||
if (nitter_enabled) {
|
if (nitter_enabled) {
|
||||||
Intent delegate = new Intent(Intent.ACTION_VIEW);
|
Intent delegate = new Intent(Intent.ACTION_VIEW);
|
||||||
String transformedURL = transformUrl(url);
|
String transformedURL = transformUrl(url);
|
||||||
|
Log.v(MainActivity.TAG,"urlT: " + url);
|
||||||
if (transformedURL != null) {
|
if (transformedURL != null) {
|
||||||
delegate.setData(Uri.parse(transformUrl(url)));
|
delegate.setData(Uri.parse(transformUrl(url)));
|
||||||
delegate.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
delegate.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
@ -296,6 +307,61 @@ public class TransformActivity extends Activity {
|
||||||
forwardToBrowser(intent);
|
forwardToBrowser(intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//Transform an Invidious URL from an instance to another one selected by the end user.
|
||||||
|
else if (Arrays.asList(invidious_instances).contains(host)) {
|
||||||
|
boolean invidious_enabled = sharedpreferences.getBoolean(SET_INVIDIOUS_ENABLED, true);
|
||||||
|
if (invidious_enabled) {
|
||||||
|
String invidiousHost = sharedpreferences.getString(MainActivity.SET_INVIDIOUS_HOST, MainActivity.DEFAULT_INVIDIOUS_HOST).toLowerCase();
|
||||||
|
String transformedURL = url;
|
||||||
|
if( host != null && host.compareTo(invidiousHost) != 0 ){
|
||||||
|
transformedURL = url.replace(host, invidiousHost);
|
||||||
|
}
|
||||||
|
Intent delegate = new Intent(Intent.ACTION_VIEW);
|
||||||
|
delegate.setData(Uri.parse(transformedURL));
|
||||||
|
delegate.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
if (delegate.resolveActivity(getPackageManager()) != null) {
|
||||||
|
startActivity(delegate);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
forwardToBrowser(intent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Transform a Nitter URL from an instance to another one selected by the end user.
|
||||||
|
else if (Arrays.asList(nitter_instances).contains(host)) {
|
||||||
|
boolean nitter_enabled = sharedpreferences.getBoolean(SET_NITTER_ENABLED, true);
|
||||||
|
if (nitter_enabled) {
|
||||||
|
String nitterHost = sharedpreferences.getString(MainActivity.SET_NITTER_HOST, MainActivity.DEFAULT_NITTER_HOST).toLowerCase();
|
||||||
|
String transformedURL = url;
|
||||||
|
if( host != null && host.compareTo(nitterHost) != 0 ){
|
||||||
|
transformedURL = url.replace(host, nitterHost);
|
||||||
|
}
|
||||||
|
intent.setData(Uri.parse(transformedURL));
|
||||||
|
forwardToBrowser(intent);
|
||||||
|
} else {
|
||||||
|
forwardToBrowser(intent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Transform a Bibliogram URL from an instance to another one selected by the end user.
|
||||||
|
else if (Arrays.asList(bibliogram_instances).contains(host)) {
|
||||||
|
boolean bibliogram_enabled = sharedpreferences.getBoolean(SET_BIBLIOGRAM_ENABLED, true);
|
||||||
|
if (bibliogram_enabled) {
|
||||||
|
String bibliogramHost = sharedpreferences.getString(MainActivity.SET_BIBLIOGRAM_HOST, MainActivity.DEFAULT_BIBLIOGRAM_HOST).toLowerCase();
|
||||||
|
String transformedURL = url;
|
||||||
|
if( host != null && host.compareTo(bibliogramHost) != 0 ){
|
||||||
|
transformedURL = url.replace(host, bibliogramHost);
|
||||||
|
}
|
||||||
|
Intent delegate = new Intent(Intent.ACTION_VIEW);
|
||||||
|
delegate.setData(Uri.parse(transformedURL));
|
||||||
|
delegate.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
if (delegate.resolveActivity(getPackageManager()) != null) {
|
||||||
|
startActivity(delegate);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
forwardToBrowser(intent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
//It's a sharing intent
|
//It's a sharing intent
|
||||||
|
@ -320,7 +386,11 @@ public class TransformActivity extends Activity {
|
||||||
private void forwardToBrowser(Intent i) {
|
private void forwardToBrowser(Intent i) {
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.setAction(Intent.ACTION_VIEW);
|
intent.setAction(Intent.ACTION_VIEW);
|
||||||
intent.setDataAndType(i.getData(), i.getType());
|
String type = i.getType();
|
||||||
|
if( type == null) {
|
||||||
|
type = "text/html";
|
||||||
|
}
|
||||||
|
intent.setDataAndType(i.getData(), type);
|
||||||
List<ResolveInfo> activities = getPackageManager().queryIntentActivities(intent, 0);
|
List<ResolveInfo> activities = getPackageManager().queryIntentActivities(intent, 0);
|
||||||
ArrayList<Intent> targetIntents = new ArrayList<>();
|
ArrayList<Intent> targetIntents = new ArrayList<>();
|
||||||
String thisPackageName = getApplicationContext().getPackageName();
|
String thisPackageName = getApplicationContext().getPackageName();
|
||||||
|
@ -340,8 +410,8 @@ public class TransformActivity extends Activity {
|
||||||
Intent chooserIntent = Intent.createChooser(targetIntents.remove(0), getString(R.string.open_with));
|
Intent chooserIntent = Intent.createChooser(targetIntents.remove(0), getString(R.string.open_with));
|
||||||
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, targetIntents.toArray(new Parcelable[]{}));
|
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, targetIntents.toArray(new Parcelable[]{}));
|
||||||
startActivity(chooserIntent);
|
startActivity(chooserIntent);
|
||||||
finish();
|
|
||||||
}
|
}
|
||||||
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
Added:
|
Added:
|
||||||
|
- Allow to redirect Invidious, Nitter and Bibliogram links from an instance to your selected one.
|
||||||
- Unshorten support for buff.ly
|
- Unshorten support for buff.ly
|
Loading…
Reference in New Issue