mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-21 13:18: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() }
|
.map { it.last() }
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.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()
|
val switchThumbEnabled: Observable<Int> = prefs.dark.asObservable()
|
||||||
.map { dark ->
|
.map { dark -> if (dark) R.color.switch_thumb_enabled_dark else R.color.switch_thumb_enabled_light }
|
||||||
when (dark) {
|
|
||||||
true -> R.color.switch_thumb_enabled_dark
|
|
||||||
false -> R.color.switch_thumb_enabled_light
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.map { res -> context.resources.getColor(res) }
|
.map { res -> context.resources.getColor(res) }
|
||||||
|
|
||||||
val switchThumbDisabled: Observable<Int> = prefs.dark.asObservable()
|
val switchThumbDisabled: Observable<Int> = prefs.dark.asObservable()
|
||||||
.map { dark ->
|
.map { dark -> if (dark) R.color.switch_thumb_disabled_dark else R.color.switch_thumb_disabled_light }
|
||||||
when (dark) {
|
|
||||||
true -> R.color.switch_thumb_disabled_dark
|
|
||||||
false -> R.color.switch_thumb_disabled_light
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.map { res -> context.resources.getColor(res) }
|
.map { res -> context.resources.getColor(res) }
|
||||||
|
|
||||||
val switchTrackEnabled: Observable<Int> = prefs.dark.asObservable()
|
val switchTrackEnabled: Observable<Int> = prefs.dark.asObservable()
|
||||||
.map { dark ->
|
.map { dark -> if (dark) R.color.switch_track_enabled_dark else R.color.switch_track_enabled_light }
|
||||||
when (dark) {
|
|
||||||
true -> R.color.switch_track_enabled_dark
|
|
||||||
false -> R.color.switch_track_enabled_light
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.map { res -> context.resources.getColor(res) }
|
.map { res -> context.resources.getColor(res) }
|
||||||
|
|
||||||
val switchTrackDisabled: Observable<Int> = prefs.dark.asObservable()
|
val switchTrackDisabled: Observable<Int> = prefs.dark.asObservable()
|
||||||
.map { dark ->
|
.map { dark -> if (dark) R.color.switch_track_disabled_dark else R.color.switch_track_disabled_light }
|
||||||
when (dark) {
|
|
||||||
true -> R.color.switch_track_disabled_dark
|
|
||||||
false -> R.color.switch_track_disabled_light
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.map { res -> context.resources.getColor(res) }
|
.map { res -> context.resources.getColor(res) }
|
||||||
|
|
||||||
val bubbleColor = 0xFFFFFFFF.toInt()
|
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() {
|
override fun onDestroy() {
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
disposables.dispose()
|
disposables.dispose()
|
||||||
|
|||||||
@@ -72,7 +72,6 @@ class ComposeActivity : QkActivity<ComposeViewModel>(), ComposeView {
|
|||||||
messageList.layoutManager = layoutManager
|
messageList.layoutManager = layoutManager
|
||||||
messageList.adapter = messageAdapter
|
messageList.adapter = messageAdapter
|
||||||
|
|
||||||
|
|
||||||
val states = arrayOf(
|
val states = arrayOf(
|
||||||
intArrayOf(android.R.attr.state_enabled),
|
intArrayOf(android.R.attr.state_enabled),
|
||||||
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)) }
|
.map { color -> ColorStateList(states, intArrayOf(color, colors.textTertiary)) }
|
||||||
.subscribe { tintList -> send.imageTintList = tintList }
|
.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)
|
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
|
// Don't allow clicks to pass through the drawer layout
|
||||||
drawer.clicks().subscribe()
|
drawer.clicks().subscribe()
|
||||||
|
|
||||||
|
disposables += colors.background
|
||||||
|
.doOnNext { color -> window.decorView.setBackgroundColor(color) }
|
||||||
|
.doOnNext { color -> drawer.setBackgroundColor(color) }
|
||||||
|
.subscribe()
|
||||||
|
|
||||||
val states = arrayOf(
|
val states = arrayOf(
|
||||||
intArrayOf(android.R.attr.state_selected),
|
intArrayOf(android.R.attr.state_selected),
|
||||||
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.common.di.appComponent
|
||||||
import com.moez.QKSMS.presentation.base.QkActivity
|
import com.moez.QKSMS.presentation.base.QkActivity
|
||||||
import com.moez.QKSMS.presentation.view.PreferenceView
|
import com.moez.QKSMS.presentation.view.PreferenceView
|
||||||
|
import io.reactivex.rxkotlin.plusAssign
|
||||||
import io.reactivex.subjects.PublishSubject
|
import io.reactivex.subjects.PublishSubject
|
||||||
import io.reactivex.subjects.Subject
|
import io.reactivex.subjects.Subject
|
||||||
import kotlinx.android.synthetic.main.settings_activity.*
|
import kotlinx.android.synthetic.main.settings_activity.*
|
||||||
@@ -59,6 +60,9 @@ class SettingsActivity : QkActivity<SettingsViewModel>(), SettingsView {
|
|||||||
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||||
viewModel.bindView(this)
|
viewModel.bindView(this)
|
||||||
|
|
||||||
|
disposables += colors.background
|
||||||
|
.subscribe { color -> window.decorView.setBackgroundColor(color) }
|
||||||
|
|
||||||
// Listen to clicks for all of the preferences
|
// Listen to clicks for all of the preferences
|
||||||
(0 until preferences.childCount)
|
(0 until preferences.childCount)
|
||||||
.map { index -> preferences.getChildAt(index) }
|
.map { index -> preferences.getChildAt(index) }
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@color/backgroundLight"
|
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<include
|
<include
|
||||||
@@ -52,14 +51,13 @@
|
|||||||
android:id="@+id/composeBar"
|
android:id="@+id/composeBar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@color/white"
|
|
||||||
android:gravity="center_vertical">
|
android:gravity="center_vertical">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/attach"
|
android:id="@+id/attach"
|
||||||
android:layout_width="56dp"
|
android:layout_width="56dp"
|
||||||
android:layout_height="56dp"
|
android:layout_height="56dp"
|
||||||
android:background="?selectableItemBackgroundBorderless"
|
android:background="@drawable/ripple"
|
||||||
android:padding="16dp"
|
android:padding="16dp"
|
||||||
android:src="@drawable/ic_add_circle_black_24dp"
|
android:src="@drawable/ic_add_circle_black_24dp"
|
||||||
android:tint="@color/textSecondary" />
|
android:tint="@color/textSecondary" />
|
||||||
@@ -85,7 +83,7 @@
|
|||||||
android:id="@+id/send"
|
android:id="@+id/send"
|
||||||
android:layout_width="56dp"
|
android:layout_width="56dp"
|
||||||
android:layout_height="56dp"
|
android:layout_height="56dp"
|
||||||
android:background="?selectableItemBackgroundBorderless"
|
android:background="@drawable/ripple"
|
||||||
android:padding="16dp"
|
android:padding="16dp"
|
||||||
android:src="@drawable/ic_send_black_24dp"
|
android:src="@drawable/ic_send_black_24dp"
|
||||||
android:tint="@color/textTertiary" />
|
android:tint="@color/textTertiary" />
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="?android:attr/selectableItemBackground"
|
android:background="@drawable/ripple"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:paddingBottom="8dp"
|
android:paddingBottom="8dp"
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="?android:attr/selectableItemBackground"
|
android:background="@drawable/ripple"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:paddingBottom="8dp"
|
android:paddingBottom="8dp"
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="?android:attr/selectableItemBackground"
|
android:background="@drawable/ripple"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:paddingBottom="16dp">
|
android:paddingBottom="16dp">
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="?android:attr/selectableItemBackground"
|
android:background="@drawable/ripple"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:paddingBottom="16dp">
|
android:paddingBottom="16dp">
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
<color name="bubbleLight">#F4F4F4</color>
|
<color name="bubbleLight">#F4F4F4</color>
|
||||||
|
|
||||||
<color name="backgroundLight">#F2F2F2</color>
|
<color name="backgroundLight">#F2F2F2</color>
|
||||||
|
<color name="backgroundDark">#212121</color>
|
||||||
<color name="statusLight">#F1F1F1</color>
|
<color name="statusLight">#F1F1F1</color>
|
||||||
|
|
||||||
<color name="list_separator">#F2F2F2</color>
|
<color name="list_separator">#F2F2F2</color>
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
<style name="DrawerRow">
|
<style name="DrawerRow">
|
||||||
<item name="android:layout_height">48dp</item>
|
<item name="android:layout_height">48dp</item>
|
||||||
<item name="android:layout_width">match_parent</item>
|
<item name="android:layout_width">match_parent</item>
|
||||||
<item name="android:background">?android:attr/selectableItemBackground</item>
|
<item name="android:background">@drawable/ripple</item>
|
||||||
<item name="android:gravity">center_vertical</item>
|
<item name="android:gravity">center_vertical</item>
|
||||||
<item name="android:paddingStart">16dp</item>
|
<item name="android:paddingStart">16dp</item>
|
||||||
<item name="android:paddingEnd">16dp</item>
|
<item name="android:paddingEnd">16dp</item>
|
||||||
|
|||||||
Reference in New Issue
Block a user