Fixed dark and light modes mixing on dark theme

This commit is contained in:
Jay 2020-01-08 23:18:30 -08:00
parent 53a44fb211
commit 7edc47f24e
3 changed files with 28 additions and 14 deletions

View File

@ -185,7 +185,7 @@ dependencies {
implementation "com.github.inorichi.injekt:injekt-core:65b0440"
// Image library
final glide_version = '4.10.0'
final glide_version = '4.11.0'
implementation "com.github.bumptech.glide:glide:$glide_version"
implementation "com.github.bumptech.glide:okhttp3-integration:$glide_version"
kapt "com.github.bumptech.glide:compiler:$glide_version"

View File

@ -4,6 +4,7 @@ import android.animation.ObjectAnimator
import android.app.SearchManager
import android.content.Intent
import android.content.res.Configuration
import android.content.res.Resources
import android.graphics.Color
import android.graphics.Rect
import android.os.Build
@ -94,17 +95,22 @@ class MainActivity : BaseActivity() {
lateinit var tabAnimator: TabsAnimator
override fun getTheme(): Resources.Theme {
val theme = super.getTheme()
theme.applyStyle(when (preferences.theme()) {
3, 6 -> R.style.Theme_Tachiyomi_Amoled
4, 7 -> R.style.Theme_Tachiyomi_DarkBlue
else -> R.style.Theme_Tachiyomi
}, true)
return theme
}
override fun onCreate(savedInstanceState: Bundle?) {
setDefaultNightMode(when (preferences.theme()) {
1 -> MODE_NIGHT_NO
2, 3, 4 -> MODE_NIGHT_YES
else -> MODE_NIGHT_FOLLOW_SYSTEM
})
setTheme(when (preferences.theme()) {
3, 6 -> R.style.Theme_Tachiyomi_Amoled
4, 7 -> R.style.Theme_Tachiyomi_DarkBlue
else -> R.style.Theme_Tachiyomi
})
super.onCreate(savedInstanceState)
// Do not let the launcher create a new activity http://stackoverflow.com/questions/16283079

View File

@ -3,16 +3,19 @@ package eu.kanade.tachiyomi.ui.manga.info
import android.content.Context
import android.content.Intent
import android.content.res.Configuration
import android.content.res.Resources
import android.graphics.Bitmap
import android.graphics.Color
import android.os.Build
import android.os.Bundle
import android.os.PersistableBundle
import android.view.Menu
import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import android.webkit.WebView
import android.widget.LinearLayout
import androidx.appcompat.app.AppCompatDelegate
import androidx.core.graphics.ColorUtils
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
@ -49,12 +52,17 @@ class WebViewActivity : BaseActivity() {
}
}
override fun onCreate(savedInstanceState: Bundle?) {
setTheme(when (preferences.theme()) {
override fun getTheme(): Resources.Theme {
val theme = super.getTheme()
theme.applyStyle(when (preferences.theme()) {
3, 6 -> R.style.Theme_Tachiyomi_Amoled
4, 7 -> R.style.Theme_Tachiyomi_DarkBlue
else -> R.style.Theme_Tachiyomi
})
}, true)
return theme
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.webview_activity)
title = intent.extras?.getString(TITLE_KEY)
@ -90,9 +98,9 @@ class WebViewActivity : BaseActivity() {
0, insets.systemWindowInsetBottom
)
}
window.statusBarColor = getResourceColor(R.attr.colorPrimary)
content.setOnApplyWindowInsetsListener { v, insets ->
window.statusBarColor = getResourceColor(R.attr.colorPrimary)
window.navigationBarColor =
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
v.context.getResourceColor(android.R.attr.colorPrimary)
@ -107,12 +115,12 @@ class WebViewActivity : BaseActivity() {
}
v.setPadding(insets.systemWindowInsetLeft, insets.systemWindowInsetTop,
insets.systemWindowInsetRight, 0)
val currentNightMode = resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
if (Build.VERSION.SDK_INT >= 26 && currentNightMode == Configuration.UI_MODE_NIGHT_NO) {
content.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
}
insets
}
val currentNightMode = resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
if (Build.VERSION.SDK_INT >= 26 && currentNightMode == Configuration.UI_MODE_NIGHT_NO) {
content.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
}
if (bundle == null) {
val source = sourceManager.get(intent.extras!!.getLong(SOURCE_KEY)) as? HttpSource ?: return