Merge pull request #940 from nobk/fs-1

解决全面屏手势与阅读翻页冲突
pull/942/head
kunfei 4 years ago committed by GitHub
commit 12c4d1c9f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      app/src/main/java/io/legado/app/constant/PreferKey.kt
  2. 3
      app/src/main/java/io/legado/app/help/AppConfig.kt
  3. 4
      app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt
  4. 42
      app/src/main/java/io/legado/app/ui/book/read/page/ReadView.kt
  5. 1
      app/src/main/res/values-zh-rHK/strings.xml
  6. 1
      app/src/main/res/values-zh-rTW/strings.xml
  7. 1
      app/src/main/res/values-zh/strings.xml
  8. 1
      app/src/main/res/values/strings.xml
  9. 7
      app/src/main/res/xml/pref_config_read.xml

@ -72,6 +72,7 @@ object PreferKey {
const val exportCharset = "exportCharset"
const val exportUseReplace = "exportUseReplace"
const val useZhLayout = "useZhLayout"
const val fullScreenGesturesSupport = "fullScreenGesturesSupport"
const val cPrimary = "colorPrimary"
const val cAccent = "colorAccent"

@ -190,6 +190,9 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
val replaceEnableDefault get() = appCtx.getPrefBoolean(PreferKey.replaceEnableDefault, true)
val fullScreenGesturesSupport: Boolean
get () = appCtx.getPrefBoolean(PreferKey.fullScreenGesturesSupport, false)
private fun getPrefUserAgent(): String {
val ua = appCtx.getPrefString(PreferKey.userAgent)
if (ua.isNullOrBlank()) {

@ -16,6 +16,7 @@ import io.legado.app.help.ReadBookConfig
import io.legado.app.lib.theme.ATH
import io.legado.app.lib.theme.bottomBackground
import io.legado.app.ui.book.read.ReadBookActivity
import io.legado.app.ui.book.read.page.ReadView
import io.legado.app.utils.dp
import io.legado.app.utils.getPrefBoolean
import io.legado.app.utils.postEvent
@ -127,6 +128,9 @@ class MoreConfigDialog : DialogFragment() {
"clickRegionalConfig" -> {
(activity as? ReadBookActivity)?.showClickRegionalConfig()
}
"fullScreenGesturesSupport" -> {
((activity as? ReadBookActivity)?.findViewById(R.id.read_view) as ReadView).setRect9x()
}
}
return super.onPreferenceTreeClick(preference)
}

@ -77,15 +77,15 @@ class ReadView(context: Context, attrs: AttributeSet) :
private var firstCharIndex: Int = 0
val slopSquare by lazy { ViewConfiguration.get(context).scaledTouchSlop }
private val tlRect = RectF(0f, 0f, width * 0.33f, height * 0.33f)
private val tcRect = RectF(width * 0.33f, 0f, width * 0.66f, height * 0.33f)
private val trRect = RectF(width * 0.36f, 0f, width - 0f, height * 0.33f)
private val mlRect = RectF(0f, height * 0.33f, width * 0.33f, height * 0.66f)
private val mcRect = RectF(width * 0.33f, height * 0.33f, width * 0.66f, height * 0.66f)
private val mrRect = RectF(width * 0.66f, height * 0.33f, width - 0f, height * 0.66f)
private val blRect = RectF(0f, height * 0.66f, width * 0.33f, height - 0f)
private val bcRect = RectF(width * 0.33f, height * 0.66f, width * 0.66f, height - 0f)
private val brRect = RectF(width * 0.66f, height * 0.66f, width - 0f, height - 0f)
private val tlRect = RectF()
private val tcRect = RectF()
private val trRect = RectF()
private val mlRect = RectF()
private val mcRect = RectF()
private val mrRect = RectF()
private val blRect = RectF()
private val bcRect = RectF()
private val brRect = RectF()
private val autoPageRect by lazy { Rect() }
private val autoPagePint by lazy { Paint().apply { color = context.accentColor } }
private val boundary by lazy { BreakIterator.getWordInstance(Locale.getDefault()) }
@ -99,19 +99,25 @@ class ReadView(context: Context, attrs: AttributeSet) :
setWillNotDraw(false)
upPageAnim()
}
setRect9x()
}
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
super.onSizeChanged(w, h, oldw, oldh)
tlRect.set(0f, 0f, width * 0.33f, height * 0.33f)
public fun setRect9x() {
val edge = if (AppConfig.fullScreenGesturesSupport) { 200f } else { 0f }
tlRect.set(0f + edge, 0f, width * 0.33f, height * 0.33f)
tcRect.set(width * 0.33f, 0f, width * 0.66f, height * 0.33f)
trRect.set(width * 0.36f, 0f, width - 0f, height * 0.33f)
mlRect.set(0f, height * 0.33f, width * 0.33f, height * 0.66f)
trRect.set(width * 0.36f, 0f, width - 0f - edge, height * 0.33f)
mlRect.set(0f + edge, height * 0.33f, width * 0.33f, height * 0.66f)
mcRect.set(width * 0.33f, height * 0.33f, width * 0.66f, height * 0.66f)
mrRect.set(width * 0.66f, height * 0.33f, width - 0f, height * 0.66f)
blRect.set(0f, height * 0.66f, width * 0.33f, height - 10f)
bcRect.set(width * 0.33f, height * 0.66f, width * 0.66f, height - 0f)
brRect.set(width * 0.66f, height * 0.66f, width - 0f, height - 0f)
mrRect.set(width * 0.66f, height * 0.33f, width - 0f - edge, height * 0.66f)
blRect.set(0f + edge, height * 0.66f, width * 0.33f, height - 10f - edge)
bcRect.set(width * 0.33f, height * 0.66f, width * 0.66f, height - 0f - edge)
brRect.set(width * 0.66f, height * 0.66f, width - 0f - edge, height - 0f - edge)
}
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
super.onSizeChanged(w, h, oldw, oldh)
setRect9x()
prevPage.x = -w.toFloat()
pageDelegate?.setViewSize(w, h)
}

@ -680,6 +680,7 @@
<string name="middle"></string>
<string name="information">信息</string>
<string name="switchLayout">切換佈局</string>
<string name="full_screen_gestures_support">全面屏手勢優化</string>
<!--color-->
<string name="primary">主色調</string>

@ -693,6 +693,7 @@
<string name="information">訊息</string>
<string name="switchLayout">切換布局</string>
<string name="text_font_weight_converter">文章字重轉換</string>
<string name="full_screen_gestures_support">全面屏手勢優化</string>
<!--color-->
<string name="primary">主色調</string>

@ -693,6 +693,7 @@
<string name="information">信息</string>
<string name="switchLayout">切换布局</string>
<string name="text_font_weight_converter">文章字重切换</string>
<string name="full_screen_gestures_support">全面屏手势优化</string>
<!--color-->
<string name="primary">主色调</string>

@ -694,6 +694,7 @@
<string name="information">Information</string>
<string name="switchLayout">Switch Layout</string>
<string name="text_font_weight_converter">Text font weight switching</string>
<string name="full_screen_gestures_support">Full screen gestures support</string>
<!--color-->
<string name="primary">Primary</string>

@ -103,6 +103,13 @@
app:iconSpaceReserved="false"
app:isBottomBackground="true" />
<io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="false"
android:key="fullScreenGesturesSupport"
android:title="@string/full_screen_gestures_support"
app:iconSpaceReserved="false"
app:isBottomBackground="true" />
<io.legado.app.ui.widget.prefs.Preference
android:key="customPageKey"
android:title="@string/custom_page_key"

Loading…
Cancel
Save