paint single unicode hearts as red and slightly larger
This commit is contained in:
parent
d9e5035c08
commit
4c486f5e58
|
@ -9,6 +9,7 @@ import java.util.Arrays;
|
||||||
|
|
||||||
import eu.siacs.conversations.Config;
|
import eu.siacs.conversations.Config;
|
||||||
import eu.siacs.conversations.utils.GeoHelper;
|
import eu.siacs.conversations.utils.GeoHelper;
|
||||||
|
import eu.siacs.conversations.utils.UIHelper;
|
||||||
import eu.siacs.conversations.xmpp.jid.InvalidJidException;
|
import eu.siacs.conversations.xmpp.jid.InvalidJidException;
|
||||||
import eu.siacs.conversations.xmpp.jid.Jid;
|
import eu.siacs.conversations.xmpp.jid.Jid;
|
||||||
|
|
||||||
|
@ -375,7 +376,9 @@ public class Message extends AbstractEntity {
|
||||||
!message.bodyContainsDownloadable() &&
|
!message.bodyContainsDownloadable() &&
|
||||||
!this.bodyContainsDownloadable() &&
|
!this.bodyContainsDownloadable() &&
|
||||||
!message.getBody().startsWith(ME_COMMAND) &&
|
!message.getBody().startsWith(ME_COMMAND) &&
|
||||||
!this.getBody().startsWith(ME_COMMAND)
|
!this.getBody().startsWith(ME_COMMAND) &&
|
||||||
|
!this.bodyIsHeart() &&
|
||||||
|
!message.bodyIsHeart()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -474,6 +477,11 @@ public class Message extends AbstractEntity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean bodyIsHeart() {
|
||||||
|
return body != null &&
|
||||||
|
(body.trim().equals(UIHelper.BLACK_HEART_SUIT) || body.trim().equals(UIHelper.HEAVY_BLACK_HEART_SUIT));
|
||||||
|
}
|
||||||
|
|
||||||
public ImageParams getImageParams() {
|
public ImageParams getImageParams() {
|
||||||
ImageParams params = getLegacyImageParams();
|
ImageParams params = getLegacyImageParams();
|
||||||
if (params != null) {
|
if (params != null) {
|
||||||
|
|
|
@ -7,7 +7,9 @@ import android.graphics.Typeface;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.text.Spannable;
|
import android.text.Spannable;
|
||||||
import android.text.SpannableString;
|
import android.text.SpannableString;
|
||||||
|
import android.text.Spanned;
|
||||||
import android.text.style.ForegroundColorSpan;
|
import android.text.style.ForegroundColorSpan;
|
||||||
|
import android.text.style.RelativeSizeSpan;
|
||||||
import android.text.style.StyleSpan;
|
import android.text.style.StyleSpan;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
@ -213,6 +215,18 @@ public class MessageAdapter extends ArrayAdapter<Message> {
|
||||||
viewHolder.messageBody.setTextIsSelectable(false);
|
viewHolder.messageBody.setTextIsSelectable(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void displayHeartMesage(final ViewHolder viewHolder, final String body) {
|
||||||
|
if (viewHolder.download_button != null) {
|
||||||
|
viewHolder.download_button.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
viewHolder.image.setVisibility(View.GONE);
|
||||||
|
viewHolder.messageBody.setVisibility(View.VISIBLE);
|
||||||
|
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(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||||
|
viewHolder.messageBody.setText(span);
|
||||||
|
}
|
||||||
|
|
||||||
private void displayTextMessage(final ViewHolder viewHolder, final Message message) {
|
private void displayTextMessage(final ViewHolder viewHolder, final Message message) {
|
||||||
if (viewHolder.download_button != null) {
|
if (viewHolder.download_button != null) {
|
||||||
viewHolder.download_button.setVisibility(View.GONE);
|
viewHolder.download_button.setVisibility(View.GONE);
|
||||||
|
@ -527,10 +541,14 @@ public class MessageAdapter extends ArrayAdapter<Message> {
|
||||||
} else {
|
} else {
|
||||||
if (GeoHelper.isGeoUri(message.getBody())) {
|
if (GeoHelper.isGeoUri(message.getBody())) {
|
||||||
displayLocationMessage(viewHolder,message);
|
displayLocationMessage(viewHolder,message);
|
||||||
|
} else {
|
||||||
|
if (message.bodyIsHeart()) {
|
||||||
|
displayHeartMesage(viewHolder," "+message.getBody().trim()+" ");
|
||||||
} else {
|
} else {
|
||||||
displayTextMessage(viewHolder, message);
|
displayTextMessage(viewHolder, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
displayStatus(viewHolder, message);
|
displayStatus(viewHolder, message);
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,10 @@ import android.text.format.DateUtils;
|
||||||
import android.util.Pair;
|
import android.util.Pair;
|
||||||
|
|
||||||
public class UIHelper {
|
public class UIHelper {
|
||||||
|
|
||||||
|
public static String BLACK_HEART_SUIT = "\u2665";
|
||||||
|
public static String HEAVY_BLACK_HEART_SUIT = "\u2764";
|
||||||
|
|
||||||
private static final int SHORT_DATE_FLAGS = DateUtils.FORMAT_SHOW_DATE
|
private static final int SHORT_DATE_FLAGS = DateUtils.FORMAT_SHOW_DATE
|
||||||
| DateUtils.FORMAT_NO_YEAR | DateUtils.FORMAT_ABBREV_ALL;
|
| DateUtils.FORMAT_NO_YEAR | DateUtils.FORMAT_ABBREV_ALL;
|
||||||
private static final int FULL_DATE_FLAGS = DateUtils.FORMAT_SHOW_TIME
|
private static final int FULL_DATE_FLAGS = DateUtils.FORMAT_SHOW_TIME
|
||||||
|
|
Loading…
Reference in a new issue