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

[webview_flutter] Extract Android implementation into a separate package #4343

Merged

Conversation

mvanbeusekom
Copy link
Contributor

@mvanbeusekom mvanbeusekom commented Sep 14, 2021

This PR puts the native Android implementation of the platform interface (which was separated in #4302) into its own package, in preparation for moving the main plugin to a federated architecture.

Relevant issue:

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the relevant style guides and ran the auto-formatter. (Note that unlike the flutter/flutter repo, the flutter/plugins repo does use dart format.)
  • I signed the CLA.
  • The title of the PR starts with the name of the plugin surrounded by square brackets, e.g. [shared_preferences]
  • I listed at least one issue that this PR fixes in the description above.
  • 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 updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Creates a new `webview_flutter_android` directory and adds
the following meta-data files:
- `AUTHORS`: copied from the `webview_flutter` package and added my name;
- `CHANGELOG.md`: new file adding description for release 0.0.1;
- `LICENSE`: copied from the `webview_flutter` package;
- `README.md`: new file adding the standard platform implementation
  description;
- `pubspec.yaml`: new file adding package meta-data for the
  `webview_flutter_android` package.
A one to one copy of the `webview_flutter/android` folder to
`webview_flutter_android/` using the following command:
```
cp -R ./webview_flutter/android ./webview_flutter_android/
```
Copied the Android specific .dart files over from the
`./webview_flutter` package. Note that the `SurfaceAndroidWebView` class
in the `./webview_flutter_android/lib/webview_surface_android.dart` file
is copied directly (without modifactions) from the
`./webview_flutter/lib/webview_flutter.dart` file.
Make sure the `AndroidWebView` and `SurfaceAndroidWebView` widgets
extend the `WebViewPlatform` class from the
`webview_flutter_platform_interface` package correctly by accepting an
instance of the `JavascriptChannelRegistry` class.
This commit makes a direct copy of the `webview_flutter/example` app to
the  `webview_flutter_android` package. After the copy the `example/ios`
folder is removed as it doesn't serve a purpose in the Android specific
package. Commands run where:
```
cp -R ./webview_flutter/example ./webview_flutter_android/
rm -rf ./webview_flutter_android/example/ios
```
This commit updates the example App so it directly implements an Android
specific implementation of the webview_flutter_platform_interface.
Updated the existing integration tests (copied from webview_flutter
package) so they work correctly with the implementation of the
webview_flutter_android package.
@google-cla
Copy link

google-cla bot commented Sep 14, 2021

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added the cla: no label Sep 14, 2021
@github-actions github-actions bot added p: webview_flutter Edits files for a webview_flutter plugin platform-android labels Sep 14, 2021
@mvanbeusekom mvanbeusekom force-pushed the webview/federated_architecture_part_3 branch from d5c75af to e157c6e Compare September 14, 2021 10:28
@google-cla
Copy link

google-cla bot commented Sep 14, 2021

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

@mvanbeusekom mvanbeusekom force-pushed the webview/federated_architecture_part_3 branch from e157c6e to 7e4193b Compare September 14, 2021 11:26
@google-cla
Copy link

google-cla bot commented Sep 14, 2021

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

@BeMacized
Copy link
Contributor

@flutter/googlebot I consent.

Updated the pubspec.yaml to depend on version 1.0.0 of the
webview_flutter_platform_interface package instead of using a path
reference (which is now possible since the platform interface package
has now been published).

Co-authored-by: BeMacized <[email protected]>
@mvanbeusekom mvanbeusekom force-pushed the webview/federated_architecture_part_3 branch from 7e4193b to 881e652 Compare September 14, 2021 13:23
@google-cla
Copy link

google-cla bot commented Sep 14, 2021

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@BeMacized
Copy link
Contributor

@googlebot I consent.

Make sure the `webview_flutter` and `webview_flutter_android` example
apps use different application identifiers so that the CI doesn't run
into problems.
Make sure the webview_flutter_android and webview_flutter_wkwebview
packages are excluded from the Build All plugins step as they will cause
conflicts with the current implementation which is still part of the
webview_flutter package.
description: A Flutter plugin that provides a WebView widget on Android.
repository: https://github.com/flutter/plugins/tree/master/packages/webview_flutter/webview_flutter_android
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+webview%22
version: 0.0.1
Copy link
Contributor

Choose a reason for hiding this comment

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

Same version comment here as for iOS.

@@ -352,3 +364,599 @@ class NavigationControls extends StatelessWidget {
);
}
}

/// A web view widget for showing html content.
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment here as for iOS about moving to a separate file.

import 'package:webview_flutter_platform_interface/webview_flutter_platform_interface.dart';

void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();

const bool _skipDueIssue86757 = false;
const bool _skipDueIssue86757 = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: _skipDueToIssue86757

Move the `WebView` and related `WebViewController` classes from the
main.dart into a separate web_view.dart file.
@mvanbeusekom mvanbeusekom force-pushed the webview/federated_architecture_part_3 branch from a982131 to d6f1705 Compare September 20, 2021 13:59
Copy link
Contributor

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

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

Changes LGTM

@mvanbeusekom mvanbeusekom added the waiting for tree to go green (Use "autosubmit") This PR is approved and tested, but waiting for the tree to be green to land. label Sep 20, 2021
@fluttergithubbot
Copy link

This pull request is not suitable for automatic merging in its current state.

  • The status or check suite android-platform_tests has failed. Please fix the issues identified (or deflake) before re-applying this label.

@fluttergithubbot fluttergithubbot removed the waiting for tree to go green (Use "autosubmit") This PR is approved and tested, but waiting for the tree to be green to land. label Sep 20, 2021
@mvanbeusekom mvanbeusekom merged commit 19bc12e into flutter:master Sep 21, 2021
@mvanbeusekom mvanbeusekom deleted the webview/federated_architecture_part_3 branch September 21, 2021 06:40
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Sep 21, 2021
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Sep 21, 2021
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Sep 21, 2021
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Sep 21, 2021
amantoux pushed a commit to amantoux/plugins that referenced this pull request Sep 27, 2021
…age (flutter#4343)

* Setup webview_flutter_android package.

Creates a new `webview_flutter_android` directory and adds
the following meta-data files:
- `AUTHORS`: copied from the `webview_flutter` package and added my name;
- `CHANGELOG.md`: new file adding description for release 0.0.1;
- `LICENSE`: copied from the `webview_flutter` package;
- `README.md`: new file adding the standard platform implementation
  description;
- `pubspec.yaml`: new file adding package meta-data for the
  `webview_flutter_android` package.

* Direct copy of "android" folder.

A one to one copy of the `webview_flutter/android` folder to
`webview_flutter_android/` using the following command:
```
cp -R ./webview_flutter/android ./webview_flutter_android/
```

* Direct copy of Android specific .dart files.

Copied the Android specific .dart files over from the
`./webview_flutter` package. Note that the `SurfaceAndroidWebView` class
in the `./webview_flutter_android/lib/webview_surface_android.dart` file
is copied directly (without modifactions) from the
`./webview_flutter/lib/webview_flutter.dart` file.

* Modify .dart code to work with platform_interface.

Make sure the `AndroidWebView` and `SurfaceAndroidWebView` widgets
extend the `WebViewPlatform` class from the
`webview_flutter_platform_interface` package correctly by accepting an
instance of the `JavascriptChannelRegistry` class.

* Direct copy of the `webview_flutter/example` app.

This commit makes a direct copy of the `webview_flutter/example` app to
the  `webview_flutter_android` package. After the copy the `example/ios`
folder is removed as it doesn't serve a purpose in the Android specific
package. Commands run where:
```
cp -R ./webview_flutter/example ./webview_flutter_android/
rm -rf ./webview_flutter_android/example/ios
```

* Update example to Android specific implementation.

This commit updates the example App so it directly implements an Android
specific implementation of the webview_flutter_platform_interface.

* Update integration tests.

Updated the existing integration tests (copied from webview_flutter
package) so they work correctly with the implementation of the
webview_flutter_android package.

* Update webview_flutter_platform_interface dependency

Updated the pubspec.yaml to depend on version 1.0.0 of the
webview_flutter_platform_interface package instead of using a path
reference (which is now possible since the platform interface package
has now been published).

Co-authored-by: BeMacized <[email protected]>

* Use different bundle ID for Android example app.

Make sure the `webview_flutter` and `webview_flutter_android` example
apps use different application identifiers so that the CI doesn't run
into problems.

* Skip flaky integration_tests (issue 86757).

* Exlude platform implementations from build all step.

Make sure the webview_flutter_android and webview_flutter_wkwebview
packages are excluded from the Build All plugins step as they will cause
conflicts with the current implementation which is still part of the
webview_flutter package.

* Split helper classes from main example widget.

Move the `WebView` and related `WebViewController` classes from the
main.dart into a separate web_view.dart file.

Co-authored-by: BeMacized <[email protected]>
NickalasB added a commit to NickalasB/plugins that referenced this pull request Sep 27, 2021
* master: (51 commits)
  [webview_flutter] Update version number app_facing package (flutter#4375)
  [webview_flutter] Adjust integration test domains (flutter#4383)
  Remove some trivial custom analysis options files (flutter#4379)
  [google_maps_flutter_platfomr_interface] Add Marker drag events (flutter#2653)
  [flutter_plugin_tools] Improve version check error handling (flutter#4376)
  [flutter_plugin_tools] Allow overriding breaking change check (flutter#4369)
  [url_launcher] Error handling when URL cannot be parsed with Uri.parse (flutter#4365)
  [webview_flutter] Migrate main package to fully federated architecture. (flutter#4366)
  [google_sign_in] Bump minimum Flutter version and iOS deployment target (flutter#4334)
  Add false secret lists, and enforce ordering (flutter#4372)
  [camera_web] Update usage documentation (flutter#4371)
  [video_player] VTT Support (flutter#2878)
  Require authors file (flutter#4367)
  [flutter_plugin_tools] Fix federated safety check (flutter#4368)
  [webview_flutter] Extract WKWebView implementation into a separate package (flutter#4345)
  [webview_flutter] Extract Android implementation into a separate package (flutter#4343)
  [in_app_purchase] Ensure the `introductoryPriceMicros` field is populated correctly. (flutter#4364)
  [flutter_plugin_tools] Add a federated PR safety check (flutter#4329)
  [camera] Add web support (flutter#4240)
  [webview_flutter] Bump minimum Flutter version and iOS deployment target (flutter#4361)
  ...

# Conflicts:
#	packages/webview_flutter/webview_flutter/lib/platform_interface.dart
#	packages/webview_flutter/webview_flutter/lib/src/webview_method_channel.dart
#	packages/webview_flutter/webview_flutter/lib/webview_flutter.dart
KyleFin pushed a commit to KyleFin/plugins that referenced this pull request Dec 21, 2021
…age (flutter#4343)

* Setup webview_flutter_android package.

Creates a new `webview_flutter_android` directory and adds
the following meta-data files:
- `AUTHORS`: copied from the `webview_flutter` package and added my name;
- `CHANGELOG.md`: new file adding description for release 0.0.1;
- `LICENSE`: copied from the `webview_flutter` package;
- `README.md`: new file adding the standard platform implementation
  description;
- `pubspec.yaml`: new file adding package meta-data for the
  `webview_flutter_android` package.

* Direct copy of "android" folder.

A one to one copy of the `webview_flutter/android` folder to
`webview_flutter_android/` using the following command:
```
cp -R ./webview_flutter/android ./webview_flutter_android/
```

* Direct copy of Android specific .dart files.

Copied the Android specific .dart files over from the
`./webview_flutter` package. Note that the `SurfaceAndroidWebView` class
in the `./webview_flutter_android/lib/webview_surface_android.dart` file
is copied directly (without modifactions) from the
`./webview_flutter/lib/webview_flutter.dart` file.

* Modify .dart code to work with platform_interface.

Make sure the `AndroidWebView` and `SurfaceAndroidWebView` widgets
extend the `WebViewPlatform` class from the
`webview_flutter_platform_interface` package correctly by accepting an
instance of the `JavascriptChannelRegistry` class.

* Direct copy of the `webview_flutter/example` app.

This commit makes a direct copy of the `webview_flutter/example` app to
the  `webview_flutter_android` package. After the copy the `example/ios`
folder is removed as it doesn't serve a purpose in the Android specific
package. Commands run where:
```
cp -R ./webview_flutter/example ./webview_flutter_android/
rm -rf ./webview_flutter_android/example/ios
```

* Update example to Android specific implementation.

This commit updates the example App so it directly implements an Android
specific implementation of the webview_flutter_platform_interface.

* Update integration tests.

Updated the existing integration tests (copied from webview_flutter
package) so they work correctly with the implementation of the
webview_flutter_android package.

* Update webview_flutter_platform_interface dependency

Updated the pubspec.yaml to depend on version 1.0.0 of the
webview_flutter_platform_interface package instead of using a path
reference (which is now possible since the platform interface package
has now been published).

Co-authored-by: BeMacized <[email protected]>

* Use different bundle ID for Android example app.

Make sure the `webview_flutter` and `webview_flutter_android` example
apps use different application identifiers so that the CI doesn't run
into problems.

* Skip flaky integration_tests (issue 86757).

* Exlude platform implementations from build all step.

Make sure the webview_flutter_android and webview_flutter_wkwebview
packages are excluded from the Build All plugins step as they will cause
conflicts with the current implementation which is still part of the
webview_flutter package.

* Split helper classes from main example widget.

Move the `WebView` and related `WebViewController` classes from the
main.dart into a separate web_view.dart file.

Co-authored-by: BeMacized <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes p: webview_flutter Edits files for a webview_flutter plugin platform-android
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants