pull/1352/head
gedoor 3 years ago
parent 6dd279b4da
commit 1a5f94e43a
  1. 14
      app/src/main/java/io/legado/app/model/ReadBook.kt
  2. 23
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
  3. 2
      app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt
  4. 8
      app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt
  5. 29
      app/src/main/res/layout/view_read_menu.xml
  6. 1
      app/src/main/res/values-es-rES/strings.xml
  7. 1
      app/src/main/res/values-ja-rJP/strings.xml
  8. 1
      app/src/main/res/values-pt-rBR/strings.xml
  9. 1
      app/src/main/res/values-zh-rHK/strings.xml
  10. 1
      app/src/main/res/values-zh-rTW/strings.xml
  11. 1
      app/src/main/res/values-zh/strings.xml
  12. 1
      app/src/main/res/values/strings.xml

@ -1,6 +1,5 @@
package io.legado.app.model package io.legado.app.model
import androidx.lifecycle.MutableLiveData
import io.legado.app.constant.AppLog import io.legado.app.constant.AppLog
import io.legado.app.constant.BookType import io.legado.app.constant.BookType
import io.legado.app.data.appDb import io.legado.app.data.appDb
@ -28,7 +27,6 @@ import splitties.init.appCtx
@Suppress("MemberVisibilityCanBePrivate") @Suppress("MemberVisibilityCanBePrivate")
object ReadBook : CoroutineScope by MainScope() { object ReadBook : CoroutineScope by MainScope() {
var titleDate = MutableLiveData<String>()
var book: Book? = null var book: Book? = null
var inBookshelf = false var inBookshelf = false
var chapterSize = 0 var chapterSize = 0
@ -55,7 +53,7 @@ object ReadBook : CoroutineScope by MainScope() {
isLocalBook = book.origin == BookType.local isLocalBook = book.origin == BookType.local
chapterSize = book.totalChapterNum chapterSize = book.totalChapterNum
clearTextChapter() clearTextChapter()
titleDate.postValue(book.name) callBack?.upMenuView()
callBack?.upPageAnim() callBack?.upPageAnim()
upWebBook(book) upWebBook(book)
ImageProvider.clearAllCache() ImageProvider.clearAllCache()
@ -139,7 +137,7 @@ object ReadBook : CoroutineScope by MainScope() {
} }
loadContent(durChapterIndex.plus(1), upContent, false) loadContent(durChapterIndex.plus(1), upContent, false)
saveRead() saveRead()
callBack?.upView() callBack?.upMenuView()
curPageChanged() curPageChanged()
return true return true
} else { } else {
@ -164,7 +162,7 @@ object ReadBook : CoroutineScope by MainScope() {
} }
loadContent(durChapterIndex.minus(1), upContent, false) loadContent(durChapterIndex.minus(1), upContent, false)
saveRead() saveRead()
callBack?.upView() callBack?.upMenuView()
curPageChanged() curPageChanged()
return true return true
} else { } else {
@ -352,7 +350,7 @@ object ReadBook : CoroutineScope by MainScope() {
0 -> { 0 -> {
curTextChapter = textChapter curTextChapter = textChapter
if (upContent) callBack?.upContent(offset, resetPageOffset) if (upContent) callBack?.upContent(offset, resetPageOffset)
callBack?.upView() callBack?.upMenuView()
curPageChanged() curPageChanged()
callBack?.contentLoadFinish() callBack?.contentLoadFinish()
} }
@ -444,6 +442,8 @@ object ReadBook : CoroutineScope by MainScope() {
} }
interface CallBack { interface CallBack {
fun upMenuView()
fun loadChapterList(book: Book) fun loadChapterList(book: Book)
fun upContent( fun upContent(
@ -452,8 +452,6 @@ object ReadBook : CoroutineScope by MainScope() {
success: (() -> Unit)? = null success: (() -> Unit)? = null
) )
fun upView()
fun pageChanged() fun pageChanged()
fun contentLoadFinish() fun contentLoadFinish()

@ -79,7 +79,7 @@ class ReadBookActivity : ReadBookBaseActivity(),
it ?: return@registerForActivityResult it ?: return@registerForActivityResult
if (it.resultCode == RESULT_OK) { if (it.resultCode == RESULT_OK) {
viewModel.upBookSource { viewModel.upBookSource {
upView() upMenuView()
} }
} }
} }
@ -129,11 +129,6 @@ class ReadBookActivity : ReadBookBaseActivity(),
binding.cursorRight.setOnTouchListener(this) binding.cursorRight.setOnTouchListener(this)
upScreenTimeOut() upScreenTimeOut()
ReadBook.callBack = this ReadBook.callBack = this
ReadBook.titleDate.observe(this) {
binding.readMenu.setTitle(it)
upMenu()
upView()
}
} }
override fun onPostCreate(savedInstanceState: Bundle?) { override fun onPostCreate(savedInstanceState: Bundle?) {
@ -573,6 +568,13 @@ class ReadBookActivity : ReadBookBaseActivity(),
return false return false
} }
override fun upMenuView() {
launch {
upMenu()
binding.readMenu.upBookView()
}
}
override fun loadChapterList(book: Book) { override fun loadChapterList(book: Book) {
ReadBook.upMsg(getString(R.string.toc_updateing)) ReadBook.upMsg(getString(R.string.toc_updateing))
viewModel.loadChapterList(book) viewModel.loadChapterList(book)
@ -606,15 +608,6 @@ class ReadBookActivity : ReadBookBaseActivity(),
} }
} }
/**
* 更新视图
*/
override fun upView() {
launch {
binding.readMenu.upBookView()
}
}
override fun upPageAnim() { override fun upPageAnim() {
launch { launch {
binding.readView.upPageAnim() binding.readView.upPageAnim()

@ -71,7 +71,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
ReadBook.durChapterPos = book.durChapterPos ReadBook.durChapterPos = book.durChapterPos
ReadBook.clearTextChapter() ReadBook.clearTextChapter()
} }
ReadBook.titleDate.postValue(book.name) ReadBook.callBack?.upMenuView()
ReadBook.upWebBook(book) ReadBook.upWebBook(book)
isInitFinish = true isInitFinish = true
ReadBook.chapterSize = appDb.bookChapterDao.getChapterCount(book.bookUrl) ReadBook.chapterSize = appDb.bookChapterDao.getChapterCount(book.bookUrl)

@ -242,6 +242,8 @@ class ReadMenu @JvmOverloads constructor(
menuBottomIn = AnimationUtilsSupport.loadAnimation(context, R.anim.anim_readbook_bottom_in) menuBottomIn = AnimationUtilsSupport.loadAnimation(context, R.anim.anim_readbook_bottom_in)
menuTopIn.setAnimationListener(object : Animation.AnimationListener { menuTopIn.setAnimationListener(object : Animation.AnimationListener {
override fun onAnimationStart(animation: Animation) { override fun onAnimationStart(animation: Animation) {
binding.tvLogin.isGone = ReadBook.bookSource?.loginUrl.isNullOrEmpty()
binding.tvPay.isGone = true
callBack.upSystemUiVisibility() callBack.upSystemUiVisibility()
binding.llBrightness.visible(showBrightnessView) binding.llBrightness.visible(showBrightnessView)
} }
@ -283,12 +285,8 @@ class ReadMenu @JvmOverloads constructor(
}) })
} }
fun setTitle(title: String) {
binding.titleBar.title = title
}
fun upBookView() { fun upBookView() {
binding.tvLogin.isGone = ReadBook.bookSource?.loginUrl.isNullOrEmpty() binding.titleBar.title = ReadBook.book?.name
ReadBook.curTextChapter?.let { ReadBook.curTextChapter?.let {
binding.tvChapterName.text = it.title binding.tvChapterName.text = it.title
binding.tvChapterName.visible() binding.tvChapterName.visible()

@ -56,9 +56,25 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="0dp" android:layout_height="0dp"
android:gravity="center" android:gravity="center"
android:paddingLeft="10dp" android:paddingLeft="6dp"
android:paddingRight="10dp" android:paddingRight="6dp"
android:text="@string/login" 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" />
<io.legado.app.ui.widget.text.AccentBgTextView
android:id="@+id/tv_pay"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:gravity="center"
android:paddingLeft="6dp"
android:paddingRight="6dp"
android:text="@string/chapter_pay"
android:layout_margin="1dp"
app:radius="1dp"
app:layout_constraintBottom_toBottomOf="@+id/tv_chapter_url" app:layout_constraintBottom_toBottomOf="@+id/tv_chapter_url"
app:layout_constraintRight_toRightOf="parent" app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
@ -86,7 +102,8 @@
android:layout_height="24dp" android:layout_height="24dp"
android:layout_margin="8dp" android:layout_margin="8dp"
android:contentDescription="@string/brightness_auto" android:contentDescription="@string/brightness_auto"
android:src="@drawable/ic_brightness_auto" /> android:src="@drawable/ic_brightness_auto"
tools:ignore="ImageContrastCheck" />
<io.legado.app.ui.widget.seekbar.VerticalSeekBarWrapper <io.legado.app.ui.widget.seekbar.VerticalSeekBarWrapper
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -240,7 +257,8 @@
android:paddingBottom="10dp" android:paddingBottom="10dp"
android:text="@string/previous_chapter" android:text="@string/previous_chapter"
android:textColor="@color/primaryText" android:textColor="@color/primaryText"
android:textSize="14sp" /> android:textSize="14sp"
tools:ignore="TouchTargetSizeCheck" />
<io.legado.app.lib.theme.view.ATESeekBar <io.legado.app.lib.theme.view.ATESeekBar
android:id="@+id/seek_read_page" android:id="@+id/seek_read_page"
@ -263,7 +281,8 @@
android:paddingBottom="10dp" android:paddingBottom="10dp"
android:text="@string/next_chapter" android:text="@string/next_chapter"
android:textColor="@color/primaryText" android:textColor="@color/primaryText"
android:textSize="14sp" /> android:textSize="14sp"
tools:ignore="TouchTargetSizeCheck" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout

@ -889,5 +889,6 @@
<string name="unknown_state">未知状态</string> <string name="unknown_state">未知状态</string>
<string name="disable_source">禁用源</string> <string name="disable_source">禁用源</string>
<string name="delete_source">删除源</string> <string name="delete_source">删除源</string>
<string name="chapter_pay">购买</string>
</resources> </resources>

@ -893,5 +893,6 @@
<string name="unknown_state">未知状态</string> <string name="unknown_state">未知状态</string>
<string name="disable_source">禁用源</string> <string name="disable_source">禁用源</string>
<string name="delete_source">删除源</string> <string name="delete_source">删除源</string>
<string name="chapter_pay">购买</string>
</resources> </resources>

@ -893,5 +893,6 @@
<string name="unknown_state">未知状态</string> <string name="unknown_state">未知状态</string>
<string name="disable_source">禁用源</string> <string name="disable_source">禁用源</string>
<string name="delete_source">删除源</string> <string name="delete_source">删除源</string>
<string name="chapter_pay">购买</string>
</resources> </resources>

@ -890,5 +890,6 @@
<string name="unknown_state">未知状态</string> <string name="unknown_state">未知状态</string>
<string name="disable_source">禁用源</string> <string name="disable_source">禁用源</string>
<string name="delete_source">删除源</string> <string name="delete_source">删除源</string>
<string name="chapter_pay">购买</string>
</resources> </resources>

@ -892,5 +892,6 @@
<string name="unknown_state">未知状态</string> <string name="unknown_state">未知状态</string>
<string name="disable_source">禁用源</string> <string name="disable_source">禁用源</string>
<string name="delete_source">删除源</string> <string name="delete_source">删除源</string>
<string name="chapter_pay">购买</string>
</resources> </resources>

@ -892,5 +892,6 @@
<string name="unknown_state">未知状态</string> <string name="unknown_state">未知状态</string>
<string name="disable_source">禁用源</string> <string name="disable_source">禁用源</string>
<string name="delete_source">删除源</string> <string name="delete_source">删除源</string>
<string name="chapter_pay">购买</string>
</resources> </resources>

@ -893,5 +893,6 @@
<string name="unknown_state">未知状态</string> <string name="unknown_state">未知状态</string>
<string name="disable_source">禁用源</string> <string name="disable_source">禁用源</string>
<string name="delete_source">删除源</string> <string name="delete_source">删除源</string>
<string name="chapter_pay">购买</string>
</resources> </resources>

Loading…
Cancel
Save