Replaced lock drawables with Material Design lock icons

This commit is contained in:
Juha Heinanen
2025-11-21 13:08:06 +02:00
parent df21c2eff3
commit d6002fcd4c
6 changed files with 33 additions and 43 deletions

View File

@ -965,9 +965,9 @@ class BaresipService: Service() {
} }
"call verified", "call secure" -> { "call verified", "call secure" -> {
if (ev[0] == "call secure") { if (ev[0] == "call secure") {
call!!.security = R.drawable.locked_yellow call!!.security = R.color.colorTrafficYellow
} else { } else {
call!!.security = R.drawable.locked_green call!!.security = R.color.colorTrafficGreen
call.zid = ev[1] call.zid = ev[1]
} }
if (!isMainVisible) if (!isMainVisible)

View File

@ -9,7 +9,7 @@ class Call(val callp: Long, val ua: UserAgent, val peerUri: String, val dir: Str
var onHoldCall: Call? = null var onHoldCall: Call? = null
var newCall: Call? = null var newCall: Call? = null
var rejected = false // Incoming rejected by user or outgoing fails but not due to 408 or 480 var rejected = false // Incoming rejected by user or outgoing fails but not due to 408 or 480
var security = R.drawable.unlocked var security = R.color.colorTrafficRed
var zid = "" var zid = ""
var startTime: GregorianCalendar? = null // Set when call is established var startTime: GregorianCalendar? = null // Set when call is established
var referTo = "" var referTo = ""
@ -87,7 +87,7 @@ class Call(val callp: Long, val ua: UserAgent, val peerUri: String, val dir: Str
} }
init { init {
if (ua.account.mediaEnc != "") security = R.drawable.unlocked if (ua.account.mediaEnc != "") security = R.color.colorTrafficRed
} }
fun destroy() { fun destroy() {

View File

@ -62,6 +62,8 @@ import androidx.compose.material.icons.filled.Dialpad
import androidx.compose.material.icons.filled.History import androidx.compose.material.icons.filled.History
import androidx.compose.material.icons.filled.KeyboardArrowDown import androidx.compose.material.icons.filled.KeyboardArrowDown
import androidx.compose.material.icons.filled.KeyboardArrowUp import androidx.compose.material.icons.filled.KeyboardArrowUp
import androidx.compose.material.icons.filled.Lock
import androidx.compose.material.icons.filled.LockOpen
import androidx.compose.material.icons.filled.Menu import androidx.compose.material.icons.filled.Menu
import androidx.compose.material.icons.filled.Mic import androidx.compose.material.icons.filled.Mic
import androidx.compose.material.icons.filled.MicOff import androidx.compose.material.icons.filled.MicOff
@ -815,7 +817,7 @@ private fun BottomBar(ctx: Context, viewModel: ViewModel, navController: NavCont
private val callUri = mutableStateOf("") private val callUri = mutableStateOf("")
private var callUriEnabled = mutableStateOf(true) private var callUriEnabled = mutableStateOf(true)
private val callUriLabel = mutableStateOf("") private val callUriLabel = mutableStateOf("")
private var securityIcon = mutableIntStateOf(-1) private var securityIconTint = mutableIntStateOf(-1)
private val showCallTimer = mutableStateOf(false) private val showCallTimer = mutableStateOf(false)
private var callDuration = 0 private var callDuration = 0
private val showSuggestions = mutableStateOf(false) private val showSuggestions = mutableStateOf(false)
@ -1049,8 +1051,8 @@ private fun AccountSpinner(ctx: Context, viewModel: ViewModel, navController: Na
) { ) {
Icon( Icon(
imageVector = ImageVector.vectorResource( imageVector = ImageVector.vectorResource(
uasStatus.value[selected] ?: uasStatus.value[selected] ?: R.drawable.circle_yellow
R.drawable.locked_yellow), ),
contentDescription = null, contentDescription = null,
tint = Color.Unspecified, tint = Color.Unspecified,
modifier = Modifier modifier = Modifier
@ -1265,7 +1267,7 @@ private fun CallUriRow(ctx: Context, viewModel: ViewModel) {
}, },
modifier = Modifier.padding(start = 6.dp, modifier = Modifier.padding(start = 6.dp,
top = 4.dp, top = 4.dp,
end = if (securityIcon.intValue != -1) 6.dp else 0.dp), end = if (securityIconTint.intValue != -1) 6.dp else 0.dp),
) )
DisposableEffect(Unit) { DisposableEffect(Unit) {
onDispose { onDispose {
@ -1276,28 +1278,31 @@ private fun CallUriRow(ctx: Context, viewModel: ViewModel) {
} }
} }
} }
if (securityIcon.intValue != -1) { if (securityIconTint.intValue != -1) {
Icon( Icon(
imageVector = ImageVector.vectorResource(securityIcon.intValue), imageVector = if (securityIconTint.intValue == R.color.colorTrafficRed)
Icons.Filled.LockOpen
else
Icons.Filled.Lock,
contentDescription = null, contentDescription = null,
modifier = Modifier modifier = Modifier
.size(28.dp) .size(28.dp)
.padding(top = 4.dp) .padding(top = 4.dp)
.clickable { .clickable {
when (securityIcon.intValue) { when (securityIconTint.intValue) {
R.drawable.unlocked -> { R.color.colorTrafficRed -> {
alertTitle.value = ctx.getString(R.string.alert) alertTitle.value = ctx.getString(R.string.alert)
alertMessage.value = ctx.getString(R.string.call_not_secure) alertMessage.value = ctx.getString(R.string.call_not_secure)
showAlert.value = true showAlert.value = true
} }
R.drawable.locked_yellow -> { R.color.colorTrafficYellow -> {
alertTitle.value = ctx.getString(R.string.alert) alertTitle.value = ctx.getString(R.string.alert)
alertMessage.value = ctx.getString(R.string.peer_not_verified) alertMessage.value = ctx.getString(R.string.peer_not_verified)
showAlert.value = true showAlert.value = true
} }
R.drawable.locked_green -> { R.color.colorTrafficGreen -> {
dialogTitle.value = ctx.getString(R.string.info) dialogTitle.value = ctx.getString(R.string.info)
dialogMessage.value = ctx.getString(R.string.call_is_secure) dialogMessage.value = ctx.getString(R.string.call_is_secure)
positiveText.value = ctx.getString(R.string.unverify) positiveText.value = ctx.getString(R.string.unverify)
@ -1311,7 +1316,7 @@ private fun CallUriRow(ctx: Context, viewModel: ViewModel) {
"Command 'zrtp_unverify ${call.zid}' failed" "Command 'zrtp_unverify ${call.zid}' failed"
) )
else else
securityIcon.intValue = R.drawable.locked_yellow securityIconTint.intValue = R.color.colorTrafficYellow
} }
} }
negativeText.value = ctx.getString(R.string.cancel) negativeText.value = ctx.getString(R.string.cancel)
@ -1319,7 +1324,7 @@ private fun CallUriRow(ctx: Context, viewModel: ViewModel) {
} }
} }
}, },
tint = Color.Unspecified, tint = colorResource(securityIconTint.intValue)
) )
} }
} }
@ -2049,7 +2054,7 @@ private fun showCall(ctx: Context, viewModel: ViewModel, ua: UserAgent?, showCal
callUriLabel.value = ctx.getString(R.string.outgoing_call_to_dots) callUriLabel.value = ctx.getString(R.string.outgoing_call_to_dots)
callUriEnabled.value = true callUriEnabled.value = true
showCallTimer.value = false showCallTimer.value = false
securityIcon.intValue = -1 securityIconTint.intValue = -1
showHangupButton.value = false showHangupButton.value = false
callTransfer.value = false callTransfer.value = false
dtmfText.value = "" dtmfText.value = ""
@ -2089,7 +2094,7 @@ private fun showCall(ctx: Context, viewModel: ViewModel, ua: UserAgent?, showCal
ctx.getString(R.string.outgoing_call_to_dots) ctx.getString(R.string.outgoing_call_to_dots)
callUri.value = Utils.friendlyUri(ctx, call.peerUri, ua.account) callUri.value = Utils.friendlyUri(ctx, call.peerUri, ua.account)
showCallTimer.value = false showCallTimer.value = false
securityIcon.intValue = -1 securityIconTint.intValue = -1
showCallButton.value = false showCallButton.value = false
showCancelButton.value = call.status == "outgoing" showCancelButton.value = call.status == "outgoing"
showHangupButton.value = !showCancelButton.value showHangupButton.value = !showCancelButton.value
@ -2099,7 +2104,7 @@ private fun showCall(ctx: Context, viewModel: ViewModel, ua: UserAgent?, showCal
} }
"incoming" -> { "incoming" -> {
showCallTimer.value = false showCallTimer.value = false
securityIcon.intValue = -1 securityIconTint.intValue = -1
val uri = call.diverterUri() val uri = call.diverterUri()
if (uri != "") { if (uri != "") {
callUriLabel.value = ctx.getString(R.string.diverted_by_dots) callUriLabel.value = ctx.getString(R.string.diverted_by_dots)
@ -2135,9 +2140,9 @@ private fun showCall(ctx: Context, viewModel: ViewModel, ua: UserAgent?, showCal
callDuration = call.duration() callDuration = call.duration()
showCallTimer.value = true showCallTimer.value = true
if (ua.account.mediaEnc == "") if (ua.account.mediaEnc == "")
securityIcon.intValue = -1 securityIconTint.intValue = -1
else else
securityIcon.intValue = call.security securityIconTint.intValue = call.security
showCallButton.value = false showCallButton.value = false
showCancelButton.value = false showCancelButton.value = false
showHangupButton.value = true showHangupButton.value = true
@ -2253,20 +2258,20 @@ fun handleServiceEvent(ctx: Context, viewModel: ViewModel, event: String, params
onPositiveClicked.value = { onPositiveClicked.value = {
call.security = if (Api.cmd_exec("zrtp_verify ${ev[2]}") != 0) { call.security = if (Api.cmd_exec("zrtp_verify ${ev[2]}") != 0) {
Log.e(TAG, "Command 'zrtp_verify ${ev[2]}' failed") Log.e(TAG, "Command 'zrtp_verify ${ev[2]}' failed")
R.drawable.locked_yellow R.color.colorTrafficYellow
} else { } else {
R.drawable.locked_green R.color.colorTrafficGreen
} }
call.zid = ev[2] call.zid = ev[2]
if (aor == viewModel.selectedAor.value) if (aor == viewModel.selectedAor.value)
securityIcon.intValue = call.security securityIconTint.intValue = call.security
} }
negativeText.value = ctx.getString(R.string.no) negativeText.value = ctx.getString(R.string.no)
onNegativeClicked.value = { onNegativeClicked.value = {
call.security = R.drawable.locked_yellow call.security = R.color.colorTrafficYellow
call.zid = ev[2] call.zid = ev[2]
if (aor == viewModel.selectedAor.value) if (aor == viewModel.selectedAor.value)
securityIcon.intValue = R.drawable.locked_yellow securityIconTint.intValue = R.color.colorTrafficYellow
onNegativeClicked.value = {} onNegativeClicked.value = {}
} }
showDialog.value = true showDialog.value = true
@ -2279,7 +2284,7 @@ fun handleServiceEvent(ctx: Context, viewModel: ViewModel, event: String, params
return return
} }
if (aor == viewModel.selectedAor.value) if (aor == viewModel.selectedAor.value)
securityIcon.intValue = call.security securityIconTint.intValue = call.security
} }
"call transfer", "transfer show" -> { "call transfer", "transfer show" -> {
if (!BaresipService.isMainVisible) if (!BaresipService.isMainVisible)
@ -2330,7 +2335,7 @@ fun handleServiceEvent(ctx: Context, viewModel: ViewModel, event: String, params
} }
else { else {
showCallTimer.value = false showCallTimer.value = false
securityIcon.intValue = -1 securityIconTint.intValue = -1
} }
if (aor == viewModel.selectedAor.value) { if (aor == viewModel.selectedAor.value) {
ua.account.resumeUri = "" ua.account.resumeUri = ""

View File

@ -1,5 +0,0 @@
<vector android:height="24dp"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@color/colorTrafficGreen" android:pathData="M18,8h-1L17,6c0,-2.76 -2.24,-5 -5,-5S7,3.24 7,6v2L6,8c-1.1,0 -2,0.9 -2,2v10c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2L20,10c0,-1.1 -0.9,-2 -2,-2zM12,17c-1.1,0 -2,-0.9 -2,-2s0.9,-2 2,-2 2,0.9 2,2 -0.9,2 -2,2zM15.1,8L8.9,8L8.9,6c0,-1.71 1.39,-3.1 3.1,-3.1 1.71,0 3.1,1.39 3.1,3.1v2z"/>
</vector>

View File

@ -1,5 +0,0 @@
<vector android:height="24dp"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@color/colorTrafficYellow" android:pathData="M18,8h-1L17,6c0,-2.76 -2.24,-5 -5,-5S7,3.24 7,6v2L6,8c-1.1,0 -2,0.9 -2,2v10c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2L20,10c0,-1.1 -0.9,-2 -2,-2zM12,17c-1.1,0 -2,-0.9 -2,-2s0.9,-2 2,-2 2,0.9 2,2 -0.9,2 -2,2zM15.1,8L8.9,8L8.9,6c0,-1.71 1.39,-3.1 3.1,-3.1 1.71,0 3.1,1.39 3.1,3.1v2z"/>
</vector>

View File

@ -1,5 +0,0 @@
<vector android:height="24dp"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@color/colorTrafficRed" android:pathData="M12,17c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2 -2,0.9 -2,2 0.9,2 2,2zM18,8h-1L17,6c0,-2.76 -2.24,-5 -5,-5S7,3.24 7,6h1.9c0,-1.71 1.39,-3.1 3.1,-3.1 1.71,0 3.1,1.39 3.1,3.1v2L6,8c-1.1,0 -2,0.9 -2,2v10c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2L20,10c0,-1.1 -0.9,-2 -2,-2zM18,20L6,20L6,10h12v10z"/>
</vector>