diff options
| author | 2023-04-23 18:46:05 -0400 | |
|---|---|---|
| committer | 2023-06-03 00:05:54 -0700 | |
| commit | d7178ed16e192fc5a64554526c8deb45c7eb3fe0 (patch) | |
| tree | ceba18655b1c3df3e90184ee524b002eeccfd9e5 /src/android | |
| parent | android: Add theme mode picker (diff) | |
| download | yuzu-d7178ed16e192fc5a64554526c8deb45c7eb3fe0.tar.gz yuzu-d7178ed16e192fc5a64554526c8deb45c7eb3fe0.tar.xz yuzu-d7178ed16e192fc5a64554526c8deb45c7eb3fe0.zip | |
android: Add black backgrounds toggle
Diffstat (limited to 'src/android')
6 files changed, 42 insertions, 1 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/Settings.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/Settings.kt index 2cf9d704e..b71291609 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/Settings.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/Settings.kt | |||
| @@ -137,6 +137,7 @@ class Settings { | |||
| 137 | const val PREF_FIRST_APP_LAUNCH = "FirstApplicationLaunch" | 137 | const val PREF_FIRST_APP_LAUNCH = "FirstApplicationLaunch" |
| 138 | const val PREF_THEME = "Theme" | 138 | const val PREF_THEME = "Theme" |
| 139 | const val PREF_THEME_MODE = "ThemeMode" | 139 | const val PREF_THEME_MODE = "ThemeMode" |
| 140 | const val PREF_BLACK_BACKGROUNDS = "BlackBackgrounds" | ||
| 140 | 141 | ||
| 141 | private val configFileSectionsMap: MutableMap<String, List<String>> = HashMap() | 142 | private val configFileSectionsMap: MutableMap<String, List<String>> = HashMap() |
| 142 | 143 | ||
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragmentPresenter.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragmentPresenter.kt index d8fa321ad..1aae96bc3 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragmentPresenter.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragmentPresenter.kt | |||
| @@ -10,6 +10,7 @@ import androidx.appcompat.app.AppCompatActivity | |||
| 10 | import androidx.preference.PreferenceManager | 10 | import androidx.preference.PreferenceManager |
| 11 | import org.yuzu.yuzu_emu.R | 11 | import org.yuzu.yuzu_emu.R |
| 12 | import org.yuzu.yuzu_emu.YuzuApplication | 12 | import org.yuzu.yuzu_emu.YuzuApplication |
| 13 | import org.yuzu.yuzu_emu.features.settings.model.AbstractBooleanSetting | ||
| 13 | import org.yuzu.yuzu_emu.features.settings.model.AbstractIntSetting | 14 | import org.yuzu.yuzu_emu.features.settings.model.AbstractIntSetting |
| 14 | import org.yuzu.yuzu_emu.features.settings.model.AbstractSetting | 15 | import org.yuzu.yuzu_emu.features.settings.model.AbstractSetting |
| 15 | import org.yuzu.yuzu_emu.features.settings.model.IntSetting | 16 | import org.yuzu.yuzu_emu.features.settings.model.IntSetting |
| @@ -380,6 +381,28 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView) | |||
| 380 | R.array.themeModeValues | 381 | R.array.themeModeValues |
| 381 | ) | 382 | ) |
| 382 | ) | 383 | ) |
| 384 | |||
| 385 | val blackBackgrounds: AbstractBooleanSetting = object : AbstractBooleanSetting { | ||
| 386 | override var boolean: Boolean | ||
| 387 | get() = preferences.getBoolean(Settings.PREF_BLACK_BACKGROUNDS, false) | ||
| 388 | set(value) { | ||
| 389 | preferences.edit().putBoolean(Settings.PREF_BLACK_BACKGROUNDS, value).apply() | ||
| 390 | settingsActivity.recreate() | ||
| 391 | } | ||
| 392 | override val key: String? = null | ||
| 393 | override val section: String? = null | ||
| 394 | override val isRuntimeEditable: Boolean = true | ||
| 395 | override val valueAsString: String | ||
| 396 | get() = preferences.getBoolean(Settings.PREF_BLACK_BACKGROUNDS, false).toString() | ||
| 397 | } | ||
| 398 | |||
| 399 | add( | ||
| 400 | SwitchSetting( | ||
| 401 | blackBackgrounds, | ||
| 402 | R.string.use_black_backgrounds, | ||
| 403 | R.string.use_black_backgrounds_description | ||
| 404 | ) | ||
| 405 | ) | ||
| 383 | } | 406 | } |
| 384 | } | 407 | } |
| 385 | } | 408 | } |
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/ThemeHelper.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/ThemeHelper.kt index 467978e6d..7c8f1d80b 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/ThemeHelper.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/ThemeHelper.kt | |||
| @@ -33,6 +33,9 @@ object ThemeHelper { | |||
| 33 | DEFAULT -> activity.setTheme(R.style.Theme_Yuzu_Main) | 33 | DEFAULT -> activity.setTheme(R.style.Theme_Yuzu_Main) |
| 34 | MATERIAL_YOU -> activity.setTheme(R.style.Theme_Yuzu_Main_MaterialYou) | 34 | MATERIAL_YOU -> activity.setTheme(R.style.Theme_Yuzu_Main_MaterialYou) |
| 35 | } | 35 | } |
| 36 | if (preferences.getBoolean(Settings.PREF_BLACK_BACKGROUNDS, false)) { | ||
| 37 | activity.setTheme(R.style.ThemeOverlay_Yuzu_Dark) | ||
| 38 | } | ||
| 36 | } | 39 | } |
| 37 | 40 | ||
| 38 | @JvmStatic | 41 | @JvmStatic |
diff --git a/src/android/app/src/main/res/layout/activity_settings.xml b/src/android/app/src/main/res/layout/activity_settings.xml index dc23200ea..2745599f4 100644 --- a/src/android/app/src/main/res/layout/activity_settings.xml +++ b/src/android/app/src/main/res/layout/activity_settings.xml | |||
| @@ -4,7 +4,8 @@ | |||
| 4 | xmlns:android="http://schemas.android.com/apk/res/android" | 4 | xmlns:android="http://schemas.android.com/apk/res/android" |
| 5 | xmlns:app="http://schemas.android.com/apk/res-auto" | 5 | xmlns:app="http://schemas.android.com/apk/res-auto" |
| 6 | android:layout_width="match_parent" | 6 | android:layout_width="match_parent" |
| 7 | android:layout_height="match_parent"> | 7 | android:layout_height="match_parent" |
| 8 | android:background="?attr/colorSurface"> | ||
| 8 | 9 | ||
| 9 | <com.google.android.material.appbar.AppBarLayout | 10 | <com.google.android.material.appbar.AppBarLayout |
| 10 | android:id="@+id/appbar_settings" | 11 | android:id="@+id/appbar_settings" |
diff --git a/src/android/app/src/main/res/values-night/themes.xml b/src/android/app/src/main/res/values-night/themes.xml new file mode 100644 index 000000000..d7d24c24d --- /dev/null +++ b/src/android/app/src/main/res/values-night/themes.xml | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | <?xml version="1.0" encoding="utf-8"?> | ||
| 2 | <resources> | ||
| 3 | |||
| 4 | <style name="ThemeOverlay.Yuzu.Dark" parent=""> | ||
| 5 | <item name="colorSurface">@android:color/black</item> | ||
| 6 | <item name="android:colorBackground">@android:color/black</item> | ||
| 7 | </style> | ||
| 8 | |||
| 9 | </resources> | ||
diff --git a/src/android/app/src/main/res/values/strings.xml b/src/android/app/src/main/res/values/strings.xml index 28c9af7bd..d37ffba0d 100644 --- a/src/android/app/src/main/res/values/strings.xml +++ b/src/android/app/src/main/res/values/strings.xml | |||
| @@ -241,4 +241,8 @@ | |||
| 241 | <string name="theme_mode_light">Light</string> | 241 | <string name="theme_mode_light">Light</string> |
| 242 | <string name="theme_mode_dark">Dark</string> | 242 | <string name="theme_mode_dark">Dark</string> |
| 243 | 243 | ||
| 244 | <!-- Black backgrounds theme --> | ||
| 245 | <string name="use_black_backgrounds">Use Black Backgrounds</string> | ||
| 246 | <string name="use_black_backgrounds_description">When using the dark theme, apply black backgrounds.</string> | ||
| 247 | |||
| 244 | </resources> | 248 | </resources> |