mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-27 12:05:22 +00:00
Fix some emoji rendering issues related to obsolete images
1) The "obsolete" images like "swimmer" need to alias to "man_swimming" so that they can be rendered correctly. 2) There are a whole bunch of emoji-data elements (like white_frowning_face) that have "unified" code points which have changed to include a "terminator." Fixes #7212
This commit is contained in:
parent
e1026785f7
commit
ba5febd222
File diff suppressed because one or more lines are too long
@ -25,6 +25,7 @@ import org.thoughtcrime.securesms.components.emoji.parsing.EmojiParser;
|
||||
import org.thoughtcrime.securesms.components.emoji.parsing.EmojiTree;
|
||||
import org.thoughtcrime.securesms.util.FutureTaskListener;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
import org.whispersystems.libsignal.util.Pair;
|
||||
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
@ -68,6 +69,10 @@ class EmojiProvider {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (Pair<String,String> obsolete : EmojiPages.OBSOLETE) {
|
||||
emojiTree.add(obsolete.first(), emojiTree.getEmoji(obsolete.second(), 0, obsolete.second().length()));
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable EmojiParser.CandidateList getCandidates(@Nullable CharSequence text) {
|
||||
|
@ -32,6 +32,8 @@ public class EmojiTree {
|
||||
|
||||
private final EmojiTreeNode root = new EmojiTreeNode();
|
||||
|
||||
private static final char TERMINATOR = '\ufe0f';
|
||||
|
||||
public void add(String emojiEncoding, EmojiDrawInfo emoji) {
|
||||
EmojiTreeNode tree = root;
|
||||
|
||||
@ -63,7 +65,13 @@ public class EmojiTree {
|
||||
tree = tree.getChild(character);
|
||||
}
|
||||
|
||||
return tree.isEndOfEmoji() ? Matches.EXACTLY : Matches.POSSIBLY;
|
||||
if (tree.isEndOfEmoji()) {
|
||||
return Matches.EXACTLY;
|
||||
} else if (sequence.charAt(endPosition-1) != TERMINATOR && tree.hasChild(TERMINATOR) && tree.getChild(TERMINATOR).isEndOfEmoji()) {
|
||||
return Matches.EXACTLY;
|
||||
} else {
|
||||
return Matches.POSSIBLY;
|
||||
}
|
||||
}
|
||||
|
||||
public @Nullable EmojiDrawInfo getEmoji(CharSequence unicode, int startPosition, int endPostiion) {
|
||||
@ -79,7 +87,9 @@ public class EmojiTree {
|
||||
tree = tree.getChild(character);
|
||||
}
|
||||
|
||||
return tree.getEmoji();
|
||||
if (tree.getEmoji() != null) return tree.getEmoji();
|
||||
else if (unicode.charAt(endPostiion-1) != TERMINATOR && tree.hasChild(TERMINATOR)) return tree.getChild(TERMINATOR).getEmoji();
|
||||
else return null;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user