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

View File

@ -1067,7 +1067,10 @@ private fun AccountContent(
@Composable
fun Voicemail() {
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()
Row(
Modifier.fillMaxWidth().padding(end = 10.dp),

View File

@ -1758,7 +1758,7 @@ class BaresipService: Service() {
android.telecom.Call.STATE_RINGING -> "incoming"
android.telecom.Call.STATE_DIALING, android.telecom.Call.STATE_CONNECTING -> "outgoing"
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 -> {
calls.find { it.callp == call.hashCode().toLong() }?.onhold = true
"connected"

View File

@ -740,6 +740,9 @@ private fun BottomBar(ctx: Context, viewModel: ViewModel, navController: NavCont
val hasNewVoicemail = remember(aor, accountUpdate) {
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) {
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 acc = ua.account
if (acc.vmUri.isNotEmpty()) {
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 = {
if (isMobile) {
val intent = Intent(ctx, MainActivity::class.java)
intent.putExtra("uap", ua.uap)
intent.putExtra("peer", acc.vmUri)
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
@ -809,22 +819,23 @@ private fun BottomBar(ctx: Context, viewModel: ViewModel, navController: NavCont
)
}
IconButton(
enabled = aor.isNotEmpty(),
onClick = {
navController.navigate("chats/$aor")
},
modifier = Modifier
.weight(1f)
.size(buttonSize)
) {
Icon(
imageVector = Icons.AutoMirrored.Filled.Chat,
contentDescription = null,
Modifier.size(buttonSize),
tint = if (hasUnreadMessages) MaterialTheme.colorScheme.error else MaterialTheme.colorScheme.secondary
)
}
if (!isMobile)
IconButton(
enabled = aor.isNotEmpty(),
onClick = {
navController.navigate("chats/$aor")
},
modifier = Modifier
.weight(1f)
.size(buttonSize)
) {
Icon(
imageVector = Icons.AutoMirrored.Filled.Chat,
contentDescription = null,
Modifier.size(buttonSize),
tint = if (hasUnreadMessages) MaterialTheme.colorScheme.error else MaterialTheme.colorScheme.secondary
)
}
IconButton(
enabled = aor.isNotEmpty(),

View File

@ -206,9 +206,10 @@
<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="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.
</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_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