0
0
mirror of https://github.com/florisboard/florisboard.git synced 2024-09-20 03:52:18 +02:00

Fix domains get extracted from emails in clipboard (#1971)

This commit is contained in:
Patrick Goldinger 2022-07-27 13:58:40 +02:00
parent 29bd8a289c
commit 772402b46f

View File

@ -363,20 +363,14 @@ class NlpManager(context: Context) {
add(ClipboardSuggestionCandidate(currentItem, sourceProvider = this@ClipboardSuggestionProvider))
if (currentItem.type == ItemType.TEXT) {
val text = currentItem.stringRepresentation()
NetworkUtils.getEmailAddresses(text).forEach { match ->
if (match.value != text) {
add(ClipboardSuggestionCandidate(currentItem.copy(text = match.value),
sourceProvider = this@ClipboardSuggestionProvider))
}
val matches = buildList {
addAll(NetworkUtils.getEmailAddresses(text))
addAll(NetworkUtils.getUrls(text))
addAll(NetworkUtils.getPhoneNumbers(text))
}
NetworkUtils.getUrls(text).forEach { match ->
if (match.value != text) {
add(ClipboardSuggestionCandidate(currentItem.copy(text = match.value),
sourceProvider = this@ClipboardSuggestionProvider))
}
}
NetworkUtils.getPhoneNumbers(text).forEach { match ->
if (match.value != text) {
matches.forEachIndexed { i, match ->
val isUniqueMatch = matches.subList(0, i).all { it.range.intersect(match.range).isEmpty() }
if (match.value != text && isUniqueMatch) {
add(ClipboardSuggestionCandidate(currentItem.copy(text = match.value),
sourceProvider = this@ClipboardSuggestionProvider))
}