More call code styling
This commit is contained in:
@ -174,18 +174,21 @@ private fun Peer(ctx: Context, callRow: CallRow) {
|
|||||||
@Composable
|
@Composable
|
||||||
private fun Details(ctx: Context, details: SnapshotStateList<Details>, onDelete: (Details) -> Unit) {
|
private fun Details(ctx: Context, details: SnapshotStateList<Details>, onDelete: (Details) -> Unit) {
|
||||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||||
Text(text = stringResource(R.string.direction),
|
Text(
|
||||||
|
text = stringResource(R.string.direction),
|
||||||
fontSize = 16.sp,
|
fontSize = 16.sp,
|
||||||
fontWeight = FontWeight.SemiBold,
|
fontWeight = FontWeight.SemiBold,
|
||||||
modifier = Modifier.width(96.dp)
|
modifier = Modifier.width(96.dp)
|
||||||
)
|
)
|
||||||
Spacer(modifier = Modifier.width(6.dp))
|
Spacer(modifier = Modifier.width(6.dp))
|
||||||
Text(text = stringResource(R.string.time),
|
Text(
|
||||||
|
text = stringResource(R.string.time),
|
||||||
fontSize = 16.sp,
|
fontSize = 16.sp,
|
||||||
fontWeight = FontWeight.SemiBold
|
fontWeight = FontWeight.SemiBold
|
||||||
)
|
)
|
||||||
Spacer(modifier = Modifier.weight(1f))
|
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),
|
modifier = Modifier.padding(end = 12.dp),
|
||||||
fontSize = 16.sp,
|
fontSize = 16.sp,
|
||||||
fontWeight = FontWeight.SemiBold
|
fontWeight = FontWeight.SemiBold
|
||||||
@ -336,8 +339,7 @@ private fun Duration(ctx: Context, detail: Details, durationText: String) {
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
withContext(Dispatchers.Main) {
|
withContext(Dispatchers.Main) {
|
||||||
Toast.makeText(ctx, "Source file not found", Toast.LENGTH_SHORT)
|
Toast.makeText(ctx, "Source file not found", Toast.LENGTH_SHORT).show()
|
||||||
.show()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
@ -354,8 +356,7 @@ private fun Duration(ctx: Context, detail: Details, durationText: String) {
|
|||||||
showDialog = showPlaybackDialog,
|
showDialog = showPlaybackDialog,
|
||||||
mediaPlayer = mediaPlayer,
|
mediaPlayer = mediaPlayer,
|
||||||
onStop = {
|
onStop = {
|
||||||
if (mediaPlayer.isPlaying)
|
if (mediaPlayer.isPlaying) mediaPlayer.stop()
|
||||||
mediaPlayer.stop()
|
|
||||||
mediaPlayer.reset()
|
mediaPlayer.reset()
|
||||||
showPlaybackDialog.value = false
|
showPlaybackDialog.value = false
|
||||||
}
|
}
|
||||||
@ -504,16 +505,10 @@ private fun Duration(ctx: Context, detail: Details, durationText: String) {
|
|||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.e(TAG, "Playback failed: $e")
|
Log.e(TAG, "Playback failed: $e")
|
||||||
Toast.makeText(
|
Toast.makeText(ctx, "Playback error", Toast.LENGTH_SHORT).show()
|
||||||
ctx, "Playback error",
|
|
||||||
Toast.LENGTH_SHORT
|
|
||||||
).show()
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Toast.makeText(
|
Toast.makeText(ctx, "Failed to process audio file", Toast.LENGTH_SHORT).show()
|
||||||
ctx, "Failed to process audio file",
|
|
||||||
Toast.LENGTH_SHORT
|
|
||||||
).show()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -578,9 +573,7 @@ private fun PlaybackDialog(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
confirmButton = {
|
confirmButton = {
|
||||||
TextButton(onClick = { onStop() }) {
|
TextButton(onClick = { onStop() }) { Text(stringResource(R.string.stop)) }
|
||||||
Text(stringResource(R.string.stop))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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}," +
|
Log.d(TAG, "[${h.aor}, ${h.peerUri}, ${h.direction}, ${h.startTime}," +
|
||||||
"${h.stopTime}, ${h.rejected}, ${h.recording}")
|
"${h.stopTime}, ${h.rejected}, ${h.recording}")
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -101,21 +101,17 @@ private fun CallsScreen(navController: NavController, viewModel: ViewModel, aor:
|
|||||||
val ctx = LocalContext.current
|
val ctx = LocalContext.current
|
||||||
|
|
||||||
LaunchedEffect(ua, refreshTrigger) {
|
LaunchedEffect(ua, refreshTrigger) {
|
||||||
if (ua.account.isMobile)
|
if (ua.account.isMobile) Utils.cancelMissedCallsNotification(ctx)
|
||||||
Utils.cancelMissedCallsNotification(ctx)
|
|
||||||
callHistory.value = loadCallHistory(aor)
|
callHistory.value = loadCallHistory(aor)
|
||||||
isHistoryLoaded = true
|
isHistoryLoaded = true
|
||||||
}
|
}
|
||||||
|
|
||||||
DisposableEffect(lifecycleOwner) {
|
DisposableEffect(lifecycleOwner) {
|
||||||
val observer = LifecycleEventObserver { _, event ->
|
val observer = LifecycleEventObserver { _, event ->
|
||||||
if (event == Lifecycle.Event.ON_RESUME)
|
if (event == Lifecycle.Event.ON_RESUME) refreshTrigger++
|
||||||
refreshTrigger++
|
|
||||||
}
|
}
|
||||||
lifecycleOwner.lifecycle.addObserver(observer)
|
lifecycleOwner.lifecycle.addObserver(observer)
|
||||||
onDispose {
|
onDispose { lifecycleOwner.lifecycle.removeObserver(observer) }
|
||||||
lifecycleOwner.lifecycle.removeObserver(observer)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BackHandler(enabled = true) {
|
BackHandler(enabled = true) {
|
||||||
@ -137,14 +133,7 @@ private fun CallsScreen(navController: NavController, viewModel: ViewModel, aor:
|
|||||||
},
|
},
|
||||||
content = { contentPadding ->
|
content = { contentPadding ->
|
||||||
if (isHistoryLoaded)
|
if (isHistoryLoaded)
|
||||||
CallsContent(
|
CallsContent(LocalContext.current, navController, viewModel, contentPadding, ua, callHistory)
|
||||||
LocalContext.current,
|
|
||||||
navController,
|
|
||||||
viewModel,
|
|
||||||
contentPadding,
|
|
||||||
ua,
|
|
||||||
callHistory
|
|
||||||
)
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -206,9 +195,7 @@ private fun TopAppBar(navController: NavController, ua: UserAgent, callHistory:
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions = {
|
actions = {
|
||||||
IconButton(
|
IconButton(onClick = { expanded = !expanded }) {
|
||||||
onClick = { expanded = !expanded }
|
|
||||||
) {
|
|
||||||
Icon(imageVector = Icons.Filled.Menu, contentDescription = "Menu")
|
Icon(imageVector = Icons.Filled.Menu, contentDescription = "Menu")
|
||||||
}
|
}
|
||||||
CustomElements.DropdownMenu(
|
CustomElements.DropdownMenu(
|
||||||
@ -230,11 +217,10 @@ private fun TopAppBar(navController: NavController, ua: UserAgent, callHistory:
|
|||||||
account.callHistory = !account.callHistory
|
account.callHistory = !account.callHistory
|
||||||
Account.saveAccounts()
|
Account.saveAccounts()
|
||||||
}
|
}
|
||||||
blocked -> {
|
blocked ->
|
||||||
navController.navigate("blocked/invite/${account.aor}")
|
navController.navigate("blocked/invite/${account.aor}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@ -250,10 +236,7 @@ private fun CallsContent(
|
|||||||
callHistory: MutableState<List<CallRow>>
|
callHistory: MutableState<List<CallRow>>
|
||||||
) {
|
) {
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier.fillMaxWidth().padding(contentPadding).padding(bottom = 16.dp),
|
||||||
.fillMaxWidth()
|
|
||||||
.padding(contentPadding)
|
|
||||||
.padding(bottom = 16.dp),
|
|
||||||
verticalArrangement = Arrangement.spacedBy(12.dp)
|
verticalArrangement = Arrangement.spacedBy(12.dp)
|
||||||
) {
|
) {
|
||||||
Account(ua.account)
|
Account(ua.account)
|
||||||
@ -378,8 +361,7 @@ private fun Calls(
|
|||||||
ctx.getString(R.string.airplane_mode)
|
ctx.getString(R.string.airplane_mode)
|
||||||
showAlert.value = true
|
showAlert.value = true
|
||||||
}
|
}
|
||||||
else
|
else if (!Utils.isDefaultSmsApp(ctx)) {
|
||||||
if (!Utils.isDefaultSmsApp(ctx)) {
|
|
||||||
alertTitle.value = ctx.getString(R.string.notice)
|
alertTitle.value = ctx.getString(R.string.notice)
|
||||||
alertMessage.value =
|
alertMessage.value =
|
||||||
ctx.getString(R.string.enable_default_messaging)
|
ctx.getString(R.string.enable_default_messaging)
|
||||||
@ -478,7 +460,7 @@ private fun Calls(
|
|||||||
else
|
else
|
||||||
CustomElements.TextAvatar(contact.name, contact.color)
|
CustomElements.TextAvatar(contact.name, contact.color)
|
||||||
}
|
}
|
||||||
null -> {
|
null ->
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.Filled.AccountCircle,
|
imageVector = Icons.Filled.AccountCircle,
|
||||||
contentDescription = "Avatar",
|
contentDescription = "Avatar",
|
||||||
@ -486,14 +468,11 @@ private fun Calls(
|
|||||||
tint = MaterialTheme.colorScheme.secondary
|
tint = MaterialTheme.colorScheme.secondary
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
Spacer(modifier = Modifier.width(4.dp))
|
Spacer(modifier = Modifier.width(4.dp))
|
||||||
var count = 1
|
var count = 1
|
||||||
for (d in callRow.details) {
|
for (d in callRow.details) {
|
||||||
if (d.recording.isNotEmpty() && d.recording[0] != "")
|
if (d.recording.isNotEmpty() && d.recording[0] != "") recordings = true
|
||||||
recordings = true
|
if (count > 3) continue
|
||||||
if (count > 3)
|
|
||||||
continue
|
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = if (callUp(d.direction))
|
imageVector = if (callUp(d.direction))
|
||||||
Icons.AutoMirrored.Filled.CallMade
|
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 (h.rejected) CALL_UP_RED else CALL_MISSED_OUT
|
||||||
}
|
}
|
||||||
if (res.isNotEmpty() && res.last().peerUri == h.peerUri)
|
if (res.isNotEmpty() && res.last().peerUri == h.peerUri)
|
||||||
res.last().details.add(CallRow.Details(
|
res.last().details.add(
|
||||||
direction, h.startTime,
|
CallRow.Details(direction, h.startTime, h.stopTime, h.recording.toList())
|
||||||
h.stopTime, h.recording.toList()
|
)
|
||||||
))
|
|
||||||
else
|
else
|
||||||
res.add(CallRow(h.aor, h.peerUri, direction, h.startTime, h.stopTime, h.recording.toList()))
|
res.add(CallRow(h.aor, h.peerUri, direction, h.startTime, h.stopTime, h.recording.toList()))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user