|
|
@ -1,24 +1,42 @@
|
|
|
|
package eu.kanade.tachiyomi.util.system
|
|
|
|
package eu.kanade.tachiyomi.util.system
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import android.content.Context
|
|
|
|
import android.graphics.Color
|
|
|
|
import android.graphics.Color
|
|
|
|
|
|
|
|
import androidx.annotation.StringRes
|
|
|
|
|
|
|
|
import androidx.annotation.StyleRes
|
|
|
|
import androidx.appcompat.app.AppCompatDelegate
|
|
|
|
import androidx.appcompat.app.AppCompatDelegate
|
|
|
|
import eu.kanade.tachiyomi.R
|
|
|
|
import eu.kanade.tachiyomi.R
|
|
|
|
|
|
|
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
|
|
|
|
|
|
|
|
|
|
|
object ThemeUtil {
|
|
|
|
object ThemeUtil {
|
|
|
|
fun isBlueTheme(theme: Int): Boolean {
|
|
|
|
|
|
|
|
return theme == 4 || theme == 8 || theme == 7
|
|
|
|
/** Migration method */
|
|
|
|
|
|
|
|
fun convertTheme(preferences: PreferencesHelper, theme: Int) {
|
|
|
|
|
|
|
|
preferences.theme().set(
|
|
|
|
|
|
|
|
when (theme) {
|
|
|
|
|
|
|
|
0 -> Themes.PURE_WHITE
|
|
|
|
|
|
|
|
1 -> Themes.LIGHT_BLUE
|
|
|
|
|
|
|
|
2 -> Themes.DARK
|
|
|
|
|
|
|
|
3 -> Themes.AMOLED
|
|
|
|
|
|
|
|
4 -> Themes.DARK_BLUE
|
|
|
|
|
|
|
|
5 -> Themes.DEFAULT
|
|
|
|
|
|
|
|
6 -> Themes.DEFAULT_AMOLED
|
|
|
|
|
|
|
|
7 -> Themes.ALL_BLUE
|
|
|
|
|
|
|
|
else -> Themes.DEFAULT
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fun isAMOLEDTheme(theme: Int): Boolean {
|
|
|
|
fun isColoredTheme(theme: Themes): Boolean {
|
|
|
|
return theme == 3 || theme == 6
|
|
|
|
return theme.styleRes == R.style.Theme_Tachiyomi_AllBlue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fun theme(theme: Int): Int {
|
|
|
|
fun isPitchBlack(context: Context, theme: Themes): Boolean {
|
|
|
|
return when {
|
|
|
|
return context.isInNightMode() && theme.styleRes == R.style.Theme_Tachiyomi_Amoled
|
|
|
|
isAMOLEDTheme(theme) -> R.style.Theme_Tachiyomi_Amoled
|
|
|
|
}
|
|
|
|
isBlueTheme(theme) -> R.style.Theme_Tachiyomi_AllBlue
|
|
|
|
|
|
|
|
else -> R.style.Theme_Tachiyomi
|
|
|
|
fun hasDarkActionBarInLight(context: Context, theme: Themes): Boolean {
|
|
|
|
}
|
|
|
|
return !context.isInNightMode() && isColoredTheme(theme)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fun readerBackgroundColor(theme: Int): Int {
|
|
|
|
fun readerBackgroundColor(theme: Int): Int {
|
|
|
@ -28,11 +46,15 @@ object ThemeUtil {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fun nightMode(theme: Int): Int {
|
|
|
|
@Suppress("unused")
|
|
|
|
return when (theme) {
|
|
|
|
enum class Themes(@StyleRes val styleRes: Int, val nightMode: Int, @StringRes val nameRes: Int) {
|
|
|
|
1, 8 -> AppCompatDelegate.MODE_NIGHT_NO
|
|
|
|
PURE_WHITE(R.style.Theme_Tachiyomi, AppCompatDelegate.MODE_NIGHT_NO, R.string.white_theme),
|
|
|
|
2, 3, 4 -> AppCompatDelegate.MODE_NIGHT_YES
|
|
|
|
LIGHT_BLUE(R.style.Theme_Tachiyomi_AllBlue, AppCompatDelegate.MODE_NIGHT_NO, R.string.light_blue),
|
|
|
|
else -> AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
|
|
|
|
DARK(R.style.Theme_Tachiyomi, AppCompatDelegate.MODE_NIGHT_YES, R.string.dark),
|
|
|
|
}
|
|
|
|
AMOLED(R.style.Theme_Tachiyomi_Amoled, AppCompatDelegate.MODE_NIGHT_YES, R.string.amoled_black),
|
|
|
|
|
|
|
|
DARK_BLUE(R.style.Theme_Tachiyomi_AllBlue, AppCompatDelegate.MODE_NIGHT_YES, R.string.dark_blue),
|
|
|
|
|
|
|
|
DEFAULT(R.style.Theme_Tachiyomi, AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM, R.string.system_default),
|
|
|
|
|
|
|
|
DEFAULT_AMOLED(R.style.Theme_Tachiyomi_Amoled, AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM, R.string.system_default_amoled),
|
|
|
|
|
|
|
|
ALL_BLUE(R.style.Theme_Tachiyomi_AllBlue, AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM, R.string.system_default_all_blue),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|