aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/ui/BlockContactDialog.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de/pixart/messenger/ui/BlockContactDialog.java')
-rw-r--r--src/main/java/de/pixart/messenger/ui/BlockContactDialog.java19
1 files changed, 7 insertions, 12 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/BlockContactDialog.java b/src/main/java/de/pixart/messenger/ui/BlockContactDialog.java
index f7711ce34..4f768b009 100644
--- a/src/main/java/de/pixart/messenger/ui/BlockContactDialog.java
+++ b/src/main/java/de/pixart/messenger/ui/BlockContactDialog.java
@@ -1,10 +1,8 @@
package de.pixart.messenger.ui;
import android.databinding.DataBindingUtil;
+import android.support.annotation.StringRes;
import android.support.v7.app.AlertDialog;
-import android.text.SpannableString;
-import android.text.Spanned;
-import android.text.style.TypefaceSpan;
import android.view.View;
import android.widget.Toast;
@@ -12,6 +10,7 @@ import de.pixart.messenger.R;
import de.pixart.messenger.databinding.DialogBlockContactBinding;
import de.pixart.messenger.entities.Blockable;
import de.pixart.messenger.entities.Conversation;
+import de.pixart.messenger.ui.util.JidDialog;
import rocks.xmpp.addr.Jid;
public final class BlockContactDialog {
@@ -24,23 +23,19 @@ public final class BlockContactDialog {
binding.reportSpam.setVisibility(!isBlocked && reporting ? View.VISIBLE : View.GONE);
builder.setView(binding.getRoot());
- String value;
- SpannableString spannable;
+ final String value;
+ @StringRes int res;
if (blockable.getJid().getLocal() == null || blockable.getAccount().isBlocked(Jid.ofDomain(blockable.getJid().getDomain()))) {
builder.setTitle(isBlocked ? R.string.action_unblock_domain : R.string.action_block_domain);
value = Jid.ofDomain(blockable.getJid().getDomain()).toString();
- spannable = new SpannableString(xmppActivity.getString(isBlocked ? R.string.unblock_domain_text : R.string.block_domain_text, value));
+ res = isBlocked ? R.string.unblock_domain_text : R.string.block_domain_text;
} else {
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().asBareJid().toString();
- spannable = new SpannableString(xmppActivity.getString(isBlocked ? R.string.unblock_contact_text : R.string.block_contact_text, value));
+ res = isBlocked ? R.string.unblock_contact_text : R.string.block_contact_text;
}
- int start = spannable.toString().indexOf(value);
- if (start >= 0) {
- spannable.setSpan(new TypefaceSpan("monospace"), start, start + value.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
- }
- binding.text.setText(spannable);
+ binding.text.setText(JidDialog.style(xmppActivity, res, value));
builder.setPositiveButton(isBlocked ? R.string.unblock : R.string.block, (dialog, which) -> {
if (isBlocked) {
xmppActivity.xmppConnectionService.sendUnblockRequest(blockable);