diff --git a/app/src/main/java/io/legado/app/data/dao/BookDao.kt b/app/src/main/java/io/legado/app/data/dao/BookDao.kt index bfc933f64..42ceea9a4 100644 --- a/app/src/main/java/io/legado/app/data/dao/BookDao.kt +++ b/app/src/main/java/io/legado/app/data/dao/BookDao.kt @@ -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 diff --git a/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt b/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt index cfdf84d02..b084d24b2 100644 --- a/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt @@ -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 { + 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) diff --git a/app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt b/app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt index f7ba8ff00..1a4e7e481 100644 --- a/app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt @@ -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 -> 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 25b65117f..0e0152540 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 @@ -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() } diff --git a/app/src/main/res/menu/book_info.xml b/app/src/main/res/menu/book_info.xml index 0d8c97281..370597f5c 100644 --- a/app/src/main/res/menu/book_info.xml +++ b/app/src/main/res/menu/book_info.xml @@ -24,6 +24,11 @@ android:title="@string/login" app:showAsAction="never" /> + +