Migrated alert dialogs to Material desing style
This commit is contained in:
@@ -1198,7 +1198,7 @@ private fun AccountContent(
|
|||||||
showDialog = showAlert,
|
showDialog = showAlert,
|
||||||
title = alertTitle.value,
|
title = alertTitle.value,
|
||||||
message = alertMessage.value,
|
message = alertMessage.value,
|
||||||
positiveButtonText = stringResource(R.string.ok),
|
lastButtonText = stringResource(R.string.ok),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -116,15 +116,15 @@ fun AccountsContent(contentPadding: PaddingValues, navController: NavController)
|
|||||||
|
|
||||||
val showDialog = remember { mutableStateOf(false) }
|
val showDialog = remember { mutableStateOf(false) }
|
||||||
val message = remember { mutableStateOf("") }
|
val message = remember { mutableStateOf("") }
|
||||||
val positiveAction = remember { mutableStateOf({}) }
|
val lastAction = remember { mutableStateOf({}) }
|
||||||
|
|
||||||
AlertDialog(
|
AlertDialog(
|
||||||
showDialog = showDialog,
|
showDialog = showDialog,
|
||||||
title = stringResource(R.string.confirmation),
|
title = stringResource(R.string.confirmation),
|
||||||
message = message.value,
|
message = message.value,
|
||||||
positiveButtonText = stringResource(R.string.delete),
|
firstButtonText = stringResource(R.string.cancel),
|
||||||
onPositiveClicked = positiveAction.value,
|
lastButtonText = stringResource(R.string.delete),
|
||||||
negativeButtonText = stringResource(R.string.cancel),
|
onLastClicked = lastAction.value,
|
||||||
)
|
)
|
||||||
|
|
||||||
val showAccounts = remember { mutableStateOf(true) }
|
val showAccounts = remember { mutableStateOf(true) }
|
||||||
@@ -169,7 +169,7 @@ fun AccountsContent(contentPadding: PaddingValues, navController: NavController)
|
|||||||
modifier = Modifier.padding(end = 8.dp),
|
modifier = Modifier.padding(end = 8.dp),
|
||||||
onClick = {
|
onClick = {
|
||||||
message.value = String.format(deleteAccountMessage, text)
|
message.value = String.format(deleteAccountMessage, text)
|
||||||
positiveAction.value = {
|
lastAction.value = {
|
||||||
CallHistoryNew.clear(aor)
|
CallHistoryNew.clear(aor)
|
||||||
Message.clearMessagesOfAor(aor)
|
Message.clearMessagesOfAor(aor)
|
||||||
ua.remove()
|
ua.remove()
|
||||||
@@ -206,7 +206,7 @@ fun NewAccount(navController: NavController) {
|
|||||||
showDialog = showAlert,
|
showDialog = showAlert,
|
||||||
title = alertTitle.value,
|
title = alertTitle.value,
|
||||||
message = alertMessage.value,
|
message = alertMessage.value,
|
||||||
positiveButtonText = stringResource(R.string.ok),
|
lastButtonText = stringResource(R.string.ok),
|
||||||
)
|
)
|
||||||
|
|
||||||
fun createNew(ctx: Context, newAor: String): Account? {
|
fun createNew(ctx: Context, newAor: String): Account? {
|
||||||
|
|||||||
@@ -176,7 +176,7 @@ private fun AudioContent(contentPadding: PaddingValues) {
|
|||||||
showDialog = showAlert,
|
showDialog = showAlert,
|
||||||
title = alertTitle.value,
|
title = alertTitle.value,
|
||||||
message = alertMessage.value,
|
message = alertMessage.value,
|
||||||
positiveButtonText = stringResource(R.string.ok),
|
lastButtonText = stringResource(R.string.ok),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -273,7 +273,7 @@ private fun ContactContent(
|
|||||||
showDialog = showAlert,
|
showDialog = showAlert,
|
||||||
title = alertTitle.value,
|
title = alertTitle.value,
|
||||||
message = alertMessage.value,
|
message = alertMessage.value,
|
||||||
positiveButtonText = stringResource(R.string.ok),
|
lastButtonText = stringResource(R.string.ok),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -145,15 +145,15 @@ private fun TopAppBar(
|
|||||||
var expanded by remember { mutableStateOf(false) }
|
var expanded by remember { mutableStateOf(false) }
|
||||||
val delete = stringResource(R.string.delete)
|
val delete = stringResource(R.string.delete)
|
||||||
val showDialog = remember { mutableStateOf(false) }
|
val showDialog = remember { mutableStateOf(false) }
|
||||||
val positiveAction = remember { mutableStateOf({}) }
|
val lastAction = remember { mutableStateOf({}) }
|
||||||
|
|
||||||
AlertDialog(
|
AlertDialog(
|
||||||
showDialog = showDialog,
|
showDialog = showDialog,
|
||||||
title = stringResource(R.string.confirmation),
|
title = stringResource(R.string.confirmation),
|
||||||
message = String.format(stringResource(R.string.blocked_delete_alert), account.text()),
|
message = String.format(stringResource(R.string.blocked_delete_alert), account.text()),
|
||||||
positiveButtonText = stringResource(R.string.delete),
|
firstButtonText = stringResource(R.string.cancel),
|
||||||
negativeButtonText = stringResource(R.string.cancel),
|
lastButtonText = stringResource(R.string.delete),
|
||||||
onPositiveClicked = positiveAction.value,
|
onLastClicked = lastAction.value,
|
||||||
)
|
)
|
||||||
|
|
||||||
TopAppBar(
|
TopAppBar(
|
||||||
@@ -200,7 +200,7 @@ private fun TopAppBar(
|
|||||||
expanded = false
|
expanded = false
|
||||||
when (selectedItem) {
|
when (selectedItem) {
|
||||||
delete -> {
|
delete -> {
|
||||||
positiveAction.value = {
|
lastAction.value = {
|
||||||
Blocked.clear(account.aor)
|
Blocked.clear(account.aor)
|
||||||
blocked.value = emptyList()
|
blocked.value = emptyList()
|
||||||
}
|
}
|
||||||
@@ -251,20 +251,16 @@ private fun Account(account: Account) {
|
|||||||
private fun Blocked(ctx: Context, navController: NavController, blocked: MutableState<List<Blocked>>) {
|
private fun Blocked(ctx: Context, navController: NavController, blocked: MutableState<List<Blocked>>) {
|
||||||
val showDialog = remember { mutableStateOf(false) }
|
val showDialog = remember { mutableStateOf(false) }
|
||||||
val message = remember { mutableStateOf("") }
|
val message = remember { mutableStateOf("") }
|
||||||
val positiveButtonText = remember { mutableStateOf("") }
|
val lastButtonText = remember { mutableStateOf("") }
|
||||||
val positiveAction = remember { mutableStateOf({}) }
|
val lastAction = remember { mutableStateOf({}) }
|
||||||
val neutralButtonText = remember { mutableStateOf("") }
|
|
||||||
val neutralAction = remember { mutableStateOf({}) }
|
|
||||||
|
|
||||||
AlertDialog(
|
AlertDialog(
|
||||||
showDialog = showDialog,
|
showDialog = showDialog,
|
||||||
title = stringResource(R.string.confirmation),
|
title = stringResource(R.string.confirmation),
|
||||||
message = message.value,
|
message = message.value,
|
||||||
positiveButtonText = positiveButtonText.value,
|
firstButtonText = stringResource(R.string.cancel),
|
||||||
onPositiveClicked = positiveAction.value,
|
lastButtonText = lastButtonText.value,
|
||||||
neutralButtonText = neutralButtonText.value,
|
onLastClicked = lastAction.value,
|
||||||
onNeutralClicked = neutralAction.value,
|
|
||||||
negativeButtonText = stringResource(R.string.cancel)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
val lazyListState = rememberLazyListState()
|
val lazyListState = rememberLazyListState()
|
||||||
@@ -289,8 +285,8 @@ private fun Blocked(ctx: Context, navController: NavController, blocked: Mutable
|
|||||||
.clickable(onClick = {
|
.clickable(onClick = {
|
||||||
message.value = String.format(ctx.getString(R.string.blocked_contact_question),
|
message.value = String.format(ctx.getString(R.string.blocked_contact_question),
|
||||||
peerUri)
|
peerUri)
|
||||||
positiveButtonText.value = ctx.getString(R.string.add_contact)
|
lastButtonText.value = ctx.getString(R.string.add_contact)
|
||||||
positiveAction.value = {
|
lastAction.value = {
|
||||||
navController.navigate("baresip_contact/$peerUri/new")
|
navController.navigate("baresip_contact/$peerUri/new")
|
||||||
}
|
}
|
||||||
showDialog.value = true
|
showDialog.value = true
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ import androidx.navigation.NavController
|
|||||||
import androidx.navigation.NavGraphBuilder
|
import androidx.navigation.NavGraphBuilder
|
||||||
import androidx.navigation.compose.composable
|
import androidx.navigation.compose.composable
|
||||||
import com.tutpro.baresip.CallRow.Details
|
import com.tutpro.baresip.CallRow.Details
|
||||||
|
import com.tutpro.baresip.CustomElements.AlertDialog
|
||||||
import com.tutpro.baresip.CustomElements.verticalScrollbar
|
import com.tutpro.baresip.CustomElements.verticalScrollbar
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
@@ -280,18 +281,17 @@ private fun startTime(detail: Details, onDelete: (Details) -> Unit): String {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
val showDialog = remember { mutableStateOf(false) }
|
val showDialog = remember { mutableStateOf(false) }
|
||||||
val positiveAction = remember { mutableStateOf({}) }
|
|
||||||
|
|
||||||
CustomElements.AlertDialog(
|
AlertDialog(
|
||||||
showDialog = showDialog,
|
showDialog = showDialog,
|
||||||
title = stringResource(R.string.confirmation),
|
title = stringResource(R.string.confirmation),
|
||||||
message = stringResource(R.string.delete_call_alert),
|
message = stringResource(R.string.delete_call_alert),
|
||||||
positiveButtonText = stringResource(R.string.delete),
|
firstButtonText = stringResource(R.string.cancel),
|
||||||
onPositiveClicked = {
|
lastButtonText = stringResource(R.string.delete),
|
||||||
|
onLastClicked = {
|
||||||
CallHistoryNew.remove(detail.startTime, detail.stopTime)
|
CallHistoryNew.remove(detail.startTime, detail.stopTime)
|
||||||
onDelete(detail)
|
onDelete(detail)
|
||||||
},
|
},
|
||||||
negativeButtonText = stringResource(R.string.cancel)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
Text(
|
Text(
|
||||||
@@ -299,9 +299,6 @@ private fun startTime(detail: Details, onDelete: (Details) -> Unit): String {
|
|||||||
modifier = Modifier.combinedClickable(
|
modifier = Modifier.combinedClickable(
|
||||||
onClick = {},
|
onClick = {},
|
||||||
onLongClick = {
|
onLongClick = {
|
||||||
positiveAction.value = {
|
|
||||||
CallHistoryNew.remove(startTime, stopTime)
|
|
||||||
}
|
|
||||||
showDialog.value = true
|
showDialog.value = true
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -371,22 +368,21 @@ private fun Duration(ctx: Context, detail: Details, durationText: String) {
|
|||||||
)
|
)
|
||||||
|
|
||||||
// 2. Download Confirmation Dialog
|
// 2. Download Confirmation Dialog
|
||||||
if (showDownloadDialog.value) {
|
if (showDownloadDialog.value)
|
||||||
CustomElements.AlertDialog(
|
AlertDialog(
|
||||||
showDialog = showDownloadDialog,
|
showDialog = showDownloadDialog,
|
||||||
title = stringResource(R.string.save_recording),
|
title = stringResource(R.string.save_recording),
|
||||||
message = stringResource(R.string.save_recording_question),
|
message = stringResource(R.string.save_recording_question),
|
||||||
positiveButtonText = stringResource(R.string.save),
|
firstButtonText = stringResource(R.string.cancel),
|
||||||
onPositiveClicked = {
|
lastButtonText = stringResource(R.string.save),
|
||||||
|
onLastClicked = {
|
||||||
showDownloadDialog.value = false
|
showDownloadDialog.value = false
|
||||||
detail.recording.firstOrNull { it.isNotEmpty() }?.let {
|
detail.recording.firstOrNull { it.isNotEmpty() }?.let {
|
||||||
val suggestedName = File(it).name
|
val suggestedName = File(it).name
|
||||||
saveLauncher.launch(suggestedName)
|
saveLauncher.launch(suggestedName)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
negativeButtonText = stringResource(R.string.cancel)
|
|
||||||
)
|
)
|
||||||
}
|
|
||||||
|
|
||||||
val hasRecording = detail.recording.isNotEmpty() && detail.recording[0].isNotEmpty()
|
val hasRecording = detail.recording.isNotEmpty() && detail.recording[0].isNotEmpty()
|
||||||
if (hasRecording) {
|
if (hasRecording) {
|
||||||
|
|||||||
@@ -156,15 +156,15 @@ private fun TopAppBar(navController: NavController, account: Account, callHistor
|
|||||||
val blocked = stringResource(R.string.blocked)
|
val blocked = stringResource(R.string.blocked)
|
||||||
|
|
||||||
val showDialog = remember { mutableStateOf(false) }
|
val showDialog = remember { mutableStateOf(false) }
|
||||||
val positiveAction = remember { mutableStateOf({}) }
|
val lastAction = remember { mutableStateOf({}) }
|
||||||
|
|
||||||
AlertDialog(
|
AlertDialog(
|
||||||
showDialog = showDialog,
|
showDialog = showDialog,
|
||||||
title = stringResource(R.string.confirmation),
|
title = stringResource(R.string.confirmation),
|
||||||
message = String.format(stringResource(R.string.delete_history_alert), account.text()),
|
message = String.format(stringResource(R.string.delete_history_alert), account.text()),
|
||||||
positiveButtonText = stringResource(R.string.delete),
|
firstButtonText = stringResource(R.string.cancel),
|
||||||
negativeButtonText = stringResource(R.string.cancel),
|
lastButtonText = stringResource(R.string.delete),
|
||||||
onPositiveClicked = positiveAction.value,
|
onLastClicked = lastAction.value,
|
||||||
)
|
)
|
||||||
|
|
||||||
TopAppBar(
|
TopAppBar(
|
||||||
@@ -211,7 +211,7 @@ private fun TopAppBar(navController: NavController, account: Account, callHistor
|
|||||||
expanded = false
|
expanded = false
|
||||||
when (selectedItem) {
|
when (selectedItem) {
|
||||||
delete -> {
|
delete -> {
|
||||||
positiveAction.value = {
|
lastAction.value = {
|
||||||
CallHistoryNew.clear(account.aor)
|
CallHistoryNew.clear(account.aor)
|
||||||
callHistory.value = emptyList()
|
callHistory.value = emptyList()
|
||||||
Blocked.clear(account.aor)
|
Blocked.clear(account.aor)
|
||||||
@@ -276,20 +276,20 @@ private fun Calls(
|
|||||||
|
|
||||||
val showDialog = remember { mutableStateOf(false) }
|
val showDialog = remember { mutableStateOf(false) }
|
||||||
val message = remember { mutableStateOf("") }
|
val message = remember { mutableStateOf("") }
|
||||||
val positiveButtonText = remember { mutableStateOf("") }
|
val secondButtonText = remember { mutableStateOf("") }
|
||||||
val positiveAction = remember { mutableStateOf({}) }
|
val secondAction = remember { mutableStateOf({}) }
|
||||||
val neutralButtonText = remember { mutableStateOf("") }
|
val lastButtonText = remember { mutableStateOf("") }
|
||||||
val neutralAction = remember { mutableStateOf({}) }
|
val lastAction = remember { mutableStateOf({}) }
|
||||||
|
|
||||||
AlertDialog(
|
AlertDialog(
|
||||||
showDialog = showDialog,
|
showDialog = showDialog,
|
||||||
title = stringResource(R.string.confirmation),
|
title = stringResource(R.string.confirmation),
|
||||||
message = message.value,
|
message = message.value,
|
||||||
positiveButtonText = positiveButtonText.value,
|
firstButtonText = stringResource(R.string.cancel),
|
||||||
onPositiveClicked = positiveAction.value,
|
secondButtonText = secondButtonText.value,
|
||||||
neutralButtonText = neutralButtonText.value,
|
onSecondClicked = secondAction.value,
|
||||||
onNeutralClicked = neutralAction.value,
|
lastButtonText = lastButtonText.value,
|
||||||
negativeButtonText = stringResource(R.string.cancel)
|
onLastClicked = lastAction.value,
|
||||||
)
|
)
|
||||||
|
|
||||||
val lazyListState = rememberLazyListState()
|
val lazyListState = rememberLazyListState()
|
||||||
@@ -329,8 +329,8 @@ private fun Calls(
|
|||||||
Log.w(TAG, "onClickListener did not find UA for $aor")
|
Log.w(TAG, "onClickListener did not find UA for $aor")
|
||||||
val peerName = Utils.friendlyUri(ctx, peerUri, account)
|
val peerName = Utils.friendlyUri(ctx, peerUri, account)
|
||||||
message.value = String.format(ctx.getString(R.string.contact_action_question), peerName)
|
message.value = String.format(ctx.getString(R.string.contact_action_question), peerName)
|
||||||
positiveButtonText.value = ctx.getString(R.string.call)
|
secondButtonText.value = ctx.getString(R.string.call)
|
||||||
positiveAction.value = {
|
secondAction.value = {
|
||||||
if (ua != null) {
|
if (ua != null) {
|
||||||
handleIntent(ctx, viewModel, intent, "call")
|
handleIntent(ctx, viewModel, intent, "call")
|
||||||
navController.navigate("main") {
|
navController.navigate("main") {
|
||||||
@@ -339,8 +339,8 @@ private fun Calls(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
neutralButtonText.value = ctx.getString(R.string.send_message)
|
lastButtonText.value = ctx.getString(R.string.send_message)
|
||||||
neutralAction.value = {
|
lastAction.value = {
|
||||||
if (ua != null) {
|
if (ua != null) {
|
||||||
handleIntent(ctx, viewModel, intent, "message")
|
handleIntent(ctx, viewModel, intent, "message")
|
||||||
navController.navigateUp()
|
navController.navigateUp()
|
||||||
@@ -360,23 +360,23 @@ private fun Calls(
|
|||||||
ctx.getString(R.string.calls_delete_question),
|
ctx.getString(R.string.calls_delete_question),
|
||||||
peerName, callText
|
peerName, callText
|
||||||
)
|
)
|
||||||
positiveButtonText.value = ctx.getString(R.string.delete)
|
secondButtonText.value = ""
|
||||||
positiveAction.value = {
|
lastButtonText.value = ctx.getString(R.string.delete)
|
||||||
|
lastAction.value = {
|
||||||
removeFromHistory(callHistory, callRow)
|
removeFromHistory(callHistory, callRow)
|
||||||
}
|
}
|
||||||
neutralButtonText.value = ""
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
message.value = String.format(
|
message.value = String.format(
|
||||||
ctx.getString(R.string.calls_add_delete_question),
|
ctx.getString(R.string.calls_add_delete_question),
|
||||||
peerName, callText
|
peerName, callText
|
||||||
)
|
)
|
||||||
positiveButtonText.value = ctx.getString(R.string.add_contact)
|
secondButtonText.value = ctx.getString(R.string.add_contact)
|
||||||
positiveAction.value = {
|
secondAction.value = {
|
||||||
navController.navigate("baresip_contact/$peerUri/new")
|
navController.navigate("baresip_contact/$peerUri/new")
|
||||||
}
|
}
|
||||||
neutralButtonText.value = ctx.getString(R.string.delete)
|
lastButtonText.value = ctx.getString(R.string.delete)
|
||||||
neutralAction.value = {
|
lastAction.value = {
|
||||||
removeFromHistory(callHistory, callRow)
|
removeFromHistory(callHistory, callRow)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -315,20 +315,20 @@ private fun Messages(
|
|||||||
|
|
||||||
val showDialog = remember { mutableStateOf(false) }
|
val showDialog = remember { mutableStateOf(false) }
|
||||||
val dialogMessage = remember { mutableStateOf("") }
|
val dialogMessage = remember { mutableStateOf("") }
|
||||||
val positiveButtonText = remember { mutableStateOf("") }
|
val secondButtonText = remember { mutableStateOf("") }
|
||||||
val positiveAction = remember { mutableStateOf({}) }
|
val secondAction = remember { mutableStateOf({}) }
|
||||||
val neutralButtonText = remember { mutableStateOf("") }
|
val lastButtonText = remember { mutableStateOf("") }
|
||||||
val neutralAction = remember { mutableStateOf({}) }
|
val lastAction = remember { mutableStateOf({}) }
|
||||||
|
|
||||||
AlertDialog(
|
AlertDialog(
|
||||||
showDialog = showDialog,
|
showDialog = showDialog,
|
||||||
title = stringResource(R.string.confirmation),
|
title = stringResource(R.string.confirmation),
|
||||||
message = dialogMessage.value,
|
message = dialogMessage.value,
|
||||||
positiveButtonText = positiveButtonText.value,
|
firstButtonText = stringResource(R.string.cancel),
|
||||||
onPositiveClicked = positiveAction.value,
|
secondButtonText = secondButtonText.value,
|
||||||
neutralButtonText = neutralButtonText.value,
|
onSecondClicked = secondAction.value,
|
||||||
onNeutralClicked = neutralAction.value,
|
lastButtonText = lastButtonText.value,
|
||||||
negativeButtonText = stringResource(R.string.cancel)
|
onLastClicked = lastAction.value,
|
||||||
)
|
)
|
||||||
|
|
||||||
val lazyListState = rememberLazyListState()
|
val lazyListState = rememberLazyListState()
|
||||||
@@ -391,23 +391,23 @@ private fun Messages(
|
|||||||
ctx.getString(R.string.long_message_question),
|
ctx.getString(R.string.long_message_question),
|
||||||
peerUri
|
peerUri
|
||||||
)
|
)
|
||||||
positiveButtonText.value = ctx.getString(R.string.add_contact)
|
secondButtonText.value = ctx.getString(R.string.add_contact)
|
||||||
positiveAction.value = {
|
secondAction.value = {
|
||||||
navController.navigate("baresip_contact/$peerUri/new")
|
navController.navigate("baresip_contact/$peerUri/new")
|
||||||
}
|
}
|
||||||
neutralButtonText.value = ctx.getString(R.string.delete)
|
lastButtonText.value = ctx.getString(R.string.delete)
|
||||||
neutralAction.value = {
|
lastAction.value = {
|
||||||
message.delete()
|
message.delete()
|
||||||
onMessageDeleted()
|
onMessageDeleted()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
dialogMessage.value = ctx.getString(R.string.short_message_question)
|
dialogMessage.value = ctx.getString(R.string.short_message_question)
|
||||||
positiveButtonText.value = ctx.getString(R.string.delete)
|
secondButtonText.value = ""
|
||||||
positiveAction.value = {
|
lastButtonText.value = ctx.getString(R.string.delete)
|
||||||
|
lastAction.value = {
|
||||||
message.delete()
|
message.delete()
|
||||||
onMessageDeleted()
|
onMessageDeleted()
|
||||||
}
|
}
|
||||||
neutralButtonText.value = ""
|
|
||||||
}
|
}
|
||||||
showDialog.value = true
|
showDialog.value = true
|
||||||
},
|
},
|
||||||
@@ -484,7 +484,7 @@ private fun NewMessage(
|
|||||||
showDialog = showDialog,
|
showDialog = showDialog,
|
||||||
title = stringResource(R.string.notice),
|
title = stringResource(R.string.notice),
|
||||||
message = dialogMessage.value,
|
message = dialogMessage.value,
|
||||||
positiveButtonText = stringResource(R.string.ok),
|
lastButtonText = stringResource(R.string.ok),
|
||||||
)
|
)
|
||||||
|
|
||||||
Row(modifier = Modifier
|
Row(modifier = Modifier
|
||||||
|
|||||||
@@ -167,15 +167,15 @@ private fun TopAppBar(
|
|||||||
val delete = stringResource(R.string.delete)
|
val delete = stringResource(R.string.delete)
|
||||||
val blocked = stringResource(R.string.blocked)
|
val blocked = stringResource(R.string.blocked)
|
||||||
val showDialog = remember { mutableStateOf(false) }
|
val showDialog = remember { mutableStateOf(false) }
|
||||||
val positiveAction = remember { mutableStateOf({}) }
|
val lastAction = remember { mutableStateOf({}) }
|
||||||
|
|
||||||
AlertDialog(
|
AlertDialog(
|
||||||
showDialog = showDialog,
|
showDialog = showDialog,
|
||||||
title = stringResource(R.string.confirmation),
|
title = stringResource(R.string.confirmation),
|
||||||
message = String.format(stringResource(R.string.delete_chats_alert), account.text()),
|
message = String.format(stringResource(R.string.delete_chats_alert), account.text()),
|
||||||
positiveButtonText = stringResource(R.string.delete),
|
firstButtonText = stringResource(R.string.cancel),
|
||||||
onPositiveClicked = positiveAction.value,
|
lastButtonText = stringResource(R.string.delete),
|
||||||
negativeButtonText = stringResource(R.string.cancel),
|
onLastClicked = lastAction.value,
|
||||||
)
|
)
|
||||||
|
|
||||||
TopAppBar(
|
TopAppBar(
|
||||||
@@ -212,7 +212,7 @@ private fun TopAppBar(
|
|||||||
menuExpanded = false
|
menuExpanded = false
|
||||||
when (selectedItem) {
|
when (selectedItem) {
|
||||||
delete -> {
|
delete -> {
|
||||||
positiveAction.value = {
|
lastAction.value = {
|
||||||
deleteMessages(uaMessages, account, "")
|
deleteMessages(uaMessages, account, "")
|
||||||
account.unreadMessages = false
|
account.unreadMessages = false
|
||||||
}
|
}
|
||||||
@@ -269,21 +269,21 @@ private fun Chats(
|
|||||||
|
|
||||||
val showDialog = remember { mutableStateOf(false) }
|
val showDialog = remember { mutableStateOf(false) }
|
||||||
val dialogMessage = remember { mutableStateOf("") }
|
val dialogMessage = remember { mutableStateOf("") }
|
||||||
val positiveButtonText = remember { mutableStateOf("") }
|
val secondButtonText = remember { mutableStateOf("") }
|
||||||
val positiveAction = remember { mutableStateOf({}) }
|
val secondAction = remember { mutableStateOf({}) }
|
||||||
val neutralButtonText = remember { mutableStateOf("") }
|
val lastButtonText = remember { mutableStateOf("") }
|
||||||
val neutralAction = remember { mutableStateOf({}) }
|
val lastAction = remember { mutableStateOf({}) }
|
||||||
|
|
||||||
if (showDialog.value)
|
if (showDialog.value)
|
||||||
AlertDialog(
|
AlertDialog(
|
||||||
showDialog = showDialog,
|
showDialog = showDialog,
|
||||||
title = stringResource(R.string.confirmation),
|
title = stringResource(R.string.confirmation),
|
||||||
message = dialogMessage.value,
|
message = dialogMessage.value,
|
||||||
positiveButtonText = positiveButtonText.value,
|
firstButtonText = stringResource(R.string.cancel),
|
||||||
onPositiveClicked = positiveAction.value,
|
secondButtonText = secondButtonText.value,
|
||||||
neutralButtonText = neutralButtonText.value,
|
onSecondClicked = secondAction.value,
|
||||||
onNeutralClicked = neutralAction.value,
|
lastButtonText = lastButtonText.value,
|
||||||
negativeButtonText = stringResource(R.string.cancel)
|
onLastClicked = lastAction.value,
|
||||||
)
|
)
|
||||||
|
|
||||||
val lazyListState = rememberLazyListState()
|
val lazyListState = rememberLazyListState()
|
||||||
@@ -359,22 +359,22 @@ private fun Chats(
|
|||||||
ctx.getString(R.string.short_chat_question),
|
ctx.getString(R.string.short_chat_question),
|
||||||
peer
|
peer
|
||||||
)
|
)
|
||||||
positiveButtonText.value = ctx.getString(R.string.delete)
|
secondButtonText.value = ""
|
||||||
positiveAction.value = {
|
lastButtonText.value = ctx.getString(R.string.delete)
|
||||||
|
lastAction.value = {
|
||||||
deleteMessages(uaMessages, account, message.peerUri)
|
deleteMessages(uaMessages, account, message.peerUri)
|
||||||
}
|
}
|
||||||
neutralButtonText.value = ""
|
|
||||||
} else {
|
} else {
|
||||||
dialogMessage.value =
|
dialogMessage.value =
|
||||||
String.format(ctx.getString(R.string.long_chat_question), peer)
|
String.format(ctx.getString(R.string.long_chat_question), peer)
|
||||||
positiveButtonText.value = ctx.getString(R.string.add_contact)
|
secondButtonText.value = ctx.getString(R.string.delete)
|
||||||
positiveAction.value = {
|
secondAction.value = {
|
||||||
navController.navigate("baresip_contact/${message.peerUri}/new")
|
|
||||||
}
|
|
||||||
neutralButtonText.value = ctx.getString(R.string.delete)
|
|
||||||
neutralAction.value = {
|
|
||||||
deleteMessages(uaMessages, account, message.peerUri)
|
deleteMessages(uaMessages, account, message.peerUri)
|
||||||
}
|
}
|
||||||
|
lastButtonText.value = ctx.getString(R.string.add_contact)
|
||||||
|
lastAction.value = {
|
||||||
|
navController.navigate("baresip_contact/${message.peerUri}/new")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
showDialog.value = true
|
showDialog.value = true
|
||||||
},
|
},
|
||||||
@@ -463,7 +463,7 @@ private fun NewChatPeer(ctx: Context, navController: NavController, account: Acc
|
|||||||
showDialog = showAlert,
|
showDialog = showAlert,
|
||||||
title = alertTitle.value,
|
title = alertTitle.value,
|
||||||
message = alertMessage.value,
|
message = alertMessage.value,
|
||||||
positiveButtonText = stringResource(R.string.ok),
|
lastButtonText = stringResource(R.string.ok),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ import androidx.navigation.NavGraphBuilder
|
|||||||
import androidx.navigation.NavType
|
import androidx.navigation.NavType
|
||||||
import androidx.navigation.compose.composable
|
import androidx.navigation.compose.composable
|
||||||
import androidx.navigation.navArgument
|
import androidx.navigation.navArgument
|
||||||
import com.tutpro.baresip.CustomElements.AlertDialog
|
|
||||||
import com.tutpro.baresip.CustomElements.verticalScrollbar
|
import com.tutpro.baresip.CustomElements.verticalScrollbar
|
||||||
|
|
||||||
fun NavGraphBuilder.codecsScreenRoute(navController: NavController) {
|
fun NavGraphBuilder.codecsScreenRoute(navController: NavController) {
|
||||||
@@ -161,11 +160,6 @@ private fun CodecsScreen(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private val alertTitle = mutableStateOf("")
|
|
||||||
private val alertMessage = mutableStateOf("")
|
|
||||||
private val showAlert = mutableStateOf(false)
|
|
||||||
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun CodecsContent(
|
private fun CodecsContent(
|
||||||
contentPadding: PaddingValues,
|
contentPadding: PaddingValues,
|
||||||
@@ -196,15 +190,6 @@ private fun CodecsContent(
|
|||||||
codecs.addAll(currentCodecs)
|
codecs.addAll(currentCodecs)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showAlert.value) {
|
|
||||||
AlertDialog(
|
|
||||||
showDialog = showAlert,
|
|
||||||
title = alertTitle.value,
|
|
||||||
message = alertMessage.value,
|
|
||||||
positiveButtonText = stringResource(R.string.ok),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
|
|||||||
@@ -215,21 +215,21 @@ private fun ContactsContent(
|
|||||||
) {
|
) {
|
||||||
val showDialog = remember { mutableStateOf(false) }
|
val showDialog = remember { mutableStateOf(false) }
|
||||||
val dialogMessage = remember { mutableStateOf("") }
|
val dialogMessage = remember { mutableStateOf("") }
|
||||||
val positiveText = remember { mutableStateOf("") }
|
val secondText = remember { mutableStateOf("") }
|
||||||
val positiveAction = remember { mutableStateOf({}) }
|
val secondAction = remember { mutableStateOf({}) }
|
||||||
val neutralText = remember { mutableStateOf("") }
|
val lastText = remember { mutableStateOf("") }
|
||||||
val neutralAction = remember { mutableStateOf({}) }
|
val lastAction = remember { mutableStateOf({}) }
|
||||||
|
|
||||||
if (showDialog.value)
|
if (showDialog.value)
|
||||||
AlertDialog(
|
AlertDialog(
|
||||||
showDialog = showDialog,
|
showDialog = showDialog,
|
||||||
title = stringResource(R.string.confirmation),
|
title = stringResource(R.string.confirmation),
|
||||||
message = dialogMessage.value,
|
message = dialogMessage.value,
|
||||||
positiveButtonText = positiveText.value,
|
firstButtonText = stringResource(R.string.cancel),
|
||||||
onPositiveClicked = positiveAction.value,
|
secondButtonText = secondText.value,
|
||||||
neutralButtonText = neutralText.value,
|
onSecondClicked = secondAction.value,
|
||||||
onNeutralClicked = neutralAction.value,
|
lastButtonText = lastText.value,
|
||||||
negativeButtonText = stringResource(R.string.cancel)
|
onLastClicked = lastAction.value,
|
||||||
)
|
)
|
||||||
|
|
||||||
val lazyListState = rememberLazyListState()
|
val lazyListState = rememberLazyListState()
|
||||||
@@ -334,8 +334,8 @@ private fun ContactsContent(
|
|||||||
ctx.getString(R.string.contact_action_question),
|
ctx.getString(R.string.contact_action_question),
|
||||||
contact.name()
|
contact.name()
|
||||||
)
|
)
|
||||||
positiveText.value = ctx.getString(R.string.call)
|
secondText.value = ctx.getString(R.string.call)
|
||||||
positiveAction.value = {
|
secondAction.value = {
|
||||||
if (ua != null) {
|
if (ua != null) {
|
||||||
handleIntent(ctx, viewModel, intent, "call")
|
handleIntent(ctx, viewModel, intent, "call")
|
||||||
navController.navigate("main") {
|
navController.navigate("main") {
|
||||||
@@ -344,8 +344,8 @@ private fun ContactsContent(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
neutralText.value = ctx.getString(R.string.send_message)
|
lastText.value = ctx.getString(R.string.send_message)
|
||||||
neutralAction.value = {
|
lastAction.value = {
|
||||||
if (ua != null) {
|
if (ua != null) {
|
||||||
handleIntent(ctx, viewModel, intent, "message")
|
handleIntent(ctx, viewModel, intent, "message")
|
||||||
navController.navigateUp()
|
navController.navigateUp()
|
||||||
@@ -358,8 +358,9 @@ private fun ContactsContent(
|
|||||||
ctx.getString(R.string.contact_delete_question),
|
ctx.getString(R.string.contact_delete_question),
|
||||||
contact.name()
|
contact.name()
|
||||||
)
|
)
|
||||||
positiveText.value = ctx.getString(R.string.delete)
|
secondText.value = ""
|
||||||
positiveAction.value = {
|
lastText.value = ctx.getString(R.string.delete)
|
||||||
|
lastAction.value = {
|
||||||
val id = contact.id
|
val id = contact.id
|
||||||
val avatarFile = File(
|
val avatarFile = File(
|
||||||
BaresipService.filesPath,
|
BaresipService.filesPath,
|
||||||
@@ -377,7 +378,6 @@ private fun ContactsContent(
|
|||||||
}
|
}
|
||||||
Contact.removeBaresipContact(contact)
|
Contact.removeBaresipContact(contact)
|
||||||
}
|
}
|
||||||
neutralText.value = ""
|
|
||||||
showDialog.value = true
|
showDialog.value = true
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -410,15 +410,15 @@ private fun ContactsContent(
|
|||||||
ctx.getString(R.string.contact_delete_question),
|
ctx.getString(R.string.contact_delete_question),
|
||||||
contact.name()
|
contact.name()
|
||||||
)
|
)
|
||||||
positiveText.value = ctx.getString(R.string.delete)
|
secondText.value = ""
|
||||||
positiveAction.value = {
|
lastText.value = ctx.getString(R.string.delete)
|
||||||
|
lastAction.value = {
|
||||||
ctx.contentResolver.delete(
|
ctx.contentResolver.delete(
|
||||||
ContactsContract.RawContacts.CONTENT_URI,
|
ContactsContract.RawContacts.CONTENT_URI,
|
||||||
ContactsContract.Contacts.DISPLAY_NAME + "='" + contact.name() + "'",
|
ContactsContract.Contacts.DISPLAY_NAME + "='" + contact.name() + "'",
|
||||||
null
|
null
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
neutralText.value = ""
|
|
||||||
showDialog.value = true
|
showDialog.value = true
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -228,18 +228,21 @@ object CustomElements {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun AlertDialog(
|
fun AlertDialog(
|
||||||
showDialog: MutableState<Boolean>,
|
showDialog: MutableState<Boolean>,
|
||||||
title: String,
|
title: String,
|
||||||
message: String,
|
message: String,
|
||||||
positiveButtonText: String = "",
|
firstButtonText: String = "",
|
||||||
onPositiveClicked: () -> Unit = {},
|
onFirstClicked: () -> Unit = {},
|
||||||
negativeButtonText: String = "",
|
secondButtonText: String = "",
|
||||||
onNegativeClicked: () -> Unit = {},
|
onSecondClicked: () -> Unit = {},
|
||||||
neutralButtonText: String = "",
|
thirdButtonText: String = "",
|
||||||
onNeutralClicked: () -> Unit = {}
|
onThirdClicked: () -> Unit = {},
|
||||||
|
lastButtonText: String = "",
|
||||||
|
onLastClicked: () -> Unit = {}
|
||||||
) {
|
) {
|
||||||
if (showDialog.value) {
|
if (showDialog.value) {
|
||||||
BasicAlertDialog(
|
BasicAlertDialog(
|
||||||
@@ -272,52 +275,59 @@ object CustomElements {
|
|||||||
)
|
)
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
|
|
||||||
// New logic starts here
|
if (lastButtonText.isNotEmpty()) {
|
||||||
if (positiveButtonText.isNotEmpty()) {
|
|
||||||
val buttonCount = listOf(positiveButtonText, negativeButtonText, neutralButtonText)
|
val buttonCount = listOf(
|
||||||
.count { it.isNotEmpty() }
|
firstButtonText, secondButtonText, thirdButtonText, lastButtonText
|
||||||
|
).count { it.isNotEmpty() }
|
||||||
|
|
||||||
if (buttonCount >= 3) {
|
if (buttonCount >= 3) {
|
||||||
// Use a Column for 3 buttons, aligned to the end (right)
|
// Use a Column for 3-4 buttons, aligned to the end (right)
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
horizontalAlignment = Alignment.End
|
horizontalAlignment = Alignment.End
|
||||||
) {
|
) {
|
||||||
// The positive button is usually last for emphasis
|
|
||||||
if (negativeButtonText.isNotEmpty()) {
|
|
||||||
TextButton(onClick = {
|
TextButton(onClick = {
|
||||||
onNegativeClicked()
|
onFirstClicked()
|
||||||
showDialog.value = false
|
showDialog.value = false
|
||||||
}) {
|
}) {
|
||||||
Text(
|
Text(
|
||||||
text = negativeButtonText.uppercase(),
|
text = firstButtonText.uppercase(),
|
||||||
fontSize = 14.sp,
|
fontSize = 14.sp,
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (neutralButtonText.isNotEmpty()) {
|
|
||||||
TextButton(onClick = {
|
TextButton(onClick = {
|
||||||
onNeutralClicked()
|
onSecondClicked()
|
||||||
showDialog.value = false
|
showDialog.value = false
|
||||||
}) {
|
}) {
|
||||||
Text(
|
Text(
|
||||||
text = neutralButtonText.uppercase(),
|
text = secondButtonText.uppercase(),
|
||||||
fontSize = 14.sp,
|
|
||||||
color = MaterialTheme.colorScheme.primary
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
TextButton(onClick = {
|
|
||||||
onPositiveClicked()
|
|
||||||
showDialog.value = false
|
|
||||||
}) {
|
|
||||||
Text(
|
|
||||||
text = positiveButtonText.uppercase(),
|
|
||||||
fontSize = 14.sp,
|
fontSize = 14.sp,
|
||||||
color = MaterialTheme.colorScheme.primary,
|
color = MaterialTheme.colorScheme.primary,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
if (thirdButtonText.isNotEmpty())
|
||||||
|
TextButton(onClick = {
|
||||||
|
onThirdClicked()
|
||||||
|
showDialog.value = false
|
||||||
|
}) {
|
||||||
|
Text(
|
||||||
|
text = thirdButtonText.uppercase(),
|
||||||
|
fontSize = 14.sp,
|
||||||
|
color = MaterialTheme.colorScheme.primary,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
TextButton(onClick = {
|
||||||
|
onLastClicked()
|
||||||
|
showDialog.value = false
|
||||||
|
}) {
|
||||||
|
Text(
|
||||||
|
text = lastButtonText.uppercase(),
|
||||||
|
fontSize = 14.sp,
|
||||||
|
color = MaterialTheme.colorScheme.primary
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Use the existing Row for 1 or 2 buttons
|
// Use the existing Row for 1 or 2 buttons
|
||||||
@@ -325,38 +335,36 @@ object CustomElements {
|
|||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
horizontalArrangement = Arrangement.End
|
horizontalArrangement = Arrangement.End
|
||||||
) {
|
) {
|
||||||
if (negativeButtonText.isNotEmpty()) {
|
if (firstButtonText.isNotEmpty())
|
||||||
TextButton(onClick = {
|
TextButton(onClick = {
|
||||||
onNegativeClicked()
|
onFirstClicked()
|
||||||
showDialog.value = false
|
showDialog.value = false
|
||||||
}) {
|
}) {
|
||||||
Text(
|
Text(
|
||||||
text = negativeButtonText.uppercase(),
|
text = firstButtonText.uppercase(),
|
||||||
fontSize = 14.sp,
|
fontSize = 14.sp,
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
if (secondButtonText.isNotEmpty())
|
||||||
if (neutralButtonText.isNotEmpty()) {
|
|
||||||
TextButton(onClick = {
|
TextButton(onClick = {
|
||||||
onNeutralClicked()
|
onSecondClicked()
|
||||||
showDialog.value = false
|
showDialog.value = false
|
||||||
}) {
|
}) {
|
||||||
Text(
|
Text(
|
||||||
text = neutralButtonText.uppercase(),
|
text = secondButtonText.uppercase(),
|
||||||
fontSize = 14.sp,
|
fontSize = 14.sp,
|
||||||
color = MaterialTheme.colorScheme.primary
|
color = MaterialTheme.colorScheme.primary
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
TextButton(onClick = {
|
TextButton(onClick = {
|
||||||
onPositiveClicked()
|
onLastClicked()
|
||||||
showDialog.value = false
|
showDialog.value = false
|
||||||
}) {
|
}) {
|
||||||
Text(
|
Text(
|
||||||
text = positiveButtonText.uppercase(),
|
text = lastButtonText.uppercase(),
|
||||||
fontSize = 14.sp,
|
fontSize = 14.sp,
|
||||||
color = MaterialTheme.colorScheme.primary,
|
color = MaterialTheme.colorScheme.primary
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -481,7 +489,7 @@ object CustomElements {
|
|||||||
.padding(top = 16.dp, start = 16.dp, end = 16.dp, bottom = 0.dp),
|
.padding(top = 16.dp, start = 16.dp, end = 16.dp, bottom = 0.dp),
|
||||||
shape = RoundedCornerShape(16.dp),
|
shape = RoundedCornerShape(16.dp),
|
||||||
colors = CardDefaults.cardColors(
|
colors = CardDefaults.cardColors(
|
||||||
containerColor = MaterialTheme.colorScheme.surfaceContainer
|
containerColor = MaterialTheme.colorScheme.surfaceVariant
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
Column(modifier = Modifier.padding(16.dp)) {
|
Column(modifier = Modifier.padding(16.dp)) {
|
||||||
|
|||||||
@@ -754,15 +754,16 @@ private fun BottomBar(ctx: Context, viewModel: ViewModel, navController: NavCont
|
|||||||
if (acc.vmUri.isNotEmpty()) {
|
if (acc.vmUri.isNotEmpty()) {
|
||||||
dialogTitle.value = ctx.getString(R.string.voicemail_messages)
|
dialogTitle.value = ctx.getString(R.string.voicemail_messages)
|
||||||
dialogMessage.value = acc.vmMessages(ctx)
|
dialogMessage.value = acc.vmMessages(ctx)
|
||||||
positiveText.value = ctx.getString(R.string.listen)
|
firstText.value = ctx.getString(R.string.cancel)
|
||||||
onPositiveClicked.value = {
|
onFirstClicked.value = {}
|
||||||
|
secondText.value = ""
|
||||||
|
lastText.value = ctx.getString(R.string.listen)
|
||||||
|
onLastClicked.value = {
|
||||||
val intent = Intent(ctx, MainActivity::class.java)
|
val intent = Intent(ctx, MainActivity::class.java)
|
||||||
intent.putExtra("uap", ua.uap)
|
intent.putExtra("uap", ua.uap)
|
||||||
intent.putExtra("peer", acc.vmUri)
|
intent.putExtra("peer", acc.vmUri)
|
||||||
handleIntent(ctx, viewModel, intent, "call")
|
handleIntent(ctx, viewModel, intent, "call")
|
||||||
}
|
}
|
||||||
negativeText.value = ctx.getString(R.string.cancel)
|
|
||||||
onNegativeClicked.value = {}
|
|
||||||
showDialog.value = true
|
showDialog.value = true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -852,10 +853,13 @@ private val showAlert = mutableStateOf(false)
|
|||||||
|
|
||||||
private val dialogTitle = mutableStateOf("")
|
private val dialogTitle = mutableStateOf("")
|
||||||
private val dialogMessage = mutableStateOf("")
|
private val dialogMessage = mutableStateOf("")
|
||||||
private val positiveText = mutableStateOf("")
|
private val firstText = mutableStateOf("")
|
||||||
private val onPositiveClicked = mutableStateOf({})
|
private val onFirstClicked = mutableStateOf({})
|
||||||
private val negativeText = mutableStateOf("")
|
|
||||||
private val onNegativeClicked = mutableStateOf({})
|
private val secondText = mutableStateOf("")
|
||||||
|
private val onSecondClicked = mutableStateOf({})
|
||||||
|
private val lastText = mutableStateOf("")
|
||||||
|
private val onLastClicked = mutableStateOf({})
|
||||||
private val showDialog = mutableStateOf(false)
|
private val showDialog = mutableStateOf(false)
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@@ -902,7 +906,7 @@ private fun MainContent(navController: NavController, viewModel: ViewModel, cont
|
|||||||
showDialog = showAlert,
|
showDialog = showAlert,
|
||||||
title = alertTitle.value,
|
title = alertTitle.value,
|
||||||
message = alertMessage.value,
|
message = alertMessage.value,
|
||||||
positiveButtonText = stringResource(R.string.ok),
|
lastButtonText = stringResource(R.string.ok),
|
||||||
)
|
)
|
||||||
|
|
||||||
if (showDialog.value)
|
if (showDialog.value)
|
||||||
@@ -910,10 +914,12 @@ private fun MainContent(navController: NavController, viewModel: ViewModel, cont
|
|||||||
showDialog = showDialog,
|
showDialog = showDialog,
|
||||||
title = stringResource(R.string.confirmation),
|
title = stringResource(R.string.confirmation),
|
||||||
message = dialogMessage.value,
|
message = dialogMessage.value,
|
||||||
positiveButtonText = positiveText.value,
|
firstButtonText = firstText.value,
|
||||||
onPositiveClicked = onPositiveClicked.value,
|
onFirstClicked = onFirstClicked.value,
|
||||||
negativeButtonText = negativeText.value,
|
secondButtonText = secondText.value,
|
||||||
onNegativeClicked = onNegativeClicked.value
|
onSecondClicked = onSecondClicked.value,
|
||||||
|
lastButtonText = lastText.value,
|
||||||
|
onLastClicked = onLastClicked.value,
|
||||||
)
|
)
|
||||||
|
|
||||||
SelectableAlertDialog(
|
SelectableAlertDialog(
|
||||||
@@ -1347,8 +1353,11 @@ private fun CallUriRow(
|
|||||||
R.color.colorTrafficGreen -> {
|
R.color.colorTrafficGreen -> {
|
||||||
dialogTitle.value = ctx.getString(R.string.info)
|
dialogTitle.value = ctx.getString(R.string.info)
|
||||||
dialogMessage.value = ctx.getString(R.string.call_is_secure)
|
dialogMessage.value = ctx.getString(R.string.call_is_secure)
|
||||||
positiveText.value = ctx.getString(R.string.unverify)
|
firstText.value = ctx.getString(R.string.cancel)
|
||||||
onPositiveClicked.value = {
|
onFirstClicked.value = {}
|
||||||
|
secondText.value = ""
|
||||||
|
lastText.value = ctx.getString(R.string.unverify)
|
||||||
|
onLastClicked.value = {
|
||||||
if (Api.cmd_exec("zrtp_unverify " + call.zid) != 0)
|
if (Api.cmd_exec("zrtp_unverify " + call.zid) != 0)
|
||||||
Log.e(
|
Log.e(
|
||||||
TAG,
|
TAG,
|
||||||
@@ -1357,7 +1366,6 @@ private fun CallUriRow(
|
|||||||
else
|
else
|
||||||
call.securityIconTint.value = R.color.colorTrafficYellow
|
call.securityIconTint.value = R.color.colorTrafficYellow
|
||||||
}
|
}
|
||||||
negativeText.value = ctx.getString(R.string.cancel)
|
|
||||||
showDialog.value = true
|
showDialog.value = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2339,12 +2347,13 @@ fun handleServiceEvent(ctx: Context, viewModel: ViewModel, event: String, params
|
|||||||
else {
|
else {
|
||||||
dialogTitle.value = ctx.getString(R.string.redirect_request)
|
dialogTitle.value = ctx.getString(R.string.redirect_request)
|
||||||
dialogMessage.value = String.format(ctx.getString(R.string.redirect_request_query), target)
|
dialogMessage.value = String.format(ctx.getString(R.string.redirect_request_query), target)
|
||||||
positiveText.value = ctx.getString(R.string.yes)
|
firstText.value = ""
|
||||||
onPositiveClicked.value = {
|
secondText.value = ctx.getString(R.string.no)
|
||||||
|
onSecondClicked.value = { }
|
||||||
|
lastText.value = ctx.getString(R.string.yes)
|
||||||
|
onLastClicked.value = {
|
||||||
redirect(ctx, viewModel, ua, target)
|
redirect(ctx, viewModel, ua, target)
|
||||||
}
|
}
|
||||||
negativeText.value = ctx.getString(R.string.no)
|
|
||||||
onNegativeClicked.value = {}
|
|
||||||
showDialog.value = true
|
showDialog.value = true
|
||||||
}
|
}
|
||||||
showCall(ctx, viewModel, ua)
|
showCall(ctx, viewModel, ua)
|
||||||
@@ -2374,8 +2383,17 @@ fun handleServiceEvent(ctx: Context, viewModel: ViewModel, event: String, params
|
|||||||
}
|
}
|
||||||
dialogTitle.value = ctx.getString(R.string.verify)
|
dialogTitle.value = ctx.getString(R.string.verify)
|
||||||
dialogMessage.value = String.format(ctx.getString(R.string.verify_sas), ev[1])
|
dialogMessage.value = String.format(ctx.getString(R.string.verify_sas), ev[1])
|
||||||
positiveText.value = ctx.getString(R.string.yes)
|
firstText.value = ""
|
||||||
onPositiveClicked.value = {
|
secondText.value = ctx.getString(R.string.no)
|
||||||
|
onSecondClicked.value = {
|
||||||
|
call.security = R.color.colorTrafficYellow
|
||||||
|
call.zid = ev[2]
|
||||||
|
if (aor == viewModel.selectedAor.value)
|
||||||
|
call.securityIconTint.value = R.color.colorTrafficYellow
|
||||||
|
secondText.value = ""
|
||||||
|
}
|
||||||
|
lastText.value = ctx.getString(R.string.yes)
|
||||||
|
onLastClicked.value = {
|
||||||
call.security = if (Api.cmd_exec("zrtp_verify ${ev[2]}") != 0) {
|
call.security = if (Api.cmd_exec("zrtp_verify ${ev[2]}") != 0) {
|
||||||
Log.e(TAG, "Command 'zrtp_verify ${ev[2]}' failed")
|
Log.e(TAG, "Command 'zrtp_verify ${ev[2]}' failed")
|
||||||
R.color.colorTrafficYellow
|
R.color.colorTrafficYellow
|
||||||
@@ -2386,14 +2404,6 @@ fun handleServiceEvent(ctx: Context, viewModel: ViewModel, event: String, params
|
|||||||
if (aor == viewModel.selectedAor.value)
|
if (aor == viewModel.selectedAor.value)
|
||||||
call.securityIconTint.value = call.security
|
call.securityIconTint.value = call.security
|
||||||
}
|
}
|
||||||
negativeText.value = ctx.getString(R.string.no)
|
|
||||||
onNegativeClicked.value = {
|
|
||||||
call.security = R.color.colorTrafficYellow
|
|
||||||
call.zid = ev[2]
|
|
||||||
if (aor == viewModel.selectedAor.value)
|
|
||||||
call.securityIconTint.value = R.color.colorTrafficYellow
|
|
||||||
onNegativeClicked.value = {}
|
|
||||||
}
|
|
||||||
showDialog.value = true
|
showDialog.value = true
|
||||||
}
|
}
|
||||||
"call verified", "call secure" -> {
|
"call verified", "call secure" -> {
|
||||||
@@ -2420,19 +2430,19 @@ fun handleServiceEvent(ctx: Context, viewModel: ViewModel, event: String, params
|
|||||||
String.format(ctx.getString(R.string.transfer_request_query), target)
|
String.format(ctx.getString(R.string.transfer_request_query), target)
|
||||||
else
|
else
|
||||||
String.format(ctx.getString(R.string.call_request_query), target)
|
String.format(ctx.getString(R.string.call_request_query), target)
|
||||||
positiveText.value = ctx.getString(R.string.yes)
|
firstText.value = ""
|
||||||
onPositiveClicked.value = {
|
secondText.value = ctx.getString(R.string.no)
|
||||||
|
onSecondClicked.value = {
|
||||||
|
if (call in Call.calls())
|
||||||
|
call!!.notifySipfrag(603, "Decline")
|
||||||
|
}
|
||||||
|
lastText.value = ctx.getString(R.string.yes)
|
||||||
|
onLastClicked.value = {
|
||||||
if (call in Call.calls())
|
if (call in Call.calls())
|
||||||
acceptTransfer(ctx, viewModel, ua, call!!, ev[1])
|
acceptTransfer(ctx, viewModel, ua, call!!, ev[1])
|
||||||
else
|
else
|
||||||
makeCall(ctx, viewModel, ev[1], false)
|
makeCall(ctx, viewModel, ev[1], false)
|
||||||
}
|
}
|
||||||
negativeText.value = ctx.getString(R.string.no)
|
|
||||||
onNegativeClicked.value = {
|
|
||||||
if (call in Call.calls())
|
|
||||||
call!!.notifySipfrag(603, "Decline")
|
|
||||||
onNegativeClicked.value = {}
|
|
||||||
}
|
|
||||||
showDialog.value = true
|
showDialog.value = true
|
||||||
}
|
}
|
||||||
"transfer accept" -> {
|
"transfer accept" -> {
|
||||||
@@ -2569,9 +2579,10 @@ fun handleIntent(ctx: Context, viewModel: ViewModel, intent: Intent, action: Str
|
|||||||
fun handleDialog(ctx: Context, title: String, message: String, action: () -> Unit = {}) {
|
fun handleDialog(ctx: Context, title: String, message: String, action: () -> Unit = {}) {
|
||||||
dialogTitle.value = title
|
dialogTitle.value = title
|
||||||
dialogMessage.value = message
|
dialogMessage.value = message
|
||||||
positiveText.value = ctx.getString(R.string.ok)
|
firstText.value = ""
|
||||||
onPositiveClicked.value = { action() }
|
secondText.value = ""
|
||||||
negativeText.value = ""
|
lastText.value = ctx.getString(R.string.ok)
|
||||||
|
onLastClicked.value = { action() }
|
||||||
showDialog.value = true
|
showDialog.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2736,13 +2747,14 @@ private fun restore(ctx: Context, password: String, onRestartApp: () -> Unit) {
|
|||||||
|
|
||||||
dialogTitle.value = ctx.getString(R.string.info)
|
dialogTitle.value = ctx.getString(R.string.info)
|
||||||
dialogMessage.value = ctx.getString(R.string.restored)
|
dialogMessage.value = ctx.getString(R.string.restored)
|
||||||
positiveText.value = ctx.getString(R.string.restart)
|
firstText.value = ctx.getString(R.string.cancel)
|
||||||
onPositiveClicked.value = {
|
onFirstClicked.value = {
|
||||||
onRestartApp()
|
|
||||||
showDialog.value = false
|
showDialog.value = false
|
||||||
}
|
}
|
||||||
negativeText.value = ctx.getString(R.string.cancel)
|
secondText.value = ""
|
||||||
onNegativeClicked.value = {
|
lastText.value = ctx.getString(R.string.restart)
|
||||||
|
onLastClicked.value = {
|
||||||
|
onRestartApp()
|
||||||
showDialog.value = false
|
showDialog.value = false
|
||||||
}
|
}
|
||||||
showDialog.value = true
|
showDialog.value = true
|
||||||
|
|||||||
@@ -200,14 +200,14 @@ private fun SettingsScreen(
|
|||||||
showDialog = showRestartDialog,
|
showDialog = showRestartDialog,
|
||||||
title = stringResource(R.string.restart_request),
|
title = stringResource(R.string.restart_request),
|
||||||
message = stringResource(R.string.config_restart),
|
message = stringResource(R.string.config_restart),
|
||||||
positiveButtonText = stringResource(R.string.restart),
|
firstButtonText = stringResource(R.string.cancel),
|
||||||
onPositiveClicked = {
|
onFirstClicked = {
|
||||||
|
navController.navigateUp()
|
||||||
|
},
|
||||||
|
lastButtonText = stringResource(R.string.restart),
|
||||||
|
onLastClicked = {
|
||||||
onRestartApp()
|
onRestartApp()
|
||||||
},
|
},
|
||||||
negativeButtonText = stringResource(R.string.cancel),
|
|
||||||
onNegativeClicked = {
|
|
||||||
navController.navigateUp()
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -218,10 +218,10 @@ private fun SettingsScreen(
|
|||||||
|
|
||||||
private val dialogTitle = mutableStateOf("")
|
private val dialogTitle = mutableStateOf("")
|
||||||
private val dialogMessage = mutableStateOf("")
|
private val dialogMessage = mutableStateOf("")
|
||||||
private val positiveText = mutableStateOf("")
|
private val firstButtonText = mutableStateOf("")
|
||||||
private val onPositiveClicked = mutableStateOf({})
|
private val onFirstClicked = mutableStateOf({})
|
||||||
private val negativeText = mutableStateOf("")
|
private val lastButtonText = mutableStateOf("")
|
||||||
private val onNegativeClicked = mutableStateOf({})
|
private val onLastClicked = mutableStateOf({})
|
||||||
private val showDialog = mutableStateOf(false)
|
private val showDialog = mutableStateOf(false)
|
||||||
|
|
||||||
private val alertTitle = mutableStateOf("")
|
private val alertTitle = mutableStateOf("")
|
||||||
@@ -249,7 +249,8 @@ private fun SettingsContent(
|
|||||||
showDialog = showAlert,
|
showDialog = showAlert,
|
||||||
title = alertTitle.value,
|
title = alertTitle.value,
|
||||||
message = alertMessage.value,
|
message = alertMessage.value,
|
||||||
positiveButtonText = okButtonText,
|
firstButtonText = "",
|
||||||
|
lastButtonText = okButtonText,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -258,10 +259,10 @@ private fun SettingsContent(
|
|||||||
showDialog = showDialog,
|
showDialog = showDialog,
|
||||||
title = dialogTitle.value,
|
title = dialogTitle.value,
|
||||||
message = dialogMessage.value,
|
message = dialogMessage.value,
|
||||||
positiveButtonText = positiveText.value,
|
firstButtonText = firstButtonText.value,
|
||||||
onPositiveClicked = onPositiveClicked.value,
|
onFirstClicked = onFirstClicked.value,
|
||||||
negativeButtonText = negativeText.value,
|
lastButtonText = lastButtonText.value,
|
||||||
onNegativeClicked = onNegativeClicked.value,
|
onLastClicked = onLastClicked.value,
|
||||||
)
|
)
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@@ -293,15 +294,13 @@ private fun SettingsContent(
|
|||||||
if (!isAppearOnTopPermissionGranted(ctx)) {
|
if (!isAppearOnTopPermissionGranted(ctx)) {
|
||||||
dialogTitle.value = noticeTitleText
|
dialogTitle.value = noticeTitleText
|
||||||
dialogMessage.value = appearOnTopPermissionMessage
|
dialogMessage.value = appearOnTopPermissionMessage
|
||||||
positiveText.value = okButtonText
|
firstButtonText.value = cancelButtonText
|
||||||
onPositiveClicked.value = {
|
onFirstClicked.value = {}
|
||||||
|
lastButtonText.value = okButtonText
|
||||||
|
onLastClicked.value = {
|
||||||
val intent = Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION)
|
val intent = Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION)
|
||||||
ctx.startActivity(intent)
|
ctx.startActivity(intent)
|
||||||
}
|
}
|
||||||
negativeText.value = cancelButtonText
|
|
||||||
onNegativeClicked.value = {
|
|
||||||
negativeText.value = ""
|
|
||||||
}
|
|
||||||
showDialog.value = true
|
showDialog.value = true
|
||||||
viewModel.autoStart.value = false
|
viewModel.autoStart.value = false
|
||||||
}
|
}
|
||||||
@@ -578,10 +577,10 @@ private fun SettingsContent(
|
|||||||
showDialog = showAlertDialog,
|
showDialog = showAlertDialog,
|
||||||
title = stringResource(R.string.notice),
|
title = stringResource(R.string.notice),
|
||||||
message = stringResource(R.string.no_read_permission),
|
message = stringResource(R.string.no_read_permission),
|
||||||
positiveButtonText = stringResource(R.string.ok),
|
firstButtonText = "",
|
||||||
onPositiveClicked = { requestPermissionLauncher.launch(Manifest.permission.READ_EXTERNAL_STORAGE) },
|
onFirstClicked = {},
|
||||||
negativeButtonText = "",
|
lastButtonText = stringResource(R.string.ok),
|
||||||
onNegativeClicked = {},
|
onLastClicked = { requestPermissionLauncher.launch(Manifest.permission.READ_EXTERNAL_STORAGE) },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -690,11 +689,11 @@ private fun SettingsContent(
|
|||||||
shouldShowRequestPermissionRationale(activity, permission) -> {
|
shouldShowRequestPermissionRationale(activity, permission) -> {
|
||||||
dialogTitle.value = noticeTitleText
|
dialogTitle.value = noticeTitleText
|
||||||
dialogMessage.value = noReadPermissionMessage
|
dialogMessage.value = noReadPermissionMessage
|
||||||
positiveText.value = okButtonText
|
firstButtonText.value = ""
|
||||||
onPositiveClicked.value = {
|
lastButtonText.value = okButtonText
|
||||||
|
onLastClicked.value = {
|
||||||
requestPermissionLauncher.launch(permission)
|
requestPermissionLauncher.launch(permission)
|
||||||
}
|
}
|
||||||
negativeText.value = ""
|
|
||||||
showDialog.value = true
|
showDialog.value = true
|
||||||
}
|
}
|
||||||
else ->
|
else ->
|
||||||
@@ -764,8 +763,8 @@ private fun SettingsContent(
|
|||||||
val contactsHelp = stringResource(R.string.contacts_help)
|
val contactsHelp = stringResource(R.string.contacts_help)
|
||||||
val consentRequestTitle = stringResource(R.string.consent_request)
|
val consentRequestTitle = stringResource(R.string.consent_request)
|
||||||
val contactsConsentMessage = stringResource(R.string.contacts_consent)
|
val contactsConsentMessage = stringResource(R.string.contacts_consent)
|
||||||
val positiveButtonText = stringResource(R.string.accept)
|
val denyText = stringResource(R.string.deny)
|
||||||
val negativeButtonText = stringResource(R.string.deny)
|
val acceptText = stringResource(R.string.accept)
|
||||||
val both = stringResource(R.string.both)
|
val both = stringResource(R.string.both)
|
||||||
val noAndroidContactsMessage = stringResource(R.string.no_android_contacts)
|
val noAndroidContactsMessage = stringResource(R.string.no_android_contacts)
|
||||||
val showAlertDialog = remember { mutableStateOf(false) }
|
val showAlertDialog = remember { mutableStateOf(false) }
|
||||||
@@ -832,8 +831,12 @@ private fun SettingsContent(
|
|||||||
if (mode != "baresip" && !Utils.checkPermissions(ctx, contactsPermissions)) {
|
if (mode != "baresip" && !Utils.checkPermissions(ctx, contactsPermissions)) {
|
||||||
dialogTitle.value = consentRequestTitle
|
dialogTitle.value = consentRequestTitle
|
||||||
dialogMessage.value = contactsConsentMessage
|
dialogMessage.value = contactsConsentMessage
|
||||||
positiveText.value = positiveButtonText
|
firstButtonText.value = denyText
|
||||||
onPositiveClicked.value = {
|
onFirstClicked.value = {
|
||||||
|
itemPosition.intValue = contactValues.indexOf(contactsMode)
|
||||||
|
}
|
||||||
|
lastButtonText.value = acceptText
|
||||||
|
onLastClicked.value = {
|
||||||
showDialog.value = false
|
showDialog.value = false
|
||||||
viewModel.contactsMode.value = mode
|
viewModel.contactsMode.value = mode
|
||||||
if (ContextCompat.checkSelfPermission(
|
if (ContextCompat.checkSelfPermission(
|
||||||
@@ -864,11 +867,6 @@ private fun SettingsContent(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
negativeText.value = negativeButtonText
|
|
||||||
onNegativeClicked.value = {
|
|
||||||
itemPosition.intValue = contactValues.indexOf(contactsMode)
|
|
||||||
negativeText.value = ""
|
|
||||||
}
|
|
||||||
showDialog.value = true
|
showDialog.value = true
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -886,15 +884,15 @@ private fun SettingsContent(
|
|||||||
showDialog = showAlertDialog,
|
showDialog = showAlertDialog,
|
||||||
title = noticeTitleText,
|
title = noticeTitleText,
|
||||||
message = noAndroidContactsMessage,
|
message = noAndroidContactsMessage,
|
||||||
positiveButtonText = okButtonText,
|
firstButtonText = "",
|
||||||
onPositiveClicked = { requestPermissionsLauncher.launch(
|
onFirstClicked = {},
|
||||||
|
lastButtonText = okButtonText,
|
||||||
|
onLastClicked = { requestPermissionsLauncher.launch(
|
||||||
arrayOf(
|
arrayOf(
|
||||||
Manifest.permission.READ_CONTACTS,
|
Manifest.permission.READ_CONTACTS,
|
||||||
Manifest.permission.WRITE_CONTACTS
|
Manifest.permission.WRITE_CONTACTS
|
||||||
)
|
)
|
||||||
)},
|
)},
|
||||||
negativeButtonText = "",
|
|
||||||
onNegativeClicked = {},
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1229,16 +1227,15 @@ private fun SettingsContent(
|
|||||||
onCheckedChange = {
|
onCheckedChange = {
|
||||||
dialogTitle.value = confirmationText
|
dialogTitle.value = confirmationText
|
||||||
dialogMessage.value = resetConfigAlert
|
dialogMessage.value = resetConfigAlert
|
||||||
positiveText.value = resetButtonText
|
firstButtonText.value = cancelButtonText
|
||||||
onPositiveClicked.value = {
|
onFirstClicked.value = {
|
||||||
|
reset = false
|
||||||
|
}
|
||||||
|
lastButtonText.value = resetButtonText
|
||||||
|
onLastClicked.value = {
|
||||||
Config.reset()
|
Config.reset()
|
||||||
onRestartApp()
|
onRestartApp()
|
||||||
}
|
}
|
||||||
negativeText.value = cancelButtonText
|
|
||||||
onNegativeClicked.value = {
|
|
||||||
reset = false
|
|
||||||
negativeText.value = ""
|
|
||||||
}
|
|
||||||
showDialog.value = true
|
showDialog.value = true
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user