From 5c5fc4656cb60504d093e40426c654faef68ca1f Mon Sep 17 00:00:00 2001 From: slymax Date: Mon, 21 Jan 2019 19:47:58 +0100 Subject: [PATCH 1/4] update gradle config --- app/build.gradle | 5 ++--- build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index ce91fd6..9ddfba8 100755 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,13 +1,12 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 25 - buildToolsVersion '27.0.3' + compileSdkVersion 28 defaultConfig { applicationId "com.example.app" minSdkVersion 21 - targetSdkVersion 25 + targetSdkVersion 28 versionCode 1 versionName "1.0" } diff --git a/build.gradle b/build.gradle index c78c3f9..c3d3fea 100755 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ buildscript { google() } dependencies { - classpath 'com.android.tools.build:gradle:3.2.1' + classpath 'com.android.tools.build:gradle:3.3.0' } } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 6621fba..dd509ce 100755 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Mon Oct 29 15:19:59 CET 2018 +#Mon Jan 21 19:31:21 CET 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip From b2f9d68d09902b78544083896803dc549c41eb2b Mon Sep 17 00:00:00 2001 From: slymax Date: Mon, 21 Jan 2019 20:36:40 +0100 Subject: [PATCH 2/4] minor fixes --- app/src/main/java/com/example/app/MainActivity.java | 6 +++--- app/src/main/java/com/example/app/MyWebViewClient.java | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/example/app/MainActivity.java b/app/src/main/java/com/example/app/MainActivity.java index 10cc58a..264c404 100755 --- a/app/src/main/java/com/example/app/MainActivity.java +++ b/app/src/main/java/com/example/app/MainActivity.java @@ -1,9 +1,8 @@ package com.example.app; +import android.annotation.SuppressLint; import android.app.Activity; import android.os.Bundle; -import android.view.Menu; -import android.view.MenuItem; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; @@ -12,12 +11,13 @@ public class MainActivity extends Activity { private WebView mWebView; + @SuppressLint("SetJavaScriptEnabled") @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); - mWebView = (WebView) findViewById(R.id.activity_main_webview); + mWebView = findViewById(R.id.activity_main_webview); // Force links and redirects to open in the WebView instead of in a browser mWebView.setWebViewClient(new WebViewClient()); diff --git a/app/src/main/java/com/example/app/MyWebViewClient.java b/app/src/main/java/com/example/app/MyWebViewClient.java index 2087cf1..dc10ce9 100755 --- a/app/src/main/java/com/example/app/MyWebViewClient.java +++ b/app/src/main/java/com/example/app/MyWebViewClient.java @@ -5,11 +5,13 @@ import android.net.Uri; import android.webkit.WebView; import android.webkit.WebViewClient; -public class MyWebViewClient extends WebViewClient { +import java.util.Objects; + +class MyWebViewClient extends WebViewClient { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { - if (Uri.parse(url).getHost().endsWith("example.com")) { + if (Objects.requireNonNull(Uri.parse(url).getHost()).endsWith("example.com")) { return false; } From 5c8b5286ab8b6aea43cd872938a39a5842c08d9a Mon Sep 17 00:00:00 2001 From: slymax Date: Mon, 21 Jan 2019 20:45:33 +0100 Subject: [PATCH 3/4] update readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6ab9c2f..b05c18f 100755 --- a/README.md +++ b/README.md @@ -15,10 +15,10 @@ If you want to create an app that displays the content of a remote website mWebView.setWebViewClient(new MyWebViewClient()); ``` -2. open the `MyWebViewClient.java` file and replace `example.com` on line **12** with your custom hostname +2. open the `MyWebViewClient.java` file and replace `example.com` on line **14** with your custom hostname ```java - if (Uri.parse(url).getHost().endsWith("example.com")) { + if (Objects.requireNonNull(Uri.parse(url).getHost()).endsWith("example.com")) { ``` ### Using a local source From 37ec256891a411c559aab73fa18d7412cd61c1c5 Mon Sep 17 00:00:00 2001 From: slymax Date: Tue, 22 Jan 2019 12:43:24 +0100 Subject: [PATCH 4/4] minor fixes --- README.md | 2 +- app/src/main/java/com/example/app/MyWebViewClient.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b05c18f..b5a39cd 100755 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ If you want to create an app that displays the content of a remote website mWebView.setWebViewClient(new MyWebViewClient()); ``` -2. open the `MyWebViewClient.java` file and replace `example.com` on line **14** with your custom hostname +2. open the `MyWebViewClient.java` file and replace `example.com` on line **15** with your custom hostname ```java if (Objects.requireNonNull(Uri.parse(url).getHost()).endsWith("example.com")) { diff --git a/app/src/main/java/com/example/app/MyWebViewClient.java b/app/src/main/java/com/example/app/MyWebViewClient.java index dc10ce9..6b528e8 100755 --- a/app/src/main/java/com/example/app/MyWebViewClient.java +++ b/app/src/main/java/com/example/app/MyWebViewClient.java @@ -9,6 +9,7 @@ import java.util.Objects; class MyWebViewClient extends WebViewClient { + @SuppressWarnings("deprecation") @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { if (Objects.requireNonNull(Uri.parse(url).getHost()).endsWith("example.com")) {