书籍信息界面菜单添加置顶

pull/1213/head
gedoor 3 years ago
parent 222324eff4
commit e0a0518103
  1. 3
      app/src/main/java/io/legado/app/data/dao/BookDao.kt
  2. 10
      app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt
  3. 10
      app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt
  4. 11
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
  5. 5
      app/src/main/res/menu/book_info.xml

@ -62,6 +62,9 @@ interface BookDao {
@get:Query("SELECT COUNT(*) FROM books")
val allBookCount: Int
@get:Query("select min(`order`) from books")
val minOrder: Int
@get:Query("select max(`order`) from books")
val maxOrder: Int

@ -15,6 +15,7 @@ import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions
import com.bumptech.glide.request.RequestOptions.bitmapTransform
import io.legado.app.R
import io.legado.app.base.VMBaseActivity
import io.legado.app.constant.AppConst
import io.legado.app.constant.BookType
import io.legado.app.constant.Theme
import io.legado.app.data.appDb
@ -36,6 +37,7 @@ import io.legado.app.ui.book.read.ReadBookActivity
import io.legado.app.ui.book.search.SearchActivity
import io.legado.app.ui.book.source.edit.BookSourceEditActivity
import io.legado.app.ui.book.toc.TocActivityResult
import io.legado.app.ui.login.SourceLoginActivity
import io.legado.app.ui.widget.image.CoverImageView
import io.legado.app.utils.*
import io.legado.app.utils.viewbindingdelegate.viewBinding
@ -151,6 +153,14 @@ class BookInfoActivity :
viewModel.loadBookInfo(it, false)
}
}
R.id.menu_login -> viewModel.bookSource?.let {
startActivity<SourceLoginActivity> {
putExtra("sourceUrl", it.bookSourceUrl)
putExtra("loginUrl", it.loginUrl)
putExtra("userAgent", it.getHeaderMap()[AppConst.UA_NAME])
}
}
R.id.menu_top -> viewModel.topBook()
R.id.menu_copy_book_url -> viewModel.bookData.value?.bookUrl?.let {
sendToClip(it)
} ?: toastOnUi(R.string.no_book)

@ -196,6 +196,16 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) {
}
}
fun topBook() {
execute {
bookData.value?.let { book ->
val minOrder = appDb.bookDao.minOrder
book.order = minOrder - 1
appDb.bookDao.update(book)
}
}
}
fun saveBook(success: (() -> Unit)? = null) {
execute {
bookData.value?.let { book ->

@ -686,7 +686,7 @@ class ReadBookActivity : ReadBookBaseActivity(),
binding.readView.upContent(1)
autoPagePlus()
binding.readMenu.setAutoPage(true)
screenTimeOut=-1L
screenTimeOut = -1L
screenOffTimerStart()
}
}
@ -703,8 +703,8 @@ class ReadBookActivity : ReadBookBaseActivity(),
var delayMillis = ReadBookConfig.autoReadSpeed * 1000L / binding.readView.height
var scrollOffset = 1
if (delayMillis < 20) {
var delayInt=delayMillis.toInt()
if(delayInt==0)delayInt =1
var delayInt = delayMillis.toInt()
if (delayInt == 0) delayInt = 1
scrollOffset = 20 / delayInt
delayMillis = 20
}
@ -973,9 +973,8 @@ class ReadBookActivity : ReadBookBaseActivity(),
}
private fun upScreenTimeOut() {
getPrefString(PreferKey.keepLight)?.let {
screenTimeOut = it.toLong() * 1000
}
val keepLightPrefer = getPrefString(PreferKey.keepLight)?.toInt() ?: 0
screenTimeOut = keepLightPrefer * 1000L
screenOffTimerStart()
}

@ -24,6 +24,11 @@
android:title="@string/login"
app:showAsAction="never" />
<item
android:id="@+id/menu_top"
android:title="@string/to_top"
app:showAsAction="never" />
<item
android:id="@+id/menu_copy_book_url"
android:title="@string/copy_book_url"

Loading…
Cancel
Save