diff options
author | M. Dietrich <mdt@emdete.de> | 2014-09-01 23:48:42 +0200 |
---|---|---|
committer | M. Dietrich <mdt@emdete.de> | 2014-09-01 23:48:42 +0200 |
commit | 546082147ae161aa7568277db653655483cd745e (patch) | |
tree | 78e23229fb9d58ebd84d116a1dde93c6d4059a13 /src/eu/siacs/conversations/utils/UIHelper.java | |
parent | 3558fa5f5bcbf73ecb5c8174b208ac0c36e708b1 (diff) |
transform ascii to emoticons (on display only)
Diffstat (limited to '')
-rw-r--r-- | src/eu/siacs/conversations/utils/UIHelper.java | 23 |
1 files changed, 23 insertions, 0 deletions
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; + } } |