mirror of
https://github.com/moparisthebest/Conversations
synced 2024-11-30 12:42:16 -05:00
cleanup: removed unused emoticon parsing
This commit is contained in:
parent
9d52f62767
commit
78370094e9
@ -18,7 +18,6 @@ public final class Config {
|
||||
|
||||
public static final int MESSAGE_MERGE_WINDOW = 20;
|
||||
|
||||
public static final boolean PARSE_EMOTICONS = false;
|
||||
public static final int PROGRESS_UI_UPDATE_INTERVAL = 750;
|
||||
|
||||
public static final boolean NO_PROXY_LOOKUP = false; //useful to debug ibb
|
||||
|
@ -2,7 +2,6 @@ package eu.siacs.conversations.ui.adapter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import eu.siacs.conversations.Config;
|
||||
import eu.siacs.conversations.R;
|
||||
import eu.siacs.conversations.entities.Conversation;
|
||||
import eu.siacs.conversations.entities.Downloadable;
|
||||
@ -139,10 +138,7 @@ public class ConversationAdapter extends ArrayAdapter<Conversation> {
|
||||
} else {
|
||||
if ((message.getEncryption() != Message.ENCRYPTION_PGP)
|
||||
&& (message.getEncryption() != Message.ENCRYPTION_DECRYPTION_FAILED)) {
|
||||
String body = Config.PARSE_EMOTICONS ? UIHelper
|
||||
.transformAsciiEmoticons(message.getBody()) : message
|
||||
.getBody();
|
||||
mLastMessage.setText(body);
|
||||
mLastMessage.setText(message.getBody());
|
||||
} else {
|
||||
mLastMessage.setText(R.string.encrypted_message_received);
|
||||
}
|
||||
|
@ -23,7 +23,6 @@ import android.widget.Toast;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import eu.siacs.conversations.Config;
|
||||
import eu.siacs.conversations.R;
|
||||
import eu.siacs.conversations.entities.Account;
|
||||
import eu.siacs.conversations.entities.Contact;
|
||||
@ -225,10 +224,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
|
||||
viewHolder.messageBody.setVisibility(View.VISIBLE);
|
||||
if (message.getBody() != null) {
|
||||
if (message.getType() != Message.TYPE_PRIVATE) {
|
||||
String body = Config.PARSE_EMOTICONS ? UIHelper
|
||||
.transformAsciiEmoticons(message.getMergedBody())
|
||||
: message.getMergedBody();
|
||||
viewHolder.messageBody.setText(body);
|
||||
viewHolder.messageBody.setText(message.getMergedBody());
|
||||
} else {
|
||||
String privateMarker;
|
||||
if (message.getStatus() <= Message.STATUS_RECEIVED) {
|
||||
|
@ -2,7 +2,6 @@ package eu.siacs.conversations.utils;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import eu.siacs.conversations.R;
|
||||
import android.content.Context;
|
||||
@ -86,47 +85,6 @@ public class UIHelper {
|
||||
}
|
||||
}
|
||||
|
||||
private final static class EmoticonPattern {
|
||||
Pattern pattern;
|
||||
String replacement;
|
||||
|
||||
EmoticonPattern(String ascii, int unicode) {
|
||||
this.pattern = Pattern.compile("(?<=(^|\\s))" + ascii
|
||||
+ "(?=(\\s|$))");
|
||||
this.replacement = new String(new int[] { unicode, }, 0, 1);
|
||||
}
|
||||
|
||||
String replaceAll(String body) {
|
||||
return pattern.matcher(body).replaceAll(replacement);
|
||||
}
|
||||
}
|
||||
|
||||
private static final EmoticonPattern[] patterns = new EmoticonPattern[] {
|
||||
new EmoticonPattern(":-?D", 0x1f600),
|
||||
new EmoticonPattern("\\^\\^", 0x1f601),
|
||||
new EmoticonPattern(":'D", 0x1f602),
|
||||
new EmoticonPattern("\\]-?D", 0x1f608),
|
||||
new EmoticonPattern(";-?\\)", 0x1f609),
|
||||
new EmoticonPattern(":-?\\)", 0x1f60a),
|
||||
new EmoticonPattern("[B8]-?\\)", 0x1f60e),
|
||||
new EmoticonPattern(":-?\\|", 0x1f610),
|
||||
new EmoticonPattern(":-?[/\\\\]", 0x1f615),
|
||||
new EmoticonPattern(":-?\\*", 0x1f617),
|
||||
new EmoticonPattern(":-?[Ppb]", 0x1f61b),
|
||||
new EmoticonPattern(":-?\\(", 0x1f61e),
|
||||
new EmoticonPattern(":-?[0Oo]", 0x1f62e),
|
||||
new EmoticonPattern("\\\\o/", 0x1F631), };
|
||||
|
||||
public static String transformAsciiEmoticons(String body) {
|
||||
if (body != null) {
|
||||
for (EmoticonPattern p : patterns) {
|
||||
body = p.replaceAll(body);
|
||||
}
|
||||
body = body.trim();
|
||||
}
|
||||
return body;
|
||||
}
|
||||
|
||||
public static int getColorForName(String name) {
|
||||
if (name.isEmpty()) {
|
||||
return 0xFF202020;
|
||||
|
Loading…
Reference in New Issue
Block a user