mirror of
https://github.com/woheller69/maps.git
synced 2025-06-28 12:19:55 +00:00
Merge pull request #6 from papjul/open_external_links
Allow to open external links
This commit is contained in:
commit
c3dffdccef
3 changed files with 20 additions and 0 deletions
|
@ -22,6 +22,7 @@ import android.app.AlertDialog;
|
||||||
import android.content.ActivityNotFoundException;
|
import android.content.ActivityNotFoundException;
|
||||||
import android.content.ClipboardManager;
|
import android.content.ClipboardManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.location.LocationListener;
|
import android.location.LocationListener;
|
||||||
|
@ -243,6 +244,21 @@ public class MainActivity extends Activity {
|
||||||
}
|
}
|
||||||
if (!allowed) {
|
if (!allowed) {
|
||||||
Log.d(TAG, "[shouldOverrideUrlLoading][NOT ON ALLOWLIST] Blocked access to " + request.getUrl().getHost());
|
Log.d(TAG, "[shouldOverrideUrlLoading][NOT ON ALLOWLIST] Blocked access to " + request.getUrl().getHost());
|
||||||
|
if (request.getUrl().toString().startsWith("https://")) {
|
||||||
|
(new AlertDialog.Builder(context)
|
||||||
|
.setTitle(R.string.title_open_link)
|
||||||
|
.setMessage(context.getString(R.string.text_open_link, request.getUrl().toString()))
|
||||||
|
.setNegativeButton(android.R.string.cancel, null)
|
||||||
|
.setPositiveButton(
|
||||||
|
android.R.string.ok,
|
||||||
|
(dialogInterface, i) ->
|
||||||
|
startActivity(new Intent(Intent.ACTION_VIEW, request.getUrl()))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.create()
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
|
||||||
return true; //Deny URLs not on ALLOWLIST
|
return true; //Deny URLs not on ALLOWLIST
|
||||||
}
|
}
|
||||||
for (String url : blockedURLs) {
|
for (String url : blockedURLs) {
|
||||||
|
|
|
@ -6,4 +6,6 @@
|
||||||
<string name="error_no_gps">Veuillez activer le GPS</string>
|
<string name="error_no_gps">Veuillez activer le GPS</string>
|
||||||
<string name="no_app_installed">Pas d\'application installée</string>
|
<string name="no_app_installed">Pas d\'application installée</string>
|
||||||
<string name="intent_string">Ouvrir dans la webview restreinte</string>
|
<string name="intent_string">Ouvrir dans la webview restreinte</string>
|
||||||
|
<string name="title_open_link">Ouvrir le lien</string>
|
||||||
|
<string name="text_open_link">Ouvrir dans le navigateur externe ? %s</string>
|
||||||
</resources>
|
</resources>
|
|
@ -5,4 +5,6 @@
|
||||||
<string name="text_location_permission">Please grant location permission and press button again.</string>
|
<string name="text_location_permission">Please grant location permission and press button again.</string>
|
||||||
<string name="error_no_gps">Please activate GPS</string>
|
<string name="error_no_gps">Please activate GPS</string>
|
||||||
<string name="no_app_installed">No app installed</string>
|
<string name="no_app_installed">No app installed</string>
|
||||||
|
<string name="title_open_link">Open link</string>
|
||||||
|
<string name="text_open_link">Open in external browser? %s</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue