diff options
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/BlockContactDialog.java | 4 | ||||
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/ConversationFragment.java | 28 | ||||
-rw-r--r-- | src/main/res/menu/block.xml | 9 | ||||
-rw-r--r-- | src/main/res/values/strings.xml | 2 |
4 files changed, 40 insertions, 3 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/BlockContactDialog.java b/src/main/java/de/pixart/messenger/ui/BlockContactDialog.java index bf33c35d9..9cc0a4ddf 100644 --- a/src/main/java/de/pixart/messenger/ui/BlockContactDialog.java +++ b/src/main/java/de/pixart/messenger/ui/BlockContactDialog.java @@ -15,6 +15,7 @@ import android.widget.Toast; import de.pixart.messenger.R; import de.pixart.messenger.entities.Blockable; +import de.pixart.messenger.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/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java index 7d7282464..e1da663d5 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java @@ -36,6 +36,7 @@ import android.widget.AdapterView; import android.widget.AdapterView.AdapterContextMenuInfo; 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; @@ -55,6 +56,7 @@ import java.util.concurrent.atomic.AtomicBoolean; import de.pixart.messenger.Config; import de.pixart.messenger.R; import de.pixart.messenger.entities.Account; +import de.pixart.messenger.entities.Blockable; import de.pixart.messenger.entities.Contact; import de.pixart.messenger.entities.Conversation; import de.pixart.messenger.entities.DownloadableFile; @@ -990,8 +992,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 @@ +<?xml version="1.0" encoding="utf-8"?> +<menu xmlns:android="http://schemas.android.com/apk/res/android"> + <item + android:id="@+id/block_domain" + android:title="@string/block_entire_domain" /> + <item + android:id="@+id/block_contact" + android:title="@string/block_stranger" /> +</menu>
\ No newline at end of file diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index aa83597ae..3b14c23a4 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -757,4 +757,6 @@ <string name="one_participant">one participant</string> <string name="more_participants">%d participants</string> <string name="presence_offline">Offline</string> + <string name="block_stranger">Block stranger</string> + <string name="block_entire_domain">Block entire domain</string> </resources> |