diff --git a/app/src/main/java/io/legado/app/constant/PreferKey.kt b/app/src/main/java/io/legado/app/constant/PreferKey.kt index 3a9eab787..320bc87ee 100644 --- a/app/src/main/java/io/legado/app/constant/PreferKey.kt +++ b/app/src/main/java/io/legado/app/constant/PreferKey.kt @@ -33,7 +33,7 @@ object PreferKey { const val changeSourceLoadToc = "changeSourceLoadToc" const val chineseConverterType = "chineseConverterType" const val launcherIcon = "launcherIcon" - const val selectText = "selectText" + const val textSelectAble = "selectText" const val lastBackup = "lastBackup" const val bodyIndent = "textIndent" } \ No newline at end of file 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 9c38fe138..5d642940d 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 @@ -554,6 +554,9 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo observeEvent(PreferKey.keepLight) { upScreenTimeOut() } + observeEvent(PreferKey.textSelectAble) { + page_view.upSelectAble(it) + } } private fun upScreenTimeOut() { 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..b087a1508 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,6 +16,7 @@ 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.utils.getPrefBoolean import io.legado.app.utils.postEvent class MoreConfigDialog : DialogFragment() { @@ -54,8 +55,7 @@ class MoreConfigDialog : DialogFragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) var preferenceFragment = childFragmentManager.findFragmentByTag(readPreferTag) - if (preferenceFragment == null) preferenceFragment = - ReadPreferenceFragment() + if (preferenceFragment == null) preferenceFragment = ReadPreferenceFragment() childFragmentManager.beginTransaction() .replace(view.id, preferenceFragment, readPreferTag) .commit() @@ -94,7 +94,8 @@ class MoreConfigDialog : DialogFragment() { when (key) { PreferKey.hideStatusBar -> postEvent(EventBus.UP_CONFIG, true) PreferKey.hideNavigationBar -> postEvent(EventBus.UP_CONFIG, true) - PreferKey.keepLight -> postEvent(PreferKey.keepLight, true) + PreferKey.keepLight -> postEvent(key, true) + PreferKey.textSelectAble -> postEvent(key, getPrefBoolean(key)) } } 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 a0a5c36d3..4ea4decdd 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 @@ -151,6 +151,10 @@ class PageView(context: Context, attrs: AttributeSet) : } } + fun upSelectAble(selectAble: Boolean) { + pageDelegate?.upSelectAble(selectAble) + } + fun upStyle() { curPage.upStyle() prevPage.upStyle() 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 d8a03a8cb..b2ac16c45 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 @@ -59,7 +59,7 @@ abstract class PageDelegate(protected val pageView: PageView) : private val detector: GestureDetector by lazy { GestureDetector(pageView.context, this).apply { - setIsLongpressEnabled(context.getPrefBoolean(PreferKey.selectText)) + setIsLongpressEnabled(context.getPrefBoolean(PreferKey.textSelectAble)) } } @@ -92,6 +92,10 @@ abstract class PageDelegate(protected val pageView: PageView) : onScroll() } + fun upSelectAble(selectAble: Boolean) { + detector.setIsLongpressEnabled(selectAble) + } + protected fun invalidate() { pageView.invalidate() } @@ -187,10 +191,6 @@ abstract class PageDelegate(protected val pageView: PageView) : open fun onScroll() {//移动contentView, slidePage } - enum class Direction { - NONE, PREV, NEXT - } - @CallSuper open fun setDirection(direction: Direction) { mDirection = direction @@ -307,6 +307,10 @@ abstract class PageDelegate(protected val pageView: PageView) : return hasNext } + enum class Direction { + NONE, PREV, NEXT + } + fun MotionEvent.toAction(action: Int): MotionEvent { return MotionEvent.obtain( downTime, @@ -323,4 +327,4 @@ abstract class PageDelegate(protected val pageView: PageView) : edgeFlags ) } -} \ No newline at end of file +}