Fixed the toolbar color with a light theme and AMOLED mode enabled

pull/65/head
Zakhar Timoshenko 5 years ago committed by Koitharu
parent 93998e460c
commit cd8e256364

@ -1,6 +1,5 @@
package org.koitharu.kotatsu.base.ui package org.koitharu.kotatsu.base.ui
import android.graphics.Color
import android.os.Build import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.view.KeyEvent import android.view.KeyEvent
@ -58,9 +57,6 @@ abstract class BaseActivity<B : ViewBinding> : AppCompatActivity(), OnApplyWindo
this.binding = binding this.binding = binding
super.setContentView(binding.root) super.setContentView(binding.root)
val toolbar = (binding.root.findViewById<View>(R.id.toolbar) as? Toolbar) val toolbar = (binding.root.findViewById<View>(R.id.toolbar) as? Toolbar)
if (get<AppSettings>().isAmoledTheme) {
toolbar?.setBackgroundColor(Color.BLACK)
}
toolbar?.let(this::setSupportActionBar) toolbar?.let(this::setSupportActionBar)
ViewCompat.setOnApplyWindowInsetsListener(binding.root, this) ViewCompat.setOnApplyWindowInsetsListener(binding.root, this)

@ -11,6 +11,7 @@ import android.view.View
import android.view.ViewGroup.MarginLayoutParams import android.view.ViewGroup.MarginLayoutParams
import androidx.appcompat.app.ActionBarDrawerToggle import androidx.appcompat.app.ActionBarDrawerToggle
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatDelegate
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.core.graphics.Insets import androidx.core.graphics.Insets
import androidx.core.view.* import androidx.core.view.*
@ -87,7 +88,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>(),
binding.drawer.addDrawerListener(drawerToggle) binding.drawer.addDrawerListener(drawerToggle)
supportActionBar?.setDisplayHomeAsUpEnabled(true) supportActionBar?.setDisplayHomeAsUpEnabled(true)
if (get<AppSettings>().isAmoledTheme) { if (get<AppSettings>().isAmoledTheme && get<AppSettings>().theme == AppCompatDelegate.MODE_NIGHT_YES) {
binding.appbar.setBackgroundColor(Color.BLACK) binding.appbar.setBackgroundColor(Color.BLACK)
binding.toolbar.setBackgroundColor(ContextCompat.getColor(this, R.color.color_background)) binding.toolbar.setBackgroundColor(ContextCompat.getColor(this, R.color.color_background))
} else { } else {

Loading…
Cancel
Save