Avoid need to restart after Colorblind setting change

This commit is contained in:
Juha Heinanen
2025-07-06 17:32:16 +03:00
parent 26f3ab6ac0
commit 926d2b672c
2 changed files with 26 additions and 1 deletions

View File

@ -1409,8 +1409,11 @@ private fun checkOnClick(ctx: Context) {
if (newColorblind) "yes" else "no" if (newColorblind) "yes" else "no"
) )
BaresipService.colorblind = newColorblind BaresipService.colorblind = newColorblind
UserAgent.updateColorblindStatus()
val baresipService = Intent(ctx, BaresipService::class.java)
baresipService.action = "Update Notification"
ctx.startService(baresipService)
save = true save = true
restart = true
} }
if ((Config.variable("log_level") == "0") != newDebug) { if ((Config.variable("log_level") == "0") != newDebug) {

View File

@ -105,6 +105,28 @@ class UserAgent(val uap: Long) {
} }
} }
fun updateColorblindStatus() {
val updatedUas = uas.value.toMutableList()
for (ua in updatedUas)
ua.status =
if (BaresipService.colorblind)
when (ua.status) {
R.drawable.circle_green -> R.drawable.circle_green_blind
R.drawable.circle_yellow -> R.drawable.circle_yellow_blind
R.drawable.circle_red -> R.drawable.circle_red_blind
else -> R.drawable.circle_white
}
else
when (ua.status) {
R.drawable.circle_green_blind -> R.drawable.circle_green
R.drawable.circle_yellow_blind -> R.drawable.circle_yellow
R.drawable.circle_red_blind -> R.drawable.circle_red
else -> R.drawable.circle_white
}
uas.value = updatedUas.toList()
uasStatus.value = statusMap()
}
fun statusMap(): Map<String, Int> { fun statusMap(): Map<String, Int> {
val result = emptyMap<String, Int>().toMutableMap() val result = emptyMap<String, Int>().toMutableMap()
for (ua in uas.value) for (ua in uas.value)