diff --git a/app/src/main/java/org/koitharu/kotatsu/base/ui/BaseActivity.kt b/app/src/main/java/org/koitharu/kotatsu/base/ui/BaseActivity.kt index 8fbaa7ad4..5e91880a1 100644 --- a/app/src/main/java/org/koitharu/kotatsu/base/ui/BaseActivity.kt +++ b/app/src/main/java/org/koitharu/kotatsu/base/ui/BaseActivity.kt @@ -1,5 +1,6 @@ package org.koitharu.kotatsu.base.ui +import android.content.res.Configuration import android.os.Build import android.os.Bundle import android.view.KeyEvent @@ -101,6 +102,12 @@ abstract class BaseActivity : AppCompatActivity(), OnApplyWindo (findViewById(R.id.toolbar) as? Toolbar)?.let(this::setSupportActionBar) } + protected fun isDarkAmoledTheme(): Boolean { + val uiMode = resources.configuration.uiMode + val isNight = uiMode and Configuration.UI_MODE_NIGHT_MASK == Configuration.UI_MODE_NIGHT_YES + return isNight && get().isAmoledTheme + } + override fun onSupportActionModeStarted(mode: ActionMode) { super.onSupportActionModeStarted(mode) val insets = ViewCompat.getRootWindowInsets(binding.root) diff --git a/app/src/main/java/org/koitharu/kotatsu/main/ui/MainActivity.kt b/app/src/main/java/org/koitharu/kotatsu/main/ui/MainActivity.kt index b0a54747f..7c68a56f5 100644 --- a/app/src/main/java/org/koitharu/kotatsu/main/ui/MainActivity.kt +++ b/app/src/main/java/org/koitharu/kotatsu/main/ui/MainActivity.kt @@ -345,7 +345,7 @@ class MainActivity : BaseActivity(), binding.drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED) drawerToggle.isDrawerIndicatorEnabled = false // Avoiding shadows on the sides if the color is transparent, so we make the AppBarLayout white/grey/black - if (get().isAmoledTheme && get().theme == AppCompatDelegate.MODE_NIGHT_YES) { + if (isDarkAmoledTheme()) { binding.toolbar.setBackgroundColor(Color.BLACK) } else { binding.appbar.setBackgroundColor(ContextCompat.getColor(this, R.color.color_surface)) @@ -365,7 +365,7 @@ class MainActivity : BaseActivity(), private fun onSearchClosed() { binding.drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED) drawerToggle.isDrawerIndicatorEnabled = true - if (get().isAmoledTheme) { + if (isDarkAmoledTheme()) { binding.toolbar.setBackgroundColor(ContextCompat.getColor(this, R.color.color_background)) } // Returning transparent color diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index b5b4aa8fd..49c6cab54 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -34,6 +34,5 @@ #212121 #99000000 #99000000 - #00FFFFFF \ No newline at end of file