From 546082147ae161aa7568277db653655483cd745e Mon Sep 17 00:00:00 2001 From: "M. Dietrich" Date: Mon, 1 Sep 2014 23:48:42 +0200 Subject: transform ascii to emoticons (on display only) --- src/eu/siacs/conversations/utils/UIHelper.java | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/eu/siacs/conversations/utils') diff --git a/src/eu/siacs/conversations/utils/UIHelper.java b/src/eu/siacs/conversations/utils/UIHelper.java index 1f584fe5..69f833f2 100644 --- a/src/eu/siacs/conversations/utils/UIHelper.java +++ b/src/eu/siacs/conversations/utils/UIHelper.java @@ -545,4 +545,27 @@ public class UIHelper { 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; + } } -- cgit v1.2.3