simplify config

This commit is contained in:
slymax 2020-03-29 18:26:24 +02:00
parent 8c64844ced
commit 717d7e8825
2 changed files with 6 additions and 4 deletions

View File

@ -6,7 +6,7 @@ This is a template project for Android Studio that allows you to create an andro
### Using a remote source ### Using a remote source
If you want to create an app that displays the content of a remote website If you want to create an app that shows the content of a remote website
1. uncomment line **24** in `MainActivity.java` and replace `https://example.com` with your remote source 1. uncomment line **24** in `MainActivity.java` and replace `https://example.com` with your remote source
@ -14,10 +14,10 @@ If you want to create an app that displays the content of a remote website
mWebView.loadUrl("https://example.com"); mWebView.loadUrl("https://example.com");
``` ```
2. open the `MyWebViewClient.java` file and replace `example.com` on line **13** with your custom hostname 2. open the `MyWebViewClient.java` file and replace `example.com` on line **13** with your hostname
```java ```java
if (url.startsWith("file:") || uri.getHost() != null && uri.getHost().endsWith("example.com")) { hostname = "example.com";
``` ```
### Using a local source ### Using a local source

View File

@ -9,8 +9,10 @@ class MyWebViewClient extends WebViewClient {
@Override @Override
public boolean shouldOverrideUrlLoading(WebView view, String url) { public boolean shouldOverrideUrlLoading(WebView view, String url) {
String hostname;
hostname = "example.com";
Uri uri = Uri.parse(url); Uri uri = Uri.parse(url);
if (url.startsWith("file:") || uri.getHost() != null && uri.getHost().endsWith("example.com")) { if (url.startsWith("file:") || uri.getHost() != null && uri.getHost().endsWith(hostname)) {
return false; return false;
} }
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));