forked from upstream-mirrors/quik
Change color of navigation bar based on theme
This commit is contained in:
@@ -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(),
|
||||
|
||||
@@ -214,4 +214,9 @@
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/toolbar" />
|
||||
|
||||
<common.widget.Separator
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent" />
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
@@ -122,4 +122,9 @@
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/toolbar" />
|
||||
|
||||
<common.widget.Separator
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent" />
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
@@ -135,6 +135,11 @@
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/toolbar" />
|
||||
|
||||
<common.widget.Separator
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent" />
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
|
||||
<include
|
||||
|
||||
@@ -73,6 +73,11 @@
|
||||
android:layout_height="8dp"
|
||||
android:background="@drawable/ab_shadow" />
|
||||
|
||||
<common.widget.Separator
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_gravity="bottom" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -199,4 +199,9 @@
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/toolbar" />
|
||||
|
||||
<common.widget.Separator
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent" />
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
@@ -83,4 +83,8 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<common.widget.Separator
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp" />
|
||||
|
||||
</LinearLayout>
|
||||
@@ -62,6 +62,11 @@
|
||||
android:layout_height="8dp"
|
||||
android:background="@drawable/ab_shadow" />
|
||||
|
||||
<common.widget.Separator
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_gravity="bottom" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
||||
Reference in New Issue
Block a user