feat: 添加文字底部对齐开关

pull/262/head
gedoor 4 years ago
parent 43bc739966
commit 72d5993546
  1. 1
      app/src/main/java/io/legado/app/constant/PreferKey.kt
  2. 1
      app/src/main/java/io/legado/app/help/ReadBookConfig.kt
  3. 3
      app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt
  4. 2
      app/src/main/java/io/legado/app/ui/book/read/page/entities/TextPage.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/strings.xml
  8. 6
      app/src/main/res/xml/pref_config_read.xml

@ -44,6 +44,7 @@ object PreferKey {
const val systemTypefaces = "system_typefaces" const val systemTypefaces = "system_typefaces"
const val readBodyToLh = "readBodyToLh" const val readBodyToLh = "readBodyToLh"
const val textFullJustify = "textFullJustify" const val textFullJustify = "textFullJustify"
const val textBottomJustify = "textBottomJustify"
const val autoReadSpeed = "autoReadSpeed" const val autoReadSpeed = "autoReadSpeed"
const val barElevation = "barElevation" const val barElevation = "barElevation"
const val transparentStatusBar = "transparentStatusBar" const val transparentStatusBar = "transparentStatusBar"

@ -144,6 +144,7 @@ object ReadBookConfig {
var isScroll = pageAnim == 3 var isScroll = pageAnim == 3
val clickTurnPage get() = App.INSTANCE.getPrefBoolean(PreferKey.clickTurnPage, true) val clickTurnPage get() = App.INSTANCE.getPrefBoolean(PreferKey.clickTurnPage, true)
val textFullJustify get() = App.INSTANCE.getPrefBoolean(PreferKey.textFullJustify, true) val textFullJustify get() = App.INSTANCE.getPrefBoolean(PreferKey.textFullJustify, true)
val textBottomJustify get() = App.INSTANCE.getPrefBoolean(PreferKey.textBottomJustify, true)
var bodyIndentCount = App.INSTANCE.getPrefInt(PreferKey.bodyIndent, 2) var bodyIndentCount = App.INSTANCE.getPrefInt(PreferKey.bodyIndent, 2)
set(value) { set(value) {
field = value field = value

@ -111,7 +111,8 @@ class MoreConfigDialog : DialogFragment() {
Help.setOrientation(it) Help.setOrientation(it)
} }
} }
PreferKey.textFullJustify -> { PreferKey.textFullJustify,
PreferKey.textBottomJustify -> {
postEvent(EventBus.UP_CONFIG, true) postEvent(EventBus.UP_CONFIG, true)
} }
} }

@ -4,6 +4,7 @@ import android.text.Layout
import android.text.StaticLayout import android.text.StaticLayout
import io.legado.app.App import io.legado.app.App
import io.legado.app.R import io.legado.app.R
import io.legado.app.help.ReadBookConfig
import io.legado.app.ui.book.read.page.ChapterProvider import io.legado.app.ui.book.read.page.ChapterProvider
import java.text.DecimalFormat import java.text.DecimalFormat
@ -19,6 +20,7 @@ data class TextPage(
) { ) {
fun upLinesPosition() = ChapterProvider.apply { fun upLinesPosition() = ChapterProvider.apply {
if (!ReadBookConfig.textBottomJustify) return@apply
if (textLines.size <= 1) return@apply if (textLines.size <= 1) return@apply
if (visibleHeight - height >= with(textLines.last()) { lineBottom - lineTop }) return@apply if (visibleHeight - height >= with(textLines.last()) { lineBottom - lineTop }) return@apply
val surplus = (visibleBottom - textLines.last().lineBottom) val surplus = (visibleBottom - textLines.last().lineBottom)

@ -705,4 +705,5 @@
<string name="import_old_summary">選擇舊版備份文件夾</string> <string name="import_old_summary">選擇舊版備份文件夾</string>
<string name="enabled">已啓用</string> <string name="enabled">已啓用</string>
<string name="disabled">已禁用</string> <string name="disabled">已禁用</string>
<string name="text_bottom_justify">文字底部對齊</string>
</resources> </resources>

@ -705,5 +705,6 @@
<string name="import_old_summary">選擇舊版備份文件夾</string> <string name="import_old_summary">選擇舊版備份文件夾</string>
<string name="enabled">已啓用</string> <string name="enabled">已啓用</string>
<string name="disabled">已禁用</string> <string name="disabled">已禁用</string>
<string name="text_bottom_justify">文字底部對齊</string>
</resources> </resources>

@ -698,6 +698,7 @@
<string name="night_navbar_color">夜间,底栏色</string> <string name="night_navbar_color">夜间,底栏色</string>
<string name="auto_change_source">自动换源</string> <string name="auto_change_source">自动换源</string>
<string name="text_full_justify">文字两端对齐</string> <string name="text_full_justify">文字两端对齐</string>
<string name="text_bottom_justify">文字底部对齐</string>
<string name="auto_page_speed">自动翻页速度</string> <string name="auto_page_speed">自动翻页速度</string>
<string name="sort_by_url">地址排序</string> <string name="sort_by_url">地址排序</string>
<string name="backup_summary">本地和WebDav一起备份</string> <string name="backup_summary">本地和WebDav一起备份</string>

@ -42,6 +42,12 @@
android:key="textFullJustify" android:key="textFullJustify"
app:iconSpaceReserved="false" /> app:iconSpaceReserved="false" />
<io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="true"
android:title="@string/text_bottom_justify"
android:key="textBottomJustify"
app:iconSpaceReserved="false" />
<io.legado.app.ui.widget.prefs.SwitchPreference <io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="true" android:defaultValue="true"
android:title="@string/volume_key_page" android:title="@string/volume_key_page"

Loading…
Cancel
Save