1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-18 22:57:48 +01:00

Added a try-catch to not crash on de-emojifying

This commit is contained in:
Taavi 2019-02-13 04:26:04 +02:00 committed by GitHub
parent 2e5a5f125a
commit 054c9722a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2018 Andreas Shimokawa, Matthieu Baerts /* Copyright (C) 2019 Andreas Shimokawa, Matthieu Baerts, Taavi Eomäe
This file is part of Gadgetbridge. This file is part of Gadgetbridge.
@ -19,10 +19,14 @@ package nodomain.freeyourgadget.gadgetbridge.util;
import android.content.Context; import android.content.Context;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.wax911.emojify.EmojiManager; import io.wax911.emojify.EmojiManager;
import io.wax911.emojify.EmojiUtils; import io.wax911.emojify.EmojiUtils;
public class EmojiConverter { public class EmojiConverter {
private static final Logger LOG = LoggerFactory.getLogger(EmojiConverter.class);
private static final String[][] simpleEmojiMapping = { private static final String[][] simpleEmojiMapping = {
{"\uD83D\uDE00", ":-D"}, // grinning {"\uD83D\uDE00", ":-D"}, // grinning
@ -80,8 +84,12 @@ public class EmojiConverter {
private static String convertAdvancedEmojiToAscii(String text, Context context) { private static String convertAdvancedEmojiToAscii(String text, Context context) {
initEmojiData(context); initEmojiData(context);
try {
return EmojiUtils.shortCodify(text); return EmojiUtils.shortCodify(text);
} catch (Exception e){
LOG.warn("An exception occured when converting advanced emoji to ASCII", text);
return text;
}
} }
public static String convertUnicodeEmojiToAscii(String text, Context context) { public static String convertUnicodeEmojiToAscii(String text, Context context) {