From 7533dabe42bc5dca9eb13f8be1078703de2d6d19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E9=93=AD=E6=9D=B0?= Date: Fri, 21 Jul 2023 16:59:46 +0800 Subject: [PATCH 1/4] Remove the wrapper of webview to solve nestedscroll issue --- .../main/java/com/google/accompanist/web/WebView.kt | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/web/src/main/java/com/google/accompanist/web/WebView.kt b/web/src/main/java/com/google/accompanist/web/WebView.kt index 724c8ea5b..f818aa0c7 100644 --- a/web/src/main/java/com/google/accompanist/web/WebView.kt +++ b/web/src/main/java/com/google/accompanist/web/WebView.kt @@ -210,7 +210,7 @@ fun WebView( AndroidView( factory = { context -> - val childView = (factory?.invoke(context) ?: WebView(context)).apply { + (factory?.invoke(context) ?: WebView(context)).apply { onCreated(this) this.layoutParams = layoutParams @@ -223,14 +223,6 @@ fun WebView( webViewClient = client }.also { state.webView = it } - // Workaround a crash on certain devices that expect WebView to be - // wrapped in a ViewGroup. - // b/243567497 - val parentLayout = FrameLayout(context) - parentLayout.layoutParams = layoutParams - parentLayout.addView(childView) - - parentLayout }, modifier = modifier, onRelease = { parentFrame -> From ebc8cefa08f4d86d602bcfbd47d11a6189f5dc5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E9=93=AD=E6=9D=B0?= Date: Sat, 22 Jul 2023 08:52:08 +0800 Subject: [PATCH 2/4] Fix format violations --- web/src/main/java/com/google/accompanist/web/WebView.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/web/src/main/java/com/google/accompanist/web/WebView.kt b/web/src/main/java/com/google/accompanist/web/WebView.kt index f818aa0c7..711d2ebff 100644 --- a/web/src/main/java/com/google/accompanist/web/WebView.kt +++ b/web/src/main/java/com/google/accompanist/web/WebView.kt @@ -222,7 +222,6 @@ fun WebView( webChromeClient = chromeClient webViewClient = client }.also { state.webView = it } - }, modifier = modifier, onRelease = { parentFrame -> From 3443f247dc07eca3638a3f5d1cc97cb0f1025920 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E9=93=AD=E6=9D=B0?= Date: Sun, 23 Jul 2023 07:50:36 +0800 Subject: [PATCH 3/4] Remove FrameLayout in WebView:Fix onRelease Bug --- web/src/main/java/com/google/accompanist/web/WebView.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/src/main/java/com/google/accompanist/web/WebView.kt b/web/src/main/java/com/google/accompanist/web/WebView.kt index 711d2ebff..2aef118e5 100644 --- a/web/src/main/java/com/google/accompanist/web/WebView.kt +++ b/web/src/main/java/com/google/accompanist/web/WebView.kt @@ -44,7 +44,6 @@ import androidx.compose.runtime.snapshotFlow import androidx.compose.runtime.snapshots.SnapshotStateList import androidx.compose.ui.Modifier import androidx.compose.ui.viewinterop.AndroidView -import androidx.core.view.children import com.google.accompanist.web.LoadingState.Finished import com.google.accompanist.web.LoadingState.Loading import kotlinx.coroutines.CoroutineScope @@ -225,7 +224,8 @@ fun WebView( }, modifier = modifier, onRelease = { parentFrame -> - val wv = parentFrame.children.first() as WebView + // Since FrameLayout is removed,parentFrame is just the WebView + val wv = parentFrame onDispose(wv) } ) From 3929bfb1adffd9d0d03a1e0475e7f7eca95a4c8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E9=93=AD=E6=9D=B0?= Date: Wed, 26 Jul 2023 08:26:33 +0800 Subject: [PATCH 4/4] Remove FrameLayout in WebView:clean unused code --- web/src/main/java/com/google/accompanist/web/WebView.kt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/web/src/main/java/com/google/accompanist/web/WebView.kt b/web/src/main/java/com/google/accompanist/web/WebView.kt index 2aef118e5..9618c13c6 100644 --- a/web/src/main/java/com/google/accompanist/web/WebView.kt +++ b/web/src/main/java/com/google/accompanist/web/WebView.kt @@ -223,10 +223,8 @@ fun WebView( }.also { state.webView = it } }, modifier = modifier, - onRelease = { parentFrame -> - // Since FrameLayout is removed,parentFrame is just the WebView - val wv = parentFrame - onDispose(wv) + onRelease = { + onDispose(it) } ) }