diff --git a/QKSMS/src/main/java/com/moez/QKSMS/common/emoji/EmojiRegistry.java b/QKSMS/src/main/java/com/moez/QKSMS/common/emoji/EmojiRegistry.java index d214e654..3189590a 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/common/emoji/EmojiRegistry.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/common/emoji/EmojiRegistry.java @@ -38,28 +38,29 @@ public class EmojiRegistry { public static String parseEmojis(String body) { if (TextUtils.isEmpty(body)) { return body; - } else { - // whitespace and punctuation characters - String ACCEPTED_CHARS = "[\\s.,?:;'\"!]"; - - // explanation: we want to match: - // 1) either an accepted char or the beginning of the text (i.e. ^) - // 2) the actual emoji code (to be inserted in the loop) - // 3) either an accepted char or the end of the text (i.e. $) - String REGEX_TEMPLATE = String.format("(^|%s)%s(%s|$)", ACCEPTED_CHARS, "%s", ACCEPTED_CHARS); - - // iterate over all the entries - for (Map.Entry entry : EmojiRegistry.EMOJIS_MAP.entrySet()) { - // quote the emoji code because some characters like ) are protected in regex land - String quoted = Pattern.quote(entry.getKey()); - String regex = String.format(REGEX_TEMPLATE, quoted); - - // the $1 and $2 represent the character* that came before the emoji and the - // character* that came after the emoji - // * - or beginning / end of text - body = body.replaceAll(regex, "$1:" + entry.getValue() + ":$2"); - } - return EmojiParser.parseToUnicode(body); } + + // whitespace and punctuation characters + String ACCEPTED_CHARS = "[\\s.,?:;'\"!]"; + + // explanation: we want to match: + // 1) either an accepted char or the beginning of the text (i.e. ^) + // 2) the actual emoji code (to be inserted in the loop) + // 3) either an accepted char or the end of the text (i.e. $) + String REGEX_TEMPLATE = String.format("(^|%s)%s(%s|$)", ACCEPTED_CHARS, "%s", ACCEPTED_CHARS); + + // iterate over all the entries + for (Map.Entry entry : EmojiRegistry.EMOJIS_MAP.entrySet()) { + // quote the emoji code because some characters like ) are protected in regex land + String quoted = Pattern.quote(entry.getKey()); + String regex = String.format(REGEX_TEMPLATE, quoted); + + // the $1 and $2 represent the character* that came before the emoji and the + // character* that came after the emoji + // * - or beginning / end of text + body = body.replaceAll(regex, "$1:" + entry.getValue() + ":$2"); + } + + return EmojiParser.parseToUnicode(body); } } diff --git a/QKSMS/src/main/java/com/moez/QKSMS/common/emoji/Emojis.java b/QKSMS/src/main/java/com/moez/QKSMS/common/emoji/Emojis.java index a6680036..3e6cade1 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/common/emoji/Emojis.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/common/emoji/Emojis.java @@ -1,5 +1,8 @@ package com.moez.QKSMS.common.emoji; +/** + * Defines all supported emojis + */ public class Emojis { public static final String SMILE = "smile"; public static final String SMILEY = "smiley"; diff --git a/QKSMS/src/main/java/com/moez/QKSMS/data/Contact.java b/QKSMS/src/main/java/com/moez/QKSMS/data/Contact.java index 53454894..23f4ecbb 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/data/Contact.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/data/Contact.java @@ -122,6 +122,7 @@ public class Contact { mIsStale = true; mSendToVoicemail = false; } + @Override public String toString() { return String.format("{ number=%s, name=%s, nameAndNumber=%s, label=%s, person_id=%d, hash=%d method_id=%d }", diff --git a/QKSMS/src/main/java/com/moez/QKSMS/data/ContactHelper.java b/QKSMS/src/main/java/com/moez/QKSMS/data/ContactHelper.java index dd382386..7dd62c47 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/data/ContactHelper.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/data/ContactHelper.java @@ -189,10 +189,9 @@ public class ContactHelper { } catch (IOException e) { e.printStackTrace(); } - return bitmap; } - + public static Bitmap blankContact(Context context, String name) { String text = name == null || PhoneNumberUtils.isWellFormedSmsAddress(PhoneNumberUtils.stripSeparators(name)) || name.length() == 0 ? "#" : "" + name.toUpperCase().charAt(0); diff --git a/QKSMS/src/main/java/com/moez/QKSMS/data/Message.java b/QKSMS/src/main/java/com/moez/QKSMS/data/Message.java index baf3db9e..0590289d 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/data/Message.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/data/Message.java @@ -82,12 +82,12 @@ public class Message { } public boolean isMms() { - boolean bool = false; + boolean isMms = false; Cursor cursor = null; try { cursor = context.getContentResolver().query(MMS_SMS_CONTENT_PROVIDER, new String[]{SmsHelper.COLUMN_MMS}, "_id=" + id, null, null); cursor.moveToFirst(); - bool = "application/vnd.wap.multipart.related".equals(cursor.getString(cursor.getColumnIndex(SmsHelper.COLUMN_MMS))); + isMms = "application/vnd.wap.multipart.related".equals(cursor.getString(cursor.getColumnIndex(SmsHelper.COLUMN_MMS))); } catch (Exception e) { e.printStackTrace(); } finally { @@ -95,7 +95,7 @@ public class Message { cursor.close(); } } - return bool; + return isMms; } public String getAddress() {