diff --git a/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt b/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt index 38ef8b79..dbb1aa34 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt @@ -676,7 +676,7 @@ class BaresipService: Service() { ua.status = if (ua.account.regint == 0) R.drawable.circle_white else - Utils.circleYellow() + circleYellow.getValue(colorblind) ua.add() val acc = ua.account @@ -773,7 +773,7 @@ class BaresipService: Service() { when (ev[0]) { "registering", "unregistering" -> { updateStatusNotification() - ua.uaUpdateStatus(Utils.circleYellow()) + ua.uaUpdateStatus(circleYellow.getValue(colorblind)) if (isMainVisible) registrationUpdate.postValue(System.currentTimeMillis()) return @@ -783,7 +783,8 @@ class BaresipService: Service() { if (Api.account_regint(ua.account.accp) == 0) R.drawable.circle_white else - Utils.circleGreen()) + circleGreen.getValue(colorblind) + ) updateStatusNotification() if (isMainVisible) registrationUpdate.postValue(System.currentTimeMillis()) @@ -793,7 +794,8 @@ class BaresipService: Service() { ua.uaUpdateStatus(if (Api.account_regint(ua.account.accp) == 0) R.drawable.circle_white else - Utils.circleRed()) + circleRed.getValue(colorblind) + ) updateStatusNotification() if (isMainVisible) registrationUpdate.postValue(System.currentTimeMillis()) @@ -1733,7 +1735,6 @@ class BaresipService: Service() { var contactsMode = "baresip" var addressFamily = "" var dnsServers = listOf() - var colorblind = false // of those accounts that have auth username without auth password val aorPasswords = mutableMapOf() var audioFocusRequest: AudioFocusRequestCompat? = null @@ -1742,6 +1743,14 @@ class BaresipService: Service() { var agcAvailable = false var rt: Ringtone? = null + var colorblind = false + val circleGreen = mapOf(true to R.drawable.circle_green_blind, + false to R.drawable.circle_green) + val circleYellow = mapOf(true to R.drawable.circle_yellow_blind, + false to R.drawable.circle_yellow) + val circleRed = mapOf(true to R.drawable.circle_red_blind, + false to R.drawable.circle_red) + private var agc: AutomaticGainControl? = null private val nsAvailable = NoiseSuppressor.isAvailable() private var ns: NoiseSuppressor? = null diff --git a/app/src/main/kotlin/com/tutpro/baresip/UserAgent.kt b/app/src/main/kotlin/com/tutpro/baresip/UserAgent.kt index 4fa82c66..9e1b44df 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/UserAgent.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/UserAgent.kt @@ -1,5 +1,7 @@ package com.tutpro.baresip +import com.tutpro.baresip.BaresipService.Companion.circleYellow +import com.tutpro.baresip.BaresipService.Companion.colorblind import com.tutpro.baresip.BaresipService.Companion.uas import com.tutpro.baresip.BaresipService.Companion.uasStatus @@ -46,7 +48,7 @@ class UserAgent(val uap: Long) { } fun reRegister() { - this.status = Utils.circleYellow() + this.status = circleYellow.getValue(colorblind) if (this.account.regint == 0) Api.ua_unregister(this.uap) else @@ -109,7 +111,7 @@ class UserAgent(val uap: Long) { val updatedUas = uas.value.toMutableList() for (ua in updatedUas) ua.status = - if (BaresipService.colorblind) + if (colorblind) when (ua.status) { R.drawable.circle_green -> R.drawable.circle_green_blind R.drawable.circle_yellow -> R.drawable.circle_yellow_blind diff --git a/app/src/main/kotlin/com/tutpro/baresip/Utils.kt b/app/src/main/kotlin/com/tutpro/baresip/Utils.kt index a0150a35..ef922d05 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/Utils.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/Utils.kt @@ -996,27 +996,6 @@ object Utils { } - fun circleGreen(): Int { - return if (BaresipService.colorblind) - R.drawable.circle_green_blind - else - R.drawable.circle_green - } - - fun circleYellow(): Int { - return if (BaresipService.colorblind) - R.drawable.circle_yellow_blind - else - R.drawable.circle_yellow - } - - fun circleRed(): Int { - return if (BaresipService.colorblind) - R.drawable.circle_red_blind - else - R.drawable.circle_red - } - /*fun listFilesInDirectory(directoryPath: String): List { val directory = File(directoryPath) if (!directory.exists()) {