Fix crashes

This commit is contained in:
tehcneko 2023-01-25 21:50:08 +08:00 committed by xtaodada
parent 9a02f92c84
commit dfb4c111a3
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659
2 changed files with 16 additions and 2 deletions

View File

@ -12,6 +12,7 @@ import androidx.annotation.RequiresApi;
import com.google.android.exoplayer2.util.Log;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.R;
import org.telegram.ui.ActionBar.Theme;
@ -139,6 +140,10 @@ public class MonetHelper {
}
public static void unregisterReceiver(Context context) {
overlayChangeReceiver.unregister(context);
try {
overlayChangeReceiver.unregister(context);
} catch (IllegalArgumentException e) {
FileLog.e(e);
}
}
}

View File

@ -62,7 +62,7 @@ public class EmojiHelper extends BaseRemoteHelper implements NotificationCenter.
private static final String EMOJI_TAG = "emoji";
private static final String EMOJI_FONT_AOSP = "NotoColorEmoji.ttf";
private static final int EMOJI_COUNT = 3538;
private final static String EMOJI_PACKS_FILE_DIR = ApplicationLoader.applicationContext.getExternalFilesDir(null).getAbsolutePath() + "/emojis/";
private static final String EMOJI_PACKS_FILE_DIR;
private static final Runnable invalidateUiRunnable = () -> NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.emojiLoaded);
private static final String[] previewEmojis = {
"\uD83D\uDE00",
@ -88,6 +88,15 @@ public class EmojiHelper extends BaseRemoteHelper implements NotificationCenter.
private String pendingDeleteEmojiPackId;
private Bulletin emojiPackBulletin;
static {
var files = ApplicationLoader.applicationContext.getExternalFilesDir(null);
if (files != null) {
EMOJI_PACKS_FILE_DIR = files.getAbsolutePath() + "/emojis/";
} else {
EMOJI_PACKS_FILE_DIR = ApplicationLoader.applicationContext.getFilesDir().getAbsolutePath() + "/emojis/";
}
}
private EmojiHelper() {
checkAccount();
emojiPack = preferences.getString("emoji_pack", "");