1
0
Fork 0
mirror of https://github.com/anyproto/anytype-kotlin.git synced 2025-06-08 05:47:05 +09:00
* #372: parse pirat flag emoji

* #372: roll back

* #372: temporary emoji fix

* #372: filter emoji

* #372: code style
This commit is contained in:
Konstantin Ivanov 2020-05-12 13:13:01 +03:00 committed by GitHub
parent ff2a5185fd
commit 045a02141d
Signed by: github
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 3 deletions

View file

@ -10,7 +10,15 @@ class DefaultEmojifier : Emojifier {
check(alias.isNotEmpty()) { "Alias cannot be empty" }
return EmojiManager.getForAlias(alias).let { result ->
Emoji(
unicode = result.unicode,
/**
* Fix pirate flag emoji render, after fixing
* in table https://github.com/vdurmont/emoji-java/blob/master/EMOJIS.md
* can be removed
*/
unicode = result.unicode.filterTextByChar(
value = '☠',
filterBy = '♾'
),
alias = result.aliases.first()
)
}
@ -21,4 +29,11 @@ class DefaultEmojifier : Emojifier {
val alias = name.substring(1, name.length - 1)
return fromAlias(alias)
}
}
}
fun String.filterTextByChar(value: Char, filterBy: Char): String =
if (contains(value)) {
filterNot { it == filterBy }
} else {
this
}

View file

@ -149,11 +149,26 @@ class PageIconPickerViewModel(
emojis.map { emoji ->
PageIconPickerView.Emoji(
alias = emoji.aliases.first(),
unicode = emoji.unicode
/**
* Fix pirate flag emoji render, after fixing
* in table https://github.com/vdurmont/emoji-java/blob/master/EMOJIS.md
* can be removed
*/
unicode = emoji.unicode.filterTextByChar(
value = '☠',
filterBy = '♾'
)
)
}
}
private fun String.filterTextByChar(value: Char, filterBy: Char): String =
if (contains(value)) {
filterNot { it == filterBy }
} else {
this
}
fun onEvent(event: Event) {
channel.offer(event)
}