Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[url_launcher] Suppress deprecation warning in WebViewActivity #3008

Merged
merged 4 commits into from
Sep 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/url_launcher/url_launcher/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +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;

Expand All @@ -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")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH looking at this snippet now I'm confused at all as to why we override this method in order to directly call loadUrl on older Android versions?

I left a question on the PR that added this though it was a year ago so not sure if the author will still be able to provide info: https://github.com/flutter/plugins/pull/1848/files#r485141991

@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
Expand All @@ -47,6 +53,7 @@ public boolean shouldOverrideUrlLoading(WebView view, String url) {
return super.shouldOverrideUrlLoading(view, url);
}

@RequiresApi(Build.VERSION_CODES.N)
@Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Expand Down
2 changes: 1 addition & 1 deletion packages/url_launcher/url_launcher/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down