This commit is contained in:
Horis
2024-12-24 14:17:19 +08:00
parent 4320bd1cc3
commit d548f63b13
@@ -23,6 +23,7 @@ import io.legado.app.ui.book.read.page.provider.ChapterProvider
import io.legado.app.ui.book.read.page.provider.TextPageFactory import io.legado.app.ui.book.read.page.provider.TextPageFactory
import io.legado.app.ui.widget.dialog.PhotoDialog import io.legado.app.ui.widget.dialog.PhotoDialog
import io.legado.app.utils.activity import io.legado.app.utils.activity
import io.legado.app.utils.dpToPx
import io.legado.app.utils.getCompatColor import io.legado.app.utils.getCompatColor
import io.legado.app.utils.showDialogFragment import io.legado.app.utils.showDialogFragment
import io.legado.app.utils.toastOnUi import io.legado.app.utils.toastOnUi
@@ -279,6 +280,8 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at
if (textPos.compare(selectEnd) <= 0) { if (textPos.compare(selectEnd) <= 0) {
selectStartMoveIndex(textPos) selectStartMoveIndex(textPos)
} else { } else {
touchRough(x - 2 * cursorWidth, y) { _, textPos, _, _, _ ->
if (textPos.compare(selectEnd) > 0) {
reverseStartCursor = true reverseStartCursor = true
reverseEndCursor = false reverseEndCursor = false
selectEnd.columnIndex++ selectEnd.columnIndex++
@@ -287,6 +290,8 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at
} }
} }
} }
}
}
/** /**
* 结束选择符移动 * 结束选择符移动
@@ -299,6 +304,8 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at
if (textPos.compare(selectStart) >= 0) { if (textPos.compare(selectStart) >= 0) {
selectEndMoveIndex(textPos) selectEndMoveIndex(textPos)
} else { } else {
touchRough(x + 2 * cursorWidth, y) { _, textPos, _, _, _ ->
if (textPos.compare(selectStart) < 0) {
reverseEndCursor = true reverseEndCursor = true
reverseStartCursor = false reverseStartCursor = false
selectStart.columnIndex-- selectStart.columnIndex--
@@ -307,6 +314,8 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at
} }
} }
} }
}
}
/** /**
* 触碰位置信息 * 触碰位置信息
@@ -690,6 +699,7 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at
Thread(it, "TextPageRender") Thread(it, "TextPageRender")
} }
} }
private val cursorWidth = 24.dpToPx()
} }
interface CallBack { interface CallBack {