pull/414/head
gedoor 4 years ago
parent 79dbcd5ec3
commit 50c0090d80
  1. 2
      app/src/main/java/io/legado/app/constant/PreferKey.kt
  2. 4
      app/src/main/java/io/legado/app/help/BookHelp.kt
  3. 16
      app/src/main/java/io/legado/app/help/ReadBookConfig.kt
  4. 2
      app/src/main/java/io/legado/app/help/storage/Restore.kt
  5. 2
      app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt
  6. 2
      app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt

@ -21,7 +21,6 @@ object PreferKey {
const val processText = "process_text" const val processText = "process_text"
const val cleanCache = "cleanCache" const val cleanCache = "cleanCache"
const val saveTabPosition = "saveTabPosition" const val saveTabPosition = "saveTabPosition"
const val pageAnim = "pageAnim"
const val fontFolder = "fontFolder" const val fontFolder = "fontFolder"
const val backupPath = "backupUri" const val backupPath = "backupUri"
const val restoreIgnore = "restoreIgnore" const val restoreIgnore = "restoreIgnore"
@ -40,7 +39,6 @@ object PreferKey {
const val launcherIcon = "launcherIcon" const val launcherIcon = "launcherIcon"
const val textSelectAble = "selectText" const val textSelectAble = "selectText"
const val lastBackup = "lastBackup" const val lastBackup = "lastBackup"
const val bodyIndent = "textIndent"
const val shareLayout = "shareLayout" const val shareLayout = "shareLayout"
const val readStyleSelect = "readStyleSelect" const val readStyleSelect = "readStyleSelect"
const val systemTypefaces = "system_typefaces" const val systemTypefaces = "system_typefaces"

@ -327,10 +327,10 @@ object BookHelp {
if (contents.isEmpty()) { if (contents.isEmpty()) {
contents.add(title) contents.add(title)
if (str != title && it.isNotEmpty()) { if (str != title && it.isNotEmpty()) {
contents.add("${ReadBookConfig.bodyIndent}$str") contents.add("${ReadBookConfig.paragraphIndent}$str")
} }
} else if (str.isNotEmpty()) { } else if (str.isNotEmpty()) {
contents.add("${ReadBookConfig.bodyIndent}$str") contents.add("${ReadBookConfig.paragraphIndent}$str")
} }
} }
return contents return contents

@ -162,15 +162,6 @@ object ReadBookConfig {
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) val textBottomJustify get() = App.INSTANCE.getPrefBoolean(PreferKey.textBottomJustify, true)
var bodyIndentCount = App.INSTANCE.getPrefInt(PreferKey.bodyIndent, 2)
set(value) {
field = value
bodyIndent = " ".repeat(value)
if (App.INSTANCE.getPrefInt(PreferKey.bodyIndent, 2) != value) {
App.INSTANCE.putPrefInt(PreferKey.bodyIndent, value)
}
}
var bodyIndent = " ".repeat(bodyIndentCount)
var hideStatusBar = App.INSTANCE.getPrefBoolean(PreferKey.hideStatusBar) var hideStatusBar = App.INSTANCE.getPrefBoolean(PreferKey.hideStatusBar)
var hideNavigationBar = App.INSTANCE.getPrefBoolean(PreferKey.hideNavigationBar) var hideNavigationBar = App.INSTANCE.getPrefBoolean(PreferKey.hideNavigationBar)
@ -242,6 +233,12 @@ object ReadBookConfig {
config.titleBottomSpacing = value config.titleBottomSpacing = value
} }
var paragraphIndent: String
get() = config.paragraphIndent
set(value) {
config.paragraphIndent = value
}
var paddingBottom: Int var paddingBottom: Int
get() = config.paddingBottom get() = config.paddingBottom
set(value) { set(value) {
@ -392,6 +389,7 @@ object ReadBookConfig {
var titleSize: Int = 0, var titleSize: Int = 0,
var titleTopSpacing: Int = 0, var titleTopSpacing: Int = 0,
var titleBottomSpacing: Int = 0, var titleBottomSpacing: Int = 0,
var paragraphIndent: String = "  ",//段落缩进
var paddingBottom: Int = 6, var paddingBottom: Int = 6,
var paddingLeft: Int = 16, var paddingLeft: Int = 16,
var paddingRight: Int = 16, var paddingRight: Int = 16,

@ -63,7 +63,6 @@ object Restore {
PreferKey.shareLayout, PreferKey.shareLayout,
PreferKey.hideStatusBar, PreferKey.hideStatusBar,
PreferKey.hideNavigationBar, PreferKey.hideNavigationBar,
PreferKey.bodyIndent,
PreferKey.autoReadSpeed PreferKey.autoReadSpeed
) )
@ -216,7 +215,6 @@ object Restore {
shareLayout = App.INSTANCE.getPrefBoolean(PreferKey.shareLayout) shareLayout = App.INSTANCE.getPrefBoolean(PreferKey.shareLayout)
hideStatusBar = App.INSTANCE.getPrefBoolean(PreferKey.hideStatusBar) hideStatusBar = App.INSTANCE.getPrefBoolean(PreferKey.hideStatusBar)
hideNavigationBar = App.INSTANCE.getPrefBoolean(PreferKey.hideNavigationBar) hideNavigationBar = App.INSTANCE.getPrefBoolean(PreferKey.hideNavigationBar)
bodyIndentCount = App.INSTANCE.getPrefInt(PreferKey.bodyIndent, 2)
autoReadSpeed = App.INSTANCE.getPrefInt(PreferKey.autoReadSpeed, 46) autoReadSpeed = App.INSTANCE.getPrefInt(PreferKey.autoReadSpeed, 46)
} }
ChapterProvider.upStyle() ChapterProvider.upStyle()

@ -126,7 +126,7 @@ class ReadStyleDialog : BaseDialogFragment(), FontSelectDialog.CallBack {
title = getString(R.string.text_indent), title = getString(R.string.text_indent),
items = resources.getStringArray(R.array.indent).toList() items = resources.getStringArray(R.array.indent).toList()
) { _, index -> ) { _, index ->
ReadBookConfig.bodyIndentCount = index ReadBookConfig.paragraphIndent = " ".repeat(index)
postEvent(EventBus.UP_CONFIG, true) postEvent(EventBus.UP_CONFIG, true)
} }
} }

@ -272,7 +272,7 @@ object ChapterProvider {
) )
return return
} }
val bodyIndent = ReadBookConfig.bodyIndent val bodyIndent = ReadBookConfig.paragraphIndent
val icw = StaticLayout.getDesiredWidth(bodyIndent, textPaint) / bodyIndent.length val icw = StaticLayout.getDesiredWidth(bodyIndent, textPaint) / bodyIndent.length
bodyIndent.toStringArray().forEach { bodyIndent.toStringArray().forEach {
val x1 = x + icw val x1 = x + icw

Loading…
Cancel
Save