Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -29,7 +29,7 @@ class CheckListClickHandler(
}

fun handleTouch(event: MotionEvent): Boolean {
val text = view.text as? Spannable ?: return false
val text = view.editableText
val layout = view.layout ?: return false

val x = event.x - view.totalPaddingLeft + view.scrollX
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class EnrichedDragHandler(
return true
}

val lengthBeforeDrop = view.text?.length ?: 0
val lengthBeforeDrop = view.length()
val didInsert = clipboardManager.insertClipData(clip, dropOffset, dropOffset)
if (!didInsert) {
return null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ class EnrichedTextInputView : AppCompatEditText {
observeAsyncImages()
if (withSelection) {
// Scroll to the last line of text
setSelection(text?.length ?: 0, text?.length ?: 0)
setSelection(length(), length())
}
}
}
Expand All @@ -479,14 +479,14 @@ class EnrichedTextInputView : AppCompatEditText {
start: Int,
stop: Int,
) {
val textLength = text?.length ?: 0
val textLength = length()
val safeStart = start.coerceIn(0, textLength)
val safeEnd = stop.coerceIn(0, textLength)
super.setSelection(safeStart, safeEnd)
}

override fun setSelection(index: Int) {
val safeIndex = index.coerceIn(0, text?.length ?: 0)
val safeIndex = index.coerceIn(0, length())
super.setSelection(safeIndex)
}

Expand All @@ -502,9 +502,7 @@ class EnrichedTextInputView : AppCompatEditText {

// this method is used to update the draw state of span
fun redrawSpan(span: EnrichedSpan) {
val text = text
if (text !is Spannable) return

val text = editableText
val start = text.getSpanStart(span)
val end = text.getSpanEnd(span)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class EnrichedSelection(
prevTextVersion = view.textVersion
}

val textLength = view.text?.length ?: 0
val textLength = view.length()
val finalStart = newStart.coerceAtMost(newEnd).coerceAtLeast(0).coerceAtMost(textLength)
val finalEnd = newEnd.coerceAtLeast(newStart).coerceAtLeast(0).coerceAtMost(textLength)

Expand Down