|
|
@ -6,6 +6,7 @@ import android.graphics.drawable.ColorDrawable |
|
|
|
import android.graphics.drawable.Drawable |
|
|
|
import android.graphics.drawable.Drawable |
|
|
|
import io.legado.app.App |
|
|
|
import io.legado.app.App |
|
|
|
import io.legado.app.R |
|
|
|
import io.legado.app.R |
|
|
|
|
|
|
|
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.ChapterProvider |
|
|
|
import io.legado.app.ui.book.read.page.ChapterProvider |
|
|
|
import io.legado.app.utils.* |
|
|
|
import io.legado.app.utils.* |
|
|
@ -23,12 +24,19 @@ object ReadBookConfig { |
|
|
|
val json = String(App.INSTANCE.assets.open(readConfigFileName).readBytes()) |
|
|
|
val json = String(App.INSTANCE.assets.open(readConfigFileName).readBytes()) |
|
|
|
GSON.fromJsonArray<Config>(json)!! |
|
|
|
GSON.fromJsonArray<Config>(json)!! |
|
|
|
} |
|
|
|
} |
|
|
|
val durConfig |
|
|
|
val durConfig get() = getConfig(styleSelect) |
|
|
|
get() = getConfig(styleSelect) |
|
|
|
private val shareConfig get() = getConfig(5) |
|
|
|
|
|
|
|
|
|
|
|
var styleSelect |
|
|
|
var styleSelect = App.INSTANCE.getPrefInt(PreferKey.readStyleSelect) |
|
|
|
get() = App.INSTANCE.getPrefInt("readStyleSelect") |
|
|
|
set(value) { |
|
|
|
set(value) = App.INSTANCE.putPrefInt("readStyleSelect", value) |
|
|
|
field = value |
|
|
|
|
|
|
|
App.INSTANCE.putPrefInt(PreferKey.readStyleSelect, value) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
var shareLayout = App.INSTANCE.getPrefBoolean(PreferKey.shareLayout) |
|
|
|
|
|
|
|
set(value) { |
|
|
|
|
|
|
|
field = value |
|
|
|
|
|
|
|
App.INSTANCE.putPrefBoolean(PreferKey.shareLayout) |
|
|
|
|
|
|
|
} |
|
|
|
var bg: Drawable? = null |
|
|
|
var bg: Drawable? = null |
|
|
|
|
|
|
|
|
|
|
|
init { |
|
|
|
init { |
|
|
@ -40,6 +48,9 @@ object ReadBookConfig { |
|
|
|
if (configList.size < 5) { |
|
|
|
if (configList.size < 5) { |
|
|
|
resetAll() |
|
|
|
resetAll() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (configList.size < 6) { |
|
|
|
|
|
|
|
configList.add(Config()) |
|
|
|
|
|
|
|
} |
|
|
|
return configList[index] |
|
|
|
return configList[index] |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -94,7 +105,106 @@ object ReadBookConfig { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
data class Config( |
|
|
|
//配置写入读取 |
|
|
|
|
|
|
|
var textBold: Boolean |
|
|
|
|
|
|
|
get() = if (shareLayout) shareConfig.textBold else durConfig.textBold |
|
|
|
|
|
|
|
set(value) = if (shareLayout) shareConfig.textBold = value else durConfig.textBold = value |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var textSize: Int |
|
|
|
|
|
|
|
get() = if (shareLayout) shareConfig.textSize else durConfig.textSize |
|
|
|
|
|
|
|
set(value) = if (shareLayout) shareConfig.textSize = value else durConfig.textSize = value |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var letterSpacing: Float |
|
|
|
|
|
|
|
get() = if (shareLayout) shareConfig.letterSpacing else durConfig.letterSpacing |
|
|
|
|
|
|
|
set(value) = |
|
|
|
|
|
|
|
if (shareLayout) shareConfig.letterSpacing = value else durConfig.letterSpacing = value |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var lineSpacingExtra: Int |
|
|
|
|
|
|
|
get() = if (shareLayout) shareConfig.lineSpacingExtra else durConfig.lineSpacingExtra |
|
|
|
|
|
|
|
set(value) = |
|
|
|
|
|
|
|
if (shareLayout) shareConfig.lineSpacingExtra = value |
|
|
|
|
|
|
|
else durConfig.lineSpacingExtra = value |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var paragraphSpacing: Int |
|
|
|
|
|
|
|
get() = if (shareLayout) shareConfig.paragraphSpacing else durConfig.paragraphSpacing |
|
|
|
|
|
|
|
set(value) = |
|
|
|
|
|
|
|
if (shareLayout) shareConfig.paragraphSpacing = value |
|
|
|
|
|
|
|
else durConfig.paragraphSpacing = value |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var titleCenter: Boolean |
|
|
|
|
|
|
|
get() = if (shareLayout) shareConfig.titleCenter else durConfig.titleCenter |
|
|
|
|
|
|
|
set(value) = |
|
|
|
|
|
|
|
if (shareLayout) shareConfig.titleCenter = value else durConfig.titleCenter = value |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var paddingBottom: Int |
|
|
|
|
|
|
|
get() = if (shareLayout) shareConfig.paddingBottom else durConfig.paddingBottom |
|
|
|
|
|
|
|
set(value) = |
|
|
|
|
|
|
|
if (shareLayout) shareConfig.paddingBottom = value else durConfig.paddingBottom = value |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var paddingLeft: Int |
|
|
|
|
|
|
|
get() = if (shareLayout) shareConfig.paddingLeft else durConfig.paddingLeft |
|
|
|
|
|
|
|
set(value) = |
|
|
|
|
|
|
|
if (shareLayout) shareConfig.paddingLeft = value else durConfig.paddingLeft = value |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var paddingRight: Int |
|
|
|
|
|
|
|
get() = if (shareLayout) shareConfig.paddingRight else durConfig.paddingRight |
|
|
|
|
|
|
|
set(value) = |
|
|
|
|
|
|
|
if (shareLayout) shareConfig.paddingRight = value else durConfig.paddingRight = value |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var paddingTop: Int |
|
|
|
|
|
|
|
get() = if (shareLayout) shareConfig.paddingTop else durConfig.paddingTop |
|
|
|
|
|
|
|
set(value) = |
|
|
|
|
|
|
|
if (shareLayout) shareConfig.paddingTop = value else durConfig.paddingTop = value |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var headerPaddingBottom: Int |
|
|
|
|
|
|
|
get() = if (shareLayout) shareConfig.headerPaddingBottom else durConfig.headerPaddingBottom |
|
|
|
|
|
|
|
set(value) = |
|
|
|
|
|
|
|
if (shareLayout) shareConfig.headerPaddingBottom = value |
|
|
|
|
|
|
|
else durConfig.headerPaddingBottom = value |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var headerPaddingLeft: Int |
|
|
|
|
|
|
|
get() = if (shareLayout) shareConfig.headerPaddingLeft else durConfig.headerPaddingLeft |
|
|
|
|
|
|
|
set(value) = |
|
|
|
|
|
|
|
if (shareLayout) shareConfig.headerPaddingLeft = value |
|
|
|
|
|
|
|
else durConfig.headerPaddingLeft = value |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var headerPaddingRight: Int |
|
|
|
|
|
|
|
get() = if (shareLayout) shareConfig.headerPaddingRight else durConfig.headerPaddingRight |
|
|
|
|
|
|
|
set(value) = |
|
|
|
|
|
|
|
if (shareLayout) shareConfig.headerPaddingRight = value |
|
|
|
|
|
|
|
else durConfig.headerPaddingRight = value |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var headerPaddingTop: Int |
|
|
|
|
|
|
|
get() = if (shareLayout) shareConfig.headerPaddingTop else durConfig.headerPaddingTop |
|
|
|
|
|
|
|
set(value) = |
|
|
|
|
|
|
|
if (shareLayout) shareConfig.headerPaddingTop = value |
|
|
|
|
|
|
|
else durConfig.headerPaddingTop = value |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var footerPaddingBottom: Int |
|
|
|
|
|
|
|
get() = if (shareLayout) shareConfig.footerPaddingBottom else durConfig.footerPaddingBottom |
|
|
|
|
|
|
|
set(value) = |
|
|
|
|
|
|
|
if (shareLayout) shareConfig.footerPaddingBottom = value |
|
|
|
|
|
|
|
else durConfig.footerPaddingBottom = value |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var footerPaddingLeft: Int |
|
|
|
|
|
|
|
get() = if (shareLayout) shareConfig.footerPaddingLeft else durConfig.footerPaddingLeft |
|
|
|
|
|
|
|
set(value) = |
|
|
|
|
|
|
|
if (shareLayout) shareConfig.footerPaddingLeft = value |
|
|
|
|
|
|
|
else durConfig.footerPaddingLeft = value |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var footerPaddingRight: Int |
|
|
|
|
|
|
|
get() = if (shareLayout) shareConfig.footerPaddingRight else durConfig.footerPaddingRight |
|
|
|
|
|
|
|
set(value) = |
|
|
|
|
|
|
|
if (shareLayout) shareConfig.footerPaddingRight = value |
|
|
|
|
|
|
|
else durConfig.footerPaddingRight = value |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var footerPaddingTop: Int |
|
|
|
|
|
|
|
get() = if (shareLayout) shareConfig.footerPaddingTop else durConfig.footerPaddingTop |
|
|
|
|
|
|
|
set(value) = |
|
|
|
|
|
|
|
if (shareLayout) shareConfig.footerPaddingTop = value |
|
|
|
|
|
|
|
else durConfig.footerPaddingTop = value |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Config( |
|
|
|
var bgStr: String = "#EEEEEE",//白天背景 |
|
|
|
var bgStr: String = "#EEEEEE",//白天背景 |
|
|
|
var bgStrNight: String = "#000000",//夜间背景 |
|
|
|
var bgStrNight: String = "#000000",//夜间背景 |
|
|
|
var bgType: Int = 0,//白天背景类型 |
|
|
|
var bgType: Int = 0,//白天背景类型 |
|
|
@ -138,7 +248,7 @@ object ReadBookConfig { |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
textColor = "#${color.hexString}" |
|
|
|
textColor = "#${color.hexString}" |
|
|
|
} |
|
|
|
} |
|
|
|
ChapterProvider.upStyle(this) |
|
|
|
ChapterProvider.upStyle() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun setStatusIconDark(isDark: Boolean) { |
|
|
|
fun setStatusIconDark(isDark: Boolean) { |
|
|
|