Skip to content

Commit

Permalink
Merge pull request #74 from KevinnZou/feature/android_layer_type supp…
Browse files Browse the repository at this point in the history
…ort Android custom layer type

feat:Android WebView support custom layer type
  • Loading branch information
KevinnZou authored Dec 27, 2023
2 parents c0bd75b + 0455bc9 commit 8d7c2a9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.multiplatform.webview.web
import android.content.Context
import android.graphics.Bitmap
import android.os.Build
import android.view.View
import android.view.ViewGroup
import android.webkit.WebChromeClient
import android.webkit.WebResourceError
Expand Down Expand Up @@ -168,8 +167,10 @@ fun AccompanistWebView(

webChromeClient = chromeClient
webViewClient = client

// Avoid covering other components
this.setLayerType(View.LAYER_TYPE_SOFTWARE, null)
this.setLayerType(state.webSettings.androidWebSettings.layerType, null)

settings.apply {
state.webSettings.let {
javaScriptEnabled = it.isJavaScriptEnabled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,18 @@ sealed class PlatformWebSettings {
* Whether the DOM storage API is enabled. The default value is {@code false}.
*/
var domStorageEnabled: Boolean = false,
) : PlatformWebSettings()
/**
* The Layer Type of the WebView.
* Default is [LayerType.HARDWARE]
*/
var layerType: Int = LayerType.HARDWARE,
) : PlatformWebSettings() {
object LayerType {
const val NONE = 0
const val SOFTWARE = 1
const val HARDWARE = 2
}
}

/**
* Desktop web settings
Expand Down

0 comments on commit 8d7c2a9

Please sign in to comment.