mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-09-12 11:37:52 +01:00
Avoid flashing white when opening debuglog in dark theme.
This commit is contained in:
@@ -330,7 +330,10 @@ public class SubmitDebugLogActivity extends BaseActivity {
|
||||
this.scrollToTopButton = findViewById(R.id.debug_log_scroll_to_top);
|
||||
this.progressCard = findViewById(R.id.debug_log_progress_card);
|
||||
|
||||
DebugLogsViewer.initWebView(logWebView, this, this::subscribeToLogLines);
|
||||
DebugLogsViewer.initWebView(logWebView, this, () -> {
|
||||
logWebView.animate().alpha(1f).setDuration(250).start();
|
||||
subscribeToLogLines();
|
||||
});
|
||||
|
||||
submitButton.setOnClickListener(v -> onSubmitClicked());
|
||||
scrollToTopButton.setOnClickListener(v -> DebugLogsViewer.scrollToTop(logWebView));
|
||||
|
||||
@@ -32,6 +32,8 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:scrollbars="vertical"
|
||||
android:background="@color/transparent_black"
|
||||
android:alpha="0"
|
||||
app:layout_constraintTop_toBottomOf="@id/debug_log_header_barrier"
|
||||
app:layout_constraintBottom_toTopOf="@id/debug_log_footer_barrier"/>
|
||||
|
||||
|
||||
@@ -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