More call code styling

This commit is contained in:
Juha Heinanen
2026-08-03 15:32:28 +03:00
parent 6ee6f8fe26
commit 1380f05d1a
3 changed files with 27 additions and 55 deletions

View File

@ -174,18 +174,21 @@ private fun Peer(ctx: Context, callRow: CallRow) {
@Composable
private fun Details(ctx: Context, details: SnapshotStateList<Details>, onDelete: (Details) -> Unit) {
Row(verticalAlignment = Alignment.CenterVertically) {
Text(text = stringResource(R.string.direction),
Text(
text = stringResource(R.string.direction),
fontSize = 16.sp,
fontWeight = FontWeight.SemiBold,
modifier = Modifier.width(96.dp)
)
Spacer(modifier = Modifier.width(6.dp))
Text(text = stringResource(R.string.time),
Text(
text = stringResource(R.string.time),
fontSize = 16.sp,
fontWeight = FontWeight.SemiBold
)
Spacer(modifier = Modifier.weight(1f))
Text(text = stringResource(R.string.calls_duration),
Text(
text = stringResource(R.string.calls_duration),
modifier = Modifier.padding(end = 12.dp),
fontSize = 16.sp,
fontWeight = FontWeight.SemiBold
@ -336,8 +339,7 @@ private fun Duration(ctx: Context, detail: Details, durationText: String) {
}
else
withContext(Dispatchers.Main) {
Toast.makeText(ctx, "Source file not found", Toast.LENGTH_SHORT)
.show()
Toast.makeText(ctx, "Source file not found", Toast.LENGTH_SHORT).show()
}
}
} catch (e: Exception) {
@ -354,8 +356,7 @@ private fun Duration(ctx: Context, detail: Details, durationText: String) {
showDialog = showPlaybackDialog,
mediaPlayer = mediaPlayer,
onStop = {
if (mediaPlayer.isPlaying)
mediaPlayer.stop()
if (mediaPlayer.isPlaying) mediaPlayer.stop()
mediaPlayer.reset()
showPlaybackDialog.value = false
}
@ -504,16 +505,10 @@ private fun Duration(ctx: Context, detail: Details, durationText: String) {
}
} catch (e: Exception) {
Log.e(TAG, "Playback failed: $e")
Toast.makeText(
ctx, "Playback error",
Toast.LENGTH_SHORT
).show()
Toast.makeText(ctx, "Playback error", Toast.LENGTH_SHORT).show()
}
else
Toast.makeText(
ctx, "Failed to process audio file",
Toast.LENGTH_SHORT
).show()
Toast.makeText(ctx, "Failed to process audio file", Toast.LENGTH_SHORT).show()
}
}
}
@ -578,9 +573,7 @@ private fun PlaybackDialog(
}
},
confirmButton = {
TextButton(onClick = { onStop() }) {
Text(stringResource(R.string.stop))
}
TextButton(onClick = { onStop() }) { Text(stringResource(R.string.stop)) }
}
)
}

View File

@ -148,5 +148,6 @@ class CallHistoryNew(val aor: String, val peerUri: String, val direction: String
Log.d(TAG, "[${h.aor}, ${h.peerUri}, ${h.direction}, ${h.startTime}," +
"${h.stopTime}, ${h.rejected}, ${h.recording}")
}
}
}

View File

@ -101,21 +101,17 @@ private fun CallsScreen(navController: NavController, viewModel: ViewModel, aor:
val ctx = LocalContext.current
LaunchedEffect(ua, refreshTrigger) {
if (ua.account.isMobile)
Utils.cancelMissedCallsNotification(ctx)
if (ua.account.isMobile) Utils.cancelMissedCallsNotification(ctx)
callHistory.value = loadCallHistory(aor)
isHistoryLoaded = true
}
DisposableEffect(lifecycleOwner) {
val observer = LifecycleEventObserver { _, event ->
if (event == Lifecycle.Event.ON_RESUME)
refreshTrigger++
if (event == Lifecycle.Event.ON_RESUME) refreshTrigger++
}
lifecycleOwner.lifecycle.addObserver(observer)
onDispose {
lifecycleOwner.lifecycle.removeObserver(observer)
}
onDispose { lifecycleOwner.lifecycle.removeObserver(observer) }
}
BackHandler(enabled = true) {
@ -137,14 +133,7 @@ private fun CallsScreen(navController: NavController, viewModel: ViewModel, aor:
},
content = { contentPadding ->
if (isHistoryLoaded)
CallsContent(
LocalContext.current,
navController,
viewModel,
contentPadding,
ua,
callHistory
)
CallsContent(LocalContext.current, navController, viewModel, contentPadding, ua, callHistory)
},
)
}
@ -206,9 +195,7 @@ private fun TopAppBar(navController: NavController, ua: UserAgent, callHistory:
}
},
actions = {
IconButton(
onClick = { expanded = !expanded }
) {
IconButton(onClick = { expanded = !expanded }) {
Icon(imageVector = Icons.Filled.Menu, contentDescription = "Menu")
}
CustomElements.DropdownMenu(
@ -230,11 +217,10 @@ private fun TopAppBar(navController: NavController, ua: UserAgent, callHistory:
account.callHistory = !account.callHistory
Account.saveAccounts()
}
blocked -> {
blocked ->
navController.navigate("blocked/invite/${account.aor}")
}
}
}
)
}
)
@ -250,10 +236,7 @@ private fun CallsContent(
callHistory: MutableState<List<CallRow>>
) {
Column(
modifier = Modifier
.fillMaxWidth()
.padding(contentPadding)
.padding(bottom = 16.dp),
modifier = Modifier.fillMaxWidth().padding(contentPadding).padding(bottom = 16.dp),
verticalArrangement = Arrangement.spacedBy(12.dp)
) {
Account(ua.account)
@ -378,8 +361,7 @@ private fun Calls(
ctx.getString(R.string.airplane_mode)
showAlert.value = true
}
else
if (!Utils.isDefaultSmsApp(ctx)) {
else if (!Utils.isDefaultSmsApp(ctx)) {
alertTitle.value = ctx.getString(R.string.notice)
alertMessage.value =
ctx.getString(R.string.enable_default_messaging)
@ -478,7 +460,7 @@ private fun Calls(
else
CustomElements.TextAvatar(contact.name, contact.color)
}
null -> {
null ->
Icon(
imageVector = Icons.Filled.AccountCircle,
contentDescription = "Avatar",
@ -486,14 +468,11 @@ private fun Calls(
tint = MaterialTheme.colorScheme.secondary
)
}
}
Spacer(modifier = Modifier.width(4.dp))
var count = 1
for (d in callRow.details) {
if (d.recording.isNotEmpty() && d.recording[0] != "")
recordings = true
if (count > 3)
continue
if (d.recording.isNotEmpty() && d.recording[0] != "") recordings = true
if (count > 3) continue
Icon(
imageVector = if (callUp(d.direction))
Icons.AutoMirrored.Filled.CallMade
@ -557,10 +536,9 @@ private fun loadCallHistory(aor: String): MutableList<CallRow> {
if (h.rejected) CALL_UP_RED else CALL_MISSED_OUT
}
if (res.isNotEmpty() && res.last().peerUri == h.peerUri)
res.last().details.add(CallRow.Details(
direction, h.startTime,
h.stopTime, h.recording.toList()
))
res.last().details.add(
CallRow.Details(direction, h.startTime, h.stopTime, h.recording.toList())
)
else
res.add(CallRow(h.aor, h.peerUri, direction, h.startTime, h.stopTime, h.recording.toList()))
}