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