From 1a3130b62198f51e426216eb0fc77f4f231fdee8 Mon Sep 17 00:00:00 2001 From: Maurits van Beusekom Date: Tue, 8 Sep 2020 09:05:30 +0200 Subject: [PATCH 1/4] Suppress depration warning --- .../io/flutter/plugins/urllauncher/WebViewActivity.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/url_launcher/url_launcher/android/src/main/java/io/flutter/plugins/urllauncher/WebViewActivity.java b/packages/url_launcher/url_launcher/android/src/main/java/io/flutter/plugins/urllauncher/WebViewActivity.java index 52714790a25c..b3d28f7a5aa3 100644 --- a/packages/url_launcher/url_launcher/android/src/main/java/io/flutter/plugins/urllauncher/WebViewActivity.java +++ b/packages/url_launcher/url_launcher/android/src/main/java/io/flutter/plugins/urllauncher/WebViewActivity.java @@ -1,5 +1,6 @@ package io.flutter.plugins.urllauncher; +import android.annotation.TargetApi; import android.app.Activity; import android.content.BroadcastReceiver; import android.content.Context; @@ -38,6 +39,11 @@ public void onReceive(Context context, Intent intent) { private final WebViewClient webViewClient = new WebViewClient() { + /* + * This method is deprecated in API 24. Still overridden to support + * earlier Android versions. + */ + @SuppressWarnings("deprecation") @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { @@ -47,6 +53,7 @@ public boolean shouldOverrideUrlLoading(WebView view, String url) { return super.shouldOverrideUrlLoading(view, url); } + @TargetApi(Build.VERSION_CODES.N) @Override public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { From 832db9adfb5335888b81ebf8b51f019fe9e64efe Mon Sep 17 00:00:00 2001 From: Maurits van Beusekom Date: Tue, 8 Sep 2020 09:43:05 +0200 Subject: [PATCH 2/4] Update version number for url_launcher --- packages/url_launcher/url_launcher/CHANGELOG.md | 4 ++++ packages/url_launcher/url_launcher/pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/url_launcher/url_launcher/CHANGELOG.md b/packages/url_launcher/url_launcher/CHANGELOG.md index d20eb9117440..e7e31acfd968 100644 --- a/packages/url_launcher/url_launcher/CHANGELOG.md +++ b/packages/url_launcher/url_launcher/CHANGELOG.md @@ -1,3 +1,7 @@ +## 5.5.3 + +* Suppress deprecation warning on the `shouldOverrideUrlLoading` method on Android. + ## 5.5.2 * Depend explicitly on the `platform_interface` package that adds the `webOnlyWindowName` parameter. diff --git a/packages/url_launcher/url_launcher/pubspec.yaml b/packages/url_launcher/url_launcher/pubspec.yaml index 7fc824c74f9a..57048a2b3f98 100644 --- a/packages/url_launcher/url_launcher/pubspec.yaml +++ b/packages/url_launcher/url_launcher/pubspec.yaml @@ -2,7 +2,7 @@ name: url_launcher description: Flutter plugin for launching a URL on Android and iOS. Supports web, phone, SMS, and email schemes. homepage: https://github.com/flutter/plugins/tree/master/packages/url_launcher/url_launcher -version: 5.5.2 +version: 5.5.3 flutter: plugin: From dd936c731a590db2b97ffde84de074450426dfa9 Mon Sep 17 00:00:00 2001 From: Maurits van Beusekom Date: Tue, 8 Sep 2020 11:11:52 +0200 Subject: [PATCH 3/4] Make use of the RequiresApi annotation instead of TargetApi --- .../io/flutter/plugins/urllauncher/WebViewActivity.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/url_launcher/url_launcher/android/src/main/java/io/flutter/plugins/urllauncher/WebViewActivity.java b/packages/url_launcher/url_launcher/android/src/main/java/io/flutter/plugins/urllauncher/WebViewActivity.java index b3d28f7a5aa3..079e2c8bbecd 100644 --- a/packages/url_launcher/url_launcher/android/src/main/java/io/flutter/plugins/urllauncher/WebViewActivity.java +++ b/packages/url_launcher/url_launcher/android/src/main/java/io/flutter/plugins/urllauncher/WebViewActivity.java @@ -1,6 +1,5 @@ package io.flutter.plugins.urllauncher; -import android.annotation.TargetApi; import android.app.Activity; import android.content.BroadcastReceiver; import android.content.Context; @@ -13,6 +12,9 @@ import android.webkit.WebResourceRequest; import android.webkit.WebView; import android.webkit.WebViewClient; + +import androidx.annotation.RequiresApi; + import java.util.HashMap; import java.util.Map; @@ -53,7 +55,7 @@ public boolean shouldOverrideUrlLoading(WebView view, String url) { return super.shouldOverrideUrlLoading(view, url); } - @TargetApi(Build.VERSION_CODES.N) + @RequiresApi(Build.VERSION_CODES.N) @Override public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { From 44da9b787c6376c747f76b252aed160287e30bb9 Mon Sep 17 00:00:00 2001 From: Maurits van Beusekom Date: Tue, 8 Sep 2020 14:00:59 +0200 Subject: [PATCH 4/4] Fixed formatting of the WebViewActivity --- .../java/io/flutter/plugins/urllauncher/WebViewActivity.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/url_launcher/url_launcher/android/src/main/java/io/flutter/plugins/urllauncher/WebViewActivity.java b/packages/url_launcher/url_launcher/android/src/main/java/io/flutter/plugins/urllauncher/WebViewActivity.java index 079e2c8bbecd..5624d75b22eb 100644 --- a/packages/url_launcher/url_launcher/android/src/main/java/io/flutter/plugins/urllauncher/WebViewActivity.java +++ b/packages/url_launcher/url_launcher/android/src/main/java/io/flutter/plugins/urllauncher/WebViewActivity.java @@ -12,9 +12,7 @@ import android.webkit.WebResourceRequest; import android.webkit.WebView; import android.webkit.WebViewClient; - import androidx.annotation.RequiresApi; - import java.util.HashMap; import java.util.Map;