mirror of
https://github.com/gedoor/legado.git
synced 2025-08-10 00:52:30 +00:00
优化
Some checks failed
Test Build / prepare (push) Has been cancelled
Test Build / build (app, release) (push) Has been cancelled
Test Build / build (app, releaseA) (push) Has been cancelled
Test Build / prerelease (push) Has been cancelled
Test Build / lanzou (push) Has been cancelled
Test Build / test_Branch (push) Has been cancelled
Test Build / telegram (push) Has been cancelled
update fork / build (push) Has been cancelled
Some checks failed
Test Build / prepare (push) Has been cancelled
Test Build / build (app, release) (push) Has been cancelled
Test Build / build (app, releaseA) (push) Has been cancelled
Test Build / prerelease (push) Has been cancelled
Test Build / lanzou (push) Has been cancelled
Test Build / test_Branch (push) Has been cancelled
Test Build / telegram (push) Has been cancelled
update fork / build (push) Has been cancelled
This commit is contained in:
@@ -46,7 +46,6 @@ import io.legado.app.utils.setLightStatusBar
|
||||
import io.legado.app.utils.setNavigationBarColorAuto
|
||||
import io.legado.app.utils.showDialogFragment
|
||||
import io.legado.app.utils.viewbindingdelegate.viewBinding
|
||||
import io.legado.app.utils.visible
|
||||
import java.time.LocalDate
|
||||
import java.time.format.DateTimeFormatter
|
||||
|
||||
@@ -58,6 +57,8 @@ abstract class BaseReadBookActivity :
|
||||
|
||||
override val binding by viewBinding(ActivityBookReadBinding::inflate)
|
||||
override val viewModel by viewModels<ReadBookViewModel>()
|
||||
protected val menuLayoutIsVisible
|
||||
get() = bottomDialog > 0 || binding.readMenu.isVisible || binding.searchMenu.bottomMenuVisible
|
||||
|
||||
var bottomDialog = 0
|
||||
set(value) {
|
||||
@@ -229,37 +230,7 @@ abstract class BaseReadBookActivity :
|
||||
|
||||
@SuppressLint("RtlHardcoded")
|
||||
private fun upNavigationBar() {
|
||||
binding.navigationBar.run {
|
||||
if (bottomDialog > 0 || binding.readMenu.isVisible || binding.searchMenu.bottomMenuVisible) {
|
||||
// val navigationBarHeight =
|
||||
// if (ReadBookConfig.hideNavigationBar) navigationBarHeight else 0
|
||||
// when (navigationBarGravity) {
|
||||
// Gravity.BOTTOM -> layoutParams =
|
||||
// (layoutParams as FrameLayout.LayoutParams).apply {
|
||||
// height = navigationBarHeight
|
||||
// width = MATCH_PARENT
|
||||
// gravity = Gravity.BOTTOM
|
||||
// }
|
||||
//
|
||||
// Gravity.LEFT -> layoutParams =
|
||||
// (layoutParams as FrameLayout.LayoutParams).apply {
|
||||
// height = MATCH_PARENT
|
||||
// width = navigationBarHeight
|
||||
// gravity = Gravity.LEFT
|
||||
// }
|
||||
//
|
||||
// Gravity.RIGHT -> layoutParams =
|
||||
// (layoutParams as FrameLayout.LayoutParams).apply {
|
||||
// height = MATCH_PARENT
|
||||
// width = navigationBarHeight
|
||||
// gravity = Gravity.RIGHT
|
||||
// }
|
||||
// }
|
||||
visible()
|
||||
} else {
|
||||
gone()
|
||||
}
|
||||
}
|
||||
binding.navigationBar.gone(!menuLayoutIsVisible)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -317,57 +288,59 @@ abstract class BaseReadBookActivity :
|
||||
}
|
||||
|
||||
fun showSimulatedReading() {
|
||||
val book = ReadBook.book ?: return
|
||||
val dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd")
|
||||
ReadBook.book?.let { book ->
|
||||
alert(titleResource = R.string.simulated_reading) {
|
||||
val alertBinding = DialogSimulatedReadingBinding.inflate(layoutInflater).apply {
|
||||
srEnabled.isChecked = book.getReadSimulating()
|
||||
editStart.setText(book.getStartChapter().toString())
|
||||
editNum.setText(book.getDailyChapters().toString())
|
||||
startDate.setText(book.getStartDate()?.format(dateFormatter))
|
||||
startDate.isFocusable = false // 设置为false,不允许获得焦点
|
||||
startDate.isCursorVisible = false // 不显示光标
|
||||
startDate.setOnClickListener {
|
||||
// 获取当前日期
|
||||
val localStartDate = LocalDate.parse(startDate.text)
|
||||
// 创建 DatePickerDialog
|
||||
val datePickerDialog = DatePickerDialog(
|
||||
root.context,
|
||||
{ _, yy, mm, dayOfMonth ->
|
||||
// 使用Java 8的日期和时间API来格式化日期
|
||||
val date = LocalDate.of(yy, mm + 1, dayOfMonth) // Java 8的LocalDate,月份从1开始
|
||||
val formattedDate = date.format(dateFormatter)
|
||||
startDate.setText(formattedDate)
|
||||
}, localStartDate.year, localStartDate.monthValue - 1, localStartDate.dayOfMonth
|
||||
)
|
||||
datePickerDialog.show()
|
||||
}
|
||||
}
|
||||
customView { alertBinding.root }
|
||||
yesButton {
|
||||
alertBinding.run {
|
||||
val start = editStart.text!!.toString().let {
|
||||
if (it.isEmpty()) 0 else it.toInt()
|
||||
}
|
||||
val num = editNum.text!!.toString().let {
|
||||
if (it.isEmpty()) book.totalChapterNum else it.toInt()
|
||||
}
|
||||
val enabled = srEnabled.isChecked
|
||||
val date = startDate.text!!.toString().let {
|
||||
if (it.isEmpty()) LocalDate.now() else LocalDate.parse(it, dateFormatter)
|
||||
}
|
||||
book.setStartDate(date)
|
||||
book.setDailyChapters(num)
|
||||
book.setStartChapter(start)
|
||||
book.setReadSimulating(enabled)
|
||||
book.save()
|
||||
ReadBook.clearTextChapter()
|
||||
viewModel.initData(intent)
|
||||
}
|
||||
}
|
||||
noButton()
|
||||
val alertBinding = DialogSimulatedReadingBinding.inflate(layoutInflater).apply {
|
||||
srEnabled.isChecked = book.getReadSimulating()
|
||||
editStart.setText(book.getStartChapter().toString())
|
||||
editNum.setText(book.getDailyChapters().toString())
|
||||
startDate.setText(book.getStartDate()?.format(dateFormatter))
|
||||
startDate.isFocusable = false // 设置为false,不允许获得焦点
|
||||
startDate.isCursorVisible = false // 不显示光标
|
||||
startDate.setOnClickListener {
|
||||
// 获取当前日期
|
||||
val localStartDate = LocalDate.parse(startDate.text)
|
||||
// 创建 DatePickerDialog
|
||||
val datePickerDialog = DatePickerDialog(
|
||||
root.context,
|
||||
{ _, yy, mm, dayOfMonth ->
|
||||
// 使用Java 8的日期和时间API来格式化日期
|
||||
val date = LocalDate.of(yy, mm + 1, dayOfMonth) // Java 8的LocalDate,月份从1开始
|
||||
val formattedDate = date.format(dateFormatter)
|
||||
startDate.setText(formattedDate)
|
||||
}, localStartDate.year,
|
||||
localStartDate.monthValue - 1,
|
||||
localStartDate.dayOfMonth
|
||||
)
|
||||
datePickerDialog.show()
|
||||
}
|
||||
}
|
||||
alert(titleResource = R.string.simulated_reading) {
|
||||
customView { alertBinding.root }
|
||||
yesButton {
|
||||
alertBinding.run {
|
||||
val start = editStart.text!!.toString().let {
|
||||
if (it.isEmpty()) 0 else it.toInt()
|
||||
}
|
||||
val num = editNum.text!!.toString().let {
|
||||
if (it.isEmpty()) book.totalChapterNum else it.toInt()
|
||||
}
|
||||
val enabled = srEnabled.isChecked
|
||||
val date = startDate.text!!.toString().let {
|
||||
if (it.isEmpty()) LocalDate.now()
|
||||
else LocalDate.parse(it, dateFormatter)
|
||||
}
|
||||
book.setStartDate(date)
|
||||
book.setDailyChapters(num)
|
||||
book.setStartChapter(start)
|
||||
book.setReadSimulating(enabled)
|
||||
book.save()
|
||||
ReadBook.clearTextChapter()
|
||||
viewModel.initData(intent)
|
||||
}
|
||||
}
|
||||
noButton()
|
||||
}
|
||||
}
|
||||
|
||||
fun showCharsetConfig() {
|
||||
|
||||
@@ -233,7 +233,6 @@ class ReadBookActivity : BaseReadBookActivity(),
|
||||
override val pageFactory get() = binding.readView.pageFactory
|
||||
override val pageDelegate get() = binding.readView.pageDelegate
|
||||
override val headerHeight: Int get() = binding.readView.curPage.headerHeight
|
||||
private val menuLayoutIsVisible get() = bottomDialog > 0 || binding.readMenu.isVisible || binding.searchMenu.bottomMenuVisible
|
||||
private val nextPageDebounce by lazy { Debounce { keyPage(PageDirection.NEXT) } }
|
||||
private val prevPageDebounce by lazy { Debounce { keyPage(PageDirection.PREV) } }
|
||||
private var bookChanged = false
|
||||
|
||||
@@ -126,21 +126,7 @@ class ReadMenu @JvmOverloads constructor(
|
||||
|
||||
@SuppressLint("RtlHardcoded")
|
||||
override fun onAnimationEnd(animation: Animation) {
|
||||
// val navigationBarHeight =
|
||||
// if (ReadBookConfig.hideNavigationBar) {
|
||||
// activity?.navigationBarHeight ?: 0
|
||||
// } else {
|
||||
// 0
|
||||
// }
|
||||
binding.run {
|
||||
vwMenuBg.setOnClickListener { runMenuOut() }
|
||||
// root.padding = 0
|
||||
// when (activity?.navigationBarGravity) {
|
||||
// Gravity.BOTTOM -> root.bottomPadding = navigationBarHeight
|
||||
// Gravity.LEFT -> root.leftPadding = navigationBarHeight
|
||||
// Gravity.RIGHT -> root.rightPadding = navigationBarHeight
|
||||
// }
|
||||
}
|
||||
binding.vwMenuBg.setOnClickListener { runMenuOut() }
|
||||
callBack.upSystemUiVisibility()
|
||||
if (!LocalConfig.readMenuHelpVersionIsLast) {
|
||||
callBack.showHelp()
|
||||
|
||||
@@ -5,14 +5,12 @@ import android.content.Context
|
||||
import android.content.res.ColorStateList
|
||||
import android.graphics.PorterDuff
|
||||
import android.util.AttributeSet
|
||||
import android.view.Gravity
|
||||
import android.view.LayoutInflater
|
||||
import android.view.animation.Animation
|
||||
import android.widget.FrameLayout
|
||||
import androidx.core.view.isVisible
|
||||
import io.legado.app.R
|
||||
import io.legado.app.databinding.ViewSearchMenuBinding
|
||||
import io.legado.app.help.config.ReadBookConfig
|
||||
import io.legado.app.lib.theme.Selector
|
||||
import io.legado.app.lib.theme.bottomBackground
|
||||
import io.legado.app.lib.theme.getPrimaryTextColor
|
||||
@@ -20,15 +18,10 @@ import io.legado.app.model.ReadBook
|
||||
import io.legado.app.ui.book.searchContent.SearchResult
|
||||
import io.legado.app.utils.ColorUtils
|
||||
import io.legado.app.utils.activity
|
||||
import io.legado.app.utils.applyNavigationBarPadding
|
||||
import io.legado.app.utils.invisible
|
||||
import io.legado.app.utils.loadAnimation
|
||||
import io.legado.app.utils.navigationBarGravity
|
||||
import io.legado.app.utils.navigationBarHeight
|
||||
import io.legado.app.utils.visible
|
||||
import splitties.views.bottomPadding
|
||||
import splitties.views.leftPadding
|
||||
import splitties.views.padding
|
||||
import splitties.views.rightPadding
|
||||
|
||||
/**
|
||||
* 搜索界面菜单
|
||||
@@ -91,6 +84,7 @@ class SearchMenu @JvmOverloads constructor(
|
||||
ivSearchContentUp.setColorFilter(textColor, PorterDuff.Mode.SRC_IN)
|
||||
ivSearchContentDown.setColorFilter(textColor, PorterDuff.Mode.SRC_IN)
|
||||
tvCurrentSearchInfo.setTextColor(textColor)
|
||||
applyNavigationBarPadding()
|
||||
}
|
||||
|
||||
|
||||
@@ -196,20 +190,7 @@ class SearchMenu @JvmOverloads constructor(
|
||||
|
||||
@SuppressLint("RtlHardcoded")
|
||||
override fun onAnimationEnd(animation: Animation) {
|
||||
val navigationBarHeight = if (ReadBookConfig.hideNavigationBar) {
|
||||
activity?.navigationBarHeight ?: 0
|
||||
} else {
|
||||
0
|
||||
}
|
||||
binding.run {
|
||||
vwMenuBg.setOnClickListener { runMenuOut() }
|
||||
root.padding = 0
|
||||
when (activity?.navigationBarGravity) {
|
||||
Gravity.BOTTOM -> root.bottomPadding = navigationBarHeight
|
||||
Gravity.LEFT -> root.leftPadding = navigationBarHeight
|
||||
Gravity.RIGHT -> root.rightPadding = navigationBarHeight
|
||||
}
|
||||
}
|
||||
binding.vwMenuBg.setOnClickListener { runMenuOut() }
|
||||
callBack.upSystemUiVisibility()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user