Add "Use system emoji"
This commit is contained in:
@@ -38,6 +38,7 @@ public class AppearancePreferencesEntry extends BaseFragment {
|
||||
|
||||
private int applicationHeaderRow;
|
||||
private int useSystemFontsRow;
|
||||
private int useSystemEmojiRow;
|
||||
private int transparentStatusBarRow;
|
||||
private int blurForAllThemesRow;
|
||||
private int applicationDividerRow;
|
||||
@@ -101,6 +102,12 @@ public class AppearancePreferencesEntry extends BaseFragment {
|
||||
((TextCheckCell) view).setChecked(ExteraConfig.useSystemFonts);
|
||||
}
|
||||
restartTooltip.showWithAction(0, UndoView.ACTION_CACHE_WAS_CLEARED, null, null);
|
||||
} else if (position == useSystemEmojiRow) {
|
||||
SharedConfig.toggleUseSystemEmoji();
|
||||
if (view instanceof TextCheckCell) {
|
||||
((TextCheckCell) view).setChecked(SharedConfig.useSystemEmoji);
|
||||
}
|
||||
restartTooltip.showWithAction(0, UndoView.ACTION_CACHE_WAS_CLEARED, null, null);
|
||||
} else if (position == transparentStatusBarRow) {
|
||||
SharedConfig.toggleNoStatusBar();
|
||||
if (view instanceof TextCheckCell) {
|
||||
@@ -171,6 +178,7 @@ public class AppearancePreferencesEntry extends BaseFragment {
|
||||
|
||||
applicationHeaderRow = rowCount++;
|
||||
useSystemFontsRow = rowCount++;
|
||||
useSystemEmojiRow = rowCount++;
|
||||
transparentStatusBarRow = rowCount++;
|
||||
blurForAllThemesRow = rowCount++;
|
||||
applicationDividerRow = rowCount++;
|
||||
@@ -231,6 +239,8 @@ public class AppearancePreferencesEntry extends BaseFragment {
|
||||
textCheckCell.setTextAndCheck(LocaleController.getString("TransparentStatusBar", R.string.TransparentStatusBar), SharedConfig.noStatusBar, true);
|
||||
} else if (position == useSystemFontsRow) {
|
||||
textCheckCell.setTextAndCheck(LocaleController.getString("UseSystemFonts", R.string.UseSystemFonts), ExteraConfig.useSystemFonts, true);
|
||||
} else if (position == useSystemEmojiRow) {
|
||||
textCheckCell.setTextAndCheck(LocaleController.getString("UseSystemEmoji", R.string.UseSystemEmoji), SharedConfig.useSystemEmoji, true);
|
||||
} else if (position == blurForAllThemesRow) {
|
||||
textCheckCell.setTextAndCheck(LocaleController.getString("BlurForAllThemes", R.string.BlurForAllThemes), ExteraConfig.blurForAllThemes, true);
|
||||
} else if (position == hideAllChatsRow) {
|
||||
@@ -283,9 +293,10 @@ public class AppearancePreferencesEntry extends BaseFragment {
|
||||
return 1;
|
||||
} else if (position == applicationHeaderRow || position == generalHeaderRow) {
|
||||
return 2;
|
||||
} else if (position == useSystemFontsRow || position == transparentStatusBarRow || position == blurForAllThemesRow ||
|
||||
position == hideAllChatsRow || position == hideProxySponsorRow || position == hidePhoneNumberRow ||
|
||||
position == showIDRow || position == chatsOnTitleRow || position == forceTabletModeRow) {
|
||||
} else if (position == useSystemFontsRow || position == useSystemEmojiRow || position == transparentStatusBarRow ||
|
||||
position == blurForAllThemesRow || position == hideAllChatsRow || position == hideProxySponsorRow ||
|
||||
position == hidePhoneNumberRow || position == showIDRow || position == chatsOnTitleRow ||
|
||||
position == forceTabletModeRow) {
|
||||
return 3;
|
||||
}
|
||||
return 1;
|
||||
|
||||
@@ -27,6 +27,7 @@ import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.text.Spannable;
|
||||
import android.text.Spanned;
|
||||
import android.text.TextPaint;
|
||||
import android.text.TextUtils;
|
||||
import android.text.style.DynamicDrawableSpan;
|
||||
import android.text.style.ImageSpan;
|
||||
@@ -146,7 +147,10 @@ public class Emoji {
|
||||
if (ch >= 0xD83C && ch <= 0xD83E) {
|
||||
if (ch == 0xD83C && a < length - 1) {
|
||||
ch = emoji.charAt(a + 1);
|
||||
if (ch == 0xDE2F || ch == 0xDC04 || ch == 0xDE1A || ch == 0xDD7F) {
|
||||
if (ch == 0xDE2F || ch == 0xDC04 || ch == 0xDE1A ||
|
||||
ch == 0xDD7F || ch == 0xDFF3 || ch == 0xDF2B ||
|
||||
ch == 0xDC41 || ch == 0xDD75 || ch == 0xDFCC ||
|
||||
ch == 0xDFCB) {
|
||||
emoji = emoji.substring(0, a + 2) + "\uFE0F" + emoji.substring(a + 2);
|
||||
length++;
|
||||
a += 2;
|
||||
@@ -158,7 +162,7 @@ public class Emoji {
|
||||
}
|
||||
} else if (ch == 0x20E3) {
|
||||
return emoji;
|
||||
} else if (ch >= 0x203C && ch <= 0x3299) {
|
||||
} else if (ch >= 0x0023 && ch <= 0x3299) {
|
||||
if (EmojiData.emojiToFE0FMap.containsKey(ch)) {
|
||||
emoji = emoji.substring(0, a + 1) + "\uFE0F" + emoji.substring(a + 1);
|
||||
length++;
|
||||
@@ -225,6 +229,7 @@ public class Emoji {
|
||||
private boolean fullSize = false;
|
||||
private static Paint paint = new Paint(Paint.FILTER_BITMAP_FLAG);
|
||||
private static Rect rect = new Rect();
|
||||
private static TextPaint textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
|
||||
|
||||
public EmojiDrawable(DrawableInfo i) {
|
||||
info = i;
|
||||
@@ -246,23 +251,23 @@ public class Emoji {
|
||||
|
||||
@Override
|
||||
public void draw(Canvas canvas) {
|
||||
/*if (MessagesController.getInstance().useSystemEmoji) {
|
||||
//textPaint.setTextSize(getBounds().width());
|
||||
canvas.drawText(EmojiData.data[info.page][info.emojiIndex], getBounds().left, getBounds().bottom, textPaint);
|
||||
return;
|
||||
}*/
|
||||
if (!isLoaded()) {
|
||||
loadEmoji(info.page, info.page2);
|
||||
canvas.drawRect(getBounds(), placeholderPaint);
|
||||
return;
|
||||
}
|
||||
|
||||
Rect b;
|
||||
if (fullSize) {
|
||||
b = getDrawRect();
|
||||
} else {
|
||||
b = getBounds();
|
||||
}
|
||||
if (SharedConfig.useSystemEmoji) {
|
||||
String emoji = fixEmoji(EmojiData.data[info.page][info.emojiIndex]);
|
||||
textPaint.setTextSize(b.height() * 0.8f);
|
||||
canvas.drawText(emoji, 0, emoji.length(), b.left, b.bottom - b.height() * 0.225f, textPaint);
|
||||
return;
|
||||
}
|
||||
if (!isLoaded()) {
|
||||
loadEmoji(info.page, info.page2);
|
||||
canvas.drawRect(getBounds(), placeholderPaint);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!canvas.quickReject(b.left, b.top, b.right, b.bottom, Canvas.EdgeType.AA)) {
|
||||
canvas.drawBitmap(emojiBmp[info.page][info.page2], null, b, paint);
|
||||
@@ -321,7 +326,7 @@ public class Emoji {
|
||||
}
|
||||
|
||||
public static CharSequence replaceEmoji(CharSequence cs, Paint.FontMetricsInt fontMetrics, int size, boolean createNew, int[] emojiOnly) {
|
||||
if (SharedConfig.useSystemEmoji || cs == null || cs.length() == 0) {
|
||||
if (cs == null || cs.length() == 0) {
|
||||
return cs;
|
||||
}
|
||||
Spannable s;
|
||||
@@ -459,12 +464,14 @@ public class Emoji {
|
||||
if (emojiOnly != null) {
|
||||
emojiOnly[0]++;
|
||||
}
|
||||
CharSequence code = emojiCode.subSequence(0, emojiCode.length());
|
||||
drawable = Emoji.getEmojiDrawable(code);
|
||||
if (drawable != null) {
|
||||
span = new EmojiSpan(drawable, DynamicDrawableSpan.ALIGN_BOTTOM, size, fontMetrics);
|
||||
s.setSpan(span, startIndex, startIndex + startLength, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
emojiCount++;
|
||||
if (!SharedConfig.useSystemEmoji) {
|
||||
CharSequence code = emojiCode.subSequence(0, emojiCode.length());
|
||||
drawable = Emoji.getEmojiDrawable(code);
|
||||
if (drawable != null) {
|
||||
span = new EmojiSpan(drawable, DynamicDrawableSpan.ALIGN_BOTTOM, size, fontMetrics);
|
||||
s.setSpan(span, startIndex, startIndex + startLength, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
emojiCount++;
|
||||
}
|
||||
}
|
||||
startLength = 0;
|
||||
startIndex = -1;
|
||||
|
||||
@@ -24,7 +24,9 @@ public class EmojiData {
|
||||
0x2197, 0x2198, 0x2199, 0x2196, 0x2195, 0x2194, 0x21AA, 0x21A9, 0x2934, 0x2935,
|
||||
0x2139, 0x2714, 0x2716, 0x2611, 0x26AA, 0x26AB, 0x25AA, 0x25AB, 0x2B1B, 0x2B1C,
|
||||
0x25FC, 0x25FB, 0x25FE, 0x25FD, 0x2660, 0x2663, 0x2665, 0x2666, 0x263A, 0x2639,
|
||||
0x270C, 0x261D, 0x2764, 0x2603, 0x23CF
|
||||
0x270C, 0x261D, 0x2764, 0x2603, 0x23CF, 0x2620, 0x26A7, 0x2642, 0x2640, 0x2695,
|
||||
0x2696, 0x2708, 0x0023, 0x002A, 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035,
|
||||
0x0036, 0x0037, 0x0038, 0x0039, 0x26F9
|
||||
};
|
||||
|
||||
public static final char[] dataChars = {
|
||||
|
||||
@@ -260,6 +260,14 @@ public class SharedConfig {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static void toggleUseSystemEmoji() {
|
||||
useSystemEmoji = !useSystemEmoji;
|
||||
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putBoolean("useSystemEmoji", useSystemEmoji);
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
public static void loadConfig() {
|
||||
synchronized (sync) {
|
||||
if (configLoaded || ApplicationLoader.applicationContext == null) {
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
<!-- Appearance -->
|
||||
<string name="UseSystemFonts">Use system fonts</string>
|
||||
<string name="UseSystemEmoji">Use system emoji</string>
|
||||
<string name="TransparentStatusBar">Transparent Status Bar</string>
|
||||
<string name="BlurForAllThemes">Blur for all themes</string>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user