diff --git a/src/android/app/src/main/java/io/github/lime3ds/android/features/settings/model/Settings.kt b/src/android/app/src/main/java/io/github/lime3ds/android/features/settings/model/Settings.kt index eead17ecf..3a13e25b2 100644 --- a/src/android/app/src/main/java/io/github/lime3ds/android/features/settings/model/Settings.kt +++ b/src/android/app/src/main/java/io/github/lime3ds/android/features/settings/model/Settings.kt @@ -213,6 +213,7 @@ class Settings { const val PREF_THEME_MODE = "ThemeMode" const val PREF_BLACK_BACKGROUNDS = "BlackBackgrounds" const val PREF_SHOW_HOME_APPS = "ShowHomeApps" + const val PREF_STATIC_THEME_COLOR = "StaticThemeColor" private val configFileSectionsMap: MutableMap> = HashMap() @@ -231,4 +232,4 @@ class Settings { ) } } -} +} \ No newline at end of file diff --git a/src/android/app/src/main/java/io/github/lime3ds/android/features/settings/ui/SettingsFragmentPresenter.kt b/src/android/app/src/main/java/io/github/lime3ds/android/features/settings/ui/SettingsFragmentPresenter.kt index df0231d4f..514ee9eb7 100644 --- a/src/android/app/src/main/java/io/github/lime3ds/android/features/settings/ui/SettingsFragmentPresenter.kt +++ b/src/android/app/src/main/java/io/github/lime3ds/android/features/settings/ui/SettingsFragmentPresenter.kt @@ -1043,6 +1043,33 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView) ) } + val staticThemeColor: AbstractIntSetting = object : AbstractIntSetting { + override var int: Int + get() = preferences.getInt(Settings.PREF_STATIC_THEME_COLOR, 0) + set(value) { + preferences.edit() + .putInt(Settings.PREF_STATIC_THEME_COLOR, value) + .apply() + settingsActivity.recreate() + } + override val key: String? = null + override val section: String? = null + override val isRuntimeEditable: Boolean = false + override val valueAsString: String + get() = preferences.getInt(Settings.PREF_STATIC_THEME_COLOR, 0).toString() + override val defaultValue: Any = 0 + } + + add( + SingleChoiceSetting( + staticThemeColor, + R.string.static_theme_color, + R.string.static_theme_color_description, + R.array.staticThemeNames, + R.array.staticThemeValues + ) + ) + val themeMode: AbstractIntSetting = object : AbstractIntSetting { override var int: Int get() = preferences.getInt(Settings.PREF_THEME_MODE, -1) diff --git a/src/android/app/src/main/java/io/github/lime3ds/android/ui/main/MainActivity.kt b/src/android/app/src/main/java/io/github/lime3ds/android/ui/main/MainActivity.kt index 983c96969..010fc3ddf 100644 --- a/src/android/app/src/main/java/io/github/lime3ds/android/ui/main/MainActivity.kt +++ b/src/android/app/src/main/java/io/github/lime3ds/android/ui/main/MainActivity.kt @@ -1,4 +1,4 @@ -// Copyright 2023 Citra Emulator Project +// Copyright Citra Emulator Project / Lime3DS Emulator Project // Licensed under GPLv2 or any later version // Refer to the license.txt file included. @@ -66,7 +66,7 @@ class MainActivity : AppCompatActivity(), ThemeProvider { override fun onCreate(savedInstanceState: Bundle?) { val splashScreen = installSplashScreen() - splashScreen.setKeepOnScreenCondition { + splashScreen.setKeepOnScreenCondition { !DirectoryInitialization.areCitraDirectoriesReady() && PermissionsHandler.hasWriteAccess(this) } @@ -76,6 +76,7 @@ class MainActivity : AppCompatActivity(), ThemeProvider { settingsViewModel.settings.loadSettings() } + ThemeUtil.ThemeChangeListener(this) ThemeUtil.setTheme(this) super.onCreate(savedInstanceState) @@ -340,4 +341,4 @@ class MainActivity : AppCompatActivity(), ThemeProvider { .build() ) } -} +} \ No newline at end of file diff --git a/src/android/app/src/main/java/io/github/lime3ds/android/utils/ThemeUtil.kt b/src/android/app/src/main/java/io/github/lime3ds/android/utils/ThemeUtil.kt index d696ec1b6..b22fff756 100644 --- a/src/android/app/src/main/java/io/github/lime3ds/android/utils/ThemeUtil.kt +++ b/src/android/app/src/main/java/io/github/lime3ds/android/utils/ThemeUtil.kt @@ -1,4 +1,4 @@ -// Copyright 2023 Citra Emulator Project +// Copyright Citra Emulator Project / Lime3DS Emulator Project // Licensed under GPLv2 or any later version // Refer to the license.txt file included. @@ -12,6 +12,9 @@ import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatDelegate import androidx.core.view.WindowCompat import androidx.core.view.WindowInsetsControllerCompat +import androidx.lifecycle.DefaultLifecycleObserver +import androidx.lifecycle.Lifecycle +import androidx.lifecycle.LifecycleOwner import androidx.preference.PreferenceManager import io.github.lime3ds.android.LimeApplication import io.github.lime3ds.android.R @@ -25,12 +28,28 @@ object ThemeUtil { private val preferences: SharedPreferences get() = PreferenceManager.getDefaultSharedPreferences(LimeApplication.appContext) + private fun getSelectedStaticThemeColor(): Int { + val themeIndex = preferences.getInt(Settings.PREF_STATIC_THEME_COLOR, 0) + val themes = arrayOf( + R.style.Theme_Lime_Blue, + R.style.Theme_Lime_Cyan, + R.style.Theme_Lime_Red, + R.style.Theme_Lime_Green, + R.style.Theme_Lime_Yellow, + R.style.Theme_Lime_Orange, + R.style.Theme_Lime_Violet, + R.style.Theme_Lime_Pink, + R.style.Theme_Lime_Gray + ) + return themes[themeIndex] + } + fun setTheme(activity: AppCompatActivity) { setThemeMode(activity) if (preferences.getBoolean(Settings.PREF_MATERIAL_YOU, false)) { activity.setTheme(R.style.Theme_Lime_Main_MaterialYou) } else { - activity.setTheme(R.style.Theme_Lime_Main) + activity.setTheme(getSelectedStaticThemeColor()) } // Using a specific night mode check because this could apply incorrectly when using the @@ -96,4 +115,17 @@ object ThemeUtil { Color.blue(color) ) } + + // Listener that detects if the theme keys are being changed from the setting menu and recreates the activity + private var listener: SharedPreferences.OnSharedPreferenceChangeListener? = null + + fun ThemeChangeListener(activity: AppCompatActivity) { + listener = SharedPreferences.OnSharedPreferenceChangeListener { _, key -> + val relevantKeys = listOf(Settings.PREF_STATIC_THEME_COLOR, Settings.PREF_MATERIAL_YOU, Settings.PREF_BLACK_BACKGROUNDS) + if (key in relevantKeys) { + activity.recreate() + } + } + preferences.registerOnSharedPreferenceChangeListener(listener) + } } diff --git a/src/android/app/src/main/res/drawable/gamelist_divider.xml b/src/android/app/src/main/res/drawable/gamelist_divider.xml index a1cec8e41..2249d2934 100644 --- a/src/android/app/src/main/res/drawable/gamelist_divider.xml +++ b/src/android/app/src/main/res/drawable/gamelist_divider.xml @@ -6,6 +6,6 @@ android:width="1dp" android:height="1dp" /> - + diff --git a/src/android/app/src/main/res/values-night/citra_colors.xml b/src/android/app/src/main/res/values-night/citra_colors.xml index 98e9d50c3..154acd91d 100644 --- a/src/android/app/src/main/res/values-night/citra_colors.xml +++ b/src/android/app/src/main/res/values-night/citra_colors.xml @@ -1,35 +1,238 @@ - #B7C4FF - #002681 - #0039B5 - #DCE1FF - #C2C5DD - #2B3042 - #424659 - #DEE1F9 - #E4BADA - #43273F - #5C3D56 - #FFD7F5 - #FFB4AB - #93000A - #690005 - #FFDAD6 - #1B1B1F - #E4E1E6 - #1B1B1F - #E4E1E6 - #45464F - #C6C5D0 - #90909A - #1B1B1F - #E4E1E6 - #154FE2 - #000000 - #B7C4FF - #45464F - #000000 - - + + #B7C4FF + #002681 + #0039B5 + #DCE1FF + #C2C5DD + #2B3042 + #424659 + #DEE1F9 + #E4BADA + #43273F + #5C3D56 + #FFD7F5 + #1B1B1F + #E4E1E6 + #1B1B1F + #E4E1E6 + #45464F + #C6C5D0 + #90909A + #1B1B1F + #E4E1E6 + #154FE2 + #B7C4FF + + + #B7FFF7 + #007D81 + #00A0B5 + #DCFFFB + #C2DDDB + #2B3F42 + #425659 + #DEF9F7 + #BAE1E4 + #274341 + #3D5C5C + #D7FFFE + #1B1F1E + #E1E6E5 + #1B1F1F + #E1E6E5 + #454F4D + #C5D0CF + #909A98 + #1B1F1F + #E1E6E5 + #15E2D1 + #B7C4FF + + + #FFB7B7 + #810000 + #B50000 + #FFDCDC + #DDC2C2 + #422B2B + #594242 + #F9DEDE + #E4BABA + #432727 + #5C3D3D + #FFD7D7 + #1F1B1B + #E6E1E1 + #1F1B1B + #E6E1E1 + #4F4545 + #D0C5C5 + #9A9090 + #1F1B1B + #E6E1E1 + #E21515 + #FFB7B7 + + + #D0FFB7 + #368100 + #1BB500 + #E5FFDC + #CDDDC2 + #32422B + #4B5942 + #E9F9DE + #CAE4BA + #2F4327 + #455C3D + #E8FFD7 + #1C1F1B + #E2E6E1 + #1C1F1B + #E2E6E1 + #494F45 + #C9D0C5 + #959A90 + #1D1F1B + #E2E6E1 + #82E215 + #CDFFB7 + + + #FFEDB7 + #817F00 + #B5A300 + #FFFDDC + #DDDDC2 + #42422B + #595942 + #F7F9DE + #E0E4BA + #424327 + #5C583D + #FFFBD7 + #1F1F1B + #E6E6E1 + #1F1F1B + #E6E5E1 + #4F4E45 + #D0D0C5 + #9A9990 + #1B1B1F + #E6E6E1 + #DBE215 + #FFFBB7 + + + #FFCBB7 + #812500 + #B55400 + #FFEBDC + #DDCDC2 + #42342B + #594A42 + #F9E6DE + #E4CCBA + #433127 + #5C463D + #FFEFD7 + #1F1D1B + #E6E3E1 + #1F1D1B + #E6E3E1 + #4F4A45 + #D0CAC5 + #9A9490 + #1F1D1B + #E6E3E1 + #E26E15 + #FFD4B7 + + + #DAB7FF + #350068 + #5A00B5 + #F4DCFF + #D2C2DD + #342B42 + #594265 + #E9DEF9 + #DACCE4 + #402743 + #5C4E5C + #FFD7FF + #1F1B1F + #E6E4E6 + #1F1B1F + #E6E4E6 + #4F454F + #D0C6D0 + #9A909A + #1F1B1F + #E6E4E6 + #B154E2 + #DAB7FF + + + #FFB7C5 + #81001E + #B50033 + #FFDCE6 + #DDC2C7 + #422B34 + #594249 + #FCF9DEE6 + #E4BAC4 + #432730 + #5C3D49 + #FFD7DF + #1F1B1C + #E6E1E2 + #1F1B1C + #E6E1E2 + #4F4547 + #D0C5C8 + #9A9093 + #1F1B1C + #E6E1E2 + #E21556 + #FFB7D6 + + + #B7B7B7 + #2B2B2B + #424242 + #E1E1E1 + #C2C2C2 + #424242 + #656565 + #EDEDED + #DADADA + #3F3F3F + #565656 + #F5F5F5 + #1B1B1B + #E4E4E4 + #1B1B1B + #E4E4E4 + #454545 + #C6C6C6 + #909090 + #1B1B1B + #E4E4E4 + #B7B7B7 + #B7B7B7 + + + #C6C5D0 + #FFB4AB + #93000A + #690005 + #FFDAD6 + #000000 + #000000 + + \ No newline at end of file diff --git a/src/android/app/src/main/res/values-v29/themes.xml b/src/android/app/src/main/res/values-v29/themes.xml index c460f40aa..e43fb2ccd 100644 --- a/src/android/app/src/main/res/values-v29/themes.xml +++ b/src/android/app/src/main/res/values-v29/themes.xml @@ -1,9 +1,9 @@ - - - - + - - + + + + + + - + + + + + + + + + + \ No newline at end of file