pull/363/head
gedoor 4 years ago
parent c83f25f8e7
commit ed525a00ef
  1. 37
      app/src/main/java/io/legado/app/help/ReadBookConfig.kt
  2. 6
      app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt

@ -4,6 +4,7 @@ import android.graphics.Color
import android.graphics.drawable.BitmapDrawable import android.graphics.drawable.BitmapDrawable
import android.graphics.drawable.ColorDrawable import android.graphics.drawable.ColorDrawable
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import android.os.Parcelable
import androidx.annotation.Keep import androidx.annotation.Keep
import io.legado.app.App import io.legado.app.App
import io.legado.app.R import io.legado.app.R
@ -11,6 +12,7 @@ import io.legado.app.constant.PreferKey
import io.legado.app.help.coroutine.Coroutine import io.legado.app.help.coroutine.Coroutine
import io.legado.app.ui.book.read.page.provider.ChapterProvider import io.legado.app.ui.book.read.page.provider.ChapterProvider
import io.legado.app.utils.* import io.legado.app.utils.*
import kotlinx.android.parcel.Parcelize
import java.io.File import java.io.File
/** /**
@ -302,7 +304,40 @@ object ReadBookConfig {
config.showFooterLine = value config.showFooterLine = value
} }
fun getExportConfig(): Config {
val exportConfig = GSON.fromJsonObject<Config>(GSON.toJson(durConfig))!!
if (shareLayout) {
val shearConfig = getConfig(5)
exportConfig.textFont = shearConfig.textFont
exportConfig.textBold = shearConfig.textBold
exportConfig.textSize = shearConfig.textSize
exportConfig.letterSpacing = shearConfig.letterSpacing
exportConfig.lineSpacingExtra = shearConfig.lineSpacingExtra
exportConfig.paragraphSpacing = shearConfig.paragraphSpacing
exportConfig.titleMode = shearConfig.titleMode
exportConfig.titleSize = shearConfig.titleSize
exportConfig.titleTopSpacing = shearConfig.titleTopSpacing
exportConfig.titleBottomSpacing = shearConfig.titleBottomSpacing
exportConfig.paddingBottom = shearConfig.paddingBottom
exportConfig.paddingLeft = shearConfig.paddingLeft
exportConfig.paddingRight = shearConfig.paddingRight
exportConfig.paddingTop = shearConfig.paddingTop
exportConfig.headerPaddingBottom = shearConfig.headerPaddingBottom
exportConfig.headerPaddingLeft = shearConfig.headerPaddingLeft
exportConfig.headerPaddingRight = shearConfig.headerPaddingRight
exportConfig.headerPaddingTop = shearConfig.headerPaddingTop
exportConfig.footerPaddingBottom = shearConfig.footerPaddingBottom
exportConfig.footerPaddingLeft = shearConfig.footerPaddingLeft
exportConfig.footerPaddingRight = shearConfig.footerPaddingRight
exportConfig.footerPaddingTop = shearConfig.footerPaddingTop
exportConfig.showHeaderLine = shearConfig.showHeaderLine
exportConfig.showFooterLine = shearConfig.showFooterLine
}
return exportConfig
}
@Keep @Keep
@Parcelize
class Config( class Config(
private var bgStr: String = "#EEEEEE",//白天背景 private var bgStr: String = "#EEEEEE",//白天背景
private var bgStrNight: String = "#000000",//夜间背景 private var bgStrNight: String = "#000000",//夜间背景
@ -340,7 +375,7 @@ object ReadBookConfig {
var footerPaddingTop: Int = 6, var footerPaddingTop: Int = 6,
var showHeaderLine: Boolean = false, var showHeaderLine: Boolean = false,
var showFooterLine: Boolean = true, var showFooterLine: Boolean = true,
) { ) : Parcelable {
fun setBg(bgType: Int, bg: String) { fun setBg(bgType: Int, bg: String) {
when { when {
AppConfig.isEInkMode -> { AppConfig.isEInkMode -> {

@ -219,7 +219,7 @@ class BgTextConfigDialog : BaseDialogFragment(), FileChooserDialog.CallBack {
val configExportPath = FileUtils.getPath(configDir, "readConfig.json") val configExportPath = FileUtils.getPath(configDir, "readConfig.json")
FileUtils.deleteFile(configExportPath) FileUtils.deleteFile(configExportPath)
val configExportFile = FileUtils.createFileIfNotExist(configExportPath) val configExportFile = FileUtils.createFileIfNotExist(configExportPath)
configExportFile.writeText(GSON.toJson(ReadBookConfig.durConfig)) configExportFile.writeText(GSON.toJson(ReadBookConfig.getExportConfig()))
exportFiles.add(configExportFile) exportFiles.add(configExportFile)
val fontPath = ReadBookConfig.textFont val fontPath = ReadBookConfig.textFont
if (fontPath.isNotEmpty()) { if (fontPath.isNotEmpty()) {
@ -324,7 +324,9 @@ class BgTextConfigDialog : BaseDialogFragment(), FileChooserDialog.CallBack {
if (config.bgType() == 2) { if (config.bgType() == 2) {
val bgName = FileUtils.getName(config.bgStr()) val bgName = FileUtils.getName(config.bgStr())
val bgPath = FileUtils.getPath(requireContext().externalFilesDir, "bg", bgName) val bgPath = FileUtils.getPath(requireContext().externalFilesDir, "bg", bgName)
FileUtils.getFile(configDir, bgName).copyTo(File(bgPath)) if (!FileUtils.exist(bgPath)) {
FileUtils.getFile(configDir, bgName).copyTo(File(bgPath))
}
} }
ReadBookConfig.durConfig = config ReadBookConfig.durConfig = config
postEvent(EventBus.UP_CONFIG, true) postEvent(EventBus.UP_CONFIG, true)

Loading…
Cancel
Save