Added Colorblind setting and registration status icons
This commit is contained in:
@ -676,7 +676,7 @@ class BaresipService: Service() {
|
||||
ua.status = if (ua.account.regint == 0)
|
||||
R.drawable.circle_white
|
||||
else
|
||||
R.drawable.circle_yellow
|
||||
Utils.circleYellow()
|
||||
ua.add()
|
||||
|
||||
val acc = ua.account
|
||||
@ -773,7 +773,7 @@ class BaresipService: Service() {
|
||||
when (ev[0]) {
|
||||
"registering", "unregistering" -> {
|
||||
updateStatusNotification()
|
||||
ua.uaUpdateStatus(R.drawable.circle_yellow)
|
||||
ua.uaUpdateStatus(Utils.circleYellow())
|
||||
if (isMainVisible)
|
||||
registrationUpdate.postValue(System.currentTimeMillis())
|
||||
return
|
||||
@ -783,7 +783,7 @@ class BaresipService: Service() {
|
||||
if (Api.account_regint(ua.account.accp) == 0)
|
||||
R.drawable.circle_white
|
||||
else
|
||||
R.drawable.circle_green)
|
||||
Utils.circleGreen())
|
||||
updateStatusNotification()
|
||||
if (isMainVisible)
|
||||
registrationUpdate.postValue(System.currentTimeMillis())
|
||||
@ -793,7 +793,7 @@ class BaresipService: Service() {
|
||||
ua.uaUpdateStatus(if (Api.account_regint(ua.account.accp) == 0)
|
||||
R.drawable.circle_white
|
||||
else
|
||||
R.drawable.circle_red)
|
||||
Utils.circleRed())
|
||||
updateStatusNotification()
|
||||
if (isMainVisible)
|
||||
registrationUpdate.postValue(System.currentTimeMillis())
|
||||
@ -1725,6 +1725,7 @@ class BaresipService: Service() {
|
||||
var contactsMode = "baresip"
|
||||
var addressFamily = ""
|
||||
var dnsServers = listOf<InetAddress>()
|
||||
var colorblind = false
|
||||
// <aor, password> of those accounts that have auth username without auth password
|
||||
val aorPasswords = mutableMapOf<String, String>()
|
||||
var audioFocusRequest: AudioFocusRequestCompat? = null
|
||||
|
||||
@ -119,6 +119,13 @@ object Config {
|
||||
AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
|
||||
}
|
||||
|
||||
val colorblind = previousVariable("colorblind")
|
||||
config = if (colorblind != "")
|
||||
"${config}colorblind $colorblind\n"
|
||||
else
|
||||
"${config}colorblind no\n"
|
||||
BaresipService.colorblind = colorblind == "yes"
|
||||
|
||||
var contactsMode = previousVariable("contacts_mode").lowercase()
|
||||
if (contactsMode != "") {
|
||||
if (contactsMode != "baresip" &&
|
||||
|
||||
@ -246,6 +246,8 @@ private var newBatteryOptimizations = false
|
||||
|
||||
private var newDarkTheme = false
|
||||
|
||||
private var newColorblind = false
|
||||
|
||||
private var newDefaultDialer = false
|
||||
|
||||
private var newDebug = false
|
||||
@ -312,6 +314,7 @@ private fun SettingsContent(
|
||||
Ringtone(ctx)
|
||||
BatteryOptimizations()
|
||||
DarkTheme()
|
||||
ColorBlind()
|
||||
if (VERSION.SDK_INT >= 29)
|
||||
DefaultDialer()
|
||||
Debug()
|
||||
@ -1085,6 +1088,37 @@ private fun DarkTheme() {
|
||||
)
|
||||
}
|
||||
}
|
||||
@Composable
|
||||
private fun ColorBlind() {
|
||||
Row(
|
||||
Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(end = 10.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.Start
|
||||
) {
|
||||
val ctx = LocalContext.current
|
||||
Text(text = stringResource(R.string.colorblind),
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.clickable {
|
||||
alertTitle.value = ctx.getString(R.string.colorblind)
|
||||
alertMessage.value = ctx.getString(R.string.colorblind_help)
|
||||
showAlert.value = true
|
||||
},
|
||||
color = LocalCustomColors.current.itemText,
|
||||
fontSize = 18.sp)
|
||||
var colorblind by remember { mutableStateOf(Config.variable("colorblind") == "yes") }
|
||||
newColorblind = colorblind
|
||||
Switch(
|
||||
checked = colorblind,
|
||||
onCheckedChange = {
|
||||
colorblind = it
|
||||
newColorblind = colorblind
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresApi(29)
|
||||
@Composable
|
||||
@ -1369,6 +1403,16 @@ private fun checkOnClick(ctx: Context) {
|
||||
save = true
|
||||
}
|
||||
|
||||
if ((Config.variable("colorblind") == "yes") != newColorblind) {
|
||||
Config.replaceVariable(
|
||||
"colorblind",
|
||||
if (newColorblind) "yes" else "no"
|
||||
)
|
||||
BaresipService.colorblind = newColorblind
|
||||
save = true
|
||||
restart = true
|
||||
}
|
||||
|
||||
if ((Config.variable("log_level") == "0") != newDebug) {
|
||||
val logLevelString = if (newDebug) "0" else "2"
|
||||
Config.replaceVariable("log_level", logLevelString)
|
||||
|
||||
@ -46,7 +46,7 @@ class UserAgent(val uap: Long) {
|
||||
}
|
||||
|
||||
fun reRegister() {
|
||||
this.status = R.drawable.circle_yellow
|
||||
this.status = Utils.circleYellow()
|
||||
if (this.account.regint == 0)
|
||||
Api.ua_unregister(this.uap)
|
||||
else
|
||||
|
||||
@ -996,6 +996,27 @@ 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<File> {
|
||||
val directory = File(directoryPath)
|
||||
if (!directory.exists()) {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<vector android:autoMirrored="true" android:height="24dp"
|
||||
<vector android:autoMirrored="true" android:height="28dp"
|
||||
android:viewportHeight="100" android:viewportWidth="100"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
android:width="28dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@color/colorTrafficGreen"
|
||||
android:pathData="M50,50m-40,0a40,40 0,1 1,80 0a40,40 0,1 1,-80 0"
|
||||
android:strokeColor="#000000" android:strokeWidth="3"/>
|
||||
|
||||
10
app/src/main/res/drawable/circle_green_blind.xml
Normal file
10
app/src/main/res/drawable/circle_green_blind.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="28dp"
|
||||
android:height="28dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="@color/colorTrafficGreen">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M424,664L706,382L650,326L424,552L310,438L254,494L424,664ZM480,880Q397,880 324,848.5Q251,817 197,763Q143,709 111.5,636Q80,563 80,480Q80,397 111.5,324Q143,251 197,197Q251,143 324,111.5Q397,80 480,80Q563,80 636,111.5Q709,143 763,197Q817,251 848.5,324Q880,397 880,480Q880,563 848.5,636Q817,709 763,763Q709,817 636,848.5Q563,880 480,880ZM480,800Q614,800 707,707Q800,614 800,480Q800,346 707,253Q614,160 480,160Q346,160 253,253Q160,346 160,480Q160,614 253,707Q346,800 480,800ZM480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Z"/>
|
||||
</vector>
|
||||
@ -1,6 +1,6 @@
|
||||
<vector android:autoMirrored="true" android:height="24dp"
|
||||
<vector android:autoMirrored="true" android:height="28dp"
|
||||
android:viewportHeight="100" android:viewportWidth="100"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
android:width="28dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@color/colorTrafficRed"
|
||||
android:pathData="M50,50m-40,0a40,40 0,1 1,80 0a40,40 0,1 1,-80 0"
|
||||
android:strokeColor="#000000" android:strokeWidth="3"/>
|
||||
|
||||
10
app/src/main/res/drawable/circle_red_blind.xml
Normal file
10
app/src/main/res/drawable/circle_red_blind.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="28dp"
|
||||
android:height="28dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="@color/colorTrafficRed">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M480,680Q497,680 508.5,668.5Q520,657 520,640Q520,623 508.5,611.5Q497,600 480,600Q463,600 451.5,611.5Q440,623 440,640Q440,657 451.5,668.5Q463,680 480,680ZM440,520L520,520L520,280L440,280L440,520ZM480,880Q397,880 324,848.5Q251,817 197,763Q143,709 111.5,636Q80,563 80,480Q80,397 111.5,324Q143,251 197,197Q251,143 324,111.5Q397,80 480,80Q563,80 636,111.5Q709,143 763,197Q817,251 848.5,324Q880,397 880,480Q880,563 848.5,636Q817,709 763,763Q709,817 636,848.5Q563,880 480,880ZM480,800Q614,800 707,707Q800,614 800,480Q800,346 707,253Q614,160 480,160Q346,160 253,253Q160,346 160,480Q160,614 253,707Q346,800 480,800ZM480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Z"/>
|
||||
</vector>
|
||||
@ -1,6 +1,6 @@
|
||||
<vector android:autoMirrored="true" android:height="24dp"
|
||||
<vector android:autoMirrored="true" android:height="28dp"
|
||||
android:viewportHeight="100" android:viewportWidth="100"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
android:width="28dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#ffffff"
|
||||
android:pathData="M50,50m-40,0a40,40 0,1 1,80 0a40,40 0,1 1,-80 0"
|
||||
android:strokeColor="#000000" android:strokeWidth="3"/>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<vector android:autoMirrored="true" android:height="24dp"
|
||||
<vector android:autoMirrored="true" android:height="28dp"
|
||||
android:viewportHeight="100" android:viewportWidth="100"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
android:width="28dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@color/colorTrafficYellow"
|
||||
android:pathData="M50,50m-40,0a40,40 0,1 1,80 0a40,40 0,1 1,-80 0"
|
||||
android:strokeColor="#000000" android:strokeWidth="3"/>
|
||||
|
||||
10
app/src/main/res/drawable/circle_yellow_blind.xml
Normal file
10
app/src/main/res/drawable/circle_yellow_blind.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="28dp"
|
||||
android:height="28dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="@color/colorTrafficYellow">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M280,540Q305,540 322.5,522.5Q340,505 340,480Q340,455 322.5,437.5Q305,420 280,420Q255,420 237.5,437.5Q220,455 220,480Q220,505 237.5,522.5Q255,540 280,540ZM480,540Q505,540 522.5,522.5Q540,505 540,480Q540,455 522.5,437.5Q505,420 480,420Q455,420 437.5,437.5Q420,455 420,480Q420,505 437.5,522.5Q455,540 480,540ZM680,540Q705,540 722.5,522.5Q740,505 740,480Q740,455 722.5,437.5Q705,420 680,420Q655,420 637.5,437.5Q620,455 620,480Q620,505 637.5,522.5Q655,540 680,540ZM480,880Q397,880 324,848.5Q251,817 197,763Q143,709 111.5,636Q80,563 80,480Q80,397 111.5,324Q143,251 197,197Q251,143 324,111.5Q397,80 480,80Q563,80 636,111.5Q709,143 763,197Q817,251 848.5,324Q880,397 880,480Q880,563 848.5,636Q817,709 763,763Q709,817 636,848.5Q563,880 480,880ZM480,800Q614,800 707,707Q800,614 800,480Q800,346 707,253Q614,160 480,160Q346,160 253,253Q160,346 160,480Q160,614 253,707Q346,800 480,800ZM480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Z"/>
|
||||
</vector>
|
||||
@ -416,6 +416,8 @@
|
||||
<string name="tone_country_help">Soitto-, odotus- ja varattuäänien maa</string>
|
||||
<string name="dark_theme">Tumma teema</string>
|
||||
<string name="dark_theme_help">Käytä aina tummaa näyttöteemaa</string>
|
||||
<string name="colorblind">Värisokea</string>
|
||||
<string name="colorblind_help">Käytä värisokealle ystävällisiä rekisteröintitilaikoineita</string>
|
||||
<string name="video_size">Videon kehyskoko</string>
|
||||
<string name="video_size_help">Lähetettävän videon kehyskoko (leveys x korkeus)</string>
|
||||
<string name="video_fps">Videokehysten lähetystaajuus</string>
|
||||
|
||||
@ -387,6 +387,8 @@
|
||||
<string name="tone_country_help">Country of call ringing, waiting, and callee busy tones</string>
|
||||
<string name="dark_theme">Dark Theme</string>
|
||||
<string name="dark_theme_help">Force dark display theme</string>
|
||||
<string name="colorblind">Colorblind</string>
|
||||
<string name="colorblind_help">Use colorblind friendly registration status icons</string>
|
||||
<string name="video_size">Video Frame Size</string>
|
||||
<string name="video_size_help">Size of transmitted video frames (width x height)</string>
|
||||
<string name="video_fps">Video Frames Per Second</string>
|
||||
|
||||
Reference in New Issue
Block a user