aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/ui/adapter
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2017-11-24 21:41:15 +0100
committerChristian Schneppe <christian@pix-art.de>2017-11-24 21:41:15 +0100
commitb741b8bf12118bd13d43c62ea5c1598bd078348e (patch)
tree0ef0abe20af33c121e4c6540b438964aa35f6685 /src/main/java/de/pixart/messenger/ui/adapter
parentfca8eacabec77f4c3604a71763915c32e09d286d (diff)
use com.android.support:support-emoji
Diffstat (limited to 'src/main/java/de/pixart/messenger/ui/adapter')
-rw-r--r--src/main/java/de/pixart/messenger/ui/adapter/ConversationAdapter.java5
-rw-r--r--src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java17
2 files changed, 15 insertions, 7 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/adapter/ConversationAdapter.java b/src/main/java/de/pixart/messenger/ui/adapter/ConversationAdapter.java
index 02b671e3d..c867dc068 100644
--- a/src/main/java/de/pixart/messenger/ui/adapter/ConversationAdapter.java
+++ b/src/main/java/de/pixart/messenger/ui/adapter/ConversationAdapter.java
@@ -29,6 +29,7 @@ import de.pixart.messenger.entities.MucOptions;
import de.pixart.messenger.entities.Transferable;
import de.pixart.messenger.ui.ConversationActivity;
import de.pixart.messenger.ui.XmppActivity;
+import de.pixart.messenger.utils.EmojiWrapper;
import de.pixart.messenger.utils.UIHelper;
import de.pixart.messenger.xmpp.chatstate.ChatState;
@@ -82,7 +83,7 @@ public class ConversationAdapter extends ArrayAdapter<Conversation> {
}
ViewHolder viewHolder = ViewHolder.get(view);
if (conversation.getMode() == Conversation.MODE_SINGLE || activity.useSubjectToIdentifyConference()) {
- viewHolder.name.setText(conversation.getName());
+ viewHolder.name.setText(EmojiWrapper.transform(conversation.getName()));
} else {
viewHolder.name.setText(conversation.getJid().toBareJid().toString());
}
@@ -142,7 +143,7 @@ public class ConversationAdapter extends ArrayAdapter<Conversation> {
final Pair<String, Boolean> preview = UIHelper.getMessagePreview(activity, message);
if (showPreviewText) {
- viewHolder.lastMessage.setText(preview.first);
+ viewHolder.lastMessage.setText(EmojiWrapper.transform(preview.first));
} else {
viewHolder.lastMessageIcon.setContentDescription(preview.first);
}
diff --git a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java
index 80d2b8f3a..dabf104bf 100644
--- a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java
+++ b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java
@@ -43,7 +43,6 @@ import android.widget.Toast;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
-import com.vdurmont.emoji.EmojiManager;
import java.io.UnsupportedEncodingException;
import java.lang.ref.WeakReference;
@@ -76,6 +75,8 @@ import de.pixart.messenger.ui.widget.ClickableMovementMethod;
import de.pixart.messenger.ui.widget.CopyTextView;
import de.pixart.messenger.ui.widget.ListSelectionManager;
import de.pixart.messenger.utils.CryptoHelper;
+import de.pixart.messenger.utils.EmojiWrapper;
+import de.pixart.messenger.utils.Emoticons;
import de.pixart.messenger.utils.GeoHelper;
import de.pixart.messenger.utils.Patterns;
import de.pixart.messenger.utils.StylingHelper;
@@ -361,9 +362,9 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
viewHolder.image.setVisibility(View.GONE);
viewHolder.messageBody.setVisibility(View.VISIBLE);
Spannable span = new SpannableString(body);
- float size = EmojiManager.isEmoji(body) ? 3.0f : 2.0f;
+ float size = Emoticons.isEmoji(body) ? 3.0f : 2.0f;
span.setSpan(new RelativeSizeSpan(size), 0, body.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
- viewHolder.messageBody.setText(span);
+ viewHolder.messageBody.setText(EmojiWrapper.transform(span));
}
private void displayXmppMessage(final ViewHolder viewHolder, final String body) {
@@ -525,13 +526,19 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
body.setSpan(new StyleSpan(Typeface.BOLD), matcher.start(), matcher.end(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
}
+ Matcher matcher = Emoticons.generatePattern(body).matcher(body);
+ while (matcher.find()) {
+ if (matcher.start() < matcher.end()) {
+ body.setSpan(new RelativeSizeSpan(1.5f), matcher.start(), matcher.end(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+ }
+ }
StylingHelper.format(body, viewHolder.messageBody.getCurrentTextColor());
Linkify.addLinks(body, XMPP_PATTERN, "xmpp");
Linkify.addLinks(body, Patterns.AUTOLINK_WEB_URL, "http", WEBURL_MATCH_FILTER, WEBURL_TRANSFORM_FILTER);
Linkify.addLinks(body, GeoHelper.GEO_URI, "geo");
FixedURLSpan.fix(body);
viewHolder.messageBody.setAutoLinkMask(0);
- viewHolder.messageBody.setText(body);
+ viewHolder.messageBody.setText(EmojiWrapper.transform(body));
viewHolder.messageBody.setTextIsSelectable(true);
viewHolder.messageBody.setMovementMethod(ClickableMovementMethod.getInstance());
listSelectionManager.onUpdate(viewHolder.messageBody, message);
@@ -919,7 +926,7 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
if (message.isGeoUri()) {
displayLocationMessage(viewHolder, message);
} else if (message.bodyIsOnlyEmojis() && message.getType() != Message.TYPE_PRIVATE) {
- displayEmojiMessage(viewHolder, message.getBody().replaceAll("\\s", ""));
+ displayEmojiMessage(viewHolder, message.getBody().trim());
} else if (message.isXmppUri()) {
displayXmppMessage(viewHolder, message.getBody().trim());
} else if (message.treatAsDownloadable()) {