Change color of navigation bar based on theme

This commit is contained in:
Moez Bhatti
2018-04-02 23:58:58 -04:00
parent 30506ce4a4
commit c8c5dd3aad
9 changed files with 43 additions and 4 deletions
@@ -65,13 +65,17 @@ abstract class QkThemedActivity<VM : QkViewModel<*, *>> : QkActivity<VM>() {
.autoDisposable(scope())
.subscribe { res -> setTheme(res) }
colors.statusBarIcons
colors.systemBarIcons
.autoDisposable(scope())
.subscribe { systemUiVisibility -> window.decorView.systemUiVisibility = systemUiVisibility }
colors.statusBar
.autoDisposable(scope())
.subscribe { color -> window.statusBarColor = color }
colors.background
.autoDisposable(scope())
.subscribe { color -> window.navigationBarColor = color }
}
override fun onPostCreate(savedInstanceState: Bundle?) {
@@ -105,7 +109,8 @@ abstract class QkThemedActivity<VM : QkViewModel<*, *>> : QkActivity<VM>() {
colors.toolbarColor
.doOnNext { color -> toolbar?.setBackgroundTint(color) }
.doOnNext { color -> // Set the color for the recent apps title
.doOnNext { color ->
// Set the color for the recent apps title
val icon = BitmapFactory.decodeResource(resources, R.mipmap.ic_launcher)
val taskDesc = ActivityManager.TaskDescription(getString(R.string.app_name), icon, color)
setTaskDescription(taskDesc)
@@ -93,9 +93,9 @@ class Colors @Inject constructor(private val context: Context, private val prefs
})
@SuppressLint("InlinedApi")
val statusBarIcons: Observable<Int> = prefs.night.asObservable()
val systemBarIcons: Observable<Int> = prefs.night.asObservable()
.map { night -> night || Build.VERSION.SDK_INT < Build.VERSION_CODES.M }
.map { lightIcons -> if (lightIcons) 0 else View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR }
.map { lightIcons -> if (lightIcons) 0 else View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR or View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR}
.distinctUntilChanged()
val statusBar: Observable<Int> = Observables.combineLatest(prefs.night.asObservable(), prefs.black.asObservable(),