Use box for call details direction icon
This commit is contained in:
@@ -8,6 +8,7 @@ import android.widget.Toast
|
|||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.PaddingValues
|
import androidx.compose.foundation.layout.PaddingValues
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
@@ -23,6 +24,7 @@ import androidx.compose.foundation.layout.width
|
|||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
import androidx.compose.foundation.lazy.items
|
import androidx.compose.foundation.lazy.items
|
||||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||||
|
import androidx.compose.foundation.shape.CircleShape
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||||
import androidx.compose.material.icons.automirrored.filled.CallMade
|
import androidx.compose.material.icons.automirrored.filled.CallMade
|
||||||
@@ -40,6 +42,7 @@ import androidx.compose.runtime.mutableStateOf
|
|||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.draw.clip
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.res.colorResource
|
import androidx.compose.ui.res.colorResource
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
@@ -71,7 +74,9 @@ fun NavGraphBuilder.callDetailsScreenRoute(navController: NavController, viewMod
|
|||||||
private fun CallDetailsScreen(navController: NavController, callRow: CallRow) {
|
private fun CallDetailsScreen(navController: NavController, callRow: CallRow) {
|
||||||
|
|
||||||
Scaffold(
|
Scaffold(
|
||||||
modifier = Modifier.fillMaxSize().imePadding(),
|
modifier = Modifier
|
||||||
|
.fillMaxSize()
|
||||||
|
.imePadding(),
|
||||||
containerColor = MaterialTheme.colorScheme.background,
|
containerColor = MaterialTheme.colorScheme.background,
|
||||||
topBar = {
|
topBar = {
|
||||||
Column(
|
Column(
|
||||||
@@ -159,7 +164,8 @@ private fun Details(ctx: Context, details: ArrayList<Details>) {
|
|||||||
}
|
}
|
||||||
val lazyListState = rememberLazyListState()
|
val lazyListState = rememberLazyListState()
|
||||||
LazyColumn(
|
LazyColumn(
|
||||||
modifier = Modifier.fillMaxWidth()
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
.verticalScrollbar(
|
.verticalScrollbar(
|
||||||
state = lazyListState,
|
state = lazyListState,
|
||||||
width = 4.dp
|
width = 4.dp
|
||||||
@@ -170,16 +176,12 @@ private fun Details(ctx: Context, details: ArrayList<Details>) {
|
|||||||
) {
|
) {
|
||||||
items(details) { detail ->
|
items(details) { detail ->
|
||||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||||
Icon(
|
Box(
|
||||||
imageVector = if (callUp(detail.direction))
|
modifier = Modifier
|
||||||
Icons.AutoMirrored.Filled.CallMade
|
.clip(CircleShape)
|
||||||
else
|
|
||||||
Icons.AutoMirrored.Filled.CallReceived,
|
|
||||||
tint = colorResource(id = callTint(detail.direction)),
|
|
||||||
contentDescription = "Direction",
|
|
||||||
modifier = Modifier.width(64.dp)
|
|
||||||
.clickable {
|
.clickable {
|
||||||
Toast.makeText(ctx,
|
Toast.makeText(
|
||||||
|
ctx,
|
||||||
when (detail.direction) {
|
when (detail.direction) {
|
||||||
CALL_DOWN_GREEN, CALL_UP_GREEN -> ctx.getString(R.string.call_answered)
|
CALL_DOWN_GREEN, CALL_UP_GREEN -> ctx.getString(R.string.call_answered)
|
||||||
CALL_DOWN_BLUE -> ctx.getString(R.string.call_answered_elsewhere)
|
CALL_DOWN_BLUE -> ctx.getString(R.string.call_answered_elsewhere)
|
||||||
@@ -189,9 +191,19 @@ private fun Details(ctx: Context, details: ArrayList<Details>) {
|
|||||||
},
|
},
|
||||||
Toast.LENGTH_SHORT
|
Toast.LENGTH_SHORT
|
||||||
).show()
|
).show()
|
||||||
}
|
},
|
||||||
)
|
contentAlignment = Alignment.Center
|
||||||
Spacer(modifier = Modifier.width(38.dp))
|
) {
|
||||||
|
Icon(
|
||||||
|
imageVector = if (callUp(detail.direction))
|
||||||
|
Icons.AutoMirrored.Filled.CallMade
|
||||||
|
else
|
||||||
|
Icons.AutoMirrored.Filled.CallReceived,
|
||||||
|
tint = colorResource(id = callTint(detail.direction)),
|
||||||
|
contentDescription = "Direction"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Spacer(modifier = Modifier.width(78.dp))
|
||||||
val durationText = startTime(detail)
|
val durationText = startTime(detail)
|
||||||
Spacer(modifier = Modifier.weight(1f))
|
Spacer(modifier = Modifier.weight(1f))
|
||||||
Duration(ctx, detail, durationText)
|
Duration(ctx, detail, durationText)
|
||||||
@@ -255,7 +267,8 @@ private fun Duration(ctx: Context, detail: Details, durationText: String) {
|
|||||||
Text(
|
Text(
|
||||||
text = durationText,
|
text = durationText,
|
||||||
color = MaterialTheme.colorScheme.error,
|
color = MaterialTheme.colorScheme.error,
|
||||||
modifier = Modifier.padding(end = 12.dp)
|
modifier = Modifier
|
||||||
|
.padding(end = 12.dp)
|
||||||
.clickable(onClick = {
|
.clickable(onClick = {
|
||||||
if (!decPlayer.isPlaying && !encPlayer.isPlaying) {
|
if (!decPlayer.isPlaying && !encPlayer.isPlaying) {
|
||||||
decPlayer.reset()
|
decPlayer.reset()
|
||||||
@@ -290,8 +303,12 @@ private fun Duration(ctx: Context, detail: Details, durationText: String) {
|
|||||||
try {
|
try {
|
||||||
val file = recording[0]
|
val file = recording[0]
|
||||||
val encFile = File(file)
|
val encFile = File(file)
|
||||||
.copyTo(File(BaresipService.filesPath +
|
.copyTo(
|
||||||
"/tmp/encode.wav"), true)
|
File(
|
||||||
|
BaresipService.filesPath +
|
||||||
|
"/tmp/encode.wav"
|
||||||
|
), true
|
||||||
|
)
|
||||||
val encUri = encFile.toUri()
|
val encUri = encFile.toUri()
|
||||||
setDataSource(ctx, encUri)
|
setDataSource(ctx, encUri)
|
||||||
prepareAsync()
|
prepareAsync()
|
||||||
@@ -312,8 +329,12 @@ private fun Duration(ctx: Context, detail: Details, durationText: String) {
|
|||||||
try {
|
try {
|
||||||
val file = recording[1]
|
val file = recording[1]
|
||||||
val decFile = File(file)
|
val decFile = File(file)
|
||||||
.copyTo(File(BaresipService.filesPath +
|
.copyTo(
|
||||||
"/tmp/decode.wav"), true)
|
File(
|
||||||
|
BaresipService.filesPath +
|
||||||
|
"/tmp/decode.wav"
|
||||||
|
), true
|
||||||
|
)
|
||||||
val decUri = decFile.toUri()
|
val decUri = decFile.toUri()
|
||||||
setDataSource(ctx, decUri)
|
setDataSource(ctx, decUri)
|
||||||
prepareAsync()
|
prepareAsync()
|
||||||
@@ -325,7 +346,8 @@ private fun Duration(ctx: Context, detail: Details, durationText: String) {
|
|||||||
Log.e(TAG, "decPlayer Exception: $e")
|
Log.e(TAG, "decPlayer Exception: $e")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (decPlayer.isPlaying && encPlayer.isPlaying) {
|
}
|
||||||
|
else if (decPlayer.isPlaying && encPlayer.isPlaying) {
|
||||||
decPlayer.stop()
|
decPlayer.stop()
|
||||||
encPlayer.stop()
|
encPlayer.stop()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user