Change background color of navigation and notification bars
MODIFY
app/src/main/AndroidManifest.xml
app/src/main/AndroidManifest.xml
android:name=".ui.modules.login.LoginActivity"
android:configChanges="orientation|screenSize"
android:label="@string/login_title"
- android:theme="@style/WulkanowyTheme.NoActionBar"
+ android:theme="@style/WulkanowyTheme.Login"
android:windowSoftInputMode="adjustResize" />
<activity
android:name=".ui.modules.main.MainActivity"
android:name=".ui.modules.message.send.SendMessageActivity"
android:configChanges="orientation|screenSize"
android:label="@string/send_message_title"
- android:theme="@style/WulkanowyTheme.NoActionBar"
+ android:theme="@style/WulkanowyTheme.MessageSend"
android:windowSoftInputMode="adjustResize" />
<activity
android:name=".ui.modules.timetablewidget.TimetableWidgetConfigureActivity"

MODIFY
app/src/main/java/io/github/wulkanowy/ui/base/ThemeManager.kt
app/src/main/java/io/github/wulkanowy/ui/base/ThemeManager.kt
@@ -8,6 +8,9 @@ import androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_NO
import androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES
import io.github.wulkanowy.R
import io.github.wulkanowy.data.repositories.PreferencesRepository
+import io.github.wulkanowy.ui.modules.login.LoginActivity
+import io.github.wulkanowy.ui.modules.main.MainActivity
+import io.github.wulkanowy.ui.modules.message.send.SendMessageActivity
import javax.inject.Inject
import javax.inject.Singleton
@@ -17,7 +20,13 @@ class ThemeManager @Inject constructor(private val preferencesRepository: Prefer
fun applyActivityTheme(activity: AppCompatActivity) {
if (isThemeApplicable(activity)) {
applyDefaultTheme()
- if (preferencesRepository.appTheme == "black") activity.setTheme(R.style.WulkanowyTheme_Black)
+ if (preferencesRepository.appTheme == "black") {
+ when (activity) {
+ is MainActivity -> activity.setTheme(R.style.WulkanowyTheme_Black)
+ is LoginActivity -> activity.setTheme(R.style.WulkanowyTheme_Login_Black)
+ is SendMessageActivity -> activity.setTheme(R.style.WulkanowyTheme_MessageSend_Black)
+ }
+ }
}
}
@@ -33,8 +42,13 @@ class ThemeManager @Inject constructor(private val preferencesRepository: Prefer
}
private fun isThemeApplicable(activity: AppCompatActivity): Boolean {
- return activity.packageManager.getPackageInfo(activity.packageName, GET_ACTIVITIES)
- .activities.singleOrNull { it.name == activity::class.java.canonicalName }?.theme
- .let { it == R.style.WulkanowyTheme_Black || it == R.style.WulkanowyTheme_NoActionBar }
+ return activity.packageManager
+ .getPackageInfo(activity.packageName, GET_ACTIVITIES)
+ .activities.singleOrNull { it.name == activity::class.java.canonicalName }
+ ?.theme.let {
+ it == R.style.WulkanowyTheme_Black || it == R.style.WulkanowyTheme_NoActionBar
+ || it == R.style.WulkanowyTheme_Login || it == R.style.WulkanowyTheme_Login_Black
+ || it == R.style.WulkanowyTheme_MessageSend || it == R.style.WulkanowyTheme_MessageSend_Black
+ }
}
}

MODIFY
app/src/main/java/io/github/wulkanowy/ui/modules/main/MainActivity.kt
app/src/main/java/io/github/wulkanowy/ui/modules/main/MainActivity.kt
@@ -11,6 +11,7 @@ import android.graphics.drawable.Icon
import android.os.Build
import android.os.Build.VERSION.SDK_INT
import android.os.Build.VERSION_CODES.LOLLIPOP
+import android.os.Build.VERSION_CODES.P
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
@@ -194,6 +195,7 @@ class MainActivity : BaseActivity<MainPresenter, ActivityMainBinding>(), MainVie
return true
}
+ @SuppressLint("NewApi")
override fun initView() {
with(binding.mainToolbar) {
if (SDK_INT >= LOLLIPOP) stateListAnimator = null
@@ -233,11 +235,17 @@ class MainActivity : BaseActivity<MainPresenter, ActivityMainBinding>(), MainVie
with(navController) {
setOnViewChangeListener { section, name ->
- binding.mainBottomNav.visibility =
if (section == MainView.Section.ACCOUNT || section == MainView.Section.STUDENT_INFO) {
- View.GONE
+ binding.mainBottomNav.visibility = View.GONE
+ if (appInfo.systemVersion >= P) {
+ window.navigationBarColor = getThemeAttrColor(R.attr.colorSurface)
+ }
} else {
- View.VISIBLE
+ binding.mainBottomNav.visibility = View.VISIBLE
+ if (appInfo.systemVersion >= P) {
+ window.navigationBarColor =
+ getThemeAttrColor(android.R.attr.navigationBarColor)
+ }
}
analytics.setCurrentScreen(this@MainActivity, name)

MODIFY
app/src/main/res/values-night/styles.xml
app/src/main/res/values-night/styles.xml
<item name="colorSwipeRefresh">@color/colorSwipeRefreshDark</item>
<item name="android:windowBackground">?colorSurface</item>
<item name="android:textColor">?android:textColorPrimary</item>
- <item name="android:navigationBarColor" tools:targetApi="lollipop">@android:color/black
+ <item name="android:navigationBarColor" tools:targetApi="lollipop">
+ @color/colorNavigationBarLight
+ </item>
+ <item name="android:statusBarColor" tools:targetApi="lollipop">
+ @color/colorStatusBarLight
</item>
- <item name="android:statusBarColor" tools:targetApi="lollipop">@android:color/black</item>
<item name="android:windowLightNavigationBar" tools:targetApi="o_mr1">false</item>
<item name="mdtp_theme_dark">true</item>
+ <item name="android:windowLightStatusBar" tools:targetApi="m">false</item>
</style>
<style name="WulkanowyTheme.Black" parent="WulkanowyTheme.NoActionBar">
<item name="colorSurface">@android:color/black</item>
+ <item name="android:navigationBarColor" tools:targetApi="lollipop">
+ @color/colorNavigationBarBlack
+ </item>
+ <item name="android:statusBarColor" tools:targetApi="lollipop">@android:color/black</item>
+ <item name="android:windowLightStatusBar" tools:targetApi="m">false</item>
+ </style>
+
+ <style name="WulkanowyTheme.Login" parent="WulkanowyTheme.NoActionBar">
+ <item name="android:navigationBarColor" tools:targetApi="lollipop">?colorSurface</item>
+ <item name="android:statusBarColor" tools:targetApi="lollipop">?colorSurface</item>
+ </style>
+
+ <style name="WulkanowyTheme.Login.Black" parent="WulkanowyTheme.Black">
+ <item name="android:navigationBarColor" tools:targetApi="lollipop">?colorSurface</item>
+ <item name="android:statusBarColor" tools:targetApi="lollipop">?colorSurface</item>
+ </style>
+
+ <style name="WulkanowyTheme.MessageSend" parent="WulkanowyTheme.NoActionBar">
+ <item name="android:navigationBarColor" tools:targetApi="lollipop">?colorSurface</item>
+ <item name="android:statusBarColor" tools:targetApi="lollipop">#1C1C1C</item>
+ </style>
+
+ <style name="WulkanowyTheme.MessageSend.Black" parent="WulkanowyTheme.Black">
+ <item name="android:navigationBarColor" tools:targetApi="lollipop">?colorSurface</item>
+ <item name="android:statusBarColor" tools:targetApi="lollipop">@android:color/black</item>
</style>
</resources>

ADD
app/src/main/res/values-v23/styles.xml
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <style name="WulkanowyTheme" parent="BaseWulkanowyTheme">
+ <item name="android:windowLightStatusBar">true</item>
+ <item name="android:statusBarColor">@android:color/white</item>
+ </style>
+
+ <style name="WulkanowyTheme.SplashScreen" parent="WulkanowyTheme.NoActionBar">
+ <item name="android:windowBackground">@drawable/layer_splash_background</item>
+ <item name="android:statusBarColor">@color/colorPrimaryDark</item>
+ <item name="android:navigationBarColor">@color/colorPrimaryDark</item>
+ <item name="android:windowLightStatusBar">false</item>
+ </style>
+</resources>
\ No newline at end of file

ADD
app/src/main/res/values-v26/styles.xml
+<resources>
+
+ <style name="WulkanowyTheme" parent="BaseWulkanowyTheme">
+ <item name="android:navigationBarColor">@android:color/black</item>
+ <item name="android:windowLightStatusBar">false</item>
+ <item name="android:statusBarColor">@android:color/darker_gray</item>
+ </style>
+
+ <style name="WulkanowyTheme.SplashScreen" parent="WulkanowyTheme.NoActionBar">
+ <item name="android:windowBackground">@drawable/layer_splash_background</item>
+ <item name="android:statusBarColor">@color/colorPrimaryDark</item>
+ <item name="android:navigationBarColor">@color/colorPrimaryDark</item>
+ <item name="android:windowLightStatusBar">false</item>
+ </style>
+</resources>

RENAME
app/src/main/res/values-v27/styles.xml
app/src/main/res/values-v28/styles.xml
<resources>
<style name="WulkanowyTheme" parent="BaseWulkanowyTheme">
- <item name="android:statusBarColor">@android:color/darker_gray</item>
<item name="android:navigationBarColor">@android:color/white</item>
<item name="android:windowLightNavigationBar">true</item>
+ <item name="android:windowLightStatusBar">true</item>
+ <item name="android:statusBarColor">@android:color/white</item>
</style>
<style name="WulkanowyTheme.SplashScreen" parent="WulkanowyTheme.NoActionBar">
<item name="android:statusBarColor">@color/colorPrimaryDark</item>
<item name="android:navigationBarColor">@color/colorPrimaryDark</item>
<item name="android:windowLightNavigationBar">false</item>
+ <item name="android:windowLightStatusBar">false</item>
</style>
</resources>
\ No newline at end of file

ADD
app/src/main/res/values-v29/styles.xml
+<resources>
+
+ <style name="WulkanowyTheme" parent="BaseWulkanowyTheme">
+ <item name="android:navigationBarColor">@android:color/white</item>
+ <item name="android:windowLightNavigationBar">true</item>
+ <item name="android:windowLightStatusBar">true</item>
+ <item name="android:statusBarColor">@android:color/white</item>
+ </style>
+
+ <style name="WulkanowyTheme.SplashScreen" parent="WulkanowyTheme.NoActionBar">
+ <item name="android:windowBackground">@drawable/layer_splash_background</item>
+ <item name="android:statusBarColor">@color/colorPrimaryDark</item>
+ <item name="android:navigationBarColor">@color/colorPrimaryDark</item>
+ <item name="android:windowLightNavigationBar">false</item>
+ <item name="android:windowLightStatusBar">false</item>
+ </style>
+</resources>
\ No newline at end of file

MODIFY
app/src/main/res/values/colors.xml
app/src/main/res/values/colors.xml
<color name="colorError">#ff5722</color>
<color name="colorErrorLight">#e84853</color>
+ <color name="colorNavigationBarLight">#2E2E2E</color>
+ <color name="colorNavigationBarBlack">#1E1E1E</color>
+
+ <color name="colorStatusBarLight">#1C1C1C</color>
+
<color name="timetable_change_light">#ffd54f</color>
<color name="timetable_change_dark">#ff8f00</color>

MODIFY
app/src/main/res/values/styles.xml
app/src/main/res/values/styles.xml
</style>
<style name="mdtp_ActionButton.Text" parent="Widget.MaterialComponents.Button.TextButton.Dialog" />
+
+ <style name="WulkanowyTheme.Login" parent="WulkanowyTheme.NoActionBar" />
+
+ <style name="WulkanowyTheme.MessageSend" parent="WulkanowyTheme.NoActionBar" />
</resources>

Change background color of navigation and notification bars (#1120)