forked from shihaam/thijooree
theme related bug fixes #8
This commit is contained in:
Generated
+2
-2
@@ -4,10 +4,10 @@
|
|||||||
<selectionStates>
|
<selectionStates>
|
||||||
<SelectionState runConfigName="app">
|
<SelectionState runConfigName="app">
|
||||||
<option name="selectionMode" value="DROPDOWN" />
|
<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">
|
<Target type="DEFAULT_BOOT">
|
||||||
<handle>
|
<handle>
|
||||||
<DeviceId pluginId="PhysicalDevice" identifier="serial=4254e2f" />
|
<DeviceId pluginId="Default" identifier="serial=10.0.1.245:5555;connection=d182cf37" />
|
||||||
</handle>
|
</handle>
|
||||||
</Target>
|
</Target>
|
||||||
</DropdownSelection>
|
</DropdownSelection>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package sh.sar.basedbank.ui.home
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
|
import android.content.res.Configuration
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.text.InputType
|
import android.text.InputType
|
||||||
@@ -135,6 +136,7 @@ class SettingsAppearanceFragment : Fragment() {
|
|||||||
})
|
})
|
||||||
binding.themeToggle.addOnButtonCheckedListener { _, checkedId, isChecked ->
|
binding.themeToggle.addOnButtonCheckedListener { _, checkedId, isChecked ->
|
||||||
if (!isChecked) return@addOnButtonCheckedListener
|
if (!isChecked) return@addOnButtonCheckedListener
|
||||||
|
val previousKey = prefs.getString("theme", "system")
|
||||||
val (key, mode) = when (checkedId) {
|
val (key, mode) = when (checkedId) {
|
||||||
R.id.btnThemeLight -> "light" to AppCompatDelegate.MODE_NIGHT_NO
|
R.id.btnThemeLight -> "light" to AppCompatDelegate.MODE_NIGHT_NO
|
||||||
R.id.btnThemeDark -> "dark" to AppCompatDelegate.MODE_NIGHT_YES
|
R.id.btnThemeDark -> "dark" to AppCompatDelegate.MODE_NIGHT_YES
|
||||||
@@ -144,6 +146,16 @@ class SettingsAppearanceFragment : Fragment() {
|
|||||||
AppCompatDelegate.setDefaultNightMode(mode)
|
AppCompatDelegate.setDefaultNightMode(mode)
|
||||||
updateAccentState(key == "system")
|
updateAccentState(key == "system")
|
||||||
updatePitchBlackState(key == "dark")
|
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
|
// Pitch black
|
||||||
@@ -158,7 +170,7 @@ class SettingsAppearanceFragment : Fragment() {
|
|||||||
// Accent color
|
// Accent color
|
||||||
val savedPreset = prefs.getString("accent_preset", ThemeHelper.PRESET_BLUE)
|
val savedPreset = prefs.getString("accent_preset", ThemeHelper.PRESET_BLUE)
|
||||||
binding.accentToggle.check(when (savedPreset) {
|
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_GREEN -> R.id.btnAccentGreen
|
||||||
ThemeHelper.PRESET_CUSTOM -> R.id.btnAccentCustom
|
ThemeHelper.PRESET_CUSTOM -> R.id.btnAccentCustom
|
||||||
else -> R.id.btnAccentBlue
|
else -> R.id.btnAccentBlue
|
||||||
|
|||||||
Reference in New Issue
Block a user