forked from github/wulkanowy-mirror
Change background color of navigation and notification bars (#1120)
This commit is contained in:
parent
4fceb854b3
commit
ff425d6d2b
@ -56,7 +56,7 @@
|
|||||||
android:name=".ui.modules.login.LoginActivity"
|
android:name=".ui.modules.login.LoginActivity"
|
||||||
android:configChanges="orientation|screenSize"
|
android:configChanges="orientation|screenSize"
|
||||||
android:label="@string/login_title"
|
android:label="@string/login_title"
|
||||||
android:theme="@style/WulkanowyTheme.NoActionBar"
|
android:theme="@style/WulkanowyTheme.Login"
|
||||||
android:windowSoftInputMode="adjustResize" />
|
android:windowSoftInputMode="adjustResize" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.modules.main.MainActivity"
|
android:name=".ui.modules.main.MainActivity"
|
||||||
@ -68,7 +68,7 @@
|
|||||||
android:name=".ui.modules.message.send.SendMessageActivity"
|
android:name=".ui.modules.message.send.SendMessageActivity"
|
||||||
android:configChanges="orientation|screenSize"
|
android:configChanges="orientation|screenSize"
|
||||||
android:label="@string/send_message_title"
|
android:label="@string/send_message_title"
|
||||||
android:theme="@style/WulkanowyTheme.NoActionBar"
|
android:theme="@style/WulkanowyTheme.MessageSend"
|
||||||
android:windowSoftInputMode="adjustResize" />
|
android:windowSoftInputMode="adjustResize" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.modules.timetablewidget.TimetableWidgetConfigureActivity"
|
android:name=".ui.modules.timetablewidget.TimetableWidgetConfigureActivity"
|
||||||
|
@ -8,6 +8,9 @@ import androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_NO
|
|||||||
import androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES
|
import androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES
|
||||||
import io.github.wulkanowy.R
|
import io.github.wulkanowy.R
|
||||||
import io.github.wulkanowy.data.repositories.PreferencesRepository
|
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.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@ -17,7 +20,13 @@ class ThemeManager @Inject constructor(private val preferencesRepository: Prefer
|
|||||||
fun applyActivityTheme(activity: AppCompatActivity) {
|
fun applyActivityTheme(activity: AppCompatActivity) {
|
||||||
if (isThemeApplicable(activity)) {
|
if (isThemeApplicable(activity)) {
|
||||||
applyDefaultTheme()
|
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 {
|
private fun isThemeApplicable(activity: AppCompatActivity): Boolean {
|
||||||
return activity.packageManager.getPackageInfo(activity.packageName, GET_ACTIVITIES)
|
return activity.packageManager
|
||||||
.activities.singleOrNull { it.name == activity::class.java.canonicalName }?.theme
|
.getPackageInfo(activity.packageName, GET_ACTIVITIES)
|
||||||
.let { it == R.style.WulkanowyTheme_Black || it == R.style.WulkanowyTheme_NoActionBar }
|
.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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import android.graphics.drawable.Icon
|
|||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Build.VERSION.SDK_INT
|
import android.os.Build.VERSION.SDK_INT
|
||||||
import android.os.Build.VERSION_CODES.LOLLIPOP
|
import android.os.Build.VERSION_CODES.LOLLIPOP
|
||||||
|
import android.os.Build.VERSION_CODES.P
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
@ -194,6 +195,7 @@ class MainActivity : BaseActivity<MainPresenter, ActivityMainBinding>(), MainVie
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("NewApi")
|
||||||
override fun initView() {
|
override fun initView() {
|
||||||
with(binding.mainToolbar) {
|
with(binding.mainToolbar) {
|
||||||
if (SDK_INT >= LOLLIPOP) stateListAnimator = null
|
if (SDK_INT >= LOLLIPOP) stateListAnimator = null
|
||||||
@ -233,11 +235,17 @@ class MainActivity : BaseActivity<MainPresenter, ActivityMainBinding>(), MainVie
|
|||||||
|
|
||||||
with(navController) {
|
with(navController) {
|
||||||
setOnViewChangeListener { section, name ->
|
setOnViewChangeListener { section, name ->
|
||||||
binding.mainBottomNav.visibility =
|
|
||||||
if (section == MainView.Section.ACCOUNT || section == MainView.Section.STUDENT_INFO) {
|
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 {
|
} else {
|
||||||
View.VISIBLE
|
binding.mainBottomNav.visibility = View.VISIBLE
|
||||||
|
if (appInfo.systemVersion >= P) {
|
||||||
|
window.navigationBarColor =
|
||||||
|
getThemeAttrColor(android.R.attr.navigationBarColor)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
analytics.setCurrentScreen(this@MainActivity, name)
|
analytics.setCurrentScreen(this@MainActivity, name)
|
||||||
|
@ -10,14 +10,43 @@
|
|||||||
<item name="colorSwipeRefresh">@color/colorSwipeRefreshDark</item>
|
<item name="colorSwipeRefresh">@color/colorSwipeRefreshDark</item>
|
||||||
<item name="android:windowBackground">?colorSurface</item>
|
<item name="android:windowBackground">?colorSurface</item>
|
||||||
<item name="android:textColor">?android:textColorPrimary</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>
|
||||||
<item name="android:statusBarColor" tools:targetApi="lollipop">@android:color/black</item>
|
|
||||||
<item name="android:windowLightNavigationBar" tools:targetApi="o_mr1">false</item>
|
<item name="android:windowLightNavigationBar" tools:targetApi="o_mr1">false</item>
|
||||||
<item name="mdtp_theme_dark">true</item>
|
<item name="mdtp_theme_dark">true</item>
|
||||||
|
<item name="android:windowLightStatusBar" tools:targetApi="m">false</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="WulkanowyTheme.Black" parent="WulkanowyTheme.NoActionBar">
|
<style name="WulkanowyTheme.Black" parent="WulkanowyTheme.NoActionBar">
|
||||||
<item name="colorSurface">@android:color/black</item>
|
<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>
|
</style>
|
||||||
</resources>
|
</resources>
|
||||||
|
14
app/src/main/res/values-v23/styles.xml
Normal file
14
app/src/main/res/values-v23/styles.xml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?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>
|
15
app/src/main/res/values-v26/styles.xml
Normal file
15
app/src/main/res/values-v26/styles.xml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<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>
|
@ -1,9 +1,10 @@
|
|||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
<style name="WulkanowyTheme" parent="BaseWulkanowyTheme">
|
<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:navigationBarColor">@android:color/white</item>
|
||||||
<item name="android:windowLightNavigationBar">true</item>
|
<item name="android:windowLightNavigationBar">true</item>
|
||||||
|
<item name="android:windowLightStatusBar">true</item>
|
||||||
|
<item name="android:statusBarColor">@android:color/white</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="WulkanowyTheme.SplashScreen" parent="WulkanowyTheme.NoActionBar">
|
<style name="WulkanowyTheme.SplashScreen" parent="WulkanowyTheme.NoActionBar">
|
||||||
@ -11,5 +12,6 @@
|
|||||||
<item name="android:statusBarColor">@color/colorPrimaryDark</item>
|
<item name="android:statusBarColor">@color/colorPrimaryDark</item>
|
||||||
<item name="android:navigationBarColor">@color/colorPrimaryDark</item>
|
<item name="android:navigationBarColor">@color/colorPrimaryDark</item>
|
||||||
<item name="android:windowLightNavigationBar">false</item>
|
<item name="android:windowLightNavigationBar">false</item>
|
||||||
|
<item name="android:windowLightStatusBar">false</item>
|
||||||
</style>
|
</style>
|
||||||
</resources>
|
</resources>
|
17
app/src/main/res/values-v29/styles.xml
Normal file
17
app/src/main/res/values-v29/styles.xml
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<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>
|
@ -6,6 +6,11 @@
|
|||||||
<color name="colorError">#ff5722</color>
|
<color name="colorError">#ff5722</color>
|
||||||
<color name="colorErrorLight">#e84853</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_light">#ffd54f</color>
|
||||||
<color name="timetable_change_dark">#ff8f00</color>
|
<color name="timetable_change_dark">#ff8f00</color>
|
||||||
|
|
||||||
|
@ -34,4 +34,8 @@
|
|||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="mdtp_ActionButton.Text" parent="Widget.MaterialComponents.Button.TextButton.Dialog" />
|
<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>
|
</resources>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user