mirror of
https://gitlab.com/SpaccInc/SpaccDotWeb.git
synced 2025-06-05 21:29:12 +02:00
[SpaccDotWeb.Android] Add missing changes
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
<li><a href="data:text/plain;utf8,Hello World!">data:text/plain</a></li>
|
||||
<li><a href="data:text/html;utf8,<h2>Hello World!">data:text/html</a></li>
|
||||
<li><a href="mailto:example@example.com">mailto:</a></li>
|
||||
<li><a href="intent://#Intent;action=android.intent.action.VIEW;scheme=http;type=video/mp4;end">intent://</a></li>
|
||||
</ul>
|
||||
<h3>Files</h3>
|
||||
<p>Upload: <label><input type="file"/></label></p>
|
||||
|
@@ -1,9 +1,12 @@
|
||||
package org.eu.spacc.spaccdotweb.android.webview;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.webkit.WebView;
|
||||
import org.eu.spacc.spaccdotweb.android.utils.ApiUtils;
|
||||
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@@ -19,12 +22,24 @@ public class WebViewClient extends android.webkit.WebViewClient {
|
||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||
// TODO: This should not override all HTTP links if the app loads from remote (which will allow proper internal navigation and file downloads)
|
||||
// NOTE: It seems like the WebView overrides loading of data: URIs before we can get it here...
|
||||
List<String> protocols = Arrays.asList("data", "http", "https", "mailto", "ftp");
|
||||
if (protocols.contains(url.toLowerCase().split(":")[0])) {
|
||||
ApiUtils.openOrShareUrl(context, Uri.parse(url));
|
||||
List<String> externalProtocols = Arrays.asList("data", "http", "https", "mailto", "ftp");
|
||||
String protocol = url.toLowerCase().split(":")[0];
|
||||
if (protocol.equals("file")) {
|
||||
return super.shouldOverrideUrlLoading(view, url);
|
||||
} else if (protocol.equals("intent")) {
|
||||
ApiUtils.apiRun(4, () -> {
|
||||
try {
|
||||
// TODO: Should this handle broadcasts and services differently?
|
||||
context.startActivity(Intent.parseUri(url, 0));
|
||||
} catch (URISyntaxException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
} else {
|
||||
return super.shouldOverrideUrlLoading(view, url);
|
||||
ApiUtils.openOrShareUrl(context, Uri.parse(url));
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user