Skip to content

[webview_flutter_android] Updates plugin to use ProxyApiss #7794

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 96 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
3a06ba1
recreate android webkit libbrary pigeon file
bparrishMines Jun 5, 2024
022f335
formatting
bparrishMines Jun 5, 2024
eba1170
compilation works
bparrishMines Jun 5, 2024
139b71b
new proxy apis for data classes
bparrishMines Jun 5, 2024
817900f
add version checker and cookie manager impl
bparrishMines Jun 5, 2024
b2df316
use class level requiresapi
bparrishMines Jun 5, 2024
da9e40f
add missing method and webview implementation
bparrishMines Jun 5, 2024
8b7f3a6
websettings and javascriptchannel implementations
bparrishMines Jun 5, 2024
6710e7d
finish webviewclient
bparrishMines Jun 5, 2024
d95064a
formatting call on main thread and downloadlistener
bparrishMines Jun 5, 2024
bca2a8f
webchromeclient impl i think
bparrishMines Jun 6, 2024
44069c5
some more implementations
bparrishMines Jun 6, 2024
7d08599
last couple implementations
bparrishMines Jun 6, 2024
5af1f19
formatting and update the java plugin class
bparrishMines Jun 6, 2024
8be75df
gen new proxy
bparrishMines Jun 6, 2024
840a9c0
fix proxy name
bparrishMines Jun 6, 2024
0bb7d0c
convert android_webview_controller
bparrishMines Jun 6, 2024
38887e4
fix on requeest headres nullness
bparrishMines Jun 6, 2024
9437524
fix prompting
bparrishMines Jun 10, 2024
d64584f
Merge branch 'main' of github.com:flutter/packages into webview_andro…
bparrishMines Aug 2, 2024
15fd208
Merge branch 'main' of github.com:flutter/packages into webview_andro…
bparrishMines Aug 30, 2024
04e8b65
regen and update pigeon
bparrishMines Aug 30, 2024
3313810
add licenses and fix code
bparrishMines Aug 30, 2024
73333f4
Merge branch 'main' of github.com:flutter/packages into webview_andro…
bparrishMines Sep 10, 2024
1a66dda
Merge branch 'main' of github.com:flutter/packages into webview_andro…
bparrishMines Sep 11, 2024
73af051
update tests
bparrishMines Sep 17, 2024
3247075
formatting and new code gen
bparrishMines Sep 30, 2024
3244f36
java tests compile
bparrishMines Sep 30, 2024
7439716
passing tests
bparrishMines Oct 1, 2024
417c9d4
fix cookiemanager tests
bparrishMines Oct 1, 2024
edc96ed
fix evaluate javascript
bparrishMines Oct 1, 2024
4ecf2cb
destroy test
bparrishMines Oct 1, 2024
6b6f5af
fix android proxy
bparrishMines Oct 1, 2024
b566a80
fix legacy errors
bparrishMines Oct 2, 2024
875a3db
fix legacy tests and regen mockitos
bparrishMines Oct 2, 2024
1ecebcf
fix navigation tests
bparrishMines Oct 2, 2024
bf34fe7
get test file compiling
bparrishMines Oct 2, 2024
adcd9aa
fix geolocation test
bparrishMines Oct 3, 2024
79f39e8
fix android_controller tests
bparrishMines Oct 3, 2024
b84aa1b
fix all unit tests
bparrishMines Oct 3, 2024
a8bc402
fix integration tests
bparrishMines Oct 3, 2024
29f24ab
remove unused files and chage pigeon file to android_webview
bparrishMines Oct 3, 2024
436f627
fix integration tests
bparrishMines Oct 3, 2024
604da48
fix tests and analysis
bparrishMines Oct 4, 2024
b864491
Merge branch 'main' of github.com:flutter/packages into webview_andro…
bparrishMines Oct 4, 2024
63add96
version bump
bparrishMines Oct 4, 2024
362de78
use different test strings
bparrishMines Oct 4, 2024
7a74ee3
remove instancemanager test
bparrishMines Oct 4, 2024
7979424
some formatting
bparrishMines Oct 4, 2024
14f2b9f
changelog
bparrishMines Oct 4, 2024
d004bdc
improvements and lints
bparrishMines Oct 4, 2024
db583c5
Merge branch 'main' of github.com:flutter/packages into webview_andro…
bparrishMines Oct 4, 2024
27060b6
null annotations
bparrishMines Oct 4, 2024
d4a017a
fix tests
bparrishMines Oct 4, 2024
61e5be0
Merge branch 'main' of github.com:flutter/packages into webview_andro…
bparrishMines Oct 7, 2024
0d2a6de
fix unit tests
bparrishMines Oct 7, 2024
504f4e7
Merge branch 'main' of github.com:flutter/packages into webview_andro…
bparrishMines Oct 7, 2024
97db13f
fix jvm target
bparrishMines Oct 7, 2024
c43e103
fix
bparrishMines Oct 7, 2024
91924ab
add annotation
bparrishMines Oct 7, 2024
bd240fe
nullability annotations
bparrishMines Oct 7, 2024
2406ecb
Merge branch 'main' of github.com:flutter/packages into webview_andro…
bparrishMines Oct 17, 2024
97794ec
formatting
bparrishMines Oct 17, 2024
11acdbd
remove 21 checks
bparrishMines Oct 17, 2024
d51c389
Merge branch 'main' of github.com:flutter/packages into webview_andro…
bparrishMines Oct 17, 2024
1e0c79e
Merge branch 'main' of github.com:flutter/packages into webview_andro…
bparrishMines Oct 28, 2024
4b05e38
formatting and remove version checks
bparrishMines Oct 28, 2024
b7891e3
fix cookiemanager
bparrishMines Oct 28, 2024
66d47d3
formatting and fix log message
bparrishMines Oct 28, 2024
577d75a
remove api requirement
bparrishMines Oct 28, 2024
7a324c2
other class
bparrishMines Oct 28, 2024
6402f15
update instancemanager
bparrishMines Oct 28, 2024
80f2510
Merge branch 'main' of github.com:flutter/packages into webview_andro…
bparrishMines Nov 4, 2024
8e3beed
Merge branch 'main' of github.com:flutter/packages into webview_andro…
bparrishMines Nov 5, 2024
d16ad98
bump pubspec version
bparrishMines Nov 5, 2024
d2e4f7e
nits
bparrishMines Nov 5, 2024
74c1566
Merge branch 'main' of github.com:flutter/packages into webview_andro…
bparrishMines Nov 5, 2024
c893bd4
maybe fix
bparrishMines Nov 5, 2024
0c22e1e
add contributing doc
bparrishMines Nov 5, 2024
f3824f1
fix changelog
bparrishMines Nov 5, 2024
464c2a8
add contribution guide
bparrishMines Nov 7, 2024
320b8ac
update contributing
bparrishMines Nov 13, 2024
78ca1bd
Merge branch 'main' of github.com:flutter/packages into webview_andro…
bparrishMines Nov 13, 2024
4ab4648
fix version bump
bparrishMines Nov 13, 2024
c313cc8
Merge branch 'main' of github.com:flutter/packages into webview_andro…
bparrishMines Nov 13, 2024
050c8e4
fix type
bparrishMines Nov 19, 2024
0d5ad0f
Merge branch 'main' of github.com:flutter/packages into webview_andro…
bparrishMines Nov 19, 2024
9c92615
contributing fixes
bparrishMines Nov 19, 2024
72f26ae
change pigeon file name
bparrishMines Nov 19, 2024
7c35e9b
fix plugin
bparrishMines Nov 19, 2024
7d63b78
try higher kotlin versiong
bparrishMines Nov 19, 2024
dd57f9f
fix compilation
bparrishMines Nov 19, 2024
dfeff6d
fix kotlin version
bparrishMines Nov 19, 2024
4567360
fix pigeon name
bparrishMines Nov 19, 2024
bdf82ea
by not in
bparrishMines Nov 19, 2024
2ecb73b
Merge branch 'main' of github.com:flutter/packages into webview_andro…
bparrishMines Nov 19, 2024
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
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 4.1.0

* Updates internal API wrapper to use `ProxyApi`s.

## 4.0.3

* Bumps androidx.annotation:annotation from 1.8.2 to 1.9.1.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Contributing to `webview_flutter_android`

Please start by taking a look at the general guide to contributing to the `flutter/packages` repo:
https://github.com/flutter/packages/blob/main/CONTRIBUTING.md

## Package Structure

This plugin serves as a platform implementation plugin as outlined in [federated plugins](https://docs.flutter.dev/packages-and-plugins/developing-packages#federated-plugins).
The sections below will provide an overview of how this plugin implements this portion with Android.

For making changes to this package, please take a look at [changing federated plugins](https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins).

### Quick Overview

This plugin implements the platform interface provided by `webview_flutter_platform_interface` using
the native WebKit APIs for Android.

#### SDK Wrappers

To access native APIS, this plugins uses Dart wrappers of the native library. The native library is
wrapped using using the `ProxyApi` feature from the `pigeon` package.

The wrappers for the native library can be updated and modified by changing `pigeons/android_webkit.dart`.

The generated files are located:
* `lib/src/android_webkit.g.dart`
* `android/src/main/java/io/flutter/plugins/webviewflutter/AndroidWebkitLibrary.g.kt`

To update the wrapper, follow the steps below:

##### 1. Ensure the project has been built at least once

Run `flutter build apk --debug` in `example/`.

##### 2. Make changes to the respective pigeon file that matches the native SDK

* Android Dependency: https://developer.android.com/reference/android/webkit/package-summary
* Pigeon file to update: `pigeons/android_webkit.dart`

##### 3. Run the code generator from the terminal

Run: `dart run pigeon --input pigeons/android_webkit.dart`

##### 4. Update the generated APIs in native code

Running the `flutter build` command from step 1 again should provide build errors and indicate what
needs to be done. Alternatively, it can be easier to update native code with the platform's specific
IDE:

Open `example/android/` in a separate Android Studio project.

##### 5. Write API tests

Assuming a non-static method or constructor was added to the native wrapper, a native test will need
to be added.

Tests location: `android/src/test/java/io/flutter/plugins/webviewflutter/`

## Important Notes

### Calling `WebView.destroy()` after Dart Instance is Garbage Collected

To avoid a potentially breaking change, the code in `android/src/main/java/io/flutter/plugins/webviewflutter/AndroidWebkitLibrary.g.kt`
needs to be updated after the pigeon generator is run. Please add

```kotlin
val instance: Any? = getInstance(identifier)
if (instance is WebViewProxyApi.WebViewPlatformView) {
instance.destroy()
}
```

to `AndroidWebkitLibraryPigeonInstanceManager.remove`. The current implementation of the native
code doesn't currently support handling when the Dart instance is garbage collected.
4 changes: 4 additions & 0 deletions packages/webview_flutter/webview_flutter_android/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,9 @@ androidController.setCustomWidgetCallbacks(
);
```

## Contributing

For information on contributing to this plugin, see [`CONTRIBUTING.md`](CONTRIBUTING.md).

[1]: https://pub.dev/packages/webview_flutter
[2]: https://flutter.dev/to/endorsed-federated-plugin
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ group 'io.flutter.plugins.webviewflutter'
version '1.0-SNAPSHOT'

buildscript {
ext.kotlin_version = '1.9.10'
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:8.0.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

Expand All @@ -20,11 +22,21 @@ rootProject.allprojects {
}

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

android {
namespace 'io.flutter.plugins.webviewflutter'
compileSdk 34

compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}

kotlinOptions {
jvmTarget = '11'
}

defaultConfig {
minSdkVersion 21
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand All @@ -44,11 +56,6 @@ android {
testImplementation 'androidx.test:core:1.3.0'
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}

testOptions {
unitTests.includeAndroidResources = true
unitTests.returnDefaultValues = true
Expand Down
Loading