移除共享布局
This commit is contained in:
@@ -46,16 +46,13 @@ 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
|
||||
@@ -64,7 +61,6 @@ object ReadBookConfig {
|
||||
|
||||
init {
|
||||
initConfigs()
|
||||
initShareConfig()
|
||||
}
|
||||
|
||||
@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) {
|
||||
val drawable = durConfig.curBgDrawable(width, height)
|
||||
if (drawable is BitmapDrawable && drawable.bitmap != null) {
|
||||
@@ -125,10 +107,6 @@ object ReadBookConfig {
|
||||
FileUtils.delete(configFilePath)
|
||||
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)
|
||||
}
|
||||
}
|
||||
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 useZhLayout = appCtx.getPrefBoolean(PreferKey.useZhLayout)
|
||||
|
||||
val config get() = if (shareLayout) shareConfig else durConfig
|
||||
val config get() = durConfig
|
||||
|
||||
var bgAlpha: Int
|
||||
get() = config.bgAlpha
|
||||
@@ -431,43 +402,7 @@ object ReadBookConfig {
|
||||
}
|
||||
|
||||
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 {
|
||||
|
||||
@@ -29,6 +29,8 @@ import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
import java.util.concurrent.TimeUnit
|
||||
import kotlin.coroutines.coroutineContext
|
||||
import androidx.core.content.edit
|
||||
import androidx.core.net.toUri
|
||||
|
||||
/**
|
||||
* 备份
|
||||
@@ -144,10 +146,6 @@ object Backup {
|
||||
FileUtils.createFileIfNotExist(backupPath + File.separator + ReadBookConfig.configFileName)
|
||||
.writeText(it)
|
||||
}
|
||||
GSON.toJson(ReadBookConfig.shareConfig).let {
|
||||
FileUtils.createFileIfNotExist(backupPath + File.separator + ReadBookConfig.shareConfigFileName)
|
||||
.writeText(it)
|
||||
}
|
||||
GSON.toJson(ThemeConfig.configList).let {
|
||||
FileUtils.createFileIfNotExist(backupPath + File.separator + ThemeConfig.configFileName)
|
||||
.writeText(it)
|
||||
@@ -158,27 +156,27 @@ object Backup {
|
||||
}
|
||||
coroutineContext.ensureActive()
|
||||
appCtx.getSharedPreferences(backupPath, "config")?.let { sp ->
|
||||
val edit = sp.edit()
|
||||
appCtx.defaultSharedPreferences.all.forEach { (key, value) ->
|
||||
if (BackupConfig.keyIsNotIgnore(key)) {
|
||||
when (key) {
|
||||
PreferKey.webDavPassword -> {
|
||||
edit.putString(key, aes.runCatching {
|
||||
encryptBase64(value.toString())
|
||||
}.getOrDefault(value.toString()))
|
||||
}
|
||||
sp.edit(commit = true) {
|
||||
appCtx.defaultSharedPreferences.all.forEach { (key, value) ->
|
||||
if (BackupConfig.keyIsNotIgnore(key)) {
|
||||
when (key) {
|
||||
PreferKey.webDavPassword -> {
|
||||
putString(key, aes.runCatching {
|
||||
encryptBase64(value.toString())
|
||||
}.getOrDefault(value.toString()))
|
||||
}
|
||||
|
||||
else -> when (value) {
|
||||
is Int -> edit.putInt(key, value)
|
||||
is Boolean -> edit.putBoolean(key, value)
|
||||
is Long -> edit.putLong(key, value)
|
||||
is Float -> edit.putFloat(key, value)
|
||||
is String -> edit.putString(key, value)
|
||||
else -> when (value) {
|
||||
is Int -> putInt(key, value)
|
||||
is Boolean -> putBoolean(key, value)
|
||||
is Long -> putLong(key, value)
|
||||
is Float -> putFloat(key, value)
|
||||
is String -> putString(key, value)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
edit.commit()
|
||||
}
|
||||
coroutineContext.ensureActive()
|
||||
val zipFileName = getNowZipFileName()
|
||||
@@ -200,7 +198,7 @@ object Backup {
|
||||
}
|
||||
|
||||
path.isContentScheme() -> {
|
||||
copyBackup(context, Uri.parse(path), backupFileName)
|
||||
copyBackup(context, path.toUri(), backupFileName)
|
||||
}
|
||||
|
||||
else -> {
|
||||
|
||||
@@ -228,7 +228,6 @@ object Restore {
|
||||
}?.runCatching {
|
||||
FileUtils.delete(ReadBookConfig.shareConfigFilePath)
|
||||
copyTo(File(ReadBookConfig.shareConfigFilePath))
|
||||
ReadBookConfig.initShareConfig()
|
||||
}?.onFailure {
|
||||
AppLog.put("恢复阅读界面出错\n${it.localizedMessage}", it)
|
||||
}
|
||||
@@ -269,7 +268,6 @@ object Restore {
|
||||
ReadBookConfig.apply {
|
||||
comicStyleSelect = appCtx.getPrefInt(PreferKey.comicStyleSelect)
|
||||
readStyleSelect = appCtx.getPrefInt(PreferKey.readStyleSelect)
|
||||
shareLayout = appCtx.getPrefBoolean(PreferKey.shareLayout)
|
||||
hideStatusBar = appCtx.getPrefBoolean(PreferKey.hideStatusBar)
|
||||
hideNavigationBar = appCtx.getPrefBoolean(PreferKey.hideNavigationBar)
|
||||
autoReadSpeed = appCtx.getPrefInt(PreferKey.autoReadSpeed, 46)
|
||||
|
||||
@@ -76,7 +76,6 @@ class ReadStyleDialog : BaseBottomSheetDialogFragment(R.layout.dialog_read_book_
|
||||
}
|
||||
|
||||
private fun initData() {
|
||||
binding.cbShareLayout.isChecked = ReadBookConfig.shareLayout
|
||||
upView()
|
||||
styleAdapter.setItems(ReadBookConfig.configList)
|
||||
}
|
||||
@@ -132,12 +131,6 @@ class ReadStyleDialog : BaseBottomSheetDialogFragment(R.layout.dialog_read_book_
|
||||
ReadBook.loadContent(false)
|
||||
}
|
||||
|
||||
cbShareLayout.setOnCheckedChangeListener { _, isChecked ->
|
||||
ReadBookConfig.shareLayout = isChecked
|
||||
upView()
|
||||
postEvent(EventBus.UP_CONFIG, arrayListOf(1, 2, 5))
|
||||
}
|
||||
|
||||
dsbTextSize.onChanged = {
|
||||
ReadBookConfig.textSize = it + 5
|
||||
postEvent(EventBus.UP_CONFIG, arrayListOf(8, 5))
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
android:id="@+id/scrollView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="24dp"
|
||||
app:layout_constraintTop_toBottomOf="@id/tool_bar">
|
||||
|
||||
<io.legato.kazusa.ui.widget.text.TextInputLayout
|
||||
|
||||
@@ -242,14 +242,6 @@
|
||||
android:textSize="12sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<com.google.android.material.checkbox.MaterialCheckBox
|
||||
android:id="@+id/cb_share_layout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="20dp"
|
||||
android:text="@string/share_layout"
|
||||
android:layout_marginStart="6dp"
|
||||
android:layout_marginEnd="16dp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
|
||||
Reference in New Issue
Block a user