confirm pin & unpin the message

This commit is contained in:
2021-10-11 00:18:48 +03:00
parent 1288778b7b
commit 63de514975
2 changed files with 32 additions and 5 deletions
@@ -483,11 +483,12 @@ class MessagesHistoryFragment :
if (attachmentController.message.value != message)
attachmentController.message.value = message
}
pin -> viewModel.pinMessage(
peerId = conversation.id,
messageId = message.id,
pin = !isMessageAlreadyPinned
)
pin ->
showPinMessageDialog(
peerId = conversation.id,
messageId = message.id,
pin = !isMessageAlreadyPinned
)
edit -> {
attachmentController.isEditing = true
@@ -499,6 +500,30 @@ class MessagesHistoryFragment :
}.show()
}
private fun showPinMessageDialog(
peerId: Int,
messageId: Int?,
pin: Boolean
) {
MaterialAlertDialogBuilder(requireContext())
.setTitle(
if (pin) R.string.confirm_pin_message
else R.string.confirm_unpin_message
)
.setPositiveButton(
if (pin) R.string.action_pin
else R.string.action_unpin
) { _, _ ->
viewModel.pinMessage(
peerId = peerId,
messageId = messageId,
pin = pin
)
}
.setNegativeButton(android.R.string.cancel, null)
.show()
}
private fun showDeleteMessageDialog(message: VkMessage) {
val binding = DialogMessageDeleteBinding.inflate(layoutInflater, null, false)
+2
View File
@@ -146,4 +146,6 @@
<string name="message_call_state_cancelled">Cancelled</string>
<string name="message_call_state_missed">Missed</string>
<string name="message_call_unknown">Unknown</string>
<string name="confirm_pin_message">Pin the message?</string>
<string name="confirm_unpin_message">Unpin the message?</string>
</resources>