mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 22:30:30 +05:30
commit
929899ec08
@ -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<SwitchPreferenceCompat>("pure_theme")
|
||||
pureTheme?.setOnPreferenceChangeListener { _, _ ->
|
||||
val restartDialog = RequireRestartDialog()
|
||||
restartDialog.show(childFragmentManager, "RequireRestartDialog")
|
||||
true
|
||||
}
|
||||
|
||||
val accentColor = findPreference<ListPreference>("accent_color")
|
||||
updateAccentColorValues(accentColor!!)
|
||||
accentColor.setOnPreferenceChangeListener { _, _ ->
|
||||
@ -46,7 +53,7 @@ class AppearanceSettings : PreferenceFragmentCompat() {
|
||||
true
|
||||
}
|
||||
|
||||
val hideTrending = findPreference<SwitchPreference>("hide_trending_page")
|
||||
val hideTrending = findPreference<SwitchPreferenceCompat>("hide_trending_page")
|
||||
hideTrending?.setOnPreferenceChangeListener { _, _ ->
|
||||
val restartDialog = RequireRestartDialog()
|
||||
restartDialog.show(childFragmentManager, "RequireRestartDialog")
|
||||
|
@ -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<SwitchPreference>("auth_instance_toggle")
|
||||
val authInstanceToggle = findPreference<SwitchPreferenceCompat>("auth_instance_toggle")
|
||||
authInstanceToggle?.setOnPreferenceChangeListener { _, newValue ->
|
||||
authInstance.isVisible = newValue == true
|
||||
logout()
|
||||
|
@ -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)
|
||||
|
10
app/src/main/res/drawable/ic_invert_colors.xml
Normal file
10
app/src/main/res/drawable/ic_invert_colors.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:tint="?android:attr/colorControlNormal"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:pathData="M12,4.81L12,19c-3.31,0 -6,-2.63 -6,-5.87c0,-1.56 0.62,-3.03 1.75,-4.14L12,4.81M6.35,7.56L6.35,7.56C4.9,8.99 4,10.96 4,13.13C4,17.48 7.58,21 12,21c4.42,0 8,-3.52 8,-7.87c0,-2.17 -0.9,-4.14 -2.35,-5.57l0,0L12,2L6.35,7.56z"
|
||||
android:fillColor="#000000"/>
|
||||
</vector>
|
@ -8,7 +8,7 @@
|
||||
|
||||
</style>
|
||||
|
||||
<style name="MaterialYou.Black" parent="MaterialYou">
|
||||
<style name="MaterialYou.Pure" parent="MaterialYou">
|
||||
|
||||
<item name="android:colorBackground">@android:color/black</item>
|
||||
<item name="colorSurface">@android:color/black</item>
|
||||
@ -33,7 +33,7 @@
|
||||
|
||||
</style>
|
||||
|
||||
<style name="Theme.Red.Black" parent="Theme.Red">
|
||||
<style name="Theme.Red.Pure" parent="Theme.Red">
|
||||
|
||||
<item name="android:colorBackground">@android:color/black</item>
|
||||
<item name="colorSurface">@android:color/black</item>
|
||||
@ -58,7 +58,7 @@
|
||||
|
||||
</style>
|
||||
|
||||
<style name="Theme.Blue.Black" parent="Theme.Blue">
|
||||
<style name="Theme.Blue.Pure" parent="Theme.Blue">
|
||||
|
||||
<item name="android:colorBackground">@android:color/black</item>
|
||||
<item name="colorSurface">@android:color/black</item>
|
||||
@ -83,7 +83,7 @@
|
||||
|
||||
</style>
|
||||
|
||||
<style name="Theme.Yellow.Black" parent="Theme.Yellow">
|
||||
<style name="Theme.Yellow.Pure" parent="Theme.Yellow">
|
||||
|
||||
<item name="android:colorBackground">@android:color/black</item>
|
||||
<item name="colorSurface">@android:color/black</item>
|
||||
@ -108,7 +108,7 @@
|
||||
|
||||
</style>
|
||||
|
||||
<style name="Theme.Green.Black" parent="Theme.Green">
|
||||
<style name="Theme.Green.Pure" parent="Theme.Green">
|
||||
|
||||
<item name="android:colorBackground">@android:color/black</item>
|
||||
<item name="colorSurface">@android:color/black</item>
|
||||
@ -133,7 +133,7 @@
|
||||
|
||||
</style>
|
||||
|
||||
<style name="Theme.Purple.Black" parent="Theme.Purple">
|
||||
<style name="Theme.Purple.Pure" parent="Theme.Purple">
|
||||
|
||||
<item name="android:colorBackground">@android:color/black</item>
|
||||
<item name="colorSurface">@android:color/black</item>
|
||||
|
@ -533,14 +533,12 @@
|
||||
<item>@string/systemDefault</item>
|
||||
<item>@string/lightTheme</item>
|
||||
<item>@string/darkTheme</item>
|
||||
<item>@string/oledTheme</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="themesValue">
|
||||
<item>A</item>
|
||||
<item>L</item>
|
||||
<item>D</item>
|
||||
<item>O</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="accents">
|
||||
|
@ -239,4 +239,6 @@
|
||||
<string name="never">Never</string>
|
||||
<string name="autoRotatePlayer">Auto fullscreen</string>
|
||||
<string name="autoRotatePlayer_summary">Automatically switch to player fullscreen when the device gets turned.</string>
|
||||
<string name="pure_theme">Pure theme</string>
|
||||
<string name="pure_theme_summary">Pure white/black theme</string>
|
||||
</resources>
|
@ -126,5 +126,4 @@
|
||||
</style>
|
||||
|
||||
|
||||
|
||||
</resources>
|
@ -8,6 +8,13 @@
|
||||
|
||||
</style>
|
||||
|
||||
<style name="Theme.MaterialYou.Pure" parent="MaterialYou">
|
||||
|
||||
<item name="android:colorBackground">@android:color/white</item>
|
||||
<item name="colorSurface">@android:color/white</item>
|
||||
|
||||
</style>
|
||||
|
||||
<style name="Theme.Red" parent="Theme.Material3.Light.NoActionBar">
|
||||
|
||||
<item name="colorPrimary">@color/red_light_accentLight</item>
|
||||
@ -27,6 +34,13 @@
|
||||
|
||||
</style>
|
||||
|
||||
<style name="Theme.Red.Pure" parent="Theme.Red">
|
||||
|
||||
<item name="android:colorBackground">@android:color/white</item>
|
||||
<item name="colorSurface">@android:color/white</item>
|
||||
|
||||
</style>
|
||||
|
||||
<style name="Theme.Blue" parent="Theme.Material3.Light.NoActionBar">
|
||||
|
||||
<item name="colorPrimary">@color/blue_light_accentLight</item>
|
||||
@ -46,6 +60,13 @@
|
||||
|
||||
</style>
|
||||
|
||||
<style name="Theme.Blue.Pure" parent="Theme.Blue">
|
||||
|
||||
<item name="android:colorBackground">@android:color/white</item>
|
||||
<item name="colorSurface">@android:color/white</item>
|
||||
|
||||
</style>
|
||||
|
||||
<style name="Theme.Yellow" parent="Theme.Material3.Light.NoActionBar">
|
||||
|
||||
<item name="colorPrimary">@color/yellow_light_accentLight</item>
|
||||
@ -65,6 +86,13 @@
|
||||
|
||||
</style>
|
||||
|
||||
<style name="Theme.Yellow.Pure" parent="Theme.Yellow">
|
||||
|
||||
<item name="android:colorBackground">@android:color/white</item>
|
||||
<item name="colorSurface">@android:color/white</item>
|
||||
|
||||
</style>
|
||||
|
||||
<style name="Theme.Green" parent="Theme.Material3.Light.NoActionBar">
|
||||
|
||||
<item name="colorPrimary">@color/green_light_accentLight</item>
|
||||
@ -84,6 +112,13 @@
|
||||
|
||||
</style>
|
||||
|
||||
<style name="Theme.Green.Pure" parent="Theme.Green">
|
||||
|
||||
<item name="android:colorBackground">@android:color/white</item>
|
||||
<item name="colorSurface">@android:color/white</item>
|
||||
|
||||
</style>
|
||||
|
||||
<style name="Theme.Purple" parent="Theme.Material3.Light.NoActionBar">
|
||||
|
||||
<item name="colorPrimary">@color/purple_light_accentLight</item>
|
||||
@ -103,4 +138,11 @@
|
||||
|
||||
</style>
|
||||
|
||||
<style name="Theme.Purple.Pure" parent="Theme.Purple">
|
||||
|
||||
<item name="android:colorBackground">@android:color/white</item>
|
||||
<item name="colorSurface">@android:color/white</item>
|
||||
|
||||
</style>
|
||||
|
||||
</resources>
|
@ -33,7 +33,7 @@
|
||||
|
||||
<PreferenceCategory app:title="@string/search_history">
|
||||
|
||||
<SwitchPreference
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="true"
|
||||
android:icon="@drawable/ic_history_filled"
|
||||
app:key="search_history_toggle"
|
||||
@ -48,13 +48,13 @@
|
||||
|
||||
<PreferenceCategory app:title="@string/watch_history">
|
||||
|
||||
<SwitchPreference
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="true"
|
||||
android:icon="@drawable/ic_time_outlined"
|
||||
app:key="watch_history_toggle"
|
||||
app:title="@string/watch_history" />
|
||||
|
||||
<SwitchPreference
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="true"
|
||||
android:icon="@drawable/ic_play_filled"
|
||||
app:key="watch_position_toggle"
|
||||
|
@ -13,6 +13,13 @@
|
||||
app:title="@string/app_theme"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:icon="@drawable/ic_invert_colors"
|
||||
android:summary="@string/pure_theme_summary"
|
||||
app:defaultValue="false"
|
||||
app:key="pure_theme"
|
||||
app:title="@string/pure_theme" />
|
||||
|
||||
<ListPreference
|
||||
android:icon="@drawable/ic_color"
|
||||
app:defaultValue="purple"
|
||||
@ -44,7 +51,7 @@
|
||||
app:title="@string/defaultTab"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
|
||||
<SwitchPreference
|
||||
<SwitchPreferenceCompat
|
||||
android:icon="@drawable/ic_trending"
|
||||
app:defaultValue="false"
|
||||
app:key="hide_trending_page"
|
||||
@ -73,7 +80,7 @@
|
||||
|
||||
<PreferenceCategory>
|
||||
|
||||
<SwitchPreference
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="true"
|
||||
android:icon="@drawable/ic_list"
|
||||
app:key="related_streams_toggle"
|
||||
|
@ -23,7 +23,7 @@
|
||||
app:key="clearCustomInstances"
|
||||
app:title="@string/clear_customInstances" />
|
||||
|
||||
<SwitchPreference
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="false"
|
||||
android:icon="@drawable/ic_auth"
|
||||
app:key="auth_instance_toggle"
|
||||
|
Loading…
Reference in New Issue
Block a user