Do not show chat button on mainscreen of mobile account

Call voicemail directly when voicemail button it touched on mainscreen of mobile account
Properly handle canceling of mobile call
This commit is contained in:
Juha Heinanen
2026-05-12 08:33:44 +03:00
parent ca1d991c98
commit 294d30055d
4 changed files with 42 additions and 27 deletions
@@ -1067,7 +1067,10 @@ private fun AccountContent(
@Composable @Composable
fun Voicemail() { fun Voicemail() {
val voicemailUriTitle = stringResource(R.string.voicemail_uri) val voicemailUriTitle = stringResource(R.string.voicemail_uri)
val voicemailUriHelp = stringResource(R.string.voicemain_uri_help) val voicemailUriHelp = if (ua.account.isMobile)
stringResource(R.string.voicemain_tel_uri_help)
else
stringResource(R.string.voicemain_uri_help)
val vmUri by viewModel.vmUri.collectAsState() val vmUri by viewModel.vmUri.collectAsState()
Row( Row(
Modifier.fillMaxWidth().padding(end = 10.dp), Modifier.fillMaxWidth().padding(end = 10.dp),
@@ -1758,7 +1758,7 @@ class BaresipService: Service() {
android.telecom.Call.STATE_RINGING -> "incoming" android.telecom.Call.STATE_RINGING -> "incoming"
android.telecom.Call.STATE_DIALING, android.telecom.Call.STATE_CONNECTING -> "outgoing" android.telecom.Call.STATE_DIALING, android.telecom.Call.STATE_CONNECTING -> "outgoing"
android.telecom.Call.STATE_ACTIVE -> "connected" android.telecom.Call.STATE_ACTIVE -> "connected"
android.telecom.Call.STATE_DISCONNECTED -> "closed" android.telecom.Call.STATE_DISCONNECTED, android.telecom.Call.STATE_DISCONNECTING -> "closed"
android.telecom.Call.STATE_HOLDING -> { android.telecom.Call.STATE_HOLDING -> {
calls.find { it.callp == call.hashCode().toLong() }?.onhold = true calls.find { it.callp == call.hashCode().toLong() }?.onhold = true
"connected" "connected"
@@ -740,6 +740,9 @@ private fun BottomBar(ctx: Context, viewModel: ViewModel, navController: NavCont
val hasNewVoicemail = remember(aor, accountUpdate) { val hasNewVoicemail = remember(aor, accountUpdate) {
if (aor.isNotEmpty()) (Account.ofAor(aor)?.vmNew ?: 0) > 0 else false if (aor.isNotEmpty()) (Account.ofAor(aor)?.vmNew ?: 0) > 0 else false
} }
val isMobile = remember(aor, accountUpdate) {
if (aor.isNotEmpty()) Account.ofAor(aor)?.isMobile ?: false else false
}
val hasUnreadMessages = remember(aor, accountUpdate) { val hasUnreadMessages = remember(aor, accountUpdate) {
if (aor.isNotEmpty()) Account.ofAor(aor)?.unreadMessages ?: false else false if (aor.isNotEmpty()) Account.ofAor(aor)?.unreadMessages ?: false else false
} }
@@ -768,19 +771,26 @@ private fun BottomBar(ctx: Context, viewModel: ViewModel, navController: NavCont
val ua = UserAgent.ofAor(aor)!! val ua = UserAgent.ofAor(aor)!!
val acc = ua.account val acc = ua.account
if (acc.vmUri.isNotEmpty()) { if (acc.vmUri.isNotEmpty()) {
dialogTitle.value = ctx.getString(R.string.voicemail_messages) if (isMobile) {
dialogMessage.value = acc.vmMessages(ctx)
firstText.value = ctx.getString(R.string.cancel)
onFirstClicked.value = {}
secondText.value = ""
lastText.value = ctx.getString(R.string.listen)
onLastClicked.value = {
val intent = Intent(ctx, MainActivity::class.java) val intent = Intent(ctx, MainActivity::class.java)
intent.putExtra("uap", ua.uap) intent.putExtra("uap", ua.uap)
intent.putExtra("peer", acc.vmUri) intent.putExtra("peer", acc.vmUri)
handleIntent(ctx, viewModel, intent, "call") handleIntent(ctx, viewModel, intent, "call")
} else {
dialogTitle.value = ctx.getString(R.string.voicemail_messages)
dialogMessage.value = acc.vmMessages(ctx)
firstText.value = ctx.getString(R.string.cancel)
onFirstClicked.value = {}
secondText.value = ""
lastText.value = ctx.getString(R.string.listen)
onLastClicked.value = {
val intent = Intent(ctx, MainActivity::class.java)
intent.putExtra("uap", ua.uap)
intent.putExtra("peer", acc.vmUri)
handleIntent(ctx, viewModel, intent, "call")
}
showDialog.value = true
} }
showDialog.value = true
} }
}, },
modifier = Modifier modifier = Modifier
@@ -809,22 +819,23 @@ private fun BottomBar(ctx: Context, viewModel: ViewModel, navController: NavCont
) )
} }
IconButton( if (!isMobile)
enabled = aor.isNotEmpty(), IconButton(
onClick = { enabled = aor.isNotEmpty(),
navController.navigate("chats/$aor") onClick = {
}, navController.navigate("chats/$aor")
modifier = Modifier },
.weight(1f) modifier = Modifier
.size(buttonSize) .weight(1f)
) { .size(buttonSize)
Icon( ) {
imageVector = Icons.AutoMirrored.Filled.Chat, Icon(
contentDescription = null, imageVector = Icons.AutoMirrored.Filled.Chat,
Modifier.size(buttonSize), contentDescription = null,
tint = if (hasUnreadMessages) MaterialTheme.colorScheme.error else MaterialTheme.colorScheme.secondary Modifier.size(buttonSize),
) tint = if (hasUnreadMessages) MaterialTheme.colorScheme.error else MaterialTheme.colorScheme.secondary
} )
}
IconButton( IconButton(
enabled = aor.isNotEmpty(), enabled = aor.isNotEmpty(),
+2 -1
View File
@@ -206,9 +206,10 @@
<string name="block_unknown">Block Unknown</string> <string name="block_unknown">Block Unknown</string>
<string name="block_unknown_help">Block calls and messages from peers that are not found in contacts.</string> <string name="block_unknown_help">Block calls and messages from peers that are not found in contacts.</string>
<string name="voicemail_uri">Voicemail URI</string> <string name="voicemail_uri">Voicemail URI</string>
<string name="voicemain_uri_help">SIP or TEL URI for checking of voicemail messages. If left empty, voicemail <string name="voicemain_uri_help">SIP URI for checking of voicemail messages. If left empty, voicemail
messages (Message Waiting Indications) are not subscribed to. messages (Message Waiting Indications) are not subscribed to.
</string> </string>
<string name="voicemain_tel_uri_help">TEL URI for checking of voicemail messages.</string>
<string name="country_code">Country Code</string> <string name="country_code">Country Code</string>
<string name="country_code_help">E.164 country code of this account. If From URI userpart of <string name="country_code_help">E.164 country code of this account. If From URI userpart of
incoming call or message contains a telephone number that does not start with \'+\' sign and if contact incoming call or message contains a telephone number that does not start with \'+\' sign and if contact