mirror of
https://github.com/moparisthebest/Conversations
synced 2024-11-24 09:42:17 -05:00
Merge pull request #380 from emdete/unicode_emoticons
add translation from ascii to unicode emoticons
This commit is contained in:
commit
6291ebf1a3
@ -59,7 +59,7 @@ public class ConversationAdapter extends ArrayAdapter<Conversation> {
|
|||||||
|| latestMessage.getType() == Message.TYPE_PRIVATE) {
|
|| latestMessage.getType() == Message.TYPE_PRIVATE) {
|
||||||
if ((latestMessage.getEncryption() != Message.ENCRYPTION_PGP)
|
if ((latestMessage.getEncryption() != Message.ENCRYPTION_PGP)
|
||||||
&& (latestMessage.getEncryption() != Message.ENCRYPTION_DECRYPTION_FAILED)) {
|
&& (latestMessage.getEncryption() != Message.ENCRYPTION_DECRYPTION_FAILED)) {
|
||||||
convLastMsg.setText(conv.getLatestMessage().getBody());
|
convLastMsg.setText(UIHelper.transformAsciiEmoticons(conv.getLatestMessage().getBody()));
|
||||||
} else {
|
} else {
|
||||||
convLastMsg.setText(activity
|
convLastMsg.setText(activity
|
||||||
.getText(R.string.encrypted_message_received));
|
.getText(R.string.encrypted_message_received));
|
||||||
|
@ -215,7 +215,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
|
|||||||
viewHolder.messageBody.setVisibility(View.VISIBLE);
|
viewHolder.messageBody.setVisibility(View.VISIBLE);
|
||||||
if (message.getBody() != null) {
|
if (message.getBody() != null) {
|
||||||
if (message.getType() != Message.TYPE_PRIVATE) {
|
if (message.getType() != Message.TYPE_PRIVATE) {
|
||||||
viewHolder.messageBody.setText(message.getMergedBody());
|
viewHolder.messageBody.setText(UIHelper.transformAsciiEmoticons(message.getMergedBody()));
|
||||||
} else {
|
} else {
|
||||||
String privateMarker;
|
String privateMarker;
|
||||||
if (message.getStatus() <= Message.STATUS_RECEIVED) {
|
if (message.getStatus() <= Message.STATUS_RECEIVED) {
|
||||||
|
@ -545,4 +545,27 @@ public class UIHelper {
|
|||||||
return getContactPicture(account.getJid(), size, context, false);
|
return getContactPicture(account.getJid(), size, context, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public static String transformAsciiEmoticons(String body) {
|
||||||
|
if (body != null) {
|
||||||
|
for (String[] r: new String[][]{ // see https://de.wikipedia.org/wiki/Unicodeblock_Smileys
|
||||||
|
{":-?\\)", " 😀 ", },
|
||||||
|
{";-?\\)", " 😉 ", },
|
||||||
|
{":-?D", " 😃 ", },
|
||||||
|
{":-?[Ppb]", " 😋 ", },
|
||||||
|
{"8-?\\)", " 😎 ", },
|
||||||
|
{":-?\\|", " 😐 ", },
|
||||||
|
{":-?[/\\\\]", " 😕 ", },
|
||||||
|
{":-?\\*", " 😗 ", },
|
||||||
|
{":-?[0Oo]", " 😮 ", },
|
||||||
|
{":-?\\(", " 😞 ", },
|
||||||
|
{"\\^\\^", " 😁 ", },
|
||||||
|
}) {
|
||||||
|
String p = r[0];
|
||||||
|
p = "(^" + p + "$|^" + p + " +| +" + p + " +| +" + p + "$)";
|
||||||
|
body = body.replaceAll(p, r[1]);
|
||||||
|
}
|
||||||
|
body = body.trim();
|
||||||
|
}
|
||||||
|
return body;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user