From 91612ff12733e9abac210a2db9b8aa2c3f29a7bf Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 14 Feb 2020 21:42:14 +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 --- .../app/ui/book/read/config/MoreConfigDialog.kt | 8 ++++++++ .../io/legado/app/ui/book/read/page/PageView.kt | 4 ++++ .../read/page/delegate/HorizontalPageDelegate.kt | 12 +++++++++--- .../book/read/page/delegate/ScrollPageDelegate.kt | 15 ++++++++------- 4 files changed, 29 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt index ecb7df170..843f60d11 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt @@ -16,7 +16,9 @@ import io.legado.app.constant.EventBus import io.legado.app.constant.PreferKey import io.legado.app.lib.theme.ATH import io.legado.app.ui.book.read.Help +import io.legado.app.ui.book.read.ReadBookActivity import io.legado.app.utils.postEvent +import kotlinx.android.synthetic.main.activity_book_read.* class MoreConfigDialog : DialogFragment() { private val readPreferTag = "readPreferenceFragment" @@ -95,6 +97,12 @@ class MoreConfigDialog : DialogFragment() { PreferKey.hideStatusBar -> postEvent(EventBus.UP_CONFIG, true) PreferKey.hideNavigationBar -> postEvent(EventBus.UP_CONFIG, true) PreferKey.keepLight -> postEvent(PreferKey.keepLight, true) + PreferKey.selectText -> { + val activity = activity + if (activity is ReadBookActivity) { + activity.page_view.upSelectAble() + } + } } } 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 7f93b9968..b344d5aae 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 @@ -174,6 +174,10 @@ class PageView(context: Context, attrs: AttributeSet) : nextPage?.upBattery(battery) } + fun upSelectAble() { + pageDelegate?.upSelectAble() + } + override val isScrollDelegate: Boolean get() = pageDelegate is ScrollPageDelegate diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/HorizontalPageDelegate.kt b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/HorizontalPageDelegate.kt index fb928a56e..0e075a6ce 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/HorizontalPageDelegate.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/HorizontalPageDelegate.kt @@ -1,5 +1,6 @@ package io.legado.app.ui.book.read.page.delegate +import android.text.method.ScrollingMovementMethod import android.view.MotionEvent import io.legado.app.constant.PreferKey import io.legado.app.ui.book.read.page.PageView @@ -50,8 +51,13 @@ abstract class HorizontalPageDelegate(pageView: PageView) : PageDelegate(pageVie } override fun upSelectAble() { - pageView.curPage - ?.contentTextView() - ?.isSelected = context.getPrefBoolean(PreferKey.selectText) + pageView.curPage?.contentTextView()?.apply { + if (context.getPrefBoolean(PreferKey.selectText)) { + isSelected = false + } else { + movementMethod = ScrollingMovementMethod.getInstance() + isSelected = true + } + } } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/ScrollPageDelegate.kt b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/ScrollPageDelegate.kt index d586a35f5..8e1c517e2 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/ScrollPageDelegate.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/ScrollPageDelegate.kt @@ -121,13 +121,14 @@ class ScrollPageDelegate(pageView: PageView) : PageDelegate(pageView) { } override fun upSelectAble() { - if (context.getPrefBoolean(PreferKey.selectText)) { - pageView.curPage?.contentTextView()?.isSelected = true - } else { - pageView.curPage?.isSelected = false - pageView.curPage - ?.contentTextView() - ?.movementMethod = ScrollingMovementMethod.getInstance() + pageView.curPage?.contentTextView()?.apply { + if (context.getPrefBoolean(PreferKey.selectText)) { + isSelected = false + movementMethod = ScrollingMovementMethod.getInstance() + } else { + movementMethod = ScrollingMovementMethod.getInstance() + isSelected = true + } } } } \ No newline at end of file