Fix issue #25 - Support maps.app.goo.gl shortener + use geo URIs

This commit is contained in:
Thomas 2020-05-23 10:46:44 +02:00
parent abe0bdd058
commit 59b90142d5
5 changed files with 30 additions and 16 deletions

View File

@ -51,6 +51,7 @@
<data android:host="ow.ly" />
<data android:host="bl.ink" />
<data android:host="buff.ly" />
<data android:host="maps.app.goo.gl" />
<!-- INSTAGRAM URLs -->
<data android:host="instagram.com" />
@ -120,6 +121,7 @@
<data android:host="ow.ly" />
<data android:host="bl.ink" />
<data android:host="buff.ly" />
<data android:host="maps.app.goo.gl" />
<!-- INSTAGRAM URLs -->
<data android:host="instagram.com" />

View File

@ -49,6 +49,7 @@
<data android:host="ow.ly" />
<data android:host="bl.ink" />
<data android:host="buff.ly" />
<data android:host="maps.app.goo.gl" />
<!-- INSTAGRAM URLs -->
<data android:host="instagram.com" />
@ -90,6 +91,7 @@
<data android:host="ow.ly" />
<data android:host="bl.ink" />
<data android:host="buff.ly" />
<data android:host="maps.app.goo.gl" />
<!-- INSTAGRAM URLs -->
<data android:host="instagram.com" />

View File

@ -68,7 +68,8 @@ public class CheckAppActivity extends AppCompatActivity {
"goo.gl",
"ow.ly",
"bl.ink",
"buff.ly"
"buff.ly",
"maps.app.goo.gl"
};
//Supported instances to redirect one instance to another faster for the user
public static String[] invidious_instances = {

View File

@ -379,7 +379,7 @@ public class TransformActivity extends Activity {
if (osm_enabled) {
Matcher matcher = maps.matcher(url);
while (matcher.find()) {
final String localization = matcher.group(1);
final String localization = matcher.group(2);
assert localization != null;
String[] data = localization.split(",");
if (data.length > 2) {
@ -427,9 +427,9 @@ public class TransformActivity extends Activity {
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, extraText);
sendIntent.setType("text/plain");
if( BuildConfig.fullLinks) {
if (BuildConfig.fullLinks) {
forwardToBrowser(TransformActivity.this, sendIntent);
}else{
} else {
startActivity(sendIntent);
finish();
}

View File

@ -88,7 +88,7 @@ public class Utils {
public static final Pattern nitterPattern = Pattern.compile("(mobile\\.|www\\.)?twitter.com([\\w-/]+)");
public static final Pattern bibliogramPostPattern = Pattern.compile("(m\\.|www\\.)?instagram.com(/p/[\\w-/]+)");
public static final Pattern bibliogramAccountPattern = Pattern.compile("(m\\.|www\\.)?instagram.com(((?!/p/).)+)");
public static final Pattern maps = Pattern.compile("/maps/place/[^@]+@([\\d.,z]{3,}).*");
public static final Pattern maps = Pattern.compile("/maps/place/([^@]+@)?([\\d.,z]+).*");
public static final Pattern ampExtract = Pattern.compile("amp/s/(.*)");
public static final String RECEIVE_STREAMING_URL = "receive_streaming_url";
private static final Pattern extractPlace = Pattern.compile("/maps/place/(((?!/data).)*)");
@ -152,7 +152,7 @@ public class Utils {
httpsURLConnection.setRequestProperty("http.keepAlive", "false");
httpsURLConnection.setInstanceFollowRedirects(false);
httpsURLConnection.setRequestMethod("HEAD");
if (httpsURLConnection.getResponseCode() == 301) {
if (httpsURLConnection.getResponseCode() == 301 || httpsURLConnection.getResponseCode() == 302) {
Map<String, List<String>> map = httpsURLConnection.getHeaderFields();
for (Map.Entry<String, List<String>> entry : map.entrySet()) {
if (entry.toString().toLowerCase().startsWith("location")) {
@ -224,7 +224,6 @@ public class Utils {
} else {
scheme += "://";
}
if (Arrays.asList(twitter_domains).contains(host)) {
boolean nitter_enabled = sharedpreferences.getBoolean(SET_NITTER_ENABLED, true);
if (nitter_enabled) {
@ -277,18 +276,21 @@ public class Utils {
if (osm_enabled) {
Matcher matcher = maps.matcher(url);
while (matcher.find()) {
final String localization = matcher.group(1);
final String localization = matcher.group(2);
assert localization != null;
String[] data = localization.split(",");
if (data.length > 2) {
if (data.length >= 2) {
String zoom;
String[] details = data[2].split("\\.");
if (details.length > 0) {
zoom = details[0];
if (data.length > 2) {
String[] details = data[2].split("\\.");
if (details.length > 0) {
zoom = details[0];
} else {
zoom = data[2];
}
} else {
zoom = data[2];
zoom = "16";
}
String osmHost = sharedpreferences.getString(MainActivity.SET_OSM_HOST, MainActivity.DEFAULT_OSM_HOST).toLowerCase();
boolean geo_uri_enabled = sharedpreferences.getBoolean(MainActivity.SET_GEO_URIS, false);
if (!geo_uri_enabled) {
@ -537,7 +539,14 @@ public class Utils {
Intent delegate = new Intent(Intent.ACTION_VIEW);
delegate.setData(Uri.parse(notShortnedURLDialog.get(notShortnedURLDialog.size() - 1)));
delegate.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
forwardToBrowser(context, delegate);
if (BuildConfig.fullLinks) {
forwardToBrowser(context, delegate);
} else {
if (delegate.resolveActivity(context.getPackageManager()) != null) {
context.startActivity(delegate);
((Activity) context).finish();
}
}
}
dialog.dismiss();
((Activity) context).finish();
@ -645,7 +654,7 @@ public class Utils {
String newUrlFinal = notShortnedURLDialog.get(notShortnedURLDialog.size() - 1);
Matcher matcher = maps.matcher(notShortnedURLDialog.get(notShortnedURLDialog.size() - 1));
while (matcher.find()) {
final String localization = matcher.group(1);
final String localization = matcher.group(2);
assert localization != null;
String[] data = localization.split(",");
if (data.length > 2) {