theme related bug fixes #8
Auto Tag on Version Change / check-version (push) Successful in 6s
Auto Tag on Version Change / check-version (push) Successful in 6s
This commit is contained in:
Generated
+2
-2
@@ -4,10 +4,10 @@
|
||||
<selectionStates>
|
||||
<SelectionState runConfigName="app">
|
||||
<option name="selectionMode" value="DROPDOWN" />
|
||||
<DropdownSelection timestamp="2026-05-28T18:41:19.777722821Z">
|
||||
<DropdownSelection timestamp="2026-06-03T08:28:30.389803148Z">
|
||||
<Target type="DEFAULT_BOOT">
|
||||
<handle>
|
||||
<DeviceId pluginId="PhysicalDevice" identifier="serial=4254e2f" />
|
||||
<DeviceId pluginId="Default" identifier="serial=10.0.1.245:5555;connection=d182cf37" />
|
||||
</handle>
|
||||
</Target>
|
||||
</DropdownSelection>
|
||||
|
||||
@@ -2,6 +2,7 @@ package sh.sar.basedbank.ui.home
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.content.res.Configuration
|
||||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import android.text.InputType
|
||||
@@ -135,6 +136,7 @@ class SettingsAppearanceFragment : Fragment() {
|
||||
})
|
||||
binding.themeToggle.addOnButtonCheckedListener { _, checkedId, isChecked ->
|
||||
if (!isChecked) return@addOnButtonCheckedListener
|
||||
val previousKey = prefs.getString("theme", "system")
|
||||
val (key, mode) = when (checkedId) {
|
||||
R.id.btnThemeLight -> "light" to AppCompatDelegate.MODE_NIGHT_NO
|
||||
R.id.btnThemeDark -> "dark" to AppCompatDelegate.MODE_NIGHT_YES
|
||||
@@ -144,6 +146,16 @@ class SettingsAppearanceFragment : Fragment() {
|
||||
AppCompatDelegate.setDefaultNightMode(mode)
|
||||
updateAccentState(key == "system")
|
||||
updatePitchBlackState(key == "dark")
|
||||
if (key == "system") {
|
||||
requireActivity().recreate()
|
||||
} else if (previousKey == "system") {
|
||||
// setDefaultNightMode only recreates if the effective mode changes.
|
||||
// If system was already dark and we switch to dark (or light→light),
|
||||
// no recreation is triggered and the custom accent never gets applied.
|
||||
val currentIsNight = (resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES
|
||||
val newIsNight = mode == AppCompatDelegate.MODE_NIGHT_YES
|
||||
if (currentIsNight == newIsNight) requireActivity().recreate()
|
||||
}
|
||||
}
|
||||
|
||||
// Pitch black
|
||||
@@ -158,7 +170,7 @@ class SettingsAppearanceFragment : Fragment() {
|
||||
// Accent color
|
||||
val savedPreset = prefs.getString("accent_preset", ThemeHelper.PRESET_BLUE)
|
||||
binding.accentToggle.check(when (savedPreset) {
|
||||
ThemeHelper.PRESET_RED -> R.id.btnAccentOrange
|
||||
ThemeHelper.PRESET_RED -> R.id.btnAccentOrange
|
||||
ThemeHelper.PRESET_GREEN -> R.id.btnAccentGreen
|
||||
ThemeHelper.PRESET_CUSTOM -> R.id.btnAccentCustom
|
||||
else -> R.id.btnAccentBlue
|
||||
|
||||
Reference in New Issue
Block a user