|
|
@ -9,44 +9,43 @@ import splitties.init.appCtx |
|
|
|
|
|
|
|
|
|
|
|
@Suppress("MemberVisibilityCanBePrivate") |
|
|
|
@Suppress("MemberVisibilityCanBePrivate") |
|
|
|
object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener { |
|
|
|
object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener { |
|
|
|
private val context get() = appCtx |
|
|
|
val isGooglePlay = appCtx.channel == "google" |
|
|
|
val isGooglePlay = context.channel == "google" |
|
|
|
|
|
|
|
var userAgent: String = getPrefUserAgent() |
|
|
|
var userAgent: String = getPrefUserAgent() |
|
|
|
var replaceEnableDefault = context.getPrefBoolean(PreferKey.replaceEnableDefault, true) |
|
|
|
var replaceEnableDefault = appCtx.getPrefBoolean(PreferKey.replaceEnableDefault, true) |
|
|
|
var isEInkMode = context.getPrefString(PreferKey.themeMode) == "3" |
|
|
|
var isEInkMode = appCtx.getPrefString(PreferKey.themeMode) == "3" |
|
|
|
var clickActionTL = context.getPrefInt(PreferKey.clickActionTL, 2) |
|
|
|
var clickActionTL = appCtx.getPrefInt(PreferKey.clickActionTL, 2) |
|
|
|
var clickActionTC = context.getPrefInt(PreferKey.clickActionTC, 2) |
|
|
|
var clickActionTC = appCtx.getPrefInt(PreferKey.clickActionTC, 2) |
|
|
|
var clickActionTR = context.getPrefInt(PreferKey.clickActionTR, 1) |
|
|
|
var clickActionTR = appCtx.getPrefInt(PreferKey.clickActionTR, 1) |
|
|
|
var clickActionML = context.getPrefInt(PreferKey.clickActionML, 2) |
|
|
|
var clickActionML = appCtx.getPrefInt(PreferKey.clickActionML, 2) |
|
|
|
var clickActionMC = context.getPrefInt(PreferKey.clickActionMC, 0) |
|
|
|
var clickActionMC = appCtx.getPrefInt(PreferKey.clickActionMC, 0) |
|
|
|
var clickActionMR = context.getPrefInt(PreferKey.clickActionMR, 1) |
|
|
|
var clickActionMR = appCtx.getPrefInt(PreferKey.clickActionMR, 1) |
|
|
|
var clickActionBL = context.getPrefInt(PreferKey.clickActionBL, 2) |
|
|
|
var clickActionBL = appCtx.getPrefInt(PreferKey.clickActionBL, 2) |
|
|
|
var clickActionBC = context.getPrefInt(PreferKey.clickActionBC, 1) |
|
|
|
var clickActionBC = appCtx.getPrefInt(PreferKey.clickActionBC, 1) |
|
|
|
var clickActionBR = context.getPrefInt(PreferKey.clickActionBR, 1) |
|
|
|
var clickActionBR = appCtx.getPrefInt(PreferKey.clickActionBR, 1) |
|
|
|
|
|
|
|
|
|
|
|
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) { |
|
|
|
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) { |
|
|
|
when (key) { |
|
|
|
when (key) { |
|
|
|
PreferKey.themeMode -> isEInkMode = context.getPrefString(PreferKey.themeMode) == "3" |
|
|
|
PreferKey.themeMode -> isEInkMode = appCtx.getPrefString(PreferKey.themeMode) == "3" |
|
|
|
PreferKey.clickActionTL -> clickActionTL = |
|
|
|
PreferKey.clickActionTL -> clickActionTL = |
|
|
|
context.getPrefInt(PreferKey.clickActionTL, 2) |
|
|
|
appCtx.getPrefInt(PreferKey.clickActionTL, 2) |
|
|
|
PreferKey.clickActionTC -> clickActionTC = |
|
|
|
PreferKey.clickActionTC -> clickActionTC = |
|
|
|
context.getPrefInt(PreferKey.clickActionTC, 2) |
|
|
|
appCtx.getPrefInt(PreferKey.clickActionTC, 2) |
|
|
|
PreferKey.clickActionTR -> clickActionTR = |
|
|
|
PreferKey.clickActionTR -> clickActionTR = |
|
|
|
context.getPrefInt(PreferKey.clickActionTR, 2) |
|
|
|
appCtx.getPrefInt(PreferKey.clickActionTR, 2) |
|
|
|
PreferKey.clickActionML -> clickActionML = |
|
|
|
PreferKey.clickActionML -> clickActionML = |
|
|
|
context.getPrefInt(PreferKey.clickActionML, 2) |
|
|
|
appCtx.getPrefInt(PreferKey.clickActionML, 2) |
|
|
|
PreferKey.clickActionMC -> clickActionMC = |
|
|
|
PreferKey.clickActionMC -> clickActionMC = |
|
|
|
context.getPrefInt(PreferKey.clickActionMC, 2) |
|
|
|
appCtx.getPrefInt(PreferKey.clickActionMC, 2) |
|
|
|
PreferKey.clickActionMR -> clickActionMR = |
|
|
|
PreferKey.clickActionMR -> clickActionMR = |
|
|
|
context.getPrefInt(PreferKey.clickActionMR, 2) |
|
|
|
appCtx.getPrefInt(PreferKey.clickActionMR, 2) |
|
|
|
PreferKey.clickActionBL -> clickActionBL = |
|
|
|
PreferKey.clickActionBL -> clickActionBL = |
|
|
|
context.getPrefInt(PreferKey.clickActionBL, 2) |
|
|
|
appCtx.getPrefInt(PreferKey.clickActionBL, 2) |
|
|
|
PreferKey.clickActionBC -> clickActionBC = |
|
|
|
PreferKey.clickActionBC -> clickActionBC = |
|
|
|
context.getPrefInt(PreferKey.clickActionBC, 2) |
|
|
|
appCtx.getPrefInt(PreferKey.clickActionBC, 2) |
|
|
|
PreferKey.clickActionBR -> clickActionBR = |
|
|
|
PreferKey.clickActionBR -> clickActionBR = |
|
|
|
context.getPrefInt(PreferKey.clickActionBR, 2) |
|
|
|
appCtx.getPrefInt(PreferKey.clickActionBR, 2) |
|
|
|
PreferKey.readBodyToLh -> ReadBookConfig.readBodyToLh = |
|
|
|
PreferKey.readBodyToLh -> ReadBookConfig.readBodyToLh = |
|
|
|
context.getPrefBoolean(PreferKey.readBodyToLh, true) |
|
|
|
appCtx.getPrefBoolean(PreferKey.readBodyToLh, true) |
|
|
|
PreferKey.userAgent -> userAgent = getPrefUserAgent() |
|
|
|
PreferKey.userAgent -> userAgent = getPrefUserAgent() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -61,109 +60,115 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var isNightTheme: Boolean |
|
|
|
var isNightTheme: Boolean |
|
|
|
get() = isNightTheme(context) |
|
|
|
get() = isNightTheme(appCtx) |
|
|
|
set(value) { |
|
|
|
set(value) { |
|
|
|
if (isNightTheme != value) { |
|
|
|
if (isNightTheme != value) { |
|
|
|
if (value) { |
|
|
|
if (value) { |
|
|
|
context.putPrefString(PreferKey.themeMode, "2") |
|
|
|
appCtx.putPrefString(PreferKey.themeMode, "2") |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
context.putPrefString(PreferKey.themeMode, "1") |
|
|
|
appCtx.putPrefString(PreferKey.themeMode, "1") |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
val isTransparentStatusBar: Boolean |
|
|
|
val isTransparentStatusBar: Boolean |
|
|
|
get() = context.getPrefBoolean(PreferKey.transparentStatusBar, true) |
|
|
|
get() = appCtx.getPrefBoolean(PreferKey.transparentStatusBar, true) |
|
|
|
|
|
|
|
|
|
|
|
val immNavigationBar: Boolean |
|
|
|
val immNavigationBar: Boolean |
|
|
|
get() = context.getPrefBoolean(PreferKey.immNavigationBar, true) |
|
|
|
get() = appCtx.getPrefBoolean(PreferKey.immNavigationBar, true) |
|
|
|
|
|
|
|
|
|
|
|
val screenOrientation: String? |
|
|
|
val screenOrientation: String? |
|
|
|
get() = context.getPrefString(PreferKey.screenOrientation) |
|
|
|
get() = appCtx.getPrefString(PreferKey.screenOrientation) |
|
|
|
|
|
|
|
|
|
|
|
var backupPath: String? |
|
|
|
var backupPath: String? |
|
|
|
get() = context.getPrefString(PreferKey.backupPath) |
|
|
|
get() = appCtx.getPrefString(PreferKey.backupPath) |
|
|
|
set(value) { |
|
|
|
set(value) { |
|
|
|
if (value.isNullOrEmpty()) { |
|
|
|
if (value.isNullOrEmpty()) { |
|
|
|
context.removePref(PreferKey.backupPath) |
|
|
|
appCtx.removePref(PreferKey.backupPath) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
context.putPrefString(PreferKey.backupPath, value) |
|
|
|
appCtx.putPrefString(PreferKey.backupPath, value) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
val isShowRSS: Boolean |
|
|
|
val isShowRSS: Boolean |
|
|
|
get() = context.getPrefBoolean(PreferKey.showRss, true) |
|
|
|
get() = appCtx.getPrefBoolean(PreferKey.showRss, true) |
|
|
|
|
|
|
|
|
|
|
|
val autoRefreshBook: Boolean |
|
|
|
val autoRefreshBook: Boolean |
|
|
|
get() = context.getPrefBoolean(PreferKey.autoRefresh) |
|
|
|
get() = appCtx.getPrefBoolean(PreferKey.autoRefresh) |
|
|
|
|
|
|
|
|
|
|
|
var threadCount: Int |
|
|
|
var threadCount: Int |
|
|
|
get() = context.getPrefInt(PreferKey.threadCount, 16) |
|
|
|
get() = appCtx.getPrefInt(PreferKey.threadCount, 16) |
|
|
|
set(value) { |
|
|
|
set(value) { |
|
|
|
context.putPrefInt(PreferKey.threadCount, value) |
|
|
|
appCtx.putPrefInt(PreferKey.threadCount, value) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var importBookPath: String? |
|
|
|
var importBookPath: String? |
|
|
|
get() = context.getPrefString("importBookPath") |
|
|
|
get() = appCtx.getPrefString("importBookPath") |
|
|
|
set(value) { |
|
|
|
set(value) { |
|
|
|
if (value == null) { |
|
|
|
if (value == null) { |
|
|
|
context.removePref("importBookPath") |
|
|
|
appCtx.removePref("importBookPath") |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
context.putPrefString("importBookPath", value) |
|
|
|
appCtx.putPrefString("importBookPath", value) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var ttsSpeechRate: Int |
|
|
|
var ttsSpeechRate: Int |
|
|
|
get() = context.getPrefInt(PreferKey.ttsSpeechRate, 5) |
|
|
|
get() = appCtx.getPrefInt(PreferKey.ttsSpeechRate, 5) |
|
|
|
set(value) { |
|
|
|
set(value) { |
|
|
|
context.putPrefInt(PreferKey.ttsSpeechRate, value) |
|
|
|
appCtx.putPrefInt(PreferKey.ttsSpeechRate, value) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var chineseConverterType: Int |
|
|
|
var chineseConverterType: Int |
|
|
|
get() = context.getPrefInt(PreferKey.chineseConverterType) |
|
|
|
get() = appCtx.getPrefInt(PreferKey.chineseConverterType) |
|
|
|
set(value) { |
|
|
|
set(value) { |
|
|
|
context.putPrefInt(PreferKey.chineseConverterType, value) |
|
|
|
appCtx.putPrefInt(PreferKey.chineseConverterType, value) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var systemTypefaces: Int |
|
|
|
var systemTypefaces: Int |
|
|
|
get() = context.getPrefInt(PreferKey.systemTypefaces) |
|
|
|
get() = appCtx.getPrefInt(PreferKey.systemTypefaces) |
|
|
|
set(value) { |
|
|
|
set(value) { |
|
|
|
context.putPrefInt(PreferKey.systemTypefaces, value) |
|
|
|
appCtx.putPrefInt(PreferKey.systemTypefaces, value) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var elevation: Int |
|
|
|
var elevation: Int |
|
|
|
get() = context.getPrefInt(PreferKey.barElevation, AppConst.sysElevation) |
|
|
|
get() = appCtx.getPrefInt(PreferKey.barElevation, AppConst.sysElevation) |
|
|
|
set(value) { |
|
|
|
set(value) { |
|
|
|
context.putPrefInt(PreferKey.barElevation, value) |
|
|
|
appCtx.putPrefInt(PreferKey.barElevation, value) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var exportCharset: String |
|
|
|
var exportCharset: String |
|
|
|
get() { |
|
|
|
get() { |
|
|
|
val c = context.getPrefString(PreferKey.exportCharset) |
|
|
|
val c = appCtx.getPrefString(PreferKey.exportCharset) |
|
|
|
if (c.isNullOrBlank()) { |
|
|
|
if (c.isNullOrBlank()) { |
|
|
|
return "UTF-8" |
|
|
|
return "UTF-8" |
|
|
|
} |
|
|
|
} |
|
|
|
return c |
|
|
|
return c |
|
|
|
} |
|
|
|
} |
|
|
|
set(value) { |
|
|
|
set(value) { |
|
|
|
context.putPrefString(PreferKey.exportCharset, value) |
|
|
|
appCtx.putPrefString(PreferKey.exportCharset, value) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var exportUseReplace: Boolean |
|
|
|
|
|
|
|
get() = appCtx.getPrefBoolean(PreferKey.exportUseReplace, true) |
|
|
|
|
|
|
|
set(value) { |
|
|
|
|
|
|
|
appCtx.putPrefBoolean(PreferKey.exportUseReplace, value) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
val autoChangeSource: Boolean |
|
|
|
val autoChangeSource: Boolean |
|
|
|
get() = context.getPrefBoolean(PreferKey.autoChangeSource, true) |
|
|
|
get() = appCtx.getPrefBoolean(PreferKey.autoChangeSource, true) |
|
|
|
|
|
|
|
|
|
|
|
val changeSourceLoadInfo get() = context.getPrefBoolean(PreferKey.changeSourceLoadToc) |
|
|
|
val changeSourceLoadInfo get() = appCtx.getPrefBoolean(PreferKey.changeSourceLoadToc) |
|
|
|
|
|
|
|
|
|
|
|
val changeSourceLoadToc get() = context.getPrefBoolean(PreferKey.changeSourceLoadToc) |
|
|
|
val changeSourceLoadToc get() = appCtx.getPrefBoolean(PreferKey.changeSourceLoadToc) |
|
|
|
|
|
|
|
|
|
|
|
val importKeepName get() = context.getPrefBoolean(PreferKey.importKeepName) |
|
|
|
val importKeepName get() = appCtx.getPrefBoolean(PreferKey.importKeepName) |
|
|
|
|
|
|
|
|
|
|
|
val syncBookProgress get() = context.getPrefBoolean(PreferKey.syncBookProgress, true) |
|
|
|
val syncBookProgress get() = appCtx.getPrefBoolean(PreferKey.syncBookProgress, true) |
|
|
|
|
|
|
|
|
|
|
|
val preDownload get() = context.getPrefBoolean(PreferKey.preDownload, true) |
|
|
|
val preDownload get() = appCtx.getPrefBoolean(PreferKey.preDownload, true) |
|
|
|
|
|
|
|
|
|
|
|
private fun getPrefUserAgent(): String { |
|
|
|
private fun getPrefUserAgent(): String { |
|
|
|
val ua = context.getPrefString(PreferKey.userAgent) |
|
|
|
val ua = appCtx.getPrefString(PreferKey.userAgent) |
|
|
|
if (ua.isNullOrBlank()) { |
|
|
|
if (ua.isNullOrBlank()) { |
|
|
|
return "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36" |
|
|
|
return "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36" |
|
|
|
} |
|
|
|
} |
|
|
|