aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2017-08-03 08:55:22 +0200
committerChristian Schneppe <christian@pix-art.de>2017-08-03 08:55:22 +0200
commitaffb3c4254aa25e99e0682b5c0e96b4c7dd174fb (patch)
treec5452cdb12690402e7811c69378637aa0364ad9e /src/main/java
parentbec8886c3028261820691c2d86f677fefbfc9a81 (diff)
display messages that only contain emoji slightly larger
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/de/pixart/messenger/entities/Message.java10
-rw-r--r--src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java11
-rw-r--r--src/main/java/de/pixart/messenger/utils/UIHelper.java6
3 files changed, 12 insertions, 15 deletions
diff --git a/src/main/java/de/pixart/messenger/entities/Message.java b/src/main/java/de/pixart/messenger/entities/Message.java
index d13e90743..885e84f1d 100644
--- a/src/main/java/de/pixart/messenger/entities/Message.java
+++ b/src/main/java/de/pixart/messenger/entities/Message.java
@@ -4,6 +4,8 @@ import android.content.ContentValues;
import android.database.Cursor;
import android.text.SpannableStringBuilder;
+import com.vdurmont.emoji.EmojiManager;
+
import java.net.MalformedURLException;
import java.net.URL;
@@ -501,8 +503,8 @@ public class Message extends AbstractEntity {
!this.treatAsDownloadable() &&
!message.getBody().startsWith(ME_COMMAND) &&
!this.getBody().startsWith(ME_COMMAND) &&
- !this.bodyIsHeart() &&
- !message.bodyIsHeart() &&
+ !this.bodyIsOnlyEmojis() &&
+ !message.bodyIsOnlyEmojis() &&
!this.bodyIsXmpp() &&
!message.bodyIsXmpp() &&
((this.axolotlFingerprint == null && message.axolotlFingerprint == null) || this.axolotlFingerprint.equals(message.getFingerprint())) &&
@@ -669,8 +671,8 @@ public class Message extends AbstractEntity {
}
}
- public boolean bodyIsHeart() {
- return body != null && UIHelper.HEARTS.contains(body.trim());
+ public boolean bodyIsOnlyEmojis() {
+ return EmojiManager.isOnlyEmojis(body.trim());
}
public boolean bodyIsXmpp() {
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 8320ac8ad..9aa34d88a 100644
--- a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java
+++ b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java
@@ -43,6 +43,7 @@ import android.widget.Toast;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
+import com.vdurmont.emoji.EmojiManager;
import java.io.File;
import java.io.IOException;
@@ -361,7 +362,7 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
viewHolder.messageBody.setTextIsSelectable(false);
}
- private void displayHeartMessage(final ViewHolder viewHolder, final String body) {
+ private void displayEmojiMessage(final ViewHolder viewHolder, final String body) {
viewHolder.aw_player.setVisibility(View.GONE);
if (viewHolder.download_button != null) {
viewHolder.download_button.setVisibility(View.GONE);
@@ -370,8 +371,8 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
viewHolder.messageBody.setVisibility(View.VISIBLE);
viewHolder.messageBody.setIncludeFontPadding(false);
Spannable span = new SpannableString(body);
- span.setSpan(new RelativeSizeSpan(4.0f), 0, body.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
- span.setSpan(new ForegroundColorSpan(activity.getWarningTextColor()), 0, body.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+ float size = EmojiManager.isEmoji(body) ? 3.0f : 2.0f;
+ span.setSpan(new RelativeSizeSpan(size), 0, body.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
viewHolder.messageBody.setText(span);
}
@@ -962,8 +963,8 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
} else {
if (GeoHelper.isGeoUri(message.getBody())) {
displayLocationMessage(viewHolder, message);
- } else if (message.bodyIsHeart()) {
- displayHeartMessage(viewHolder, message.getBody().trim());
+ } else if (message.bodyIsOnlyEmojis()) {
+ displayEmojiMessage(viewHolder, message.getBody().trim());
} else if (message.bodyIsXmpp()) {
displayXmppMessage(viewHolder, message.getBody().trim());
} else if (message.treatAsDownloadable()) {
diff --git a/src/main/java/de/pixart/messenger/utils/UIHelper.java b/src/main/java/de/pixart/messenger/utils/UIHelper.java
index ab749ca2d..955b7db10 100644
--- a/src/main/java/de/pixart/messenger/utils/UIHelper.java
+++ b/src/main/java/de/pixart/messenger/utils/UIHelper.java
@@ -28,12 +28,6 @@ import de.pixart.messenger.xmpp.jid.Jid;
public class UIHelper {
- private static String BLACK_HEART_SUIT = "\u2665";
- private static String HEAVY_BLACK_HEART_SUIT = "\u2764";
- private static String WHITE_HEART_SUIT = "\u2661";
-
- public static final List<String> HEARTS = Arrays.asList(BLACK_HEART_SUIT,HEAVY_BLACK_HEART_SUIT,WHITE_HEART_SUIT);
-
private static final List<String> LOCATION_QUESTIONS = Arrays.asList(
"where are you", //en
"where are you now", //en