Added tooltips to main actiity top app bar icons

This commit is contained in:
Juha Heinanen
2025-04-26 12:32:33 +03:00
@@ -151,7 +151,6 @@ import java.io.File
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.Date import java.util.Date
import java.util.Locale import java.util.Locale
import kotlin.collections.set
import kotlin.system.exitProcess import kotlin.system.exitProcess
class MainActivity : ComponentActivity() { class MainActivity : ComponentActivity() {
@@ -608,8 +607,7 @@ class MainActivity : ComponentActivity() {
showCall(ua) showCall(ua)
} }
} }
} } else if (offset > swipeThreshold) {
else if (offset > swipeThreshold) {
if (uas.value.isNotEmpty()) { if (uas.value.isNotEmpty()) {
val curPos = UserAgent.findAorIndex(viewModel.selectedAor.value) val curPos = UserAgent.findAorIndex(viewModel.selectedAor.value)
val newPos = when (curPos) { val newPos = when (curPos) {
@@ -679,30 +677,39 @@ class MainActivity : ComponentActivity() {
containerColor = LocalCustomColors.current.primary containerColor = LocalCustomColors.current.primary
), ),
actions = { actions = {
IconButton(
modifier = Modifier.padding(end=12.dp), Icon(
imageVector = recImage,
modifier = Modifier.size(40.dp).combinedClickable(
onClick = { onClick = {
if (Call.call("connected") == null) { if (Call.call("connected") == null) {
BaresipService.isRecOn = !BaresipService.isRecOn BaresipService.isRecOn = !BaresipService.isRecOn
recImage = if (BaresipService.isRecOn) { recImage = if (BaresipService.isRecOn) {
Api.module_load("sndfile") Api.module_load("sndfile")
recOnImage recOnImage
} } else {
else {
Api.module_unload("sndfile") Api.module_unload("sndfile")
recOffImage recOffImage
} }
} } else
else
Toast.makeText(ctx, R.string.rec_in_call, Toast.LENGTH_SHORT).show() Toast.makeText(ctx, R.string.rec_in_call, Toast.LENGTH_SHORT).show()
},
onLongClick = {
alertTitle.value = "Call Recording"
alertMessage.value = "If activated, new incoming and outgoing calls will be recorded." +
" Recordings can be played on Call Details page"
showAlert.value = true
} }
) { ),
Icon(imageVector = recImage,
tint = Color.Unspecified, tint = Color.Unspecified,
contentDescription = null) contentDescription = null
} )
IconButton(
modifier = Modifier.padding(end=12.dp), Spacer(modifier = Modifier.width(22.dp))
Icon(
imageVector = ImageVector.vectorResource(micIcon),
modifier = Modifier.size(40.dp).combinedClickable(
onClick = { onClick = {
if (Call.call("connected") != null) { if (Call.call("connected") != null) {
BaresipService.isMicMuted = !BaresipService.isMicMuted BaresipService.isMicMuted = !BaresipService.isMicMuted
@@ -714,15 +721,22 @@ class MainActivity : ComponentActivity() {
Api.calls_mute(false) Api.calls_mute(false)
} }
} }
} },
) { onLongClick = {
Icon( alertTitle.value = "Microphone"
imageVector = ImageVector.vectorResource(micIcon), alertMessage.value = "If activated during call, microphone is muted."
showAlert.value = true
},
),
tint = Color.Unspecified, tint = Color.Unspecified,
contentDescription = null) contentDescription = null
} )
IconButton(
modifier = Modifier.padding(end=6.dp), Spacer(modifier = Modifier.width(16.dp))
Icon(
imageVector = ImageVector.vectorResource(speakerIcon),
modifier = Modifier.size(40.dp).combinedClickable(
onClick = { onClick = {
if (Build.VERSION.SDK_INT >= 31) if (Build.VERSION.SDK_INT >= 31)
Log.d(TAG, "Toggling speakerphone when dev/mode is " + Log.d(TAG, "Toggling speakerphone when dev/mode is " +
@@ -733,13 +747,19 @@ class MainActivity : ComponentActivity() {
R.drawable.speaker_on R.drawable.speaker_on
else else
R.drawable.speaker_off R.drawable.speaker_off
} },
) { onLongClick = {
Icon( alertTitle.value = "Speakerphone"
imageVector = ImageVector.vectorResource(speakerIcon), alertMessage.value = "If activated, audio is player via device speakerphone."
showAlert.value = true
},
),
tint = Color.Unspecified, tint = Color.Unspecified,
contentDescription = null) contentDescription = null
} )
Spacer(modifier = Modifier.width(8.dp))
IconButton( IconButton(
onClick = { menuExpanded = !menuExpanded } onClick = { menuExpanded = !menuExpanded }
) { ) {
@@ -749,6 +769,7 @@ class MainActivity : ComponentActivity() {
tint = LocalCustomColors.current.light tint = LocalCustomColors.current.light
) )
} }
DropdownMenu( DropdownMenu(
expanded = menuExpanded, expanded = menuExpanded,
onDismissRequest = { menuExpanded = false }, onDismissRequest = { menuExpanded = false },
@@ -1701,7 +1722,8 @@ class MainActivity : ComponentActivity() {
alertTitle.value = getString(R.string.notice) alertTitle.value = getString(R.string.notice)
alertMessage.value = String.format(getString(R.string.invalid_sip_or_tel_uri), uri) alertMessage.value = String.format(getString(R.string.invalid_sip_or_tel_uri), uri)
showAlert.value = true showAlert.value = true
} else if (!BaresipService.requestAudioFocus(applicationContext)) { }
else if (!BaresipService.requestAudioFocus(applicationContext)) {
Toast.makeText(applicationContext, R.string.audio_focus_denied, Toast.makeText(applicationContext, R.string.audio_focus_denied,
Toast.LENGTH_SHORT).show() Toast.LENGTH_SHORT).show()
} else { } else {