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

Conversation

mvanbeusekom
Copy link
Contributor

@mvanbeusekom mvanbeusekom commented Sep 8, 2020

Description

The url_launcher overrides the deprecated shouldOverrideUrlLoading(WebView view, String url) method to be backwards compatible with versions before Android API 24. This however currently displays the warning "WebViewActivity.java uses or overrides a deprecated API." when building for Android. This is causing some problems for developers who treat these warnings as errors as part of their build configuration.

This PR addresses this issue by annotating the shouldOverrideUrlLoading(WebView view, String url) method with the @SuppressWarnings("deprecation") attribute.

This PR also adds the @RequiresApi(Build.VERSION_CODES.N) annotation to the shouldOverrideUrlLoading(WebView view, WebResourceRequest request) method, which gives the Android/ Java tooling an indication this method should only by used from API 24 and higher.

Related Issues

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • My PR includes unit or integration tests for all changed/updated/fixed behaviors (See Contributor Guide).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (flutter analyze) does not report any problems on my PR.
  • I read and followed the Flutter Style Guide.
  • The title of the PR starts with the name of the plugin surrounded by square brackets, e.g. [shared_preferences]
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy.
  • I updated CHANGELOG.md to add a description of the change.
  • I signed the CLA.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (please indicate a breaking change in CHANGELOG.md and increment major revision).
  • No, this is not a breaking change.

* 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

Copy link
Contributor

@amirh amirh left a comment

Choose a reason for hiding this comment

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

LGTM

@amirh amirh merged commit 00d85b0 into flutter:master Sep 8, 2020
@Zazo032 Zazo032 mentioned this pull request Sep 9, 2020
12 tasks
@mvanbeusekom mvanbeusekom deleted the issue/37616 branch September 10, 2020 18:50
danielroek pushed a commit to Baseflow/flutter-plugins that referenced this pull request Sep 18, 2020
…er#3008)

The url_launcher overrides the deprecated shouldOverrideUrlLoading(WebView view, String url) method to be backwards compatible with versions before Android API 24. This however currently displays the warning "WebViewActivity.java uses or overrides a deprecated API." when building for Android. This is causing some problems for developers who treat these warnings as errors as part of their build configuration.

This PR addresses this issue by annotating the shouldOverrideUrlLoading(WebView view, String url) method with the @SuppressWarnings("deprecation") attribute.

This PR also adds the @RequiresApi(Build.VERSION_CODES.N) annotation to the shouldOverrideUrlLoading(WebView view, WebResourceRequest request) method, which gives the Android/ Java tooling an indication this method should only by used from API 24 and higher.
jorgefspereira pushed a commit to jorgefspereira/plugins_flutter that referenced this pull request Oct 10, 2020
…er#3008)

The url_launcher overrides the deprecated shouldOverrideUrlLoading(WebView view, String url) method to be backwards compatible with versions before Android API 24. This however currently displays the warning "WebViewActivity.java uses or overrides a deprecated API." when building for Android. This is causing some problems for developers who treat these warnings as errors as part of their build configuration.

This PR addresses this issue by annotating the shouldOverrideUrlLoading(WebView view, String url) method with the @SuppressWarnings("deprecation") attribute.

This PR also adds the @RequiresApi(Build.VERSION_CODES.N) annotation to the shouldOverrideUrlLoading(WebView view, WebResourceRequest request) method, which gives the Android/ Java tooling an indication this method should only by used from API 24 and higher.
FlutterSu pushed a commit to FlutterSu/flutter-plugins that referenced this pull request Nov 20, 2020
…er#3008)

The url_launcher overrides the deprecated shouldOverrideUrlLoading(WebView view, String url) method to be backwards compatible with versions before Android API 24. This however currently displays the warning "WebViewActivity.java uses or overrides a deprecated API." when building for Android. This is causing some problems for developers who treat these warnings as errors as part of their build configuration.

This PR addresses this issue by annotating the shouldOverrideUrlLoading(WebView view, String url) method with the @SuppressWarnings("deprecation") attribute.

This PR also adds the @RequiresApi(Build.VERSION_CODES.N) annotation to the shouldOverrideUrlLoading(WebView view, WebResourceRequest request) method, which gives the Android/ Java tooling an indication this method should only by used from API 24 and higher.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants