aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/de/pixart/messenger/ui/BlockContactDialog.java4
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConversationFragment.java28
2 files changed, 29 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();
+ }
}
};