From da9cc26ae3f761630dc52258440c8c5d117168fc Mon Sep 17 00:00:00 2001 From: Jay Date: Thu, 9 Jan 2020 21:24:44 -0800 Subject: [PATCH] Added dark theme fix back --- .../eu/kanade/tachiyomi/ui/main/MainActivity.kt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt index 961b801363..46099cc878 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt @@ -9,9 +9,11 @@ import android.graphics.Color import android.graphics.Rect import android.os.Build import android.os.Bundle +import android.util.Log import android.view.MotionEvent import android.view.View import android.view.ViewGroup +import android.webkit.WebView import android.widget.FrameLayout import android.widget.LinearLayout import androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM @@ -59,7 +61,9 @@ import eu.kanade.tachiyomi.util.updatePadding import eu.kanade.tachiyomi.util.updatePaddingRelative import kotlinx.android.synthetic.main.main_activity.* import kotlinx.coroutines.delay +import timber.log.Timber import uy.kohesive.injekt.injectLazy +import java.lang.Exception import java.util.Date class MainActivity : BaseActivity() { @@ -106,6 +110,15 @@ class MainActivity : BaseActivity() { } override fun onCreate(savedInstanceState: Bundle?) { + // Some webview somwewhere breaks night mode, we create a webview to solve this: https://stackoverflow.com/a/45430282 + if (preferences.theme() in 2..4) { + Timber.d("Manually instantiating WebView to avoid night mode issue."); + try { + WebView(applicationContext) + } catch (e: Exception) { + Timber.e(e, "Exception when creating webview at start") + } + } setDefaultNightMode(when (preferences.theme()) { 1 -> MODE_NIGHT_NO 2, 3, 4 -> MODE_NIGHT_YES