Avoid need to restart after Colorblind setting change
This commit is contained in:
@ -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) {
|
||||||
|
|||||||
@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user