diff --git a/app/src/main/java/com/github/libretube/preferences/AppearanceSettings.kt b/app/src/main/java/com/github/libretube/preferences/AppearanceSettings.kt index dfe9003dc..5a6dcc5e9 100644 --- a/app/src/main/java/com/github/libretube/preferences/AppearanceSettings.kt +++ b/app/src/main/java/com/github/libretube/preferences/AppearanceSettings.kt @@ -3,7 +3,7 @@ package com.github.libretube.preferences import android.os.Bundle import androidx.preference.ListPreference import androidx.preference.PreferenceFragmentCompat -import androidx.preference.SwitchPreference +import androidx.preference.SwitchPreferenceCompat import com.github.libretube.R import com.github.libretube.activities.SettingsActivity import com.github.libretube.dialogs.RequireRestartDialog @@ -25,6 +25,13 @@ class AppearanceSettings : PreferenceFragmentCompat() { true } + val pureTheme = findPreference("pure_theme") + pureTheme?.setOnPreferenceChangeListener { _, _ -> + val restartDialog = RequireRestartDialog() + restartDialog.show(childFragmentManager, "RequireRestartDialog") + true + } + val accentColor = findPreference("accent_color") updateAccentColorValues(accentColor!!) accentColor.setOnPreferenceChangeListener { _, _ -> @@ -46,7 +53,7 @@ class AppearanceSettings : PreferenceFragmentCompat() { true } - val hideTrending = findPreference("hide_trending_page") + val hideTrending = findPreference("hide_trending_page") hideTrending?.setOnPreferenceChangeListener { _, _ -> val restartDialog = RequireRestartDialog() restartDialog.show(childFragmentManager, "RequireRestartDialog") diff --git a/app/src/main/java/com/github/libretube/preferences/InstanceSettings.kt b/app/src/main/java/com/github/libretube/preferences/InstanceSettings.kt index 169cf7358..084d661af 100644 --- a/app/src/main/java/com/github/libretube/preferences/InstanceSettings.kt +++ b/app/src/main/java/com/github/libretube/preferences/InstanceSettings.kt @@ -18,7 +18,7 @@ import androidx.lifecycle.lifecycleScope import androidx.preference.ListPreference import androidx.preference.Preference import androidx.preference.PreferenceFragmentCompat -import androidx.preference.SwitchPreference +import androidx.preference.SwitchPreferenceCompat import com.github.libretube.R import com.github.libretube.activities.SettingsActivity import com.github.libretube.dialogs.CustomInstanceDialog @@ -146,7 +146,7 @@ class InstanceSettings : PreferenceFragmentCompat() { true } - val authInstanceToggle = findPreference("auth_instance_toggle") + val authInstanceToggle = findPreference("auth_instance_toggle") authInstanceToggle?.setOnPreferenceChangeListener { _, newValue -> authInstance.isVisible = newValue == true logout() diff --git a/app/src/main/java/com/github/libretube/util/ThemeHelper.kt b/app/src/main/java/com/github/libretube/util/ThemeHelper.kt index 8fa3bbb68..f246704c4 100644 --- a/app/src/main/java/com/github/libretube/util/ThemeHelper.kt +++ b/app/src/main/java/com/github/libretube/util/ThemeHelper.kt @@ -18,15 +18,15 @@ object ThemeHelper { fun updateTheme(activity: AppCompatActivity) { val themeMode = PreferenceHelper.getString(activity, "theme_toggle", "A")!! - val blackModeEnabled = themeMode == "O" + val pureThemeEnabled = PreferenceHelper.getBoolean(activity, "pure_theme", false) - updateAccentColor(activity, blackModeEnabled) + updateAccentColor(activity, pureThemeEnabled) updateThemeMode(themeMode) } private fun updateAccentColor( activity: AppCompatActivity, - blackThemeEnabled: Boolean + pureThemeEnabled: Boolean ) { val theme = when ( PreferenceHelper.getString( @@ -37,15 +37,16 @@ object ThemeHelper { ) { "my" -> { applyDynamicColors(activity) - if (blackThemeEnabled) R.style.MaterialYou_Black + if (pureThemeEnabled) R.style.MaterialYou_Pure else R.style.MaterialYou } - "red" -> if (blackThemeEnabled) R.style.Theme_Red_Black else R.style.Theme_Red - "blue" -> if (blackThemeEnabled) R.style.Theme_Blue_Black else R.style.Theme_Blue - "yellow" -> if (blackThemeEnabled) R.style.Theme_Yellow_Black else R.style.Theme_Yellow - "green" -> if (blackThemeEnabled) R.style.Theme_Green_Black else R.style.Theme_Green - "purple" -> if (blackThemeEnabled) R.style.Theme_Purple_Black else R.style.Theme_Purple - else -> if (blackThemeEnabled) R.style.Theme_Purple_Black else R.style.Theme_Purple + // set the theme, use the pure theme if enabled + "red" -> if (pureThemeEnabled) R.style.Theme_Red_Pure else R.style.Theme_Red + "blue" -> if (pureThemeEnabled) R.style.Theme_Blue_Pure else R.style.Theme_Blue + "yellow" -> if (pureThemeEnabled) R.style.Theme_Yellow_Pure else R.style.Theme_Yellow + "green" -> if (pureThemeEnabled) R.style.Theme_Green_Pure else R.style.Theme_Green + "purple" -> if (pureThemeEnabled) R.style.Theme_Purple_Pure else R.style.Theme_Purple + else -> if (pureThemeEnabled) R.style.Theme_Purple_Pure else R.style.Theme_Purple } activity.setTheme(theme) } @@ -62,7 +63,6 @@ object ThemeHelper { "A" -> AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM "L" -> AppCompatDelegate.MODE_NIGHT_NO "D" -> AppCompatDelegate.MODE_NIGHT_YES - "O" -> AppCompatDelegate.MODE_NIGHT_YES else -> AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM } AppCompatDelegate.setDefaultNightMode(mode) diff --git a/app/src/main/res/drawable/ic_invert_colors.xml b/app/src/main/res/drawable/ic_invert_colors.xml new file mode 100644 index 000000000..ece905850 --- /dev/null +++ b/app/src/main/res/drawable/ic_invert_colors.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/values-night/themes.xml b/app/src/main/res/values-night/themes.xml index 2efaffbdd..90b219957 100644 --- a/app/src/main/res/values-night/themes.xml +++ b/app/src/main/res/values-night/themes.xml @@ -8,7 +8,7 @@ - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index 1fe185fca..39c561d75 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -8,6 +8,13 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/xml/advanced_settings.xml b/app/src/main/res/xml/advanced_settings.xml index 596003be4..41298efff 100644 --- a/app/src/main/res/xml/advanced_settings.xml +++ b/app/src/main/res/xml/advanced_settings.xml @@ -33,7 +33,7 @@ - - - + + - - -