Make hide phone number setting animated

This commit is contained in:
NekoInverter 2021-01-08 17:09:16 +08:00 committed by 世界
parent b1770331f8
commit cfdf57c280
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4
4 changed files with 53 additions and 5 deletions

View File

@ -166,7 +166,8 @@ public class Emoji {
if (ch >= 0xD83C && ch <= 0xD83E) {
if (ch == 0xD83C && a < length - 1) {
ch = emoji.charAt(a + 1);
if (ch >= 0xDC04 && ch <= 0xDE51) {
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;
@ -178,8 +179,8 @@ public class Emoji {
}
} else if (ch == 0x20E3) {
return emoji;
} else if (ch >= 0x00A9 && ch <= 0x3299) {
//if (EmojiData.emojiToFE0FMap.containsKey(ch)) {
} else if (ch >= 0x0023 && ch <= 0x3299) {
if (EmojiData.emojiToFE0FMap.containsKey(ch)) {
emoji = emoji.substring(0, a + 1) + "\uFE0F" + emoji.substring(a + 1);
length++;
a++;
@ -292,6 +293,11 @@ public class Emoji {
textPaint.setTypeface(EmojiProvider.getFont());
} catch (RuntimeException ignored) {
}
} else if (NekoConfig.useSystemEmoji) {
try {
textPaint.setTypeface(NekoConfig.getSystemEmojiTypeface());
} catch (RuntimeException ignored) {
}
}
textPaint.setTextSize(b.height() * 0.8f);

View File

@ -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 = {

View File

@ -5,8 +5,10 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.graphics.Typeface;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.NotificationsService;
@ -15,6 +17,10 @@ import org.telegram.messenger.R;
import java.util.Locale;
import cn.hutool.core.util.StrUtil;
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class NekoConfig {
@ -97,6 +103,8 @@ public class NekoConfig {
public static String googleCloudTranslateKey;
public static String cachePath;
private static Typeface systemEmojiTypeface;
public static boolean loadSystemEmojiFailed = false;
public static String translateToLang;
public static String translateInputLang;
@ -708,4 +716,37 @@ public class NekoConfig {
}
private static final String EMOJI_FONT_AOSP = "NotoColorEmoji.ttf";
public static Typeface getSystemEmojiTypeface() {
if (!loadSystemEmojiFailed && systemEmojiTypeface == null) {
try {
Pattern p = Pattern.compile(">(.*emoji.*)</font>", Pattern.CASE_INSENSITIVE);
BufferedReader br = new BufferedReader(new FileReader("/system/etc/fonts.xml"));
String line;
while ((line = br.readLine()) != null) {
Matcher m = p.matcher(line);
if (m.find()) {
systemEmojiTypeface = Typeface.createFromFile("/system/fonts/" + m.group(1));
FileLog.d("emoji font file fonts.xml = " + m.group(1));
break;
}
}
br.close();
} catch (Exception e) {
FileLog.e(e);
}
if (systemEmojiTypeface == null) {
try {
systemEmojiTypeface = Typeface.createFromFile("/system/fonts/" + EMOJI_FONT_AOSP);
FileLog.d("emoji font file = " + EMOJI_FONT_AOSP);
} catch (Exception e) {
FileLog.e(e);
loadSystemEmojiFailed = true;
}
}
}
return systemEmojiTypeface;
}
}

View File

@ -121,7 +121,6 @@
<string name="JumpToBeginning">Jump to beginning</string>
<string name="ProviderDeepLTranslate">DeepL Translate</string>
<string name="Halloween">Halloween</string>
<string name="CheckUpdate">Check for update</string>
<string name="LastUpdateFormatted">Last successfully checked %1$s.</string>
<string name="LastUpdateDateFormatted">Last successfully checked on %1$s.</string>
<string name="LastUpdateRecently">Last successfully checked just now.</string>