diff --git a/app/src/main/java/io/legado/app/model/ReadBook.kt b/app/src/main/java/io/legado/app/model/ReadBook.kt index 90751ab0e..4b0ccad93 100644 --- a/app/src/main/java/io/legado/app/model/ReadBook.kt +++ b/app/src/main/java/io/legado/app/model/ReadBook.kt @@ -1,6 +1,5 @@ package io.legado.app.model -import androidx.lifecycle.MutableLiveData import io.legado.app.constant.AppLog import io.legado.app.constant.BookType import io.legado.app.data.appDb @@ -28,7 +27,6 @@ import splitties.init.appCtx @Suppress("MemberVisibilityCanBePrivate") object ReadBook : CoroutineScope by MainScope() { - var titleDate = MutableLiveData() var book: Book? = null var inBookshelf = false var chapterSize = 0 @@ -55,7 +53,7 @@ object ReadBook : CoroutineScope by MainScope() { isLocalBook = book.origin == BookType.local chapterSize = book.totalChapterNum clearTextChapter() - titleDate.postValue(book.name) + callBack?.upMenuView() callBack?.upPageAnim() upWebBook(book) ImageProvider.clearAllCache() @@ -139,7 +137,7 @@ object ReadBook : CoroutineScope by MainScope() { } loadContent(durChapterIndex.plus(1), upContent, false) saveRead() - callBack?.upView() + callBack?.upMenuView() curPageChanged() return true } else { @@ -164,7 +162,7 @@ object ReadBook : CoroutineScope by MainScope() { } loadContent(durChapterIndex.minus(1), upContent, false) saveRead() - callBack?.upView() + callBack?.upMenuView() curPageChanged() return true } else { @@ -352,7 +350,7 @@ object ReadBook : CoroutineScope by MainScope() { 0 -> { curTextChapter = textChapter if (upContent) callBack?.upContent(offset, resetPageOffset) - callBack?.upView() + callBack?.upMenuView() curPageChanged() callBack?.contentLoadFinish() } @@ -444,6 +442,8 @@ object ReadBook : CoroutineScope by MainScope() { } interface CallBack { + fun upMenuView() + fun loadChapterList(book: Book) fun upContent( @@ -452,8 +452,6 @@ object ReadBook : CoroutineScope by MainScope() { success: (() -> Unit)? = null ) - fun upView() - fun pageChanged() fun contentLoadFinish() diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt index 5e49fb060..cb41cdb1e 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt @@ -79,7 +79,7 @@ class ReadBookActivity : ReadBookBaseActivity(), it ?: return@registerForActivityResult if (it.resultCode == RESULT_OK) { viewModel.upBookSource { - upView() + upMenuView() } } } @@ -129,11 +129,6 @@ class ReadBookActivity : ReadBookBaseActivity(), binding.cursorRight.setOnTouchListener(this) upScreenTimeOut() ReadBook.callBack = this - ReadBook.titleDate.observe(this) { - binding.readMenu.setTitle(it) - upMenu() - upView() - } } override fun onPostCreate(savedInstanceState: Bundle?) { @@ -573,6 +568,13 @@ class ReadBookActivity : ReadBookBaseActivity(), return false } + override fun upMenuView() { + launch { + upMenu() + binding.readMenu.upBookView() + } + } + override fun loadChapterList(book: Book) { ReadBook.upMsg(getString(R.string.toc_updateing)) viewModel.loadChapterList(book) @@ -606,15 +608,6 @@ class ReadBookActivity : ReadBookBaseActivity(), } } - /** - * 更新视图 - */ - override fun upView() { - launch { - binding.readMenu.upBookView() - } - } - override fun upPageAnim() { launch { binding.readView.upPageAnim() diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt index 8dbd19949..b820cc181 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt @@ -71,7 +71,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { ReadBook.durChapterPos = book.durChapterPos ReadBook.clearTextChapter() } - ReadBook.titleDate.postValue(book.name) + ReadBook.callBack?.upMenuView() ReadBook.upWebBook(book) isInitFinish = true ReadBook.chapterSize = appDb.bookChapterDao.getChapterCount(book.bookUrl) diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt index 706e162d5..81e1c01b9 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt @@ -242,6 +242,8 @@ class ReadMenu @JvmOverloads constructor( menuBottomIn = AnimationUtilsSupport.loadAnimation(context, R.anim.anim_readbook_bottom_in) menuTopIn.setAnimationListener(object : Animation.AnimationListener { override fun onAnimationStart(animation: Animation) { + binding.tvLogin.isGone = ReadBook.bookSource?.loginUrl.isNullOrEmpty() + binding.tvPay.isGone = true callBack.upSystemUiVisibility() binding.llBrightness.visible(showBrightnessView) } @@ -283,12 +285,8 @@ class ReadMenu @JvmOverloads constructor( }) } - fun setTitle(title: String) { - binding.titleBar.title = title - } - fun upBookView() { - binding.tvLogin.isGone = ReadBook.bookSource?.loginUrl.isNullOrEmpty() + binding.titleBar.title = ReadBook.book?.name ReadBook.curTextChapter?.let { binding.tvChapterName.text = it.title binding.tvChapterName.visible() diff --git a/app/src/main/res/layout/view_read_menu.xml b/app/src/main/res/layout/view_read_menu.xml index 29421a357..e41cd22fd 100644 --- a/app/src/main/res/layout/view_read_menu.xml +++ b/app/src/main/res/layout/view_read_menu.xml @@ -56,9 +56,25 @@ android:layout_width="wrap_content" android:layout_height="0dp" android:gravity="center" - android:paddingLeft="10dp" - android:paddingRight="10dp" + android:paddingLeft="6dp" + android:paddingRight="6dp" android:text="@string/login" + android:layout_margin="1dp" + app:radius="1dp" + app:layout_constraintBottom_toBottomOf="@+id/tv_chapter_url" + app:layout_constraintRight_toLeftOf="@+id/tv_pay" + app:layout_constraintTop_toTopOf="parent" /> + + @@ -86,7 +102,8 @@ android:layout_height="24dp" android:layout_margin="8dp" android:contentDescription="@string/brightness_auto" - android:src="@drawable/ic_brightness_auto" /> + android:src="@drawable/ic_brightness_auto" + tools:ignore="ImageContrastCheck" /> + android:textSize="14sp" + tools:ignore="TouchTargetSizeCheck" /> + android:textSize="14sp" + tools:ignore="TouchTargetSizeCheck" /> 未知状态 禁用源 删除源 + 购买 diff --git a/app/src/main/res/values-ja-rJP/strings.xml b/app/src/main/res/values-ja-rJP/strings.xml index bbe1e1db7..a31235a29 100644 --- a/app/src/main/res/values-ja-rJP/strings.xml +++ b/app/src/main/res/values-ja-rJP/strings.xml @@ -893,5 +893,6 @@ 未知状态 禁用源 删除源 + 购买 diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index 2cb7e116c..19d170a43 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -893,5 +893,6 @@ 未知状态 禁用源 删除源 + 购买 diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index 824adddc0..bfedef73e 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -890,5 +890,6 @@ 未知状态 禁用源 删除源 + 购买 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index c2b0207db..f36f0fa06 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -892,5 +892,6 @@ 未知状态 禁用源 删除源 + 购买 diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index e9167fffe..577a468bf 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -892,5 +892,6 @@ 未知状态 禁用源 删除源 + 购买 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6ed219e18..5a991fa86 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -893,5 +893,6 @@ 未知状态 禁用源 删除源 + 购买