diff --git a/src/main/java/eu/siacs/conversations/ui/BlockContactDialog.java b/src/main/java/eu/siacs/conversations/ui/BlockContactDialog.java index 6276afbc0..4db77cef4 100644 --- a/src/main/java/eu/siacs/conversations/ui/BlockContactDialog.java +++ b/src/main/java/eu/siacs/conversations/ui/BlockContactDialog.java @@ -15,6 +15,7 @@ import android.widget.Toast; import eu.siacs.conversations.R; import eu.siacs.conversations.entities.Blockable; +import eu.siacs.conversations.entities.Conversation; public final class BlockContactDialog { public static void show(final XmppActivity xmppActivity, @@ -37,7 +38,8 @@ public final class BlockContactDialog { value = blockable.getJid().toDomainJid().toString(); spannable = new SpannableString(xmppActivity.getString(isBlocked ? R.string.unblock_domain_text : R.string.block_domain_text, value)); } else { - builder.setTitle(isBlocked ? R.string.action_unblock_contact : R.string.action_block_contact); + int resBlockAction = blockable instanceof Conversation && ((Conversation) blockable).isWithStranger() ? R.string.block_stranger : R.string.action_block_contact; + builder.setTitle(isBlocked ? R.string.action_unblock_contact : resBlockAction); value = blockable.getJid().toBareJid().toString(); spannable = new SpannableString(xmppActivity.getString(isBlocked ? R.string.unblock_contact_text : R.string.block_contact_text, value)); } diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index 6a2af2095..89f210906 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -37,6 +37,7 @@ import android.widget.AdapterView.AdapterContextMenuInfo; import android.widget.EditText; import android.widget.ImageButton; import android.widget.ListView; +import android.widget.PopupMenu; import android.widget.RelativeLayout; import android.widget.TextView; import android.widget.TextView.OnEditorActionListener; @@ -53,6 +54,7 @@ import java.util.concurrent.atomic.AtomicBoolean; import eu.siacs.conversations.Config; import eu.siacs.conversations.R; import eu.siacs.conversations.entities.Account; +import eu.siacs.conversations.entities.Blockable; import eu.siacs.conversations.entities.Contact; import eu.siacs.conversations.entities.Conversation; import eu.siacs.conversations.entities.DownloadableFile; @@ -957,8 +959,30 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa private OnClickListener mBlockClickListener = new OnClickListener() { @Override - public void onClick(final View v) { - BlockContactDialog.show(activity, conversation); + public void onClick(final View view) { + final Jid jid = conversation.getJid(); + if (jid.isDomainJid()) { + BlockContactDialog.show(activity, conversation); + } else { + PopupMenu popupMenu = new PopupMenu(activity, view); + popupMenu.inflate(R.menu.block); + popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { + @Override + public boolean onMenuItemClick(MenuItem menuItem) { + Blockable blockable; + switch (menuItem.getItemId()) { + case R.id.block_domain: + blockable = conversation.getAccount().getRoster().getContact(jid.toDomainJid()); + break; + default: + blockable = conversation; + } + BlockContactDialog.show(activity, blockable); + return true; + } + }); + popupMenu.show(); + } } }; diff --git a/src/main/res/menu/block.xml b/src/main/res/menu/block.xml new file mode 100644 index 000000000..1256f7142 --- /dev/null +++ b/src/main/res/menu/block.xml @@ -0,0 +1,9 @@ + +
\ No newline at end of file diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index b4544328f..ac9f7f716 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -741,4 +741,6 @@