Skip to content
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,34 @@ class ParametrizedStyles(private val view: EnrichedTextInputView) {
return Triple(result, start, end)
}

private fun detectLinkConflicts(): Boolean {
Comment thread
exploIF marked this conversation as resolved.
Outdated
val mergingConfig = EnrichedSpans.getMergingConfigForStyle(EnrichedSpans.LINK, view.htmlStyle)?: return false
val conflictingStyles = mergingConfig.conflictingStyles
val blockingStyles = mergingConfig.blockingStyles

for (style in blockingStyles) {
if (view.spanState?.getStart(style) != null) return true
}

for (style in conflictingStyles) {
if (view.spanState?.getStart(style) != null) return true
}

return false
}

private fun afterTextChangedLinks(result: Triple<String, Int, Int>) {
if (detectLinkConflicts()) {
Comment thread
exploIF marked this conversation as resolved.
Outdated
return
}

// Do not detect link if it's applied manually
if (isSettingLinkSpan) return
val spannable = view.text as Spannable
val (word, start, end) = result

// TODO: Consider using more reliable regex, this one matches almost anything
val urlPattern = android.util.Patterns.WEB_URL.matcher(word)

val spans = spannable.getSpans(start, end, EnrichedLinkSpan::class.java)
for (span in spans) {
spannable.removeSpan(span)
Expand Down
Loading