Use compose alert dialog in call details activity
Added playing_recording string
This commit is contained in:
@ -38,6 +38,8 @@ import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.material3.TopAppBarDefaults
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.painterResource
|
||||
@ -46,8 +48,8 @@ import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.core.net.toUri
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.tutpro.baresip.CallsActivity.Companion.uaHistory
|
||||
import com.tutpro.baresip.CustomElements.AlertDialog
|
||||
import com.tutpro.baresip.CustomElements.verticalScrollbar
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
@ -258,18 +260,22 @@ class CallDetailsActivity : ComponentActivity() {
|
||||
|
||||
@Composable
|
||||
fun Duration(ctx: Context, detail: CallRow.Details, durationText: String) {
|
||||
|
||||
val showDialog = remember { mutableStateOf(false) }
|
||||
val recording = detail.recording
|
||||
|
||||
AlertDialog(
|
||||
showDialog = showDialog,
|
||||
title = getString(R.string.playing_recording),
|
||||
message = "",
|
||||
)
|
||||
|
||||
if (recording[0] != "") {
|
||||
Text(
|
||||
text = durationText,
|
||||
color = LocalCustomColors.current.accent,
|
||||
modifier = Modifier.padding(end = 12.dp)
|
||||
.clickable(onClick = {
|
||||
val builder = MaterialAlertDialogBuilder(ctx, R.style.AlertDialogTheme)
|
||||
builder.setTitle("Playing recording ...")
|
||||
.setMessage("")
|
||||
.setCancelable(true)
|
||||
val dialog = builder.create()
|
||||
if (!decPlayer.isPlaying && !encPlayer.isPlaying) {
|
||||
decPlayer.reset()
|
||||
encPlayer.reset()
|
||||
@ -293,12 +299,12 @@ class CallDetailsActivity : ComponentActivity() {
|
||||
it.start()
|
||||
decPlayer.start()
|
||||
Log.d(TAG, "Started players")
|
||||
dialog.show()
|
||||
showDialog.value = true
|
||||
}
|
||||
setOnCompletionListener {
|
||||
Log.d(TAG, "Stopping encPlayer")
|
||||
it.stop()
|
||||
dialog.cancel()
|
||||
showDialog.value = false
|
||||
}
|
||||
try {
|
||||
val file = recording[0]
|
||||
@ -320,6 +326,7 @@ class CallDetailsActivity : ComponentActivity() {
|
||||
setOnCompletionListener {
|
||||
Log.d(TAG, "Stopping decPlayer")
|
||||
it.stop()
|
||||
showDialog.value = false
|
||||
}
|
||||
try {
|
||||
val file = recording[1]
|
||||
|
||||
@ -133,11 +133,11 @@ class CallsActivity : ComponentActivity() {
|
||||
val disable = String.format(getString(R.string.disable_history))
|
||||
val enable = String.format(getString(R.string.enable_history))
|
||||
|
||||
val openDialog = remember { mutableStateOf(false) }
|
||||
val showDialog = remember { mutableStateOf(false) }
|
||||
val positiveAction = remember { mutableStateOf({}) }
|
||||
|
||||
AlertDialog(
|
||||
openDialog = openDialog,
|
||||
showDialog = showDialog,
|
||||
title = getString(R.string.confirmation),
|
||||
message = String.format(getString(R.string.delete_history_alert), aor.substringAfter(":")),
|
||||
positiveButtonText = getString(R.string.delete),
|
||||
@ -187,7 +187,7 @@ class CallsActivity : ComponentActivity() {
|
||||
CallHistoryNew.save()
|
||||
uaHistory.value = emptyList()
|
||||
}
|
||||
openDialog.value = true
|
||||
showDialog.value = true
|
||||
}
|
||||
disable, enable -> {
|
||||
account.callHistory = !account.callHistory
|
||||
@ -237,7 +237,7 @@ class CallsActivity : ComponentActivity() {
|
||||
@Composable
|
||||
fun Calls(ctx: Context, account: Account) {
|
||||
|
||||
val openDialog = remember { mutableStateOf(false) }
|
||||
val showDialog = remember { mutableStateOf(false) }
|
||||
val message = remember { mutableStateOf("") }
|
||||
val positiveButtonText = remember { mutableStateOf("") }
|
||||
val positiveAction = remember { mutableStateOf({}) }
|
||||
@ -245,7 +245,7 @@ class CallsActivity : ComponentActivity() {
|
||||
val neutralAction = remember { mutableStateOf({}) }
|
||||
|
||||
AlertDialog(
|
||||
openDialog = openDialog,
|
||||
showDialog = showDialog,
|
||||
title = getString(R.string.confirmation),
|
||||
message = message.value,
|
||||
positiveButtonText = positiveButtonText.value,
|
||||
@ -308,7 +308,7 @@ class CallsActivity : ComponentActivity() {
|
||||
i.putExtra("peer", peerUri)
|
||||
startActivity(i)
|
||||
}
|
||||
openDialog.value = true
|
||||
showDialog.value = true
|
||||
},
|
||||
onLongClick = {
|
||||
val peerUri = callRow.peerUri
|
||||
@ -350,7 +350,7 @@ class CallsActivity : ComponentActivity() {
|
||||
CallHistoryNew.save()
|
||||
}
|
||||
}
|
||||
openDialog.value = true
|
||||
showDialog.value = true
|
||||
}
|
||||
)
|
||||
) {
|
||||
|
||||
@ -319,20 +319,20 @@ object CustomElements {
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun AlertDialog(
|
||||
openDialog: MutableState<Boolean>,
|
||||
showDialog: MutableState<Boolean>,
|
||||
title: String,
|
||||
message: String,
|
||||
positiveButtonText: String,
|
||||
onPositiveClicked: () -> Unit,
|
||||
positiveButtonText: String = "",
|
||||
onPositiveClicked: () -> Unit = {},
|
||||
negativeButtonText: String = "",
|
||||
onNegativeClicked: () -> Unit = {},
|
||||
neutralButtonText: String = "",
|
||||
onNeutralClicked: () -> Unit = {}
|
||||
) {
|
||||
if (openDialog.value) {
|
||||
if (showDialog.value) {
|
||||
BasicAlertDialog(
|
||||
onDismissRequest = {
|
||||
openDialog.value = false
|
||||
showDialog.value = false
|
||||
},
|
||||
content = {
|
||||
Card(
|
||||
@ -364,7 +364,7 @@ object CustomElements {
|
||||
) {
|
||||
TextButton(onClick = {
|
||||
onPositiveClicked()
|
||||
openDialog.value = false
|
||||
showDialog.value = false
|
||||
}) {
|
||||
androidx.compose.material3.Text(
|
||||
text = positiveButtonText.uppercase(),
|
||||
@ -374,7 +374,7 @@ object CustomElements {
|
||||
}
|
||||
TextButton(onClick = {
|
||||
onNeutralClicked()
|
||||
openDialog.value = false
|
||||
showDialog.value = false
|
||||
}) {
|
||||
androidx.compose.material3.Text(
|
||||
text = neutralButtonText.uppercase(),
|
||||
@ -384,7 +384,7 @@ object CustomElements {
|
||||
}
|
||||
TextButton(onClick = {
|
||||
onNegativeClicked()
|
||||
openDialog.value = false
|
||||
showDialog.value = false
|
||||
}) {
|
||||
androidx.compose.material3.Text(
|
||||
text = negativeButtonText.uppercase(),
|
||||
@ -394,45 +394,45 @@ object CustomElements {
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.End
|
||||
) {
|
||||
if (negativeButtonText.isNotEmpty())
|
||||
else
|
||||
if (positiveButtonText.isNotEmpty())
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.End
|
||||
) {
|
||||
if (negativeButtonText.isNotEmpty())
|
||||
TextButton(onClick = {
|
||||
onNegativeClicked()
|
||||
showDialog.value = false
|
||||
}) {
|
||||
androidx.compose.material3.Text(
|
||||
text = negativeButtonText.uppercase(),
|
||||
fontSize = 14.sp,
|
||||
color = LocalCustomColors.current.gray
|
||||
)
|
||||
}
|
||||
if (neutralButtonText.isNotEmpty())
|
||||
TextButton(onClick = {
|
||||
onNeutralClicked()
|
||||
showDialog.value = false
|
||||
}) {
|
||||
androidx.compose.material3.Text(
|
||||
text = neutralButtonText.uppercase(),
|
||||
fontSize = 14.sp,
|
||||
color = LocalCustomColors.current.alert
|
||||
)
|
||||
}
|
||||
TextButton(onClick = {
|
||||
onNegativeClicked()
|
||||
openDialog.value = false
|
||||
onPositiveClicked()
|
||||
showDialog.value = false
|
||||
}) {
|
||||
androidx.compose.material3.Text(
|
||||
text = negativeButtonText.uppercase(),
|
||||
text = positiveButtonText.uppercase(),
|
||||
fontSize = 14.sp,
|
||||
color = LocalCustomColors.current.gray
|
||||
color = LocalCustomColors.current.alert,
|
||||
)
|
||||
}
|
||||
if (neutralButtonText.isNotEmpty())
|
||||
TextButton(onClick = {
|
||||
onNeutralClicked()
|
||||
openDialog.value = false
|
||||
}) {
|
||||
androidx.compose.material3.Text(
|
||||
text = neutralButtonText.uppercase(),
|
||||
fontSize = 14.sp,
|
||||
color = LocalCustomColors.current.alert
|
||||
)
|
||||
}
|
||||
TextButton(onClick = {
|
||||
onPositiveClicked()
|
||||
openDialog.value = false
|
||||
}) {
|
||||
androidx.compose.material3.Text(
|
||||
text = positiveButtonText.uppercase(),
|
||||
fontSize = 14.sp,
|
||||
color = LocalCustomColors.current.alert,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -261,6 +261,7 @@
|
||||
<string name="peer">Kumppani</string>
|
||||
<string name="time">Aika</string>
|
||||
<string name="calls_duration">Kesto</string>
|
||||
<string name="playing_recording">Tallenteen kuuntelu …</string>
|
||||
<string name="calls_call_message_question">Haluatko soittaa tai lähettää viestin kohteeseen
|
||||
\'%1$s\'\?
|
||||
</string>
|
||||
|
||||
@ -247,6 +247,7 @@
|
||||
<string name="direction">Direction</string>
|
||||
<string name="time">Time</string>
|
||||
<string name="calls_duration">Duration</string>
|
||||
<string name="playing_recording">Playing recording …</string>
|
||||
<string name="calls_call_message_question">Do you want to call or send message to \'%1$s\'\?</string>
|
||||
<string name="calls_add_delete_question">Do you want to add \'%1$s\' to contacts or delete
|
||||
%2$s from call history\?
|
||||
|
||||
Reference in New Issue
Block a user