mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-17 03:28:52 +01:00
Background colour respects dark mode
This commit is contained in:
@@ -17,40 +17,28 @@ class Colors @Inject constructor(context: Context, prefs: Preferences) {
|
||||
.map { it.last() }
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
|
||||
val background: Observable<Int> = prefs.dark.asObservable()
|
||||
.map { dark -> if (dark) R.color.backgroundDark else R.color.white }
|
||||
.map { res -> context.resources.getColor(res) }
|
||||
|
||||
val composeBackground: Observable<Int> = prefs.dark.asObservable()
|
||||
.map { dark -> if (dark) R.color.backgroundDark else R.color.backgroundLight }
|
||||
.map { res -> context.resources.getColor(res) }
|
||||
|
||||
val switchThumbEnabled: Observable<Int> = prefs.dark.asObservable()
|
||||
.map { dark ->
|
||||
when (dark) {
|
||||
true -> R.color.switch_thumb_enabled_dark
|
||||
false -> R.color.switch_thumb_enabled_light
|
||||
}
|
||||
}
|
||||
.map { dark -> if (dark) R.color.switch_thumb_enabled_dark else R.color.switch_thumb_enabled_light }
|
||||
.map { res -> context.resources.getColor(res) }
|
||||
|
||||
val switchThumbDisabled: Observable<Int> = prefs.dark.asObservable()
|
||||
.map { dark ->
|
||||
when (dark) {
|
||||
true -> R.color.switch_thumb_disabled_dark
|
||||
false -> R.color.switch_thumb_disabled_light
|
||||
}
|
||||
}
|
||||
.map { dark -> if (dark) R.color.switch_thumb_disabled_dark else R.color.switch_thumb_disabled_light }
|
||||
.map { res -> context.resources.getColor(res) }
|
||||
|
||||
val switchTrackEnabled: Observable<Int> = prefs.dark.asObservable()
|
||||
.map { dark ->
|
||||
when (dark) {
|
||||
true -> R.color.switch_track_enabled_dark
|
||||
false -> R.color.switch_track_enabled_light
|
||||
}
|
||||
}
|
||||
.map { dark -> if (dark) R.color.switch_track_enabled_dark else R.color.switch_track_enabled_light }
|
||||
.map { res -> context.resources.getColor(res) }
|
||||
|
||||
val switchTrackDisabled: Observable<Int> = prefs.dark.asObservable()
|
||||
.map { dark ->
|
||||
when (dark) {
|
||||
true -> R.color.switch_track_disabled_dark
|
||||
false -> R.color.switch_track_disabled_light
|
||||
}
|
||||
}
|
||||
.map { dark -> if (dark) R.color.switch_track_disabled_dark else R.color.switch_track_disabled_light }
|
||||
.map { res -> context.resources.getColor(res) }
|
||||
|
||||
val bubbleColor = 0xFFFFFFFF.toInt()
|
||||
|
||||
@@ -45,6 +45,15 @@ abstract class QkActivity<VM : QkViewModel<*, *>> : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPostCreate(savedInstanceState: Bundle?) {
|
||||
super.onPostCreate(savedInstanceState)
|
||||
|
||||
disposables += colors.background
|
||||
.doOnNext { color -> window.statusBarColor = color }
|
||||
.doOnNext { color -> toolbar?.setBackgroundColor(color) }
|
||||
.subscribe()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
disposables.dispose()
|
||||
|
||||
@@ -72,7 +72,6 @@ class ComposeActivity : QkActivity<ComposeViewModel>(), ComposeView {
|
||||
messageList.layoutManager = layoutManager
|
||||
messageList.adapter = messageAdapter
|
||||
|
||||
|
||||
val states = arrayOf(
|
||||
intArrayOf(android.R.attr.state_enabled),
|
||||
intArrayOf(-android.R.attr.state_enabled))
|
||||
@@ -81,6 +80,12 @@ class ComposeActivity : QkActivity<ComposeViewModel>(), ComposeView {
|
||||
.map { color -> ColorStateList(states, intArrayOf(color, colors.textTertiary)) }
|
||||
.subscribe { tintList -> send.imageTintList = tintList }
|
||||
|
||||
disposables += colors.background
|
||||
.subscribe { color -> composeBar.setBackgroundColor(color) }
|
||||
|
||||
disposables += colors.composeBackground
|
||||
.subscribe { color -> window.decorView.setBackgroundColor(color) }
|
||||
|
||||
window.callback = ComposeWindowCallback(window.callback, this)
|
||||
}
|
||||
|
||||
|
||||
@@ -66,6 +66,11 @@ class MainActivity : QkActivity<MainViewModel>(), MainView {
|
||||
// Don't allow clicks to pass through the drawer layout
|
||||
drawer.clicks().subscribe()
|
||||
|
||||
disposables += colors.background
|
||||
.doOnNext { color -> window.decorView.setBackgroundColor(color) }
|
||||
.doOnNext { color -> drawer.setBackgroundColor(color) }
|
||||
.subscribe()
|
||||
|
||||
val states = arrayOf(
|
||||
intArrayOf(android.R.attr.state_selected),
|
||||
intArrayOf(-android.R.attr.state_selected))
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.moez.QKSMS.R
|
||||
import com.moez.QKSMS.common.di.appComponent
|
||||
import com.moez.QKSMS.presentation.base.QkActivity
|
||||
import com.moez.QKSMS.presentation.view.PreferenceView
|
||||
import io.reactivex.rxkotlin.plusAssign
|
||||
import io.reactivex.subjects.PublishSubject
|
||||
import io.reactivex.subjects.Subject
|
||||
import kotlinx.android.synthetic.main.settings_activity.*
|
||||
@@ -59,6 +60,9 @@ class SettingsActivity : QkActivity<SettingsViewModel>(), SettingsView {
|
||||
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||
viewModel.bindView(this)
|
||||
|
||||
disposables += colors.background
|
||||
.subscribe { color -> window.decorView.setBackgroundColor(color) }
|
||||
|
||||
// Listen to clicks for all of the preferences
|
||||
(0 until preferences.childCount)
|
||||
.map { index -> preferences.getChildAt(index) }
|
||||
|
||||
Reference in New Issue
Block a user