pull/737/head
Robot 4 years ago
commit 6ed9ac714a
  1. 1
      app/src/main/assets/updateLog.md
  2. 3
      app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt
  3. 1
      app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt
  4. 18
      app/src/main/java/io/legado/app/ui/book/read/page/ReadView.kt

@ -7,6 +7,7 @@
* 修复bug * 修复bug
* 优化中文排序 * 优化中文排序
* 优化编码识别 * 优化编码识别
* 选择文字时优先选词
**2020/12/06** **2020/12/06**
* 添加规则订阅功能,订阅界面第一个图标,可以订阅书源/订阅源/替换规则 * 添加规则订阅功能,订阅界面第一个图标,可以订阅书源/订阅源/替换规则

@ -40,7 +40,8 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at
private val selectStart = arrayOf(0, 0, 0) private val selectStart = arrayOf(0, 0, 0)
private val selectEnd = arrayOf(0, 0, 0) private val selectEnd = arrayOf(0, 0, 0)
private var textChapter: TextChapter? = null private var textChapter: TextChapter? = null
private var textPage: TextPage = TextPage() var textPage: TextPage = TextPage()
private set
//滚动参数 //滚动参数
private val pageFactory: TextPageFactory get() = callBack.pageFactory private val pageFactory: TextPageFactory get() = callBack.pageFactory

@ -276,4 +276,5 @@ class PageView(context: Context) : FrameLayout(context) {
val selectedText: String get() = binding.contentTextView.selectedText val selectedText: String get() = binding.contentTextView.selectedText
val textPage get() = binding.contentTextView.textPage
} }

@ -22,8 +22,11 @@ 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.utils.activity import io.legado.app.utils.activity
import io.legado.app.utils.screenshot import io.legado.app.utils.screenshot
import java.text.BreakIterator
import java.util.*
import kotlin.math.abs import kotlin.math.abs
class ReadView(context: Context, attrs: AttributeSet) : class ReadView(context: Context, attrs: AttributeSet) :
FrameLayout(context, attrs), FrameLayout(context, attrs),
DataSource { DataSource {
@ -250,8 +253,21 @@ class ReadView(context: Context, attrs: AttributeSet) :
firstRelativePage = relativePage firstRelativePage = relativePage
firstLineIndex = lineIndex firstLineIndex = lineIndex
firstCharIndex = charIndex firstCharIndex = charIndex
val boundary = BreakIterator.getWordInstance(Locale.getDefault())
val lineText = curPage.textPage.textLines[lineIndex].text
boundary.setText(lineText)
var start = boundary.first()
var end = boundary.next()
while (end != BreakIterator.DONE) {
if (charIndex in start until end) {
firstCharIndex = start
break
}
start = end
end = boundary.next()
}
curPage.selectStartMoveIndex(firstRelativePage, firstLineIndex, firstCharIndex) curPage.selectStartMoveIndex(firstRelativePage, firstLineIndex, firstCharIndex)
curPage.selectEndMoveIndex(firstRelativePage, firstLineIndex, firstCharIndex) curPage.selectEndMoveIndex(firstRelativePage, firstLineIndex, end - 1)
} }
} }

Loading…
Cancel
Save