From 43004c8fad1e5f688ce71812cc9a05955393e27d Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 21 Feb 2020 15:49:44 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/ui/book/read/ReadBookActivity.kt | 6 ++++++ .../main/java/io/legado/app/ui/book/read/page/PageView.kt | 7 +++++-- .../legado/app/ui/book/read/page/delegate/PageDelegate.kt | 3 +++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt index 5d642940d..44c67ba8b 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt @@ -35,6 +35,7 @@ import io.legado.app.ui.book.read.config.BgTextConfigDialog.Companion.TEXT_COLOR import io.legado.app.ui.book.read.page.ChapterProvider import io.legado.app.ui.book.read.page.PageView import io.legado.app.ui.book.read.page.delegate.PageDelegate +import io.legado.app.ui.book.read.page.entities.TextChar import io.legado.app.ui.book.source.edit.BookSourceEditActivity import io.legado.app.ui.changesource.ChangeSourceDialog import io.legado.app.ui.chapterlist.ChapterListActivity @@ -389,6 +390,11 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo } } + override fun selectText(textChar: TextChar) { + cursor_left + cursor_right + } + override fun showReadAloudDialog() { ReadAloudDialog().show(supportFragmentManager, "readAloud") } diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt index 3295a0b58..68708c725 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt @@ -11,6 +11,7 @@ import io.legado.app.help.ReadBookConfig import io.legado.app.service.help.ReadBook import io.legado.app.ui.book.read.page.delegate.* import io.legado.app.ui.book.read.page.entities.TextChapter +import io.legado.app.ui.book.read.page.entities.TextChar import io.legado.app.utils.activity import io.legado.app.utils.getPrefInt @@ -241,6 +242,8 @@ class PageView(context: Context, attrs: AttributeSet) : interface CallBack { + val isInitFinish: Boolean + /** * 保存页数 */ @@ -251,8 +254,8 @@ class PageView(context: Context, attrs: AttributeSet) : */ fun clickCenter() - val isInitFinish: Boolean - fun screenOffTimerStart() + + fun selectText(textChar: TextChar) } } diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt index b0be332dc..aa525f948 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt @@ -268,6 +268,9 @@ abstract class PageDelegate(protected val pageView: PageView) : override fun onLongPress(e: MotionEvent) { val textChar = curPage.selectText(e) + textChar?.let { + pageView.callBack?.selectText(it) + } } /**