diff --git a/apps/android/app/src/main/java/chat/simplex/app/MainActivity.kt b/apps/android/app/src/main/java/chat/simplex/app/MainActivity.kt index 953b59863..49d3f75c1 100644 --- a/apps/android/app/src/main/java/chat/simplex/app/MainActivity.kt +++ b/apps/android/app/src/main/java/chat/simplex/app/MainActivity.kt @@ -633,7 +633,7 @@ fun connectIfOpenedViaUri(uri: Uri, chatModel: ChatModel) { ConnectionLinkType.INVITATION -> generalGetString(R.string.connect_via_invitation_link) ConnectionLinkType.GROUP -> generalGetString(R.string.connect_via_group_link) } - AlertManager.shared.showAlertMsg( + AlertManager.shared.showAlertDialog( title = title, text = if (linkType == ConnectionLinkType.GROUP) generalGetString(R.string.you_will_join_group) diff --git a/apps/android/app/src/main/java/chat/simplex/app/views/chat/ChatInfoView.kt b/apps/android/app/src/main/java/chat/simplex/app/views/chat/ChatInfoView.kt index c74b579f0..12b21f9dd 100644 --- a/apps/android/app/src/main/java/chat/simplex/app/views/chat/ChatInfoView.kt +++ b/apps/android/app/src/main/java/chat/simplex/app/views/chat/ChatInfoView.kt @@ -111,7 +111,7 @@ fun ChatInfoView( } fun deleteContactDialog(chatInfo: ChatInfo, chatModel: ChatModel, close: (() -> Unit)? = null) { - AlertManager.shared.showAlertMsg( + AlertManager.shared.showAlertDialog( title = generalGetString(R.string.delete_contact_question), text = generalGetString(R.string.delete_contact_all_messages_deleted_cannot_undo_warning), confirmText = generalGetString(R.string.delete_verb), @@ -125,12 +125,13 @@ fun deleteContactDialog(chatInfo: ChatInfo, chatModel: ChatModel, close: (() -> close?.invoke() } } - } + }, + destructive = true, ) } fun clearChatDialog(chatInfo: ChatInfo, chatModel: ChatModel, close: (() -> Unit)? = null) { - AlertManager.shared.showAlertMsg( + AlertManager.shared.showAlertDialog( title = generalGetString(R.string.clear_chat_question), text = generalGetString(R.string.clear_chat_warning), confirmText = generalGetString(R.string.clear_verb), @@ -143,7 +144,8 @@ fun clearChatDialog(chatInfo: ChatInfo, chatModel: ChatModel, close: (() -> Unit close?.invoke() } } - } + }, + destructive = true, ) } @@ -421,13 +423,14 @@ private fun setContactAlias(contactApiId: Long, localAlias: String, chatModel: C } private fun showSwitchContactAddressAlert(m: ChatModel, contactId: Long) { - AlertManager.shared.showAlertMsg( + AlertManager.shared.showAlertDialog( title = generalGetString(R.string.switch_receiving_address_question), text = generalGetString(R.string.switch_receiving_address_desc), confirmText = generalGetString(R.string.switch_verb), onConfirm = { switchContactAddress(m, contactId) - } + }, + destructive = true, ) } diff --git a/apps/android/app/src/main/java/chat/simplex/app/views/chat/group/GroupChatInfoView.kt b/apps/android/app/src/main/java/chat/simplex/app/views/chat/group/GroupChatInfoView.kt index 89c9d1b1d..7eb93e2d3 100644 --- a/apps/android/app/src/main/java/chat/simplex/app/views/chat/group/GroupChatInfoView.kt +++ b/apps/android/app/src/main/java/chat/simplex/app/views/chat/group/GroupChatInfoView.kt @@ -108,7 +108,7 @@ fun deleteGroupDialog(chatInfo: ChatInfo, groupInfo: GroupInfo, chatModel: ChatM val alertTextKey = if (groupInfo.membership.memberCurrent) R.string.delete_group_for_all_members_cannot_undo_warning else R.string.delete_group_for_self_cannot_undo_warning - AlertManager.shared.showAlertMsg( + AlertManager.shared.showAlertDialog( title = generalGetString(R.string.delete_group_question), text = generalGetString(alertTextKey), confirmText = generalGetString(R.string.delete_verb), @@ -122,12 +122,13 @@ fun deleteGroupDialog(chatInfo: ChatInfo, groupInfo: GroupInfo, chatModel: ChatM close?.invoke() } } - } + }, + destructive = true, ) } fun leaveGroupDialog(groupInfo: GroupInfo, chatModel: ChatModel, close: (() -> Unit)? = null) { - AlertManager.shared.showAlertMsg( + AlertManager.shared.showAlertDialog( title = generalGetString(R.string.leave_group_question), text = generalGetString(R.string.you_will_stop_receiving_messages_from_this_group_chat_history_will_be_preserved), confirmText = generalGetString(R.string.leave_group_button), @@ -136,7 +137,8 @@ fun leaveGroupDialog(groupInfo: GroupInfo, chatModel: ChatModel, close: (() -> U chatModel.controller.leaveGroup(groupInfo.groupId) close?.invoke() } - } + }, + destructive = true, ) } diff --git a/apps/android/app/src/main/java/chat/simplex/app/views/chat/group/GroupLinkView.kt b/apps/android/app/src/main/java/chat/simplex/app/views/chat/group/GroupLinkView.kt index a044e9cc1..6fb2eaf9d 100644 --- a/apps/android/app/src/main/java/chat/simplex/app/views/chat/group/GroupLinkView.kt +++ b/apps/android/app/src/main/java/chat/simplex/app/views/chat/group/GroupLinkView.kt @@ -66,7 +66,7 @@ fun GroupLinkView(chatModel: ChatModel, groupInfo: GroupInfo, connReqContact: St } }, deleteLink = { - AlertManager.shared.showAlertMsg( + AlertManager.shared.showAlertDialog( title = generalGetString(R.string.delete_link_question), text = generalGetString(R.string.all_group_members_will_remain_connected), confirmText = generalGetString(R.string.delete_verb), @@ -78,7 +78,8 @@ fun GroupLinkView(chatModel: ChatModel, groupInfo: GroupInfo, connReqContact: St onGroupLinkUpdated(null to null) } } - } + }, + destructive = true, ) } ) diff --git a/apps/android/app/src/main/java/chat/simplex/app/views/chat/group/GroupMemberInfoView.kt b/apps/android/app/src/main/java/chat/simplex/app/views/chat/group/GroupMemberInfoView.kt index 0ab3e38cf..612b01782 100644 --- a/apps/android/app/src/main/java/chat/simplex/app/views/chat/group/GroupMemberInfoView.kt +++ b/apps/android/app/src/main/java/chat/simplex/app/views/chat/group/GroupMemberInfoView.kt @@ -116,7 +116,7 @@ fun GroupMemberInfoView( } fun removeMemberDialog(groupInfo: GroupInfo, member: GroupMember, chatModel: ChatModel, close: (() -> Unit)? = null) { - AlertManager.shared.showAlertMsg( + AlertManager.shared.showAlertDialog( title = generalGetString(R.string.button_remove_member), text = generalGetString(R.string.member_will_be_removed_from_group_cannot_be_undone), confirmText = generalGetString(R.string.remove_member_confirmation), @@ -128,7 +128,8 @@ fun removeMemberDialog(groupInfo: GroupInfo, member: GroupMember, chatModel: Cha } close?.invoke() } - } + }, + destructive = true, ) } diff --git a/apps/android/app/src/main/java/chat/simplex/app/views/chat/item/ChatItemView.kt b/apps/android/app/src/main/java/chat/simplex/app/views/chat/item/ChatItemView.kt index 5e64d13e8..96c6fbca7 100644 --- a/apps/android/app/src/main/java/chat/simplex/app/views/chat/item/ChatItemView.kt +++ b/apps/android/app/src/main/java/chat/simplex/app/views/chat/item/ChatItemView.kt @@ -380,13 +380,13 @@ fun deleteMessageAlertDialog(chatItem: ChatItem, questionText: String, deleteMes TextButton(onClick = { deleteMessage(chatItem.id, CIDeleteMode.cidmInternal) AlertManager.shared.hideAlert() - }) { Text(stringResource(R.string.for_me_only)) } + }) { Text(stringResource(R.string.for_me_only), color = MaterialTheme.colors.error) } if (chatItem.meta.editable) { Spacer(Modifier.padding(horizontal = 4.dp)) TextButton(onClick = { deleteMessage(chatItem.id, CIDeleteMode.cidmBroadcast) AlertManager.shared.hideAlert() - }) { Text(stringResource(R.string.for_everybody)) } + }) { Text(stringResource(R.string.for_everybody), color = MaterialTheme.colors.error) } } } } diff --git a/apps/android/app/src/main/java/chat/simplex/app/views/chatlist/ChatListNavLinkView.kt b/apps/android/app/src/main/java/chat/simplex/app/views/chatlist/ChatListNavLinkView.kt index 921197a6f..fa8b639b9 100644 --- a/apps/android/app/src/main/java/chat/simplex/app/views/chatlist/ChatListNavLinkView.kt +++ b/apps/android/app/src/main/java/chat/simplex/app/views/chatlist/ChatListNavLinkView.kt @@ -466,7 +466,8 @@ fun deleteContactConnectionAlert(connection: PendingContactConnection, chatModel onSuccess() } } - } + }, + destructive = true, ) } @@ -484,6 +485,7 @@ fun pendingContactAlertDialog(chatInfo: ChatInfo, chatModel: ChatModel) { } } }, + destructive = true, dismissText = generalGetString(R.string.cancel_verb), ) } diff --git a/apps/android/app/src/main/java/chat/simplex/app/views/database/ChatArchiveView.kt b/apps/android/app/src/main/java/chat/simplex/app/views/database/ChatArchiveView.kt index 5dc5b55fa..6df30f917 100644 --- a/apps/android/app/src/main/java/chat/simplex/app/views/database/ChatArchiveView.kt +++ b/apps/android/app/src/main/java/chat/simplex/app/views/database/ChatArchiveView.kt @@ -116,7 +116,8 @@ private fun deleteArchiveAlert(m: ChatModel, archivePath: String) { } else { Log.e(TAG, "deleteArchiveAlert delete() error") } - } + }, + destructive = true, ) } diff --git a/apps/android/app/src/main/java/chat/simplex/app/views/database/DatabaseEncryptionView.kt b/apps/android/app/src/main/java/chat/simplex/app/views/database/DatabaseEncryptionView.kt index a2e5993e0..5c24e59bd 100644 --- a/apps/android/app/src/main/java/chat/simplex/app/views/database/DatabaseEncryptionView.kt +++ b/apps/android/app/src/main/java/chat/simplex/app/views/database/DatabaseEncryptionView.kt @@ -244,7 +244,7 @@ fun encryptDatabaseSavedAlert(onConfirm: () -> Unit) { text = generalGetString(R.string.database_will_be_encrypted_and_passphrase_stored) + "\n" + storeSecurelySaved(), confirmText = generalGetString(R.string.encrypt_database), onConfirm = onConfirm, - destructive = false, + destructive = true, ) } diff --git a/apps/android/app/src/main/java/chat/simplex/app/views/database/DatabaseView.kt b/apps/android/app/src/main/java/chat/simplex/app/views/database/DatabaseView.kt index 8ac6f8cb4..5feaa4bdf 100644 --- a/apps/android/app/src/main/java/chat/simplex/app/views/database/DatabaseView.kt +++ b/apps/android/app/src/main/java/chat/simplex/app/views/database/DatabaseView.kt @@ -294,7 +294,8 @@ private fun setChatItemTTLAlert( text = generalGetString(R.string.enable_automatic_deletion_message), confirmText = generalGetString(R.string.delete_messages), onConfirm = { setCiTTL(m, selectedChatItemTTL, progressIndicator, appFilesCountAndSize, context) }, - onDismiss = { selectedChatItemTTL.value = m.chatItemTTL.value } + onDismiss = { selectedChatItemTTL.value = m.chatItemTTL.value }, + destructive = true, ) } @@ -543,7 +544,8 @@ private fun importArchiveAlert( title = generalGetString(R.string.import_database_question), text = generalGetString(R.string.your_current_chat_database_will_be_deleted_and_replaced_with_the_imported_one), confirmText = generalGetString(R.string.import_database_confirmation), - onConfirm = { importArchive(m, context, importedArchiveUri, appFilesCountAndSize, progressIndicator) } + onConfirm = { importArchive(m, context, importedArchiveUri, appFilesCountAndSize, progressIndicator) }, + destructive = true, ) } @@ -608,7 +610,8 @@ private fun deleteChatAlert(m: ChatModel, progressIndicator: MutableState Unit)? = null + confirmText: String = generalGetString(R.string.ok) ) { showAlert { AlertDialog( @@ -163,7 +163,6 @@ class AlertManager { horizontalArrangement = Arrangement.Center ) { TextButton(onClick = { - onConfirm?.invoke() hideAlert() }) { Text(confirmText, color = Color.Unspecified) } } @@ -173,13 +172,11 @@ class AlertManager { ) } } - fun showAlertMsg( title: Int, text: Int? = null, confirmText: Int = R.string.ok, - onConfirm: (() -> Unit)? = null - ) = showAlertMsg(generalGetString(title), if (text != null) generalGetString(text) else null, generalGetString(confirmText), onConfirm) + ) = showAlertMsg(generalGetString(title), if (text != null) generalGetString(text) else null, generalGetString(confirmText)) @Composable fun showInView() { diff --git a/apps/android/app/src/main/java/chat/simplex/app/views/newchat/PasteToConnect.kt b/apps/android/app/src/main/java/chat/simplex/app/views/newchat/PasteToConnect.kt index c69f9c18f..19a35a0f6 100644 --- a/apps/android/app/src/main/java/chat/simplex/app/views/newchat/PasteToConnect.kt +++ b/apps/android/app/src/main/java/chat/simplex/app/views/newchat/PasteToConnect.kt @@ -45,7 +45,7 @@ fun PasteToConnectView(chatModel: ChatModel, close: () -> Unit) { } } if (linkType == ConnectionLinkType.GROUP) { - AlertManager.shared.showAlertMsg( + AlertManager.shared.showAlertDialog( title = generalGetString(R.string.connect_via_group_link), text = generalGetString(R.string.you_will_join_group), confirmText = generalGetString(R.string.connect_via_link_verb), diff --git a/apps/android/app/src/main/java/chat/simplex/app/views/newchat/ScanToConnectView.kt b/apps/android/app/src/main/java/chat/simplex/app/views/newchat/ScanToConnectView.kt index 4f6e4c41d..d1210c8e1 100644 --- a/apps/android/app/src/main/java/chat/simplex/app/views/newchat/ScanToConnectView.kt +++ b/apps/android/app/src/main/java/chat/simplex/app/views/newchat/ScanToConnectView.kt @@ -48,7 +48,7 @@ fun ScanToConnectView(chatModel: ChatModel, close: () -> Unit) { } } if (linkType == ConnectionLinkType.GROUP) { - AlertManager.shared.showAlertMsg( + AlertManager.shared.showAlertDialog( title = generalGetString(R.string.connect_via_group_link), text = generalGetString(R.string.you_will_join_group), confirmText = generalGetString(R.string.connect_via_link_verb), diff --git a/apps/android/app/src/main/java/chat/simplex/app/views/usersettings/AdvancedNetworkSettings.kt b/apps/android/app/src/main/java/chat/simplex/app/views/usersettings/AdvancedNetworkSettings.kt index a8841e824..fe1f29802 100644 --- a/apps/android/app/src/main/java/chat/simplex/app/views/usersettings/AdvancedNetworkSettings.kt +++ b/apps/android/app/src/main/java/chat/simplex/app/views/usersettings/AdvancedNetworkSettings.kt @@ -387,7 +387,7 @@ fun FooterButton(icon: Painter, title: String, action: () -> Unit, disabled: Boo } fun showUpdateNetworkSettingsDialog(action: () -> Unit) { - AlertManager.shared.showAlertMsg( + AlertManager.shared.showAlertDialog( title = generalGetString(R.string.update_network_settings_question), text = generalGetString(R.string.updating_settings_will_reconnect_client_to_all_servers), confirmText = generalGetString(R.string.update_network_settings_confirmation), diff --git a/apps/android/app/src/main/java/chat/simplex/app/views/usersettings/NetworkAndServers.kt b/apps/android/app/src/main/java/chat/simplex/app/views/usersettings/NetworkAndServers.kt index fce9aa389..dcaad615c 100644 --- a/apps/android/app/src/main/java/chat/simplex/app/views/usersettings/NetworkAndServers.kt +++ b/apps/android/app/src/main/java/chat/simplex/app/views/usersettings/NetworkAndServers.kt @@ -59,7 +59,7 @@ fun NetworkAndServersView( showCustomModal = showCustomModal, toggleSocksProxy = { enable -> if (enable) { - AlertManager.shared.showAlertMsg( + AlertManager.shared.showAlertDialog( title = generalGetString(R.string.network_enable_socks), text = generalGetString(R.string.network_enable_socks_info), confirmText = generalGetString(R.string.confirm_verb), @@ -73,7 +73,7 @@ fun NetworkAndServersView( } ) } else { - AlertManager.shared.showAlertMsg( + AlertManager.shared.showAlertDialog( title = generalGetString(R.string.network_disable_socks), text = generalGetString(R.string.network_disable_socks_info), confirmText = generalGetString(R.string.confirm_verb), diff --git a/apps/android/app/src/main/java/chat/simplex/app/views/usersettings/RTCServers.kt b/apps/android/app/src/main/java/chat/simplex/app/views/usersettings/RTCServers.kt index c37d2a95b..fde408273 100644 --- a/apps/android/app/src/main/java/chat/simplex/app/views/usersettings/RTCServers.kt +++ b/apps/android/app/src/main/java/chat/simplex/app/views/usersettings/RTCServers.kt @@ -70,7 +70,8 @@ fun RTCServersView( resetRTCServers() isUserRTCServers = false userRTCServersStr.value = "" - } + }, + destructive = true, ) } else { isUserRTCServers = false diff --git a/apps/android/app/src/main/java/chat/simplex/app/views/usersettings/UserAddressView.kt b/apps/android/app/src/main/java/chat/simplex/app/views/usersettings/UserAddressView.kt index 574cc158a..6a2cad337 100644 --- a/apps/android/app/src/main/java/chat/simplex/app/views/usersettings/UserAddressView.kt +++ b/apps/android/app/src/main/java/chat/simplex/app/views/usersettings/UserAddressView.kt @@ -44,7 +44,7 @@ fun UserAddressView(chatModel: ChatModel) { } }, deleteAddress = { - AlertManager.shared.showAlertMsg( + AlertManager.shared.showAlertDialog( title = generalGetString(R.string.delete_address__question), text = generalGetString(R.string.all_your_contacts_will_remain_connected), confirmText = generalGetString(R.string.delete_verb), @@ -53,7 +53,8 @@ fun UserAddressView(chatModel: ChatModel) { chatModel.controller.apiDeleteUserAddress() chatModel.userAddress.value = null } - } + }, + destructive = true, ) } )