mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 22:30:30 +05:30
commit
f1f2c21938
@ -18,7 +18,7 @@ class AppearanceSettings : PreferenceFragmentCompat() {
|
|||||||
val settingsActivity = activity as SettingsActivity
|
val settingsActivity = activity as SettingsActivity
|
||||||
settingsActivity.changeTopBarText(getString(R.string.appearance))
|
settingsActivity.changeTopBarText(getString(R.string.appearance))
|
||||||
|
|
||||||
val themeToggle = findPreference<ListPreference>("theme_togglee")
|
val themeToggle = findPreference<ListPreference>("theme_toggle")
|
||||||
themeToggle?.setOnPreferenceChangeListener { _, _ ->
|
themeToggle?.setOnPreferenceChangeListener { _, _ ->
|
||||||
val restartDialog = RequireRestartDialog()
|
val restartDialog = RequireRestartDialog()
|
||||||
restartDialog.show(childFragmentManager, "RequireRestartDialog")
|
restartDialog.show(childFragmentManager, "RequireRestartDialog")
|
||||||
|
@ -17,11 +17,17 @@ import com.google.android.material.color.DynamicColors
|
|||||||
object ThemeHelper {
|
object ThemeHelper {
|
||||||
|
|
||||||
fun updateTheme(activity: AppCompatActivity) {
|
fun updateTheme(activity: AppCompatActivity) {
|
||||||
updateAccentColor(activity)
|
val themeMode = PreferenceHelper.getString(activity, "theme_toggle", "A")!!
|
||||||
updateThemeMode(activity)
|
val blackModeEnabled = themeMode == "O"
|
||||||
|
|
||||||
|
updateAccentColor(activity, blackModeEnabled)
|
||||||
|
updateThemeMode(themeMode)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateAccentColor(activity: AppCompatActivity) {
|
private fun updateAccentColor(
|
||||||
|
activity: AppCompatActivity,
|
||||||
|
blackThemeEnabled: Boolean
|
||||||
|
) {
|
||||||
val theme = when (
|
val theme = when (
|
||||||
PreferenceHelper.getString(
|
PreferenceHelper.getString(
|
||||||
activity,
|
activity,
|
||||||
@ -31,14 +37,15 @@ object ThemeHelper {
|
|||||||
) {
|
) {
|
||||||
"my" -> {
|
"my" -> {
|
||||||
applyDynamicColors(activity)
|
applyDynamicColors(activity)
|
||||||
R.style.MaterialYou
|
if (blackThemeEnabled) R.style.MaterialYou_Black
|
||||||
|
else R.style.MaterialYou
|
||||||
}
|
}
|
||||||
"red" -> R.style.Theme_Red
|
"red" -> if (blackThemeEnabled) R.style.Theme_Red_Black else R.style.Theme_Red
|
||||||
"blue" -> R.style.Theme_Blue
|
"blue" -> if (blackThemeEnabled) R.style.Theme_Blue_Black else R.style.Theme_Blue
|
||||||
"yellow" -> R.style.Theme_Yellow
|
"yellow" -> if (blackThemeEnabled) R.style.Theme_Yellow_Black else R.style.Theme_Yellow
|
||||||
"green" -> R.style.Theme_Green
|
"green" -> if (blackThemeEnabled) R.style.Theme_Green_Black else R.style.Theme_Green
|
||||||
"purple" -> R.style.Theme_Purple
|
"purple" -> if (blackThemeEnabled) R.style.Theme_Purple_Black else R.style.Theme_Purple
|
||||||
else -> R.style.Theme_Purple
|
else -> if (blackThemeEnabled) R.style.Theme_Purple_Black else R.style.Theme_Purple
|
||||||
}
|
}
|
||||||
activity.setTheme(theme)
|
activity.setTheme(theme)
|
||||||
}
|
}
|
||||||
@ -50,16 +57,15 @@ object ThemeHelper {
|
|||||||
DynamicColors.applyToActivityIfAvailable(activity)
|
DynamicColors.applyToActivityIfAvailable(activity)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateThemeMode(context: Context) {
|
private fun updateThemeMode(themeMode: String) {
|
||||||
when (PreferenceHelper.getString(context, "theme_togglee", "A")) {
|
val mode = when (themeMode) {
|
||||||
"A" -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)
|
"A" -> AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
|
||||||
"L" -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
|
"L" -> AppCompatDelegate.MODE_NIGHT_NO
|
||||||
"D" -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
|
"D" -> AppCompatDelegate.MODE_NIGHT_YES
|
||||||
"O" -> {
|
"O" -> AppCompatDelegate.MODE_NIGHT_YES
|
||||||
context.setTheme(R.style.Black)
|
else -> AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
|
||||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
AppCompatDelegate.setDefaultNightMode(mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun changeIcon(context: Context, newLogoActivityAlias: String) {
|
fun changeIcon(context: Context, newLogoActivityAlias: String) {
|
||||||
|
@ -8,6 +8,13 @@
|
|||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="MaterialYou.Black" parent="MaterialYou">
|
||||||
|
|
||||||
|
<item name="android:colorBackground">@android:color/black</item>
|
||||||
|
<item name="colorSurface">@android:color/black</item>
|
||||||
|
|
||||||
|
</style>
|
||||||
|
|
||||||
<style name="Theme.Red" parent="Theme.Material3.Dark.NoActionBar">
|
<style name="Theme.Red" parent="Theme.Material3.Dark.NoActionBar">
|
||||||
|
|
||||||
<item name="colorPrimary">@color/red_dark_accentLight</item>
|
<item name="colorPrimary">@color/red_dark_accentLight</item>
|
||||||
@ -26,6 +33,13 @@
|
|||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="Theme.Red.Black" parent="Theme.Red">
|
||||||
|
|
||||||
|
<item name="android:colorBackground">@android:color/black</item>
|
||||||
|
<item name="colorSurface">@android:color/black</item>
|
||||||
|
|
||||||
|
</style>
|
||||||
|
|
||||||
<style name="Theme.Blue" parent="Theme.Material3.Dark.NoActionBar">
|
<style name="Theme.Blue" parent="Theme.Material3.Dark.NoActionBar">
|
||||||
|
|
||||||
<item name="colorPrimary">@color/blue_dark_accentLight</item>
|
<item name="colorPrimary">@color/blue_dark_accentLight</item>
|
||||||
@ -44,6 +58,13 @@
|
|||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="Theme.Blue.Black" parent="Theme.Blue">
|
||||||
|
|
||||||
|
<item name="android:colorBackground">@android:color/black</item>
|
||||||
|
<item name="colorSurface">@android:color/black</item>
|
||||||
|
|
||||||
|
</style>
|
||||||
|
|
||||||
<style name="Theme.Yellow" parent="Theme.Material3.Dark.NoActionBar">
|
<style name="Theme.Yellow" parent="Theme.Material3.Dark.NoActionBar">
|
||||||
|
|
||||||
<item name="colorPrimary">@color/yellow_dark_accentLight</item>
|
<item name="colorPrimary">@color/yellow_dark_accentLight</item>
|
||||||
@ -62,6 +83,13 @@
|
|||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="Theme.Yellow.Black" parent="Theme.Yellow">
|
||||||
|
|
||||||
|
<item name="android:colorBackground">@android:color/black</item>
|
||||||
|
<item name="colorSurface">@android:color/black</item>
|
||||||
|
|
||||||
|
</style>
|
||||||
|
|
||||||
<style name="Theme.Green" parent="Theme.Material3.Dark.NoActionBar">
|
<style name="Theme.Green" parent="Theme.Material3.Dark.NoActionBar">
|
||||||
|
|
||||||
<item name="colorPrimary">@color/green_dark_accentLight</item>
|
<item name="colorPrimary">@color/green_dark_accentLight</item>
|
||||||
@ -80,6 +108,13 @@
|
|||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="Theme.Green.Black" parent="Theme.Green">
|
||||||
|
|
||||||
|
<item name="android:colorBackground">@android:color/black</item>
|
||||||
|
<item name="colorSurface">@android:color/black</item>
|
||||||
|
|
||||||
|
</style>
|
||||||
|
|
||||||
<style name="Theme.Purple" parent="Theme.Material3.Dark.NoActionBar">
|
<style name="Theme.Purple" parent="Theme.Material3.Dark.NoActionBar">
|
||||||
|
|
||||||
<item name="colorPrimary">@color/purple_dark_accentLight</item>
|
<item name="colorPrimary">@color/purple_dark_accentLight</item>
|
||||||
@ -98,4 +133,11 @@
|
|||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="Theme.Purple.Black" parent="Theme.Purple">
|
||||||
|
|
||||||
|
<item name="android:colorBackground">@android:color/black</item>
|
||||||
|
<item name="colorSurface">@android:color/black</item>
|
||||||
|
|
||||||
|
</style>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
@ -15,16 +15,6 @@
|
|||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="Black">
|
|
||||||
|
|
||||||
<item name="android:colorBackground">@android:color/black</item>
|
|
||||||
<item name="colorSurface">@android:color/black</item>
|
|
||||||
|
|
||||||
<item name="android:statusBarColor">@android:color/transparent</item>
|
|
||||||
<item name="android:navigationBarColor">@android:color/transparent</item>
|
|
||||||
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<style name="MaterialAlertDialog">
|
<style name="MaterialAlertDialog">
|
||||||
|
|
||||||
<item name="alertDialogTheme">@style/ThemeOverlay.Material3.MaterialAlertDialog</item>
|
<item name="alertDialogTheme">@style/ThemeOverlay.Material3.MaterialAlertDialog</item>
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
app:defaultValue="A"
|
app:defaultValue="A"
|
||||||
app:entries="@array/themes"
|
app:entries="@array/themes"
|
||||||
app:entryValues="@array/themesValue"
|
app:entryValues="@array/themesValue"
|
||||||
app:key="theme_togglee"
|
app:key="theme_toggle"
|
||||||
app:title="@string/app_theme"
|
app:title="@string/app_theme"
|
||||||
app:useSimpleSummaryProvider="true" />
|
app:useSimpleSummaryProvider="true" />
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user