diff options
Diffstat (limited to 'app/src/main/java/org')
| -rw-r--r-- | app/src/main/java/org/terst/feedreader/ui/ReaderWebView.kt | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/app/src/main/java/org/terst/feedreader/ui/ReaderWebView.kt b/app/src/main/java/org/terst/feedreader/ui/ReaderWebView.kt index 1bc1315..3af460a 100644 --- a/app/src/main/java/org/terst/feedreader/ui/ReaderWebView.kt +++ b/app/src/main/java/org/terst/feedreader/ui/ReaderWebView.kt @@ -7,6 +7,7 @@ import android.view.ScaleGestureDetector import android.view.View import android.webkit.WebChromeClient import android.webkit.WebResourceRequest +import android.view.WindowManager import android.webkit.WebView import android.webkit.WebViewClient import androidx.compose.foundation.layout.Column @@ -21,8 +22,11 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import androidx.compose.ui.viewinterop.AndroidView +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.ui.platform.LocalView import androidx.compose.ui.window.Dialog import androidx.compose.ui.window.DialogProperties +import androidx.compose.ui.window.DialogWindowProvider import org.terst.feedreader.data.DEFAULT_READER_FONT_SIZE_PX import org.terst.feedreader.data.UNZOOMED_TEXT_ZOOM_PERCENT import org.terst.feedreader.data.pinchZoomFontSizePx @@ -343,6 +347,22 @@ fun YouTubePlayerDialog(videoId: String, onDismiss: () -> Unit) { // narrow, sitting off-center). Opt out so fillMaxWidth below means the real // screen width, with our own padding controlling the margin instead. Dialog(onDismissRequest = onDismiss, properties = DialogProperties(usePlatformDefaultWidth = false)) { + // A dialog is its own Window, and video is the one kind of web content that needs the + // window it sits in to be hardware accelerated: it is composited from a separate surface + // rather than drawn into the page like everything else. Without the flag, the page + // renders perfectly and only the video is missing -- reported live as the player's + // controls, title and scrubber thumbnails all appearing over a blank area where the + // picture should be, with the audio playing. + // + // The activity has android:hardwareAccelerated, but that does not carry to a Window the + // dialog creates for itself, so it is set here explicitly. + val dialogWindow = (LocalView.current.parent as? DialogWindowProvider)?.window + LaunchedEffect(dialogWindow) { + dialogWindow?.setFlags( + WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, + WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, + ) + } AndroidView( modifier = Modifier.fillMaxWidth().padding(16.dp).aspectRatio(16f / 9f), factory = { ctx -> |
