forked from upstream-mirrors/quik
Small refactoring
This commit is contained in:
@@ -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<String, String> 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<String, String> 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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 }",
|
||||
|
||||
@@ -192,7 +192,7 @@ public class ContactHelper {
|
||||
|
||||
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);
|
||||
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user