Skip to content
Snippets Groups Projects
Commit f7f5a7ce authored by Amirhossein Naghshzan's avatar Amirhossein Naghshzan Committed by Adrien Béraud
Browse files

ConversationActionsFragment: add unblock option on contact detail page

Change-Id: I11498d74d9507252802185abcbe7ba34f7183c18
parent c23f0148
No related branches found
No related tags found
No related merge requests found
...@@ -152,12 +152,13 @@ class ConversationActionsFragment : Fragment() { ...@@ -152,12 +152,13 @@ class ConversationActionsFragment : Fragment() {
}) })
} }
if (!contact.isBanned) {
adapter.actions.add(ContactAction(R.drawable.baseline_block_24, getText(R.string.conversation_action_block_this)) { adapter.actions.add(ContactAction(R.drawable.baseline_block_24, getText(R.string.conversation_action_block_this)) {
MaterialAlertDialogBuilder(requireContext()) MaterialAlertDialogBuilder(requireContext())
.setTitle(getString(R.string.block_contact_dialog_title, conversationUri)) .setTitle(getString(R.string.block_contact_dialog_title, conversationUri))
.setMessage(getString(R.string.block_contact_dialog_message, conversationUri)) .setMessage(getString(R.string.block_contact_dialog_message, conversationUri))
.setPositiveButton(R.string.conversation_action_block_this) { _: DialogInterface?, _: Int -> .setPositiveButton(R.string.conversation_action_block_this) { _: DialogInterface?, _: Int ->
mAccountService.removeContact(conversation.accountId, contact.uri.rawRingId,true) mConversationFacade.banConversation(conversation.accountId, conversation.uri)
Toast.makeText(requireContext(), getString(R.string.block_contact_completed, conversationUri), Toast.LENGTH_LONG).show() Toast.makeText(requireContext(), getString(R.string.block_contact_completed, conversationUri), Toast.LENGTH_LONG).show()
requireActivity().finish() requireActivity().finish()
} }
...@@ -165,6 +166,21 @@ class ConversationActionsFragment : Fragment() { ...@@ -165,6 +166,21 @@ class ConversationActionsFragment : Fragment() {
.create() .create()
.show() .show()
}) })
} else {
adapter.actions.add(ContactAction(R.drawable.baseline_person_add_24, getText(R.string.conversation_action_unblock_this)) {
MaterialAlertDialogBuilder(requireContext())
.setTitle(getString(R.string.unblock_contact_dialog_title, conversationUri))
.setMessage(getString(R.string.unblock_contact_dialog_message, conversationUri))
.setPositiveButton(R.string.conversation_action_unblock_this) { _: DialogInterface?, _: Int ->
mAccountService.addContact(conversation.accountId, contact.uri.rawRingId)
Toast.makeText(requireContext(), getString(R.string.unblock_contact_completed, conversationUri), Toast.LENGTH_LONG).show()
requireActivity().finish()
}
.setNegativeButton(android.R.string.cancel, null)
.create()
.show()
})
}
} }
......
...@@ -235,6 +235,7 @@ along with this program; if not, write to the Free Software ...@@ -235,6 +235,7 @@ along with this program; if not, write to the Free Software
<string name="conversation_action_copied_peer_number_clipboard">%1$s copied to clipboard</string> <string name="conversation_action_copied_peer_number_clipboard">%1$s copied to clipboard</string>
<string name="conversation_action_select_peer_number">Select a number</string> <string name="conversation_action_select_peer_number">Select a number</string>
<string name="conversation_action_block_this">Block contact</string> <string name="conversation_action_block_this">Block contact</string>
<string name="conversation_action_unblock_this">Unblock contact</string>
<string name="conversation_action_go_to_call">Return to ongoing call</string> <string name="conversation_action_go_to_call">Return to ongoing call</string>
<string name="conversation_default_emoji" translatable="false">👍</string> <string name="conversation_default_emoji" translatable="false">👍</string>
<string name="conversation_open_file_error">There is no installed application capable of opening this file type.</string> <string name="conversation_open_file_error">There is no installed application capable of opening this file type.</string>
...@@ -242,6 +243,9 @@ along with this program; if not, write to the Free Software ...@@ -242,6 +243,9 @@ along with this program; if not, write to the Free Software
<string name="block_contact_dialog_title">Block %1$s?</string> <string name="block_contact_dialog_title">Block %1$s?</string>
<string name="block_contact_dialog_message">%1$s won\'t be able to contact you until you unblock it.</string> <string name="block_contact_dialog_message">%1$s won\'t be able to contact you until you unblock it.</string>
<string name="block_contact_completed">%1$s was blocked.</string> <string name="block_contact_completed">%1$s was blocked.</string>
<string name="unblock_contact_dialog_title">Unblock %1$s?</string>
<string name="unblock_contact_dialog_message">%1$s will be able to contact you again.</string>
<string name="unblock_contact_completed">%1$s was unblocked.</string>
<string name="conversation_contact_is_typing">Contact is typing…</string> <string name="conversation_contact_is_typing">Contact is typing…</string>
<string name="conversation_info_contact_you">You</string> <string name="conversation_info_contact_you">You</string>
<string name="conversation_members">Members</string> <string name="conversation_members">Members</string>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment