|
|
@@ -45,13 +45,16 @@ object ReadBookConfig {
|
|
|
val configFilePath = FileUtils.getPath(appCtx.filesDir, configFileName)
|
|
|
val shareConfigFilePath = FileUtils.getPath(appCtx.filesDir, shareConfigFileName)
|
|
|
val configList: ArrayList<Config> = arrayListOf()
|
|
|
+ lateinit var shareConfig: Config
|
|
|
var durConfig
|
|
|
get() = getConfig(styleSelect)
|
|
|
set(value) {
|
|
|
configList[styleSelect] = value
|
|
|
+ if (shareLayout) {
|
|
|
+ shareConfig = value
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
-
|
|
|
var isComic: Boolean = false
|
|
|
var bg: Drawable? = null
|
|
|
var bgMeanColor: Int = 0
|
|
|
@@ -60,6 +63,7 @@ object ReadBookConfig {
|
|
|
|
|
|
init {
|
|
|
initConfigs()
|
|
|
+ initShareConfig()
|
|
|
}
|
|
|
|
|
|
@Synchronized
|
|
|
@@ -87,6 +91,20 @@ 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) {
|
|
|
val drawable = durConfig.curBgDrawable(width, height)
|
|
|
if (drawable is BitmapDrawable && drawable.bitmap != null) {
|
|
|
@@ -106,6 +124,10 @@ object ReadBookConfig {
|
|
|
FileUtils.delete(configFilePath)
|
|
|
FileUtils.createFileIfNotExist(configFilePath).writeText(it)
|
|
|
}
|
|
|
+ GSON.toJson(shareConfig).let {
|
|
|
+ FileUtils.delete(shareConfigFilePath)
|
|
|
+ FileUtils.createFileIfNotExist(shareConfigFilePath).writeText(it)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -179,6 +201,13 @@ object ReadBookConfig {
|
|
|
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)
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 两端对齐
|
|
|
@@ -193,7 +222,7 @@ object ReadBookConfig {
|
|
|
var hideNavigationBar = appCtx.getPrefBoolean(PreferKey.hideNavigationBar)
|
|
|
var useZhLayout = appCtx.getPrefBoolean(PreferKey.useZhLayout)
|
|
|
|
|
|
- val config get() = durConfig
|
|
|
+ val config get() = if (shareLayout) shareConfig else durConfig
|
|
|
|
|
|
var bgAlpha: Int
|
|
|
get() = config.bgAlpha
|
|
|
@@ -437,7 +466,43 @@ object ReadBookConfig {
|
|
|
}
|
|
|
|
|
|
fun getExportConfig(): Config {
|
|
|
- return durConfig.copy()
|
|
|
+ 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
|
|
|
}
|
|
|
|
|
|
fun import(byteArray: ByteArray): Config {
|