Composed accounts activity alert dialog
This commit is contained in:
@@ -55,7 +55,7 @@ import androidx.compose.ui.text.font.FontWeight
|
|||||||
import androidx.compose.ui.text.input.KeyboardType
|
import androidx.compose.ui.text.input.KeyboardType
|
||||||
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 com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.tutpro.baresip.CustomElements.AlertDialog
|
||||||
import com.tutpro.baresip.CustomElements.verticalScrollbar
|
import com.tutpro.baresip.CustomElements.verticalScrollbar
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
@@ -153,6 +153,20 @@ class AccountsActivity : ComponentActivity() {
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun AccountsContent(ctx: Context, contentPadding: PaddingValues) {
|
fun AccountsContent(ctx: Context, contentPadding: PaddingValues) {
|
||||||
|
|
||||||
|
val showDialog = remember { mutableStateOf(false) }
|
||||||
|
val message = remember { mutableStateOf("") }
|
||||||
|
val positiveAction = remember { mutableStateOf({}) }
|
||||||
|
|
||||||
|
AlertDialog(
|
||||||
|
showDialog = showDialog,
|
||||||
|
title = getString(R.string.confirmation),
|
||||||
|
message = message.value,
|
||||||
|
positiveButtonText = getString(R.string.delete),
|
||||||
|
onPositiveClicked = positiveAction.value,
|
||||||
|
negativeButtonText = getString(R.string.cancel),
|
||||||
|
)
|
||||||
|
|
||||||
if (showAccounts.value && BaresipService.uas.value.isNotEmpty()) {
|
if (showAccounts.value && BaresipService.uas.value.isNotEmpty()) {
|
||||||
val scrollState = rememberScrollState()
|
val scrollState = rememberScrollState()
|
||||||
Column(
|
Column(
|
||||||
@@ -192,34 +206,20 @@ class AccountsActivity : ComponentActivity() {
|
|||||||
onClick = {
|
onClick = {
|
||||||
if (SystemClock.elapsedRealtime() - lastClick > 1000) {
|
if (SystemClock.elapsedRealtime() - lastClick > 1000) {
|
||||||
lastClick = SystemClock.elapsedRealtime()
|
lastClick = SystemClock.elapsedRealtime()
|
||||||
with(
|
message.value = String.format(
|
||||||
MaterialAlertDialogBuilder(
|
|
||||||
ctx,
|
|
||||||
R.style.AlertDialogTheme
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
setTitle(R.string.confirmation)
|
|
||||||
setMessage(
|
|
||||||
String.format(
|
|
||||||
ctx.getString(R.string.delete_account),
|
ctx.getString(R.string.delete_account),
|
||||||
text
|
text
|
||||||
)
|
)
|
||||||
)
|
positiveAction.value = {
|
||||||
setPositiveButton(R.string.delete) { dialog, _ ->
|
|
||||||
CallHistoryNew.clear(aor)
|
CallHistoryNew.clear(aor)
|
||||||
Message.clearMessagesOfAor(aor)
|
Message.clearMessagesOfAor(aor)
|
||||||
ua.remove()
|
ua.remove()
|
||||||
Api.ua_destroy(ua.uap)
|
Api.ua_destroy(ua.uap)
|
||||||
saveAccounts()
|
saveAccounts()
|
||||||
dialog.dismiss()
|
|
||||||
showAccounts.value = false
|
showAccounts.value = false
|
||||||
showAccounts.value = true
|
showAccounts.value = true
|
||||||
}
|
}
|
||||||
setNeutralButton(ctx.getText(R.string.cancel)) { dialog, _ ->
|
showDialog.value = true
|
||||||
dialog.dismiss()
|
|
||||||
}
|
|
||||||
show()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
containerColor = LocalCustomColors.current.background,
|
containerColor = LocalCustomColors.current.background,
|
||||||
|
|||||||
@@ -455,7 +455,7 @@ class ChatsActivity: ComponentActivity() {
|
|||||||
|
|
||||||
SelectableAlertDialog(
|
SelectableAlertDialog(
|
||||||
openDialog = showDialog,
|
openDialog = showDialog,
|
||||||
title = "Choose Destination",
|
title = getString(R.string.choose_destination_uri),
|
||||||
items = items.value,
|
items = items.value,
|
||||||
onItemClicked = itemAction.value,
|
onItemClicked = itemAction.value,
|
||||||
neutralButtonText = getString(R.string.cancel),
|
neutralButtonText = getString(R.string.cancel),
|
||||||
|
|||||||
Reference in New Issue
Block a user