Added tooltips to mic and speakerphone icons

This commit is contained in:
Juha Heinanen
2025-04-26 07:28:33 +03:00
parent 964af9fe9d
commit d19bf4db78
2 changed files with 59 additions and 69 deletions
@@ -82,7 +82,6 @@ import androidx.compose.material.icons.filled.KeyboardArrowUp
import androidx.compose.material.icons.filled.Menu
import androidx.compose.material.icons.outlined.Clear
import androidx.compose.material3.BasicAlertDialog
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonColors
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
@@ -93,21 +92,17 @@ import androidx.compose.material3.IconButton
import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.OutlinedTextFieldDefaults
import androidx.compose.material3.RichTooltip
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Surface
import androidx.compose.material3.Switch
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.material3.TextField
import androidx.compose.material3.TooltipBox
import androidx.compose.material3.TooltipDefaults
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.material3.pulltorefresh.PullToRefreshDefaults.Indicator
import androidx.compose.material3.pulltorefresh.pullToRefresh
import androidx.compose.material3.pulltorefresh.rememberPullToRefreshState
import androidx.compose.material3.rememberTooltipState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
@@ -116,7 +111,6 @@ import androidx.compose.runtime.mutableFloatStateOf
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
@@ -153,12 +147,10 @@ import com.tutpro.baresip.CustomElements.SelectableAlertDialog
import com.tutpro.baresip.CustomElements.Text
import com.tutpro.baresip.CustomElements.verticalScrollbar
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import java.io.File
import java.text.SimpleDateFormat
import java.util.Date
import java.util.Locale
import kotlin.collections.set
import kotlin.system.exitProcess
class MainActivity : ComponentActivity() {
@@ -685,34 +677,9 @@ class MainActivity : ComponentActivity() {
containerColor = LocalCustomColors.current.primary
),
actions = {
val scope = rememberCoroutineScope()
val tooltipState = rememberTooltipState()
TooltipBox(
positionProvider = TooltipDefaults.rememberRichTooltipPositionProvider(),
tooltip = {
RichTooltip(
title = { Text(
text = "Call Recording",
color = LocalCustomColors.current.alert,
fontSize = 18.sp,
modifier = Modifier.padding(bottom = 4.dp)
) },
text = { Text(
text = "If activated, new incoming or outgoing calls are recorded.",
color = LocalCustomColors.current.itemText,
fontSize = 16.sp
) },
caretSize = TooltipDefaults.caretSize,
shape = RoundedCornerShape(16.dp),
colors = TooltipDefaults.richTooltipColors(
containerColor = LocalCustomColors.current.cardBackground,
),
)
},
enableUserInput = true,
state = tooltipState
) {
IconButton(
modifier = Modifier.combinedClickable(
onClick = {
if (Call.call("connected") == null) {
BaresipService.isRecOn = !BaresipService.isRecOn
@@ -726,6 +693,14 @@ class MainActivity : ComponentActivity() {
} else
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
}
),
onClick = {}
) {
Icon(
imageVector = recImage,
@@ -733,12 +708,12 @@ class MainActivity : ComponentActivity() {
contentDescription = null
)
}
}
Spacer(modifier = Modifier.width(16.dp))
IconButton(
modifier = Modifier.padding(end=12.dp),
modifier = Modifier.padding(end=12.dp)
.combinedClickable(
onClick = {
if (Call.call("connected") != null) {
BaresipService.isMicMuted = !BaresipService.isMicMuted
@@ -750,7 +725,14 @@ class MainActivity : ComponentActivity() {
Api.calls_mute(false)
}
}
}
},
onLongClick = {
alertTitle.value = "Microphone"
alertMessage.value = "If activated, microphone is muted."
showAlert.value = true
},
),
onClick = {}
) {
Icon(
imageVector = ImageVector.vectorResource(micIcon),
@@ -759,7 +741,8 @@ class MainActivity : ComponentActivity() {
}
IconButton(
modifier = Modifier.padding(end=6.dp),
modifier = Modifier.padding(end=6.dp)
.combinedClickable(
onClick = {
if (Build.VERSION.SDK_INT >= 31)
Log.d(TAG, "Toggling speakerphone when dev/mode is " +
@@ -770,7 +753,14 @@ class MainActivity : ComponentActivity() {
R.drawable.speaker_on
else
R.drawable.speaker_off
}
},
onLongClick = {
alertTitle.value = "Speakerphone"
alertMessage.value = "If activated, audio is player via speakerphone."
showAlert.value = true
},
),
onClick = {}
) {
Icon(
imageVector = ImageVector.vectorResource(speakerIcon),