diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt index ffa6cff25..40f8912b9 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt @@ -417,7 +417,7 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at fun selectStartMoveIndex(relativePagePos: Int, lineIndex: Int, charIndex: Int) { selectStart.relativePagePos = relativePagePos selectStart.lineIndex = lineIndex - selectStart.charIndex = charIndex + selectStart.columnIndex = charIndex val textLine = relativePage(relativePagePos).getLine(lineIndex) val textColumn = textLine.getColumn(charIndex) upSelectedStart( @@ -434,7 +434,7 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at fun selectEndMoveIndex(relativePage: Int, lineIndex: Int, charIndex: Int) { selectEnd.relativePagePos = relativePage selectEnd.lineIndex = lineIndex - selectEnd.charIndex = charIndex + selectEnd.columnIndex = charIndex val textLine = relativePage(relativePage).getLine(lineIndex) val textColumn = textLine.getColumn(charIndex) upSelectedEnd(textColumn.end, textLine.lineBottom + relativeOffset(relativePage)) @@ -449,7 +449,7 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at for ((lineIndex, textLine) in relativePage(relativePos).lines.withIndex()) { textPos.lineIndex = lineIndex for ((charIndex, column) in textLine.columns.withIndex()) { - textPos.charIndex = charIndex + textPos.columnIndex = charIndex if (column is TextColumn) { column.selected = textPos.compare(selectStart) >= 0 && textPos.compare(selectEnd) <= 0 @@ -495,7 +495,7 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at textPage.lines.forEachIndexed { lineIndex, textLine -> textPos.lineIndex = lineIndex textLine.columns.forEachIndexed { charIndex, column -> - textPos.charIndex = charIndex + textPos.columnIndex = charIndex val compareStart = textPos.compare(selectStart) val compareEnd = textPos.compare(selectEnd) if (compareStart >= 0 && compareEnd <= 0) { @@ -523,7 +523,7 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at return book.createBookMark().apply { chapterIndex = page.chapterIndex chapterPos = chapter.getReadLength(page.index) + - page.getPosByLineColumn(selectStart.lineIndex, selectStart.charIndex) + page.getPosByLineColumn(selectStart.lineIndex, selectStart.columnIndex) chapterName = chapter.title bookText = getSelectedText() } diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ReadView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ReadView.kt index b2218c710..b482e95d3 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ReadView.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ReadView.kt @@ -28,7 +28,6 @@ import io.legado.app.ui.book.read.page.provider.TextPageFactory import io.legado.app.utils.activity import io.legado.app.utils.invisible import io.legado.app.utils.screenshot -import io.legado.app.utils.toastOnUi import java.text.BreakIterator import java.util.* import kotlin.math.abs @@ -305,7 +304,7 @@ class ReadView(context: Context, attrs: AttributeSet) : val endPos = textPos.copy() val page = curPage.relativePage(textPos.relativePagePos) val stringBuilder = StringBuilder() - var cIndex = textPos.charIndex + var cIndex = textPos.columnIndex var lineStart = textPos.lineIndex var lineEnd = textPos.lineIndex for (index in textPos.lineIndex - 1 downTo 0) { @@ -345,10 +344,10 @@ class ReadView(context: Context, attrs: AttributeSet) : for (j in 0 until textLine.charSize) { if (ci == start) { startPos.lineIndex = index - startPos.charIndex = j + startPos.columnIndex = j } else if (ci == end - 1) { endPos.lineIndex = index - endPos.charIndex = j + endPos.columnIndex = j return@run } ci++ @@ -358,12 +357,12 @@ class ReadView(context: Context, attrs: AttributeSet) : curPage.selectStartMoveIndex( startPos.relativePagePos, startPos.lineIndex, - startPos.charIndex + startPos.columnIndex ) curPage.selectEndMoveIndex( endPos.relativePagePos, endPos.lineIndex, - endPos.charIndex + endPos.columnIndex ) } } @@ -431,24 +430,24 @@ class ReadView(context: Context, attrs: AttributeSet) : curPage.selectStartMoveIndex( textPos.relativePagePos, textPos.lineIndex, - textPos.charIndex + textPos.columnIndex ) curPage.selectEndMoveIndex( initialTextPos.relativePagePos, initialTextPos.lineIndex, - initialTextPos.charIndex + initialTextPos.columnIndex ) } else -> { curPage.selectStartMoveIndex( initialTextPos.relativePagePos, initialTextPos.lineIndex, - initialTextPos.charIndex + initialTextPos.columnIndex ) curPage.selectEndMoveIndex( textPos.relativePagePos, textPos.lineIndex, - textPos.charIndex + textPos.columnIndex ) } } @@ -590,7 +589,7 @@ class ReadView(context: Context, attrs: AttributeSet) : val selectStartPos = curPage.selectStartPos var pagePos = selectStartPos.relativePagePos val line = selectStartPos.lineIndex - val column = selectStartPos.charIndex + val column = selectStartPos.columnIndex while (pagePos > 0) { if (!ReadBook.moveToNextPage()) { ReadBook.moveToNextChapter(false) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextPos.kt b/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextPos.kt index 35dbfa589..eac680cda 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextPos.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextPos.kt @@ -6,19 +6,19 @@ package io.legado.app.ui.book.read.page.entities data class TextPos( var relativePagePos: Int, var lineIndex: Int, - var charIndex: Int + var columnIndex: Int ) { fun upData(relativePos: Int, lineIndex: Int, charIndex: Int) { this.relativePagePos = relativePos this.lineIndex = lineIndex - this.charIndex = charIndex + this.columnIndex = charIndex } fun upData(pos: TextPos) { relativePagePos = pos.relativePagePos lineIndex = pos.lineIndex - charIndex = pos.charIndex + columnIndex = pos.columnIndex } fun compare(pos: TextPos): Int { @@ -27,8 +27,8 @@ data class TextPos( relativePagePos > pos.relativePagePos -> 3 lineIndex < pos.lineIndex -> -2 lineIndex > pos.lineIndex -> 2 - charIndex < pos.charIndex -> -1 - charIndex > pos.charIndex -> 1 + columnIndex < pos.columnIndex -> -1 + columnIndex > pos.columnIndex -> 1 else -> 0 } } @@ -39,8 +39,8 @@ data class TextPos( this.relativePagePos > relativePos -> 3 this.lineIndex < lineIndex -> -2 this.lineIndex > lineIndex -> 2 - this.charIndex < charIndex -> -1 - this.charIndex > charIndex -> 1 + this.columnIndex < charIndex -> -1 + this.columnIndex > charIndex -> 1 else -> 0 } }