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,7 +483,8 @@ class MessagesHistoryFragment :
if (attachmentController.message.value != message) if (attachmentController.message.value != message)
attachmentController.message.value = message attachmentController.message.value = message
} }
pin -> viewModel.pinMessage( pin ->
showPinMessageDialog(
peerId = conversation.id, peerId = conversation.id,
messageId = message.id, messageId = message.id,
pin = !isMessageAlreadyPinned pin = !isMessageAlreadyPinned
@@ -499,6 +500,30 @@ class MessagesHistoryFragment :
}.show() }.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) { private fun showDeleteMessageDialog(message: VkMessage) {
val binding = DialogMessageDeleteBinding.inflate(layoutInflater, null, false) 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_cancelled">Cancelled</string>
<string name="message_call_state_missed">Missed</string> <string name="message_call_state_missed">Missed</string>
<string name="message_call_unknown">Unknown</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> </resources>