|
@@ -46,16 +46,13 @@ object ReadBookConfig {
|
|
|
val configFilePath = FileUtils.getPath(appCtx.filesDir, configFileName)
|
|
val configFilePath = FileUtils.getPath(appCtx.filesDir, configFileName)
|
|
|
val shareConfigFilePath = FileUtils.getPath(appCtx.filesDir, shareConfigFileName)
|
|
val shareConfigFilePath = FileUtils.getPath(appCtx.filesDir, shareConfigFileName)
|
|
|
val configList: ArrayList<Config> = arrayListOf()
|
|
val configList: ArrayList<Config> = arrayListOf()
|
|
|
- lateinit var shareConfig: Config
|
|
|
|
|
var durConfig
|
|
var durConfig
|
|
|
get() = getConfig(styleSelect)
|
|
get() = getConfig(styleSelect)
|
|
|
set(value) {
|
|
set(value) {
|
|
|
configList[styleSelect] = value
|
|
configList[styleSelect] = value
|
|
|
- if (shareLayout) {
|
|
|
|
|
- shareConfig = value
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
var isComic: Boolean = false
|
|
var isComic: Boolean = false
|
|
|
var bg: Drawable? = null
|
|
var bg: Drawable? = null
|
|
|
var bgMeanColor: Int = 0
|
|
var bgMeanColor: Int = 0
|
|
@@ -64,7 +61,6 @@ object ReadBookConfig {
|
|
|
|
|
|
|
|
init {
|
|
init {
|
|
|
initConfigs()
|
|
initConfigs()
|
|
|
- initShareConfig()
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Synchronized
|
|
@Synchronized
|
|
@@ -92,20 +88,6 @@ object ReadBookConfig {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- fun initShareConfig() {
|
|
|
|
|
- val configFile = File(shareConfigFilePath)
|
|
|
|
|
- var c: Config? = null
|
|
|
|
|
- if (configFile.exists()) {
|
|
|
|
|
- try {
|
|
|
|
|
- val json = configFile.readText()
|
|
|
|
|
- c = GSON.fromJsonObject<Config>(json).getOrThrow()
|
|
|
|
|
- } catch (e: Exception) {
|
|
|
|
|
- e.printOnDebug()
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- shareConfig = c ?: configList.getOrNull(5) ?: Config()
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
fun upBg(width: Int, height: Int) {
|
|
fun upBg(width: Int, height: Int) {
|
|
|
val drawable = durConfig.curBgDrawable(width, height)
|
|
val drawable = durConfig.curBgDrawable(width, height)
|
|
|
if (drawable is BitmapDrawable && drawable.bitmap != null) {
|
|
if (drawable is BitmapDrawable && drawable.bitmap != null) {
|
|
@@ -125,10 +107,6 @@ object ReadBookConfig {
|
|
|
FileUtils.delete(configFilePath)
|
|
FileUtils.delete(configFilePath)
|
|
|
FileUtils.createFileIfNotExist(configFilePath).writeText(it)
|
|
FileUtils.createFileIfNotExist(configFilePath).writeText(it)
|
|
|
}
|
|
}
|
|
|
- GSON.toJson(shareConfig).let {
|
|
|
|
|
- FileUtils.delete(shareConfigFilePath)
|
|
|
|
|
- FileUtils.createFileIfNotExist(shareConfigFilePath).writeText(it)
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -202,13 +180,6 @@ object ReadBookConfig {
|
|
|
appCtx.putPrefInt(PreferKey.comicStyleSelect, value)
|
|
appCtx.putPrefInt(PreferKey.comicStyleSelect, value)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- var shareLayout = appCtx.getPrefBoolean(PreferKey.shareLayout)
|
|
|
|
|
- set(value) {
|
|
|
|
|
- field = value
|
|
|
|
|
- if (appCtx.getPrefBoolean(PreferKey.shareLayout) != value) {
|
|
|
|
|
- appCtx.putPrefBoolean(PreferKey.shareLayout, value)
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 两端对齐
|
|
* 两端对齐
|
|
@@ -223,7 +194,7 @@ object ReadBookConfig {
|
|
|
var hideNavigationBar = appCtx.getPrefBoolean(PreferKey.hideNavigationBar)
|
|
var hideNavigationBar = appCtx.getPrefBoolean(PreferKey.hideNavigationBar)
|
|
|
var useZhLayout = appCtx.getPrefBoolean(PreferKey.useZhLayout)
|
|
var useZhLayout = appCtx.getPrefBoolean(PreferKey.useZhLayout)
|
|
|
|
|
|
|
|
- val config get() = if (shareLayout) shareConfig else durConfig
|
|
|
|
|
|
|
+ val config get() = durConfig
|
|
|
|
|
|
|
|
var bgAlpha: Int
|
|
var bgAlpha: Int
|
|
|
get() = config.bgAlpha
|
|
get() = config.bgAlpha
|
|
@@ -431,43 +402,7 @@ object ReadBookConfig {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
fun getExportConfig(): Config {
|
|
fun getExportConfig(): Config {
|
|
|
- val exportConfig = durConfig.copy()
|
|
|
|
|
- if (shareLayout) {
|
|
|
|
|
- exportConfig.textFont = shareConfig.textFont
|
|
|
|
|
- exportConfig.textBold = shareConfig.textBold
|
|
|
|
|
- exportConfig.textSize = shareConfig.textSize
|
|
|
|
|
- exportConfig.letterSpacing = shareConfig.letterSpacing
|
|
|
|
|
- exportConfig.lineSpacingExtra = shareConfig.lineSpacingExtra
|
|
|
|
|
- exportConfig.paragraphSpacing = shareConfig.paragraphSpacing
|
|
|
|
|
- exportConfig.titleMode = shareConfig.titleMode
|
|
|
|
|
- exportConfig.titleSize = shareConfig.titleSize
|
|
|
|
|
- exportConfig.titleTopSpacing = shareConfig.titleTopSpacing
|
|
|
|
|
- exportConfig.titleBottomSpacing = shareConfig.titleBottomSpacing
|
|
|
|
|
- exportConfig.paddingBottom = shareConfig.paddingBottom
|
|
|
|
|
- exportConfig.paddingLeft = shareConfig.paddingLeft
|
|
|
|
|
- exportConfig.paddingRight = shareConfig.paddingRight
|
|
|
|
|
- exportConfig.paddingTop = shareConfig.paddingTop
|
|
|
|
|
- exportConfig.headerPaddingBottom = shareConfig.headerPaddingBottom
|
|
|
|
|
- exportConfig.headerPaddingLeft = shareConfig.headerPaddingLeft
|
|
|
|
|
- exportConfig.headerPaddingRight = shareConfig.headerPaddingRight
|
|
|
|
|
- exportConfig.headerPaddingTop = shareConfig.headerPaddingTop
|
|
|
|
|
- exportConfig.footerPaddingBottom = shareConfig.footerPaddingBottom
|
|
|
|
|
- exportConfig.footerPaddingLeft = shareConfig.footerPaddingLeft
|
|
|
|
|
- exportConfig.footerPaddingRight = shareConfig.footerPaddingRight
|
|
|
|
|
- exportConfig.footerPaddingTop = shareConfig.footerPaddingTop
|
|
|
|
|
- exportConfig.showHeaderLine = shareConfig.showHeaderLine
|
|
|
|
|
- exportConfig.showFooterLine = shareConfig.showFooterLine
|
|
|
|
|
- exportConfig.tipHeaderLeft = shareConfig.tipHeaderLeft
|
|
|
|
|
- exportConfig.tipHeaderMiddle = shareConfig.tipHeaderMiddle
|
|
|
|
|
- exportConfig.tipHeaderRight = shareConfig.tipHeaderRight
|
|
|
|
|
- exportConfig.tipFooterLeft = shareConfig.tipFooterLeft
|
|
|
|
|
- exportConfig.tipFooterMiddle = shareConfig.tipFooterMiddle
|
|
|
|
|
- exportConfig.tipFooterRight = shareConfig.tipFooterRight
|
|
|
|
|
- exportConfig.tipColor = shareConfig.tipColor
|
|
|
|
|
- exportConfig.headerMode = shareConfig.headerMode
|
|
|
|
|
- exportConfig.footerMode = shareConfig.footerMode
|
|
|
|
|
- }
|
|
|
|
|
- return exportConfig
|
|
|
|
|
|
|
+ return durConfig.copy()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
fun import(byteArray: ByteArray): Config {
|
|
fun import(byteArray: ByteArray): Config {
|