Merge branch 'develop' of https://framagit.org/tom79/nitterizeme into develop

 Conflicts:
	app/src/main/java/app/fedilab/nitterizeme/adapters/InstanceAdapter.java
	app/src/main/java/app/fedilab/nitterizeme/helpers/Utils.java
This commit is contained in:
Thomas 2022-07-03 09:10:23 +02:00
commit 08eb5639d3
13 changed files with 390 additions and 19 deletions

View File

@ -63,13 +63,13 @@
<data android:host="bl.ink" />
<data android:host="buff.ly" />
<data android:host="maps.app.goo.gl" />
<data android:host="vm.tiktok.com" />
<!-- INSTAGRAM URLs -->
<data android:host="instagram.com" />
<data android:host="www.instagram.com" />
<data android:host="m.instagram.com" />
<!-- TWITTER URLs -->
<data android:host="mobile.twitter.com" />
<data android:host="www.twitter.com" />
@ -84,7 +84,6 @@
<data android:host="youtu.be" />
<data android:host="youtube-nocookie.com" />
<!-- REDDIT URLs -->
<data android:host="www.reddit.com" />
<data android:host="reddit.com" />
@ -92,6 +91,11 @@
<data android:host="i.redd.it" />
<data android:host="preview.redd.it" />
<!-- TIKTOK URLs -->
<data android:host="tiktok.com" />
<data android:host="www.tiktok.com" />
<data android:host="us.tiktok.com" />
<!-- INVIDIOUS INSTANCES -->
<data android:host="invidious.snopyta.org" />
<data android:host="invidiou.sh" />
@ -118,6 +122,9 @@
<data android:host="bibliogram.dsrev.ru" />
<data android:host="bibliogram.pussthecat.org" />
<!-- PROXITOK INSTANCES -->
<data android:host="proxitok.herokuapp.com" />
<data android:host="proxitok.pussthecat.org" />
<!-- MEDIUM URLs -->
<data android:host="www.medium.com" />
@ -160,6 +167,7 @@
<data android:host="bl.ink" />
<data android:host="buff.ly" />
<data android:host="maps.app.goo.gl" />
<data android:host="vm.tiktok.com" />
<!-- INSTAGRAM URLs -->
<data android:host="instagram.com" />
@ -197,6 +205,11 @@
<data android:host="www.wikipedia.org" />
<data android:host="*.wikipedia.org" />
<!-- TIKTOK URLs -->
<data android:host="tiktok.com" />
<data android:host="www.tiktok.com" />
<data android:host="us.tiktok.com" />
<data android:host="*" />
<data android:mimeType="text/plain" />

View File

@ -63,6 +63,7 @@
<data android:host="bl.ink" />
<data android:host="buff.ly" />
<data android:host="maps.app.goo.gl" />
<data android:host="vm.tiktok.com" />
<!-- INSTAGRAM URLs -->
<data android:host="instagram.com" />
@ -84,7 +85,6 @@
<data android:host="youtu.be" />
<data android:host="youtube-nocookie.com" />
<!-- REDDIT URLs -->
<data android:host="www.reddit.com" />
<data android:host="reddit.com" />
@ -92,6 +92,11 @@
<data android:host="i.redd.it" />
<data android:host="preview.redd.it" />
<!-- TIKTOK URLs -->
<data android:host="tiktok.com" />
<data android:host="www.tiktok.com" />
<data android:host="us.tiktok.com" />
<!-- MEDIUM URLs -->
<data android:host="www.medium.com" />
<data android:host="medium.com" />
@ -131,6 +136,7 @@
<data android:host="bl.ink" />
<data android:host="buff.ly" />
<data android:host="maps.app.goo.gl" />
<data android:host="vm.tiktok.com" />
<!-- INSTAGRAM URLs -->
<data android:host="instagram.com" />
@ -150,7 +156,6 @@
<data android:host="youtu.be" />
<data android:host="youtube-nocookie.com" />
<!-- REDDIT URLs -->
<data android:host="www.reddit.com" />
<data android:host="reddit.com" />
@ -158,6 +163,11 @@
<data android:host="i.redd.it" />
<data android:host="preview.redd.it" />
<!-- TIKTOK URLs -->
<data android:host="tiktok.com" />
<data android:host="www.tiktok.com" />
<data android:host="us.tiktok.com" />
<!-- MEDIUM URLs -->
<data android:host="www.medium.com" />
<data android:host="medium.com" />

View File

@ -214,7 +214,8 @@
"urlPattern": "(https:\\/\\/|http:\\/\\/)([a-zA-Z0-9-]*\\.)?(twitter)(\\.[a-zA-Z]{2,})(.*\\?.*)",
"completeProvider": false,
"rules": [
"(ref_)?src=[^\\/|\\?|&]*(\\/|&(amp;)?)?"
"src=[^\\/|\\?|&]*(\\/|&(amp;)?)?",
"ref_[a-z_]+=[^\\/|\\?|&]*(\\/|&(amp;)?)?"
],
"exceptions": [],
"redirections": []
@ -239,6 +240,22 @@
"exceptions": [],
"redirections": []
},
"tiktok": {
"urlPattern": "(https:\\/\\/|http:\\/\\/)([a-zA-Z0-9-]*\\.)?(tiktok)(\\.[a-zA-Z]{2,})(.*\\?.*)",
"completeProvider": false,
"rules": [
"_[a-z]=[^\\/|\\?|&]*(\\/|&(amp;)?)?",
"(sec_)?(u|user_)id=[^\\/|\\?|&]*(\\/|&(amp;)?)?",
"share_[a-z_]+=[^\\/|\\?|&]*(\\/|&(amp;)?)?",
"source=[^\\/|\\?|&]*(\\/|&(amp;)?)?",
"timestamp=[^\\/|\\?|&]*(\\/|&(amp;)?)?",
"u_code=[^\\/|\\?|&]*(\\/|&(amp;)?)?",
"ugbiz_name=[^\\/|\\?|&]*(\\/|&(amp;)?)?",
"utm_[a-z_]+=[^\\/|\\?|&]*(\\/|&(amp;)?)?"
],
"exceptions": [],
"redirections": []
},
"techcrunch": {
"urlPattern": "(https:\\/\\/|http:\\/\\/)([a-zA-Z0-9-]*\\.)?([\\.]?techcrunch\\.com)(.*\\?.*)",
"completeProvider": false,

View File

@ -179,7 +179,7 @@ public class AppsPickerActivity extends Activity {
long val = -1;
if (isPresent) {
ArrayList<String> oldConcurrent = new DefaultAppDAO(AppsPickerActivity.this, db).getConcurrent(appToUse);
ArrayList<String> newConcurrent = Utils.union(oldConcurrent, packages);
ArrayList<String> newConcurrent = oldConcurrent != null ? Utils.union(oldConcurrent, packages) : packages;
newConcurrent.remove(appToUse);
new DefaultAppDAO(AppsPickerActivity.this, db).update(appToUse, newConcurrent);
} else {

View File

@ -80,6 +80,12 @@ public class CheckAppActivity extends AppCompatActivity {
"www.wikipedia.org"
};
public static String[] tiktok_domains = {
"tiktok.com",
"www.tiktok.com",
"us.tiktok.com"
};
public static String[] shortener_domains = {
"t.co",
"nyti.ms",
@ -98,11 +104,11 @@ public class CheckAppActivity extends AppCompatActivity {
"ow.ly",
"bl.ink",
"buff.ly",
"maps.app.goo.gl"
"maps.app.goo.gl",
"vm.tiktok.com"
};
//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",
@ -127,6 +133,10 @@ public class CheckAppActivity extends AppCompatActivity {
"bibliogram.dsrev.ru",
"bibliogram.pussthecat.org"
};
public static String[] proxitok_instances = {
"proxitok.herokuapp.com",
"proxitok.pussthecat.org"
};
public static String outlook_safe_domain = "safelinks.protection.outlook.com";
@ -153,23 +163,26 @@ public class CheckAppActivity extends AppCompatActivity {
twitter_domains.length
+ youtube_domains.length
+ reddit_domains.length
+ shortener_domains.length
+ instagram_domains.length
+ wikipedia_domains.length
+ medium_domains.length
+ tiktok_domains.length
+ shortener_domains.length
+ invidious_instances.length
+ nitter_instances.length
+ bibliogram_instances.length
+ wikipedia_domains.length
+ medium_domains.length
+ proxitok_instances.length
];
} else {
domains = new String[
twitter_domains.length
+ youtube_domains.length
+ reddit_domains.length
+ shortener_domains.length
+ instagram_domains.length
+ wikipedia_domains.length
+ medium_domains.length];
+ medium_domains.length
+ tiktok_domains.length
+ shortener_domains.length];
}
int i = 0;
for (String host : twitter_domains) {
@ -196,6 +209,10 @@ public class CheckAppActivity extends AppCompatActivity {
domains[i] = host;
i++;
}
for (String host : tiktok_domains) {
domains[i] = host;
i++;
}
for (String host : shortener_domains) {
domains[i] = host;
i++;
@ -213,6 +230,10 @@ public class CheckAppActivity extends AppCompatActivity {
domains[i] = host;
i++;
}
for (String host : proxitok_instances) {
domains[i] = host;
i++;
}
}
final LinearLayoutManager mLayoutManager;
@ -291,6 +312,10 @@ public class CheckAppActivity extends AppCompatActivity {
AppInfo appInfo = new AppInfo();
appInfo.setTitle("Wikipedia");
appInfos.add(appInfo);
} else if (Arrays.asList(tiktok_domains).contains(domain)) {
AppInfo appInfo = new AppInfo();
appInfo.setTitle("TikTok");
appInfos.add(appInfo);
} else if (Arrays.asList(shortener_domains).contains(domain)) {
AppInfo appInfo = new AppInfo();
appInfo.setTitle(getString(R.string.shortener_services));
@ -307,6 +332,10 @@ public class CheckAppActivity extends AppCompatActivity {
AppInfo appInfo = new AppInfo();
appInfo.setTitle(getString(R.string.bibliogram_instances));
appInfos.add(appInfo);
} else if (Arrays.asList(proxitok_instances).contains(domain)) {
AppInfo appInfo = new AppInfo();
appInfo.setTitle(getString(R.string.proxitok_instances));
appInfos.add(appInfo);
}
AppInfo appInfo = new AppInfo();
appInfo.setDomain(domain);

View File

@ -67,6 +67,7 @@ public class InstanceActivity extends AppCompatActivity {
String tedditHost = sharedpreferences.getString(MainActivity.SET_TEDDIT_HOST, MainActivity.DEFAULT_TEDDIT_HOST);
String scribeHost = sharedpreferences.getString(MainActivity.SET_SCRIBERIP_HOST, MainActivity.DEFAULT_SCRIBERIP_HOST);
String wikilessHost = sharedpreferences.getString(MainActivity.SET_WIKILESS_HOST, MainActivity.DEFAULT_WIKILESS_HOST);
String proxitokHost = sharedpreferences.getString(MainActivity.SET_PROXITOK_HOST, MainActivity.DEFAULT_PROXITOK_HOST);
ArrayList<Instance> invidiousInstances = new ArrayList<>();
ArrayList<Instance> nitterInstances = new ArrayList<>();
@ -74,6 +75,7 @@ public class InstanceActivity extends AppCompatActivity {
ArrayList<Instance> tedditInstances = new ArrayList<>();
ArrayList<Instance> scribeInstances = new ArrayList<>();
ArrayList<Instance> wikilessInstances = new ArrayList<>();
ArrayList<Instance> proxitokInstances = new ArrayList<>();
boolean customInvidiousInstance = true;
boolean customNitterInstance = true;
@ -81,6 +83,7 @@ public class InstanceActivity extends AppCompatActivity {
boolean customTedditInstance = true;
boolean customScribeInstance = true;
boolean customWikilessInstance = true;
boolean customProxitokInstance = true;
for (Instance instance : result) {
if (instance.getInstanceType() == Instance.instanceType.YOUTUBE) {
@ -113,6 +116,11 @@ public class InstanceActivity extends AppCompatActivity {
if (wikilessHost != null && wikilessHost.trim().toLowerCase().compareTo(instance.getDomain()) == 0) {
customWikilessInstance = false;
}
} else if (instance.getInstanceType() == Instance.instanceType.PROXITOK) {
proxitokInstances.add(instance);
if (proxitokHost != null && proxitokHost.trim().toLowerCase().compareTo(instance.getDomain()) == 0) {
customProxitokInstance = false;
}
}
}
List<String> defaultLocales = new ArrayList<>();
@ -160,6 +168,13 @@ public class InstanceActivity extends AppCompatActivity {
instance.setLocales(defaultLocales);
wikilessInstances.add(0, instance);
}
if (customProxitokInstance) {
Instance instance = new Instance();
instance.setChecked(true);
instance.setDomain(proxitokHost);
instance.setLocales(defaultLocales);
proxitokInstances.add(0, instance);
}
binding.instanceContainer.setVisibility(View.VISIBLE);
binding.loader.setVisibility(View.GONE);
@ -202,11 +217,20 @@ public class InstanceActivity extends AppCompatActivity {
binding.wikilessInstances.setLayoutManager(wLayoutManager);
binding.wikilessInstances.setNestedScrollingEnabled(false);
final LinearLayoutManager pLayoutManager = new LinearLayoutManager(this);
InstanceAdapter proxitokAdapter = new InstanceAdapter(proxitokInstances);
binding.proxitokInstances.setAdapter(proxitokAdapter);
binding.proxitokInstances.setLayoutManager(pLayoutManager);
binding.proxitokInstances.setNestedScrollingEnabled(false);
binding.latencyTest.setOnClickListener(v -> {
invidiousAdapter.evalLatency();
nitterAdapter.evalLatency();
bibliogramAdapter.evalLatency();
tedditAdapter.evalLatency();
scribeAdapter.evalLatency();
wikilessAdapter.evalLatency();
proxitokAdapter.evalLatency();
}
);

View File

@ -52,6 +52,7 @@ public class MainActivity extends AppCompatActivity {
public static final String SET_BIBLIOGRAM_HOST = "set_bibliogram_host";
public static final String SET_SCRIBERIP_HOST = "set_scriberip_host";
public static final String SET_WIKILESS_HOST = "set_wikiless_host";
public static final String SET_PROXITOK_HOST = "set_proxitok_host";
@SuppressWarnings({"unused", "RedundantSuppression"})
public static String TAG = "UntrackMe";
public static String DEFAULT_NITTER_HOST = "nitter.net";
@ -62,12 +63,14 @@ public class MainActivity extends AppCompatActivity {
public static String SET_SCRIBERIP_ENABLED = "set_scriberip_enabled";
public static String SET_WIKILESS_ENABLED = "set_wikiless_enabled";
public static String SET_OSM_ENABLED = "set_osm_enabled";
public static String SET_PROXITOK_ENABLED = "set_osm_enabled";
public static String DEFAULT_OSM_HOST = "www.openstreetmap.org";
public static String SET_BIBLIOGRAM_ENABLED = "set_bibliogram_enabled";
public static String DEFAULT_BIBLIOGRAM_HOST = "bibliogram.art";
public static String DEFAULT_SCRIBERIP_HOST = "scribe.rip";
public static String DEFAULT_WIKILESS_HOST = "wikiless.org";
public static String DEFAULT_TEDDIT_HOST = "teddit.net";
public static String DEFAULT_PROXITOK_HOST = "proxitok.herokuapp.com";
public static String SET_GEO_URIS = "set_geo_uris";
BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
@ -87,6 +90,7 @@ public class MainActivity extends AppCompatActivity {
private String scriberipHost;
private String wikilessHost;
private String osmHost;
private String proxitokHost;
private ContentMainBinding binding;
@Override
@ -110,6 +114,7 @@ public class MainActivity extends AppCompatActivity {
boolean teddit_enabled = sharedpreferences.getBoolean(SET_TEDDIT_ENABLED, true);
boolean scriberip_enabled = sharedpreferences.getBoolean(SET_SCRIBERIP_ENABLED, true);
boolean wikiless_enabled = sharedpreferences.getBoolean(SET_WIKILESS_ENABLED, true);
boolean proxitok_enabled = sharedpreferences.getBoolean(SET_PROXITOK_ENABLED, true);
boolean geouri_enabled = sharedpreferences.getBoolean(SET_GEO_URIS, false);
@ -120,6 +125,7 @@ public class MainActivity extends AppCompatActivity {
binding.enableScriberip.setChecked(scriberip_enabled);
binding.enableWikiless.setChecked(wikiless_enabled);
binding.enableOsm.setChecked(osm_enabled);
binding.enableProxitok.setChecked(proxitok_enabled);
nitterHost = sharedpreferences.getString(SET_NITTER_HOST, null);
@ -129,6 +135,7 @@ public class MainActivity extends AppCompatActivity {
scriberipHost = sharedpreferences.getString(SET_SCRIBERIP_HOST, null);
wikilessHost = sharedpreferences.getString(SET_WIKILESS_HOST, null);
osmHost = sharedpreferences.getString(SET_OSM_HOST, null);
proxitokHost = sharedpreferences.getString(SET_PROXITOK_HOST, null);
binding.groupCurrentInvidious.setVisibility(invidious_enabled ? View.VISIBLE : View.GONE);
binding.groupCurrentNitter.setVisibility(nitter_enabled ? View.VISIBLE : View.GONE);
@ -137,6 +144,7 @@ public class MainActivity extends AppCompatActivity {
binding.groupCurrentScriberip.setVisibility(scriberip_enabled ? View.VISIBLE : View.GONE);
binding.groupCurrentWikiless.setVisibility(wikiless_enabled ? View.VISIBLE : View.GONE);
binding.groupCurrentOsm.setVisibility((osm_enabled && geouri_enabled) ? View.VISIBLE : View.GONE);
binding.groupCurrentProxitok.setVisibility(proxitok_enabled ? View.VISIBLE : View.GONE);
binding.enableGeoUris.setVisibility(osm_enabled ? View.VISIBLE : View.GONE);
binding.enableInvidious.setOnCheckedChangeListener((buttonView, isChecked) -> {
@ -206,6 +214,14 @@ public class MainActivity extends AppCompatActivity {
binding.groupCurrentOsm.setVisibility(View.GONE);
}
});
binding.enableProxitok.setOnCheckedChangeListener((buttonView, isChecked) -> {
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putBoolean(SET_PROXITOK_ENABLED, isChecked);
editor.apply();
binding.groupCurrentProxitok.setVisibility(isChecked ? View.VISIBLE : View.GONE);
binding.groupCustomProxitok.setVisibility(View.GONE);
binding.buttonExpandInstanceProxitok.setRotation(0);
});
binding.buttonExpandInstanceNitter.setOnClickListener(v -> {
@ -319,6 +335,22 @@ public class MainActivity extends AppCompatActivity {
binding.osmInstance.setText("");
}
});
binding.buttonExpandInstanceProxitok.setOnClickListener(v -> {
boolean custom_instance_visibility = binding.groupCustomProxitok.getVisibility() == View.VISIBLE;
if (custom_instance_visibility) {
binding.buttonExpandInstanceProxitok.setRotation(0f);
binding.groupCustomProxitok.setVisibility(View.GONE);
} else {
binding.buttonExpandInstanceProxitok.setRotation(180f);
binding.groupCustomProxitok.setVisibility(View.VISIBLE);
}
if (proxitokHost != null) {
binding.proxitokInstance.setText(proxitokHost);
} else {
binding.proxitokInstance.setText("");
}
});
if (nitterHost != null) {
@ -372,6 +404,12 @@ public class MainActivity extends AppCompatActivity {
} else {
binding.groupCustomOsm.setVisibility(View.GONE);
}
if (proxitokHost != null) {
binding.proxitokInstance.setText(proxitokHost);
binding.currentInstanceProxitok.setText(proxitokHost);
} else {
binding.currentInstanceProxitok.setText(DEFAULT_PROXITOK_HOST);
}
binding.buttonSaveInstanceNitter.setOnClickListener(v -> {
SharedPreferences.Editor editor = sharedpreferences.edit();
@ -456,6 +494,18 @@ public class MainActivity extends AppCompatActivity {
}
editor.apply();
});
binding.buttonSaveInstanceProxitok.setOnClickListener(v -> {
SharedPreferences.Editor editor = sharedpreferences.edit();
if (binding.proxitokInstance.getText() != null && binding.proxitokInstance.getText().toString().trim().length() > 0) {
String custom_instance = binding.proxitokInstance.getText().toString().toLowerCase().trim();
editor.putString(SET_PROXITOK_HOST, custom_instance);
binding.currentInstanceProxitok.setText(custom_instance);
} else {
editor.putString(SET_PROXITOK_HOST, null);
binding.currentInstanceProxitok.setText(DEFAULT_PROXITOK_HOST);
}
editor.apply();
});
binding.configure.setOnClickListener(v -> {
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
@ -556,9 +606,18 @@ public class MainActivity extends AppCompatActivity {
binding.currentInstanceOsm.setText(DEFAULT_OSM_HOST);
binding.buttonExpandInstanceOsm.setRotation(0f);
break;
case SET_PROXITOK_HOST:
proxitokHost = sharedpreferences.getString(SET_PROXITOK_HOST, null);
binding.groupCustomProxitok.setVisibility(View.GONE);
if (proxitokHost != null && proxitokHost.trim().length() > 0)
binding.currentInstanceProxitok.setText(proxitokHost);
else
binding.currentInstanceProxitok.setText(DEFAULT_PROXITOK_HOST);
binding.buttonExpandInstanceProxitok.setRotation(0f);
break;
}
if (key.equals(SET_NITTER_HOST) || key.equals(SET_INVIDIOUS_HOST) || key.equals(SET_BIBLIOGRAM_HOST) || key.equals(SET_TEDDIT_HOST) || key.equals(SET_OSM_HOST)) {
if (key.equals(SET_NITTER_HOST) || key.equals(SET_INVIDIOUS_HOST) || key.equals(SET_BIBLIOGRAM_HOST) || key.equals(SET_TEDDIT_HOST) || key.equals(SET_OSM_HOST) || key.equals(SET_PROXITOK_HOST)) {
View parentLayout = findViewById(android.R.id.content);
Snackbar.make(parentLayout, R.string.instances_saved, Snackbar.LENGTH_LONG).show();
}
@ -622,6 +681,7 @@ public class MainActivity extends AppCompatActivity {
String tedditHost = sharedpreferences.getString(SET_TEDDIT_HOST, null);
String scriberipHost = sharedpreferences.getString(SET_SCRIBERIP_HOST, null);
String wikilessHost = sharedpreferences.getString(SET_WIKILESS_HOST, null);
String proxitokHost = sharedpreferences.getString(SET_PROXITOK_HOST, null);
if (nitterHost != null) {
binding.nitterInstance.setText(nitterHost);
binding.currentInstanceNitter.setText(nitterHost);
@ -646,6 +706,10 @@ public class MainActivity extends AppCompatActivity {
binding.wikilessInstance.setText(wikilessHost);
binding.currentInstanceWikiless.setText(wikilessHost);
}
if (proxitokHost != null) {
binding.proxitokInstance.setText(proxitokHost);
binding.currentInstanceProxitok.setText(proxitokHost);
}
if (BuildConfig.fullLinks) {
List<ResolveInfo> resolveInfos = getPackageManager().queryIntentActivities(new Intent(Intent.ACTION_VIEW, Uri.parse("https://fedilab.app")), PackageManager.MATCH_DEFAULT_ONLY);
String thisPackageName = getApplicationContext().getPackageName();

View File

@ -18,6 +18,7 @@ import static app.fedilab.nitterizeme.activities.MainActivity.APP_PREFS;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_BIBLIOGRAM_HOST;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_INVIDIOUS_HOST;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_NITTER_HOST;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_PROXITOK_HOST;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_SCRIBERIP_HOST;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_TEDDIT_HOST;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_WIKILESS_HOST;
@ -165,6 +166,14 @@ public class InstanceAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
}
editor.apply();
break;
case PROXITOK:
if (isChecked) {
editor.putString(SET_PROXITOK_HOST, instance.getDomain().trim());
} else {
editor.putString(SET_PROXITOK_HOST, null);
}
editor.apply();
break;
}
instanceAdapter.notifyItemRangeChanged(0, instances.size());

View File

@ -90,6 +90,7 @@ public class Instance {
INSTAGRAM,
REDDIT,
MEDIUM,
WIKIPEDIA
WIKIPEDIA,
PROXITOK
}
}

View File

@ -15,6 +15,29 @@ package app.fedilab.nitterizeme.helpers;
* see <http://www.gnu.org/licenses>. */
import static android.content.Context.DOWNLOAD_SERVICE;
import static app.fedilab.nitterizeme.activities.CheckAppActivity.bibliogram_instances;
import static app.fedilab.nitterizeme.activities.CheckAppActivity.instagram_domains;
import static app.fedilab.nitterizeme.activities.CheckAppActivity.invidious_instances;
import static app.fedilab.nitterizeme.activities.CheckAppActivity.medium_domains;
import static app.fedilab.nitterizeme.activities.CheckAppActivity.nitter_instances;
import static app.fedilab.nitterizeme.activities.CheckAppActivity.outlook_safe_domain;
import static app.fedilab.nitterizeme.activities.CheckAppActivity.reddit_domains;
import static app.fedilab.nitterizeme.activities.CheckAppActivity.shortener_domains;
import static app.fedilab.nitterizeme.activities.CheckAppActivity.tiktok_domains;
import static app.fedilab.nitterizeme.activities.CheckAppActivity.twitter_domains;
import static app.fedilab.nitterizeme.activities.CheckAppActivity.wikipedia_domains;
import static app.fedilab.nitterizeme.activities.CheckAppActivity.youtube_domains;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_BIBLIOGRAM_ENABLED;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_EMBEDDED_PLAYER;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_INVIDIOUS_ENABLED;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_NITTER_ENABLED;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_PROXITOK_ENABLED;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_SCRIBERIP_ENABLED;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_TEDDIT_ENABLED;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_TEDDIT_HOST;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_WIKILESS_ENABLED;
import static app.fedilab.nitterizeme.activities.CheckAppActivity.bibliogram_instances;
import static app.fedilab.nitterizeme.activities.CheckAppActivity.instagram_domains;
import static app.fedilab.nitterizeme.activities.CheckAppActivity.invidious_instances;
@ -102,7 +125,7 @@ public class Utils {
public static final Pattern scriberipPattern = Pattern.compile("(www\\.)?medium.com/(((?!([\"'<])).)*)");
public static final Pattern scriberipSubdomainPattern = Pattern.compile("([\\w_-]+)\\.medium.com/(((?!([\"'<])).)*)");
public static final Pattern tiktokPattern = Pattern.compile("(www\\.|us\\.)?tiktok.com/(((?!([\"'<])).)*)");
public static final Pattern wikilessPattern = Pattern.compile("([\\w_-]+)\\.(?:m\\.)?wikipedia.org/(((?!([\"'<])).)*)");
public static final Pattern bibliogramAccountPattern = Pattern.compile("(m\\.|www\\.)?instagram.com(((?!/p/).)+)");
@ -455,6 +478,26 @@ public class Utils {
} else {
return url;
}
} else if (host != null && Arrays.asList(tiktok_domains).contains(host)) {
boolean proxitok_enabled = sharedpreferences.getBoolean(SET_PROXITOK_ENABLED, true);
if (proxitok_enabled) {
String proxitokHost = sharedpreferences.getString(MainActivity.SET_PROXITOK_HOST, MainActivity.DEFAULT_PROXITOK_HOST);
assert proxitokHost != null;
proxitokHost = proxitokHost.toLowerCase();
Matcher matcher = tiktokPattern.matcher(url);
while (matcher.find()) {
String path = matcher.group(2);
if (path == null || path.trim().equals("") || path.startsWith("@") || path.startsWith("music") || path.startsWith("tag")) {
newUrl = url.replace(host, proxitokHost);
}
}
if (newUrl == null) {
newUrl = url;
}
return newUrl;
} else {
return url;
}
} else if (Arrays.asList(invidious_instances).contains(host)) {
boolean invidious_enabled = sharedpreferences.getBoolean(SET_INVIDIOUS_ENABLED, true);
newUrl = url;
@ -1197,7 +1240,8 @@ public class Utils {
|| Arrays.asList(instagram_domains).contains(host) || Arrays.asList(bibliogram_instances).contains(host)
|| url.contains("/maps/place") || url.contains("/amp/s/") || (host != null && host.contains(outlook_safe_domain))
|| Arrays.asList(youtube_domains).contains(host) || Arrays.asList(invidious_instances).contains(host)
|| (host != null && host.endsWith(medium_domains[0]) || (host != null && host.endsWith(wikipedia_domains[0])));
|| Arrays.asList(tiktok_domains).contains(host) || (host != null && host.endsWith(medium_domains[0])
|| (host != null && host.endsWith(wikipedia_domains[0])));
}
public static boolean routerEnabledForHost(Context context, String url) {
@ -1221,6 +1265,8 @@ public class Utils {
return sharedpreferences.getBoolean(SET_INVIDIOUS_ENABLED, true);
} else if (Arrays.asList(reddit_domains).contains(host)) {
return sharedpreferences.getBoolean(SET_TEDDIT_ENABLED, true);
} else if (Arrays.asList(tiktok_domains).contains(host)) {
return sharedpreferences.getBoolean(SET_PROXITOK_ENABLED, true);
} else if (host != null && host.endsWith(medium_domains[0])) {
return sharedpreferences.getBoolean(SET_SCRIBERIP_ENABLED, true);
} else if (host != null && host.endsWith(wikipedia_domains[0])) {

View File

@ -102,6 +102,19 @@
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="@string/proxitok_instances"
android:textColor="@color/colorAccent"
android:textSize="16sp" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/proxitok_instances"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>

View File

@ -907,7 +907,7 @@
style="@style/containerCard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="@id/buttons_container"
app:layout_constraintBottom_toTopOf="@id/proxitok_container"
app:layout_constraintTop_toBottomOf="@id/teddit_container">
<androidx.constraintlayout.widget.ConstraintLayout
@ -1061,13 +1061,155 @@
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="@+id/proxitok_container"
style="@style/containerCard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="@id/buttons_container"
app:layout_constraintTop_toBottomOf="@id/osm_container">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true">
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guide_proxitok"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_begin="40dp" />
<View
android:id="@+id/top_part_bg_proxitok"
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="@color/topBar"
app:layout_constraintBottom_toBottomOf="@id/guide_proxitok"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/proxitok_indications"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp"
android:text="@string/redirect_tiktok_to_proxitok"
app:layout_constraintBottom_toBottomOf="@id/guide_proxitok"
app:layout_constraintEnd_toStartOf="@id/enable_proxitok"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/enable_proxitok"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
app:layout_constraintBottom_toBottomOf="@id/guide_proxitok"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageButton
android:id="@+id/button_expand_instance_proxitok"
android:layout_width="30dp"
android:layout_height="30dp"
android:background="@null"
android:contentDescription="@string/expand_instance_details"
android:scaleType="fitCenter"
android:src="@drawable/ic_expand_more"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/guide_proxitok" />
<TextView
android:id="@+id/label_instance_proxitok"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_marginStart="@dimen/label_instance_margin_start"
android:layout_marginLeft="@dimen/label_instance_margin_start"
android:gravity="center_vertical"
android:text="@string/instance_label"
app:layout_constraintStart_toEndOf="@id/button_expand_instance_proxitok"
app:layout_constraintTop_toTopOf="@id/guide_proxitok" />
<TextView
android:id="@+id/current_instance_proxitok"
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_marginStart="5dp"
android:layout_marginLeft="5dp"
android:gravity="center_vertical"
android:textColor="#fff"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/label_instance_proxitok"
app:layout_constraintTop_toTopOf="@id/guide_proxitok" />
<androidx.constraintlayout.widget.Barrier
android:id="@+id/barrier_proxitok"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:barrierDirection="bottom"
app:constraint_referenced_ids="label_instance_proxitok,current_instance_proxitok,button_expand_instance_proxitok" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/proxitok_instance_container"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="5dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/button_save_instance_proxitok"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/barrier_proxitok">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/proxitok_instance"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/custom_proxitok"
android:inputType="textUri"
android:maxLines="1"
android:textSize="@dimen/custom_instance_input_text_size" />
</com.google.android.material.textfield.TextInputLayout>
<ImageButton
android:id="@+id/button_save_instance_proxitok"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_margin="5dp"
android:background="@null"
android:contentDescription="@string/save"
android:src="@drawable/ic_save"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/barrier_proxitok" />
<androidx.constraintlayout.widget.Group
android:id="@+id/group_current_proxitok"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:constraint_referenced_ids="label_instance_proxitok,current_instance_proxitok,button_expand_instance_proxitok" />
<androidx.constraintlayout.widget.Group
android:id="@+id/group_custom_proxitok"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
app:constraint_referenced_ids="proxitok_instance_container,button_save_instance_proxitok" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/buttons_container"
style="@style/containerCard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/osm_container">
app:layout_constraintTop_toBottomOf="@id/proxitok_container">
<Button
android:id="@+id/configure"

View File

@ -44,6 +44,7 @@
<string name="custom_osm">Custom OSM hostname</string>
<string name="redirect_youtube_to_invidious">Redirect YouTube to Invidious</string>
<string name="redirect_twitter_to_nitter">Redirect Twitter to Nitter</string>
<string name="redirect_tiktok_to_proxitok">Redirect TikTok to ProxiTok</string>
<string name="redirect_instagram_to_bibliogram">Redirect Instagram to Bibliogram</string>
<string name="redirect_reddit_to_teddit">Redirect Reddit to Teddit</string>
<string name="redirect_medium_to_scriberip">Redirect Medium to Scribe.rip</string>
@ -52,6 +53,7 @@
<string name="custom_scriberip">Custom Scribe.rip instance</string>
<string name="custom_wikiless">Custom Wikiless instance</string>
<string name="custom_teddit">Custom Teddit instance</string>
<string name="custom_proxitok">Custom ProxiTok instance</string>
<string name="redirect_gm_to_geo_uri">Redirect Google Map to Geo URI</string>
<string name="configure">Configure</string>
<string name="display_supported_links">Display supported links</string>
@ -71,6 +73,7 @@
<string name="teddit_instances">Teddit instances</string>
<string name="scribe_instances">Scribe instances</string>
<string name="wikiless_instances">Wikiless instances</string>
<string name="proxitok_instances">ProxiTok instances</string>
<string name="latency">Latency</string>
<string name="error_message_internet">Check your Internet connection</string>
<string name="instance_label">Instance:</string>