mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-29 18:53:20 -05:00
Themes cleanup (#4894)
This commit is contained in:
parent
17f7dea21b
commit
ad57fde1c5
4 changed files with 43 additions and 75 deletions
|
@ -1,65 +1,39 @@
|
||||||
package eu.kanade.tachiyomi.ui.base.activity
|
package eu.kanade.tachiyomi.ui.base.activity
|
||||||
|
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration.UI_MODE_NIGHT_MASK
|
||||||
import android.os.Build
|
import android.content.res.Configuration.UI_MODE_NIGHT_YES
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
|
import eu.kanade.tachiyomi.data.preference.PreferenceValues.DarkThemeVariant
|
||||||
|
import eu.kanade.tachiyomi.data.preference.PreferenceValues.LightThemeVariant
|
||||||
|
import eu.kanade.tachiyomi.data.preference.PreferenceValues.ThemeMode
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferenceValues as Values
|
|
||||||
|
|
||||||
abstract class BaseThemedActivity : AppCompatActivity() {
|
abstract class BaseThemedActivity : AppCompatActivity() {
|
||||||
|
|
||||||
val preferences: PreferencesHelper by injectLazy()
|
val preferences: PreferencesHelper by injectLazy()
|
||||||
|
|
||||||
private val isDarkMode: Boolean by lazy {
|
|
||||||
val themeMode = preferences.themeMode().get()
|
|
||||||
(themeMode == Values.ThemeMode.dark) ||
|
|
||||||
(
|
|
||||||
themeMode == Values.ThemeMode.system &&
|
|
||||||
(resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK == Configuration.UI_MODE_NIGHT_YES)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
private val lightTheme: Int by lazy {
|
|
||||||
when (preferences.themeLight().get()) {
|
|
||||||
Values.LightThemeVariant.blue -> R.style.Theme_Tachiyomi_LightBlue
|
|
||||||
else -> {
|
|
||||||
when {
|
|
||||||
// Light status + navigation bar
|
|
||||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1 -> {
|
|
||||||
R.style.Theme_Tachiyomi_Light_Api27
|
|
||||||
}
|
|
||||||
// Light status bar + fallback gray navigation bar
|
|
||||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.M -> {
|
|
||||||
R.style.Theme_Tachiyomi_Light_Api23
|
|
||||||
}
|
|
||||||
// Fallback gray status + navigation bar
|
|
||||||
else -> {
|
|
||||||
R.style.Theme_Tachiyomi_Light
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private val darkTheme: Int by lazy {
|
|
||||||
when (preferences.themeDark().get()) {
|
|
||||||
Values.DarkThemeVariant.blue -> R.style.Theme_Tachiyomi_DarkBlue
|
|
||||||
Values.DarkThemeVariant.amoled -> R.style.Theme_Tachiyomi_Amoled
|
|
||||||
else -> R.style.Theme_Tachiyomi_Dark
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
setTheme(
|
val isDarkMode = when (preferences.themeMode().get()) {
|
||||||
when {
|
ThemeMode.light -> false
|
||||||
isDarkMode -> darkTheme
|
ThemeMode.dark -> true
|
||||||
else -> lightTheme
|
ThemeMode.system -> resources.configuration.uiMode and UI_MODE_NIGHT_MASK == UI_MODE_NIGHT_YES
|
||||||
|
}
|
||||||
|
val themeId = if (isDarkMode) {
|
||||||
|
when (preferences.themeDark().get()) {
|
||||||
|
DarkThemeVariant.default -> R.style.Theme_Tachiyomi_Dark
|
||||||
|
DarkThemeVariant.blue -> R.style.Theme_Tachiyomi_Dark_Blue
|
||||||
|
DarkThemeVariant.amoled -> R.style.Theme_Tachiyomi_Dark_Amoled
|
||||||
}
|
}
|
||||||
)
|
} else {
|
||||||
|
when (preferences.themeLight().get()) {
|
||||||
|
LightThemeVariant.default -> R.style.Theme_Tachiyomi_Light
|
||||||
|
LightThemeVariant.blue -> R.style.Theme_Tachiyomi_Light_Blue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setTheme(themeId)
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
<style name="Base.V23.Theme.Tachiyomi.Light" parent="Base.Theme.Tachiyomi.Light">
|
||||||
<style name="Theme.Tachiyomi.Light.Api23">
|
<item name="android:statusBarColor">?attr/colorPrimary</item>
|
||||||
<item name="android:statusBarColor">@color/md_white_1000</item>
|
|
||||||
<item name="android:windowLightStatusBar">true</item>
|
<item name="android:windowLightStatusBar">true</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="Theme.Tachiyomi.Light" parent="Base.V23.Theme.Tachiyomi.Light" />
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
<style name="Base.V27.Theme.Tachiyomi.Light" parent="Base.V23.Theme.Tachiyomi.Light">
|
||||||
<style name="Theme.Tachiyomi.Light.Api27">
|
<item name="android:navigationBarColor">?attr/colorPrimary</item>
|
||||||
<item name="android:statusBarColor">@color/md_white_1000</item>
|
|
||||||
<item name="android:windowLightStatusBar">true</item>
|
|
||||||
|
|
||||||
<item name="android:navigationBarColor">@color/md_white_1000</item>
|
|
||||||
<item name="android:windowLightNavigationBar">true</item>
|
<item name="android:windowLightNavigationBar">true</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="Theme.Tachiyomi.Light" parent="Base.V27.Theme.Tachiyomi.Light" />
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -47,8 +47,9 @@
|
||||||
<item name="android:textDirection">locale</item>
|
<item name="android:textDirection">locale</item>
|
||||||
|
|
||||||
<!-- Themes -->
|
<!-- Themes -->
|
||||||
<item name="android:statusBarColor">?attr/colorPrimary</item>
|
<item name="android:statusBarColor">@color/md_black_1000</item>
|
||||||
<item name="android:navigationBarColor">?attr/colorPrimary</item>
|
<item name="android:navigationBarColor">@color/md_black_1000</item>
|
||||||
|
<item name="android:navigationBarDividerColor" tools:targetApi="o_mr1">@null</item>
|
||||||
<item name="android:enforceNavigationBarContrast" tools:targetApi="Q">false</item>
|
<item name="android:enforceNavigationBarContrast" tools:targetApi="Q">false</item>
|
||||||
<item name="windowActionModeOverlay">true</item>
|
<item name="windowActionModeOverlay">true</item>
|
||||||
<item name="elevationOverlayEnabled">false</item>
|
<item name="elevationOverlayEnabled">false</item>
|
||||||
|
@ -84,28 +85,24 @@
|
||||||
<!-- Custom Attributes-->
|
<!-- Custom Attributes-->
|
||||||
<item name="colorLibrarySelection">?attr/colorAccent</item>
|
<item name="colorLibrarySelection">?attr/colorAccent</item>
|
||||||
<item name="colorLibrarySelectionActive">@color/selectorColorLight</item>
|
<item name="colorLibrarySelectionActive">@color/selectorColorLight</item>
|
||||||
<item name="colorFilterActive">@color/filterColorDark</item>
|
<item name="colorFilterActive">@color/filterColorLight</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<!--===========-->
|
<!--===========-->
|
||||||
<!-- Main Theme-->
|
<!-- Main Theme-->
|
||||||
<!--===========-->
|
<!--===========-->
|
||||||
<style name="Theme.Tachiyomi.Light" parent="Theme.Base">
|
<style name="Base.Theme.Tachiyomi.Light" parent="Theme.Base" />
|
||||||
<item name="android:statusBarColor">@color/md_black_1000</item>
|
<style name="Theme.Tachiyomi.Light" parent="Base.Theme.Tachiyomi.Light" />
|
||||||
<item name="android:navigationBarColor">@color/md_black_1000_54</item>
|
|
||||||
|
|
||||||
<item name="colorFilterActive">@color/filterColorLight</item>
|
<style name="Theme.Tachiyomi.Light.Blue">
|
||||||
</style>
|
|
||||||
|
|
||||||
<style name="Theme.Tachiyomi.LightBlue" parent="Theme.Base">
|
|
||||||
<item name="colorPrimary">@color/colorPrimary</item>
|
<item name="colorPrimary">@color/colorPrimary</item>
|
||||||
<item name="colorOnPrimary">@color/textColorPrimaryDark</item>
|
<item name="colorOnPrimary">@color/textColorPrimaryDark</item>
|
||||||
<item name="colorAccentOnPrimary">@color/textColorPrimaryDark</item>
|
<item name="colorAccentOnPrimary">@color/textColorPrimaryDark</item>
|
||||||
<item name="colorPrimaryVariant">@color/colorPrimaryDark</item>
|
<item name="colorPrimaryVariant">@color/colorPrimaryDark</item>
|
||||||
|
<item name="colorFilterActive">@color/filterColorDark</item>
|
||||||
<item name="actionBarTheme">@style/Theme.Toolbar.Light</item>
|
<item name="actionBarTheme">@style/Theme.Toolbar.Light</item>
|
||||||
|
<item name="android:windowLightStatusBar" tools:targetApi="m">false</item>
|
||||||
<item name="android:navigationBarColor">@color/colorPrimary_70</item>
|
<item name="android:windowLightNavigationBar" tools:targetApi="o_mr1">false</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<!--=============-->
|
<!--=============-->
|
||||||
|
@ -145,6 +142,7 @@
|
||||||
<!-- Themes -->
|
<!-- Themes -->
|
||||||
<item name="android:statusBarColor">?attr/colorPrimary</item>
|
<item name="android:statusBarColor">?attr/colorPrimary</item>
|
||||||
<item name="android:navigationBarColor">?attr/colorPrimary</item>
|
<item name="android:navigationBarColor">?attr/colorPrimary</item>
|
||||||
|
<item name="android:navigationBarDividerColor" tools:targetApi="o_mr1">@null</item>
|
||||||
<item name="android:enforceNavigationBarContrast" tools:targetApi="Q">false</item>
|
<item name="android:enforceNavigationBarContrast" tools:targetApi="Q">false</item>
|
||||||
<item name="windowActionModeOverlay">true</item>
|
<item name="windowActionModeOverlay">true</item>
|
||||||
<item name="elevationOverlayEnabled">false</item>
|
<item name="elevationOverlayEnabled">false</item>
|
||||||
|
@ -184,16 +182,15 @@
|
||||||
<item name="colorFilterActive">@color/filterColorDark</item>
|
<item name="colorFilterActive">@color/filterColorDark</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="Theme.Tachiyomi.Dark" parent="Theme.Base.Dark">
|
<style name="Theme.Tachiyomi.Dark" parent="Theme.Base.Dark" />
|
||||||
</style>
|
|
||||||
|
|
||||||
<style name="Theme.Tachiyomi.DarkBlue" parent="Theme.Base.Dark">
|
<style name="Theme.Tachiyomi.Dark.Blue">
|
||||||
<item name="colorPrimary">@color/colorPrimary</item>
|
<item name="colorPrimary">@color/colorPrimary</item>
|
||||||
<item name="colorAccentOnPrimary">@color/textColorPrimaryDark</item>
|
<item name="colorAccentOnPrimary">@color/textColorPrimaryDark</item>
|
||||||
<item name="colorPrimaryVariant">@color/colorPrimary</item>
|
<item name="colorPrimaryVariant">@color/colorPrimary</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="Theme.Tachiyomi.Amoled" parent="Theme.Base.Dark">
|
<style name="Theme.Tachiyomi.Dark.Amoled">
|
||||||
<item name="colorPrimary">@color/colorAmoledPrimary</item>
|
<item name="colorPrimary">@color/colorAmoledPrimary</item>
|
||||||
<item name="colorPrimaryVariant">@color/colorAmoledPrimary</item>
|
<item name="colorPrimaryVariant">@color/colorAmoledPrimary</item>
|
||||||
<item name="colorSurface">@color/colorAmoledPrimary</item>
|
<item name="colorSurface">@color/colorAmoledPrimary</item>
|
||||||
|
@ -255,7 +252,7 @@
|
||||||
<!--===============-->
|
<!--===============-->
|
||||||
<!-- Launch Screen -->
|
<!-- Launch Screen -->
|
||||||
<!--===============-->
|
<!--===============-->
|
||||||
<style name="Theme.Splash" parent="Theme.Tachiyomi.LightBlue">
|
<style name="Theme.Splash" parent="Theme.Tachiyomi.Light.Blue">
|
||||||
<item name="colorBackgroundSplash">@color/colorPrimary</item>
|
<item name="colorBackgroundSplash">@color/colorPrimary</item>
|
||||||
|
|
||||||
<item name="android:windowBackground">@drawable/splash_background</item>
|
<item name="android:windowBackground">@drawable/splash_background</item>
|
||||||
|
|
Loading…
Reference in a new issue