mirror of
https://github.com/gedoor/legado.git
synced 2025-01-08 11:47:32 +08:00
parent
9ee30fc86c
commit
f1f1f3cd6b
@ -69,6 +69,7 @@ object PreferKey {
|
|||||||
const val launcherIcon = "launcherIcon"
|
const val launcherIcon = "launcherIcon"
|
||||||
const val textSelectAble = "selectText"
|
const val textSelectAble = "selectText"
|
||||||
const val shareLayout = "shareLayout"
|
const val shareLayout = "shareLayout"
|
||||||
|
const val comicStyleSelect = "comicStyleSelect"
|
||||||
const val readStyleSelect = "readStyleSelect"
|
const val readStyleSelect = "readStyleSelect"
|
||||||
const val systemTypefaces = "system_typefaces"
|
const val systemTypefaces = "system_typefaces"
|
||||||
const val readBodyToLh = "readBodyToLh"
|
const val readBodyToLh = "readBodyToLh"
|
||||||
|
@ -56,6 +56,7 @@ object ReadBookConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var isComic: Boolean = false
|
||||||
var bg: Drawable? = null
|
var bg: Drawable? = null
|
||||||
var bgMeanColor: Int = 0
|
var bgMeanColor: Int = 0
|
||||||
val textColor: Int get() = durConfig.curTextColor()
|
val textColor: Int get() = durConfig.curTextColor()
|
||||||
@ -150,9 +151,13 @@ object ReadBookConfig {
|
|||||||
fun deleteDur(): Boolean {
|
fun deleteDur(): Boolean {
|
||||||
if (configList.size > 5) {
|
if (configList.size > 5) {
|
||||||
configList.removeAt(styleSelect)
|
configList.removeAt(styleSelect)
|
||||||
if (styleSelect > 0) {
|
if (styleSelect <= readStyleSelect) {
|
||||||
styleSelect -= 1
|
readStyleSelect -= 1
|
||||||
}
|
}
|
||||||
|
if (styleSelect <= comicStyleSelect) {
|
||||||
|
comicStyleSelect -= 1
|
||||||
|
}
|
||||||
|
styleSelect = initSelectStyle()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
@ -173,13 +178,20 @@ object ReadBookConfig {
|
|||||||
field = value
|
field = value
|
||||||
appCtx.putPrefInt(PreferKey.autoReadSpeed, value)
|
appCtx.putPrefInt(PreferKey.autoReadSpeed, value)
|
||||||
}
|
}
|
||||||
var styleSelect = appCtx.getPrefInt(PreferKey.readStyleSelect)
|
var readStyleSelect = appCtx.getPrefInt(PreferKey.readStyleSelect)
|
||||||
set(value) {
|
set(value) {
|
||||||
field = value
|
field = value
|
||||||
if (appCtx.getPrefInt(PreferKey.readStyleSelect) != value) {
|
if (appCtx.getPrefInt(PreferKey.readStyleSelect) != value) {
|
||||||
appCtx.putPrefInt(PreferKey.readStyleSelect, value)
|
appCtx.putPrefInt(PreferKey.readStyleSelect, value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
var comicStyleSelect = appCtx.getPrefInt(PreferKey.comicStyleSelect, readStyleSelect)
|
||||||
|
set(value) {
|
||||||
|
field = value
|
||||||
|
if (appCtx.getPrefInt(PreferKey.comicStyleSelect) != value) {
|
||||||
|
appCtx.putPrefInt(PreferKey.comicStyleSelect, value)
|
||||||
|
}
|
||||||
|
}
|
||||||
var shareLayout = appCtx.getPrefBoolean(PreferKey.shareLayout)
|
var shareLayout = appCtx.getPrefBoolean(PreferKey.shareLayout)
|
||||||
set(value) {
|
set(value) {
|
||||||
field = value
|
field = value
|
||||||
@ -188,6 +200,26 @@ object ReadBookConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var styleSelect = initSelectStyle()
|
||||||
|
fun initSelectStyle(): Int {
|
||||||
|
return if (isComic) {
|
||||||
|
comicStyleSelect
|
||||||
|
}else {
|
||||||
|
readStyleSelect
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun updateStyleSelect(value: Int) {
|
||||||
|
if (styleSelect != value) {
|
||||||
|
if (isComic) {
|
||||||
|
comicStyleSelect = value
|
||||||
|
}else {
|
||||||
|
readStyleSelect = value
|
||||||
|
}
|
||||||
|
styleSelect = value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 两端对齐
|
* 两端对齐
|
||||||
*/
|
*/
|
||||||
|
@ -259,7 +259,9 @@ object Restore {
|
|||||||
edit.apply()
|
edit.apply()
|
||||||
}
|
}
|
||||||
ReadBookConfig.apply {
|
ReadBookConfig.apply {
|
||||||
styleSelect = appCtx.getPrefInt(PreferKey.readStyleSelect)
|
comicStyleSelect = appCtx.getPrefInt(PreferKey.comicStyleSelect)
|
||||||
|
readStyleSelect = appCtx.getPrefInt(PreferKey.readStyleSelect)
|
||||||
|
styleSelect = initSelectStyle()
|
||||||
shareLayout = appCtx.getPrefBoolean(PreferKey.shareLayout)
|
shareLayout = appCtx.getPrefBoolean(PreferKey.shareLayout)
|
||||||
hideStatusBar = appCtx.getPrefBoolean(PreferKey.hideStatusBar)
|
hideStatusBar = appCtx.getPrefBoolean(PreferKey.hideStatusBar)
|
||||||
hideNavigationBar = appCtx.getPrefBoolean(PreferKey.hideNavigationBar)
|
hideNavigationBar = appCtx.getPrefBoolean(PreferKey.hideNavigationBar)
|
||||||
|
@ -255,6 +255,11 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||||||
private var justInitData: Boolean = false
|
private var justInitData: Boolean = false
|
||||||
private var syncDialog: AlertDialog? = null
|
private var syncDialog: AlertDialog? = null
|
||||||
|
|
||||||
|
override fun onStart() {
|
||||||
|
viewModel.initBookType(intent) { upStyle() }
|
||||||
|
super.onStart()
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressLint("ClickableViewAccessibility")
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||||
super.onActivityCreated(savedInstanceState)
|
super.onActivityCreated(savedInstanceState)
|
||||||
@ -401,6 +406,14 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||||||
return super.onMenuOpened(featureId, menu)
|
return super.onMenuOpened(featureId, menu)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun upStyle() {
|
||||||
|
val oldIndex = ReadBookConfig.styleSelect
|
||||||
|
ReadBookConfig.styleSelect = ReadBookConfig.initSelectStyle()
|
||||||
|
if (oldIndex != ReadBookConfig.styleSelect){
|
||||||
|
postEvent(EventBus.UP_CONFIG, arrayListOf(1, 2, 5))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新菜单
|
* 更新菜单
|
||||||
*/
|
*/
|
||||||
@ -580,7 +593,7 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||||||
}
|
}
|
||||||
|
|
||||||
R.id.menu_cover_progress -> ReadBook.book?.let {
|
R.id.menu_cover_progress -> ReadBook.book?.let {
|
||||||
ReadBook.uploadProgress({ toastOnUi(R.string.upload_book_success) })
|
ReadBook.uploadProgress { toastOnUi(R.string.upload_book_success) }
|
||||||
}
|
}
|
||||||
|
|
||||||
R.id.menu_same_title_removed -> {
|
R.id.menu_same_title_removed -> {
|
||||||
|
@ -23,6 +23,7 @@ import io.legado.app.help.book.isLocalModified
|
|||||||
import io.legado.app.help.book.removeType
|
import io.legado.app.help.book.removeType
|
||||||
import io.legado.app.help.book.simulatedTotalChapterNum
|
import io.legado.app.help.book.simulatedTotalChapterNum
|
||||||
import io.legado.app.help.config.AppConfig
|
import io.legado.app.help.config.AppConfig
|
||||||
|
import io.legado.app.help.config.ReadBookConfig
|
||||||
import io.legado.app.help.coroutine.Coroutine
|
import io.legado.app.help.coroutine.Coroutine
|
||||||
import io.legado.app.model.ImageProvider
|
import io.legado.app.model.ImageProvider
|
||||||
import io.legado.app.model.ReadAloud
|
import io.legado.app.model.ReadAloud
|
||||||
@ -67,6 +68,16 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
|
|||||||
AppConfig.detectClickArea()
|
AppConfig.detectClickArea()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun initBookType(intent: Intent, callBack: (() -> Unit)? = null) {
|
||||||
|
val bookUrl = intent.getStringExtra("bookUrl")
|
||||||
|
val book = when {
|
||||||
|
bookUrl.isNullOrEmpty() -> appDb.bookDao.lastReadBook
|
||||||
|
else -> appDb.bookDao.getBook(bookUrl)
|
||||||
|
}
|
||||||
|
ReadBookConfig.isComic = book?.type == BookType.image
|
||||||
|
callBack?.invoke()
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 初始化
|
* 初始化
|
||||||
*/
|
*/
|
||||||
|
@ -165,7 +165,7 @@ class ReadStyleDialog : BaseDialogFragment(R.layout.dialog_read_book_style),
|
|||||||
private fun changeBgTextConfig(index: Int) {
|
private fun changeBgTextConfig(index: Int) {
|
||||||
val oldIndex = ReadBookConfig.styleSelect
|
val oldIndex = ReadBookConfig.styleSelect
|
||||||
if (index != oldIndex) {
|
if (index != oldIndex) {
|
||||||
ReadBookConfig.styleSelect = index
|
ReadBookConfig.updateStyleSelect(index)
|
||||||
upView()
|
upView()
|
||||||
styleAdapter.notifyItemChanged(oldIndex)
|
styleAdapter.notifyItemChanged(oldIndex)
|
||||||
styleAdapter.notifyItemChanged(index)
|
styleAdapter.notifyItemChanged(index)
|
||||||
|
Loading…
Reference in New Issue
Block a user