mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-28 12:44:34 +01:00
Avoid flashing white when opening debuglog in dark theme.
This commit is contained in:
@@ -8,6 +8,13 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<style>
|
||||
/* We keep the background transparent to avoid white flashes in dark theme */
|
||||
html, body {
|
||||
background: transparent;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#container { position: absolute; top: 0; bottom: 0; left: 0; right: 0; height: 100%; width: 100%; }
|
||||
.searchMatches { position: absolute; background-color: rgba(182, 190, 250, 0.4); }
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ package org.signal.debuglogsviewer
|
||||
|
||||
import android.content.Context
|
||||
import android.content.res.Configuration
|
||||
import android.graphics.Color
|
||||
import android.webkit.ValueCallback
|
||||
import android.webkit.WebView
|
||||
import android.webkit.WebViewClient
|
||||
@@ -28,13 +29,14 @@ object DebugLogsViewer {
|
||||
webview.isVerticalScrollBarEnabled = false
|
||||
webview.isHorizontalScrollBarEnabled = false
|
||||
|
||||
webview.setBackgroundColor(Color.TRANSPARENT)
|
||||
webview.background = null
|
||||
|
||||
webview.loadUrl("file:///android_asset/debuglogs-viewer.html")
|
||||
|
||||
webview.webViewClient = object : WebViewClient() {
|
||||
override fun onPageFinished(view: WebView?, url: String?) {
|
||||
// Set dark mode colors if in dark mode
|
||||
val isDarkMode = (context.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES
|
||||
if (isDarkMode) {
|
||||
if (context.isDarkTheme) {
|
||||
webview.evaluateJavascript("document.body.classList.add('dark');", null)
|
||||
}
|
||||
onFinished.run()
|
||||
@@ -135,6 +137,9 @@ object DebugLogsViewer {
|
||||
webview.evaluateJavascript("onSearchClose();", null)
|
||||
}
|
||||
|
||||
private val Context.isDarkTheme
|
||||
get() = (this.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES
|
||||
|
||||
fun interface LogReader {
|
||||
/** Returns the next bit of log, containing at most [size] lines (but may be less), or null if there are no logs remaining. */
|
||||
fun nextChunk(size: Int): String?
|
||||
|
||||
Reference in New Issue
Block a user