Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -48,6 +48,7 @@ data class RssArticle(
|
|||||||
pubDate = pubDate,
|
pubDate = pubDate,
|
||||||
description = description,
|
description = description,
|
||||||
content = content,
|
content = content,
|
||||||
image = image
|
image = image,
|
||||||
|
variable = variable
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ data class RssStar(
|
|||||||
pubDate = pubDate,
|
pubDate = pubDate,
|
||||||
description = description,
|
description = description,
|
||||||
content = content,
|
content = content,
|
||||||
image = image
|
image = image,
|
||||||
|
variable = variable
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -147,6 +147,7 @@ abstract class BaseReadAloudService : BaseService(),
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
||||||
|
upNotification()
|
||||||
when (intent?.action) {
|
when (intent?.action) {
|
||||||
IntentAction.play -> newReadAloud(
|
IntentAction.play -> newReadAloud(
|
||||||
intent.getBooleanExtra("play", true),
|
intent.getBooleanExtra("play", true),
|
||||||
|
|||||||
@@ -165,6 +165,7 @@ class BookInfoActivity :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
R.id.menu_share_it -> {
|
R.id.menu_share_it -> {
|
||||||
viewModel.getBook()?.let {
|
viewModel.getBook()?.let {
|
||||||
val bookJson = GSON.toJson(it)
|
val bookJson = GSON.toJson(it)
|
||||||
@@ -172,24 +173,29 @@ class BookInfoActivity :
|
|||||||
shareWithQr(shareStr, it.name)
|
shareWithQr(shareStr, it.name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
R.id.menu_refresh -> {
|
R.id.menu_refresh -> {
|
||||||
refreshBook()
|
refreshBook()
|
||||||
}
|
}
|
||||||
|
|
||||||
R.id.menu_login -> viewModel.bookSource?.let {
|
R.id.menu_login -> viewModel.bookSource?.let {
|
||||||
startActivity<SourceLoginActivity> {
|
startActivity<SourceLoginActivity> {
|
||||||
putExtra("type", "bookSource")
|
putExtra("type", "bookSource")
|
||||||
putExtra("key", it.bookSourceUrl)
|
putExtra("key", it.bookSourceUrl)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
R.id.menu_top -> viewModel.topBook()
|
R.id.menu_top -> viewModel.topBook()
|
||||||
R.id.menu_set_source_variable -> setSourceVariable()
|
R.id.menu_set_source_variable -> setSourceVariable()
|
||||||
R.id.menu_set_book_variable -> setBookVariable()
|
R.id.menu_set_book_variable -> setBookVariable()
|
||||||
R.id.menu_copy_book_url -> viewModel.getBook()?.bookUrl?.let {
|
R.id.menu_copy_book_url -> viewModel.getBook()?.bookUrl?.let {
|
||||||
sendToClip(it)
|
sendToClip(it)
|
||||||
}
|
}
|
||||||
|
|
||||||
R.id.menu_copy_toc_url -> viewModel.getBook()?.tocUrl?.let {
|
R.id.menu_copy_toc_url -> viewModel.getBook()?.tocUrl?.let {
|
||||||
sendToClip(it)
|
sendToClip(it)
|
||||||
}
|
}
|
||||||
|
|
||||||
R.id.menu_can_update -> {
|
R.id.menu_can_update -> {
|
||||||
viewModel.getBook()?.let {
|
viewModel.getBook()?.let {
|
||||||
it.canUpdate = !it.canUpdate
|
it.canUpdate = !it.canUpdate
|
||||||
@@ -198,6 +204,7 @@ class BookInfoActivity :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
R.id.menu_clear_cache -> viewModel.clearCache()
|
R.id.menu_clear_cache -> viewModel.clearCache()
|
||||||
R.id.menu_log -> showDialogFragment<AppLogDialog>()
|
R.id.menu_log -> showDialogFragment<AppLogDialog>()
|
||||||
R.id.menu_split_long_chapter -> {
|
R.id.menu_split_long_chapter -> {
|
||||||
@@ -210,6 +217,7 @@ class BookInfoActivity :
|
|||||||
item.isChecked = !item.isChecked
|
item.isChecked = !item.isChecked
|
||||||
if (!item.isChecked) longToastOnUi(R.string.need_more_time_load_content)
|
if (!item.isChecked) longToastOnUi(R.string.need_more_time_load_content)
|
||||||
}
|
}
|
||||||
|
|
||||||
R.id.menu_delete_alert -> LocalConfig.bookInfoDeleteAlert = !item.isChecked
|
R.id.menu_delete_alert -> LocalConfig.bookInfoDeleteAlert = !item.isChecked
|
||||||
R.id.menu_upload -> {
|
R.id.menu_upload -> {
|
||||||
viewModel.getBook()?.let { book ->
|
viewModel.getBook()?.let { book ->
|
||||||
@@ -298,12 +306,14 @@ class BookInfoActivity :
|
|||||||
isLoading -> {
|
isLoading -> {
|
||||||
binding.tvToc.text = getString(R.string.toc_s, getString(R.string.loading))
|
binding.tvToc.text = getString(R.string.toc_s, getString(R.string.loading))
|
||||||
}
|
}
|
||||||
|
|
||||||
chapterList.isNullOrEmpty() -> {
|
chapterList.isNullOrEmpty() -> {
|
||||||
binding.tvToc.text = getString(
|
binding.tvToc.text = getString(
|
||||||
R.string.toc_s,
|
R.string.toc_s,
|
||||||
getString(R.string.error_load_toc)
|
getString(R.string.error_load_toc)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
viewModel.bookData.value?.let {
|
viewModel.bookData.value?.let {
|
||||||
if (it.durChapterIndex < chapterList.size) {
|
if (it.durChapterIndex < chapterList.size) {
|
||||||
@@ -619,6 +629,7 @@ class BookInfoActivity :
|
|||||||
.putExtra("bookUrl", book.bookUrl)
|
.putExtra("bookUrl", book.bookUrl)
|
||||||
.putExtra("inBookshelf", viewModel.inBookshelf)
|
.putExtra("inBookshelf", viewModel.inBookshelf)
|
||||||
)
|
)
|
||||||
|
|
||||||
else -> readBookResult.launch(
|
else -> readBookResult.launch(
|
||||||
Intent(this, ReadBookActivity::class.java)
|
Intent(this, ReadBookActivity::class.java)
|
||||||
.putExtra("bookUrl", book.bookUrl)
|
.putExtra("bookUrl", book.bookUrl)
|
||||||
@@ -654,9 +665,9 @@ class BookInfoActivity :
|
|||||||
if (viewModel.inBookshelf) {
|
if (viewModel.inBookshelf) {
|
||||||
viewModel.saveBook(book)
|
viewModel.saveBook(book)
|
||||||
} else if (groupId > 0) {
|
} else if (groupId > 0) {
|
||||||
viewModel.saveBook(book)
|
viewModel.addToBookshelf {
|
||||||
viewModel.inBookshelf = true
|
upTvBookshelf()
|
||||||
upTvBookshelf()
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -143,7 +143,6 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
private var menu: Menu? = null
|
private var menu: Menu? = null
|
||||||
private var autoPageJob: Job? = null
|
|
||||||
private var backupJob: Job? = null
|
private var backupJob: Job? = null
|
||||||
private var keepScreenJon: Job? = null
|
private var keepScreenJon: Job? = null
|
||||||
private var tts: TTS? = null
|
private var tts: TTS? = null
|
||||||
@@ -173,6 +172,7 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||||||
private var bookChanged = false
|
private var bookChanged = false
|
||||||
private var pageChanged = false
|
private var pageChanged = false
|
||||||
private var reloadContent = false
|
private var reloadContent = false
|
||||||
|
private val autoPageRenderer by lazy { SyncedRenderer { doAutoPage(it) } }
|
||||||
|
|
||||||
//恢复跳转前进度对话框的交互结果
|
//恢复跳转前进度对话框的交互结果
|
||||||
private var confirmRestoreProcess: Boolean? = null
|
private var confirmRestoreProcess: Boolean? = null
|
||||||
@@ -961,7 +961,7 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||||||
override fun autoPageStop() {
|
override fun autoPageStop() {
|
||||||
if (isAutoPage) {
|
if (isAutoPage) {
|
||||||
isAutoPage = false
|
isAutoPage = false
|
||||||
autoPageJob?.cancel()
|
autoPageRenderer.stop()
|
||||||
binding.readView.invalidate()
|
binding.readView.invalidate()
|
||||||
binding.readMenu.setAutoPage(false)
|
binding.readMenu.setAutoPage(false)
|
||||||
upScreenTimeOut()
|
upScreenTimeOut()
|
||||||
@@ -969,33 +969,27 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun autoPagePlus() {
|
private fun autoPagePlus() {
|
||||||
autoPageJob?.cancel()
|
autoPageRenderer.start()
|
||||||
autoPageJob = lifecycleScope.launch {
|
}
|
||||||
while (isActive) {
|
|
||||||
var delayMillis = ReadBookConfig.autoReadSpeed * 1000L / binding.readView.height
|
private fun doAutoPage(frameTime: Double) {
|
||||||
var scrollOffset = 1
|
if (menuLayoutIsVisible) {
|
||||||
if (delayMillis < 20) {
|
return
|
||||||
var delayInt = delayMillis.toInt()
|
}
|
||||||
if (delayInt == 0) delayInt = 1
|
val readTime = ReadBookConfig.autoReadSpeed * 1000.0
|
||||||
scrollOffset = 20 / delayInt
|
val height = binding.readView.height
|
||||||
delayMillis = 20
|
val scrollOffset = (height / readTime * frameTime).toInt().coerceAtLeast(1)
|
||||||
}
|
if (binding.readView.isScroll) {
|
||||||
delay(delayMillis)
|
binding.readView.curPage.scroll(-scrollOffset)
|
||||||
if (!menuLayoutIsVisible) {
|
} else {
|
||||||
if (binding.readView.isScroll) {
|
autoPageProgress += scrollOffset
|
||||||
binding.readView.curPage.scroll(-scrollOffset)
|
if (autoPageProgress >= height) {
|
||||||
} else {
|
autoPageProgress = 0
|
||||||
autoPageProgress += scrollOffset
|
if (!binding.readView.fillPage(PageDirection.NEXT)) {
|
||||||
if (autoPageProgress >= binding.readView.height) {
|
autoPageStop()
|
||||||
autoPageProgress = 0
|
|
||||||
if (!binding.readView.fillPage(PageDirection.NEXT)) {
|
|
||||||
autoPageStop()
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
binding.readView.invalidate()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
binding.readView.invalidate()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,7 +104,9 @@ class AutoReadDialog : BaseDialogFragment(R.layout.dialog_auto_read) {
|
|||||||
binding.llCatalog.setOnClickListener { callBack?.openChapterList() }
|
binding.llCatalog.setOnClickListener { callBack?.openChapterList() }
|
||||||
binding.llAutoPageStop.setOnClickListener {
|
binding.llAutoPageStop.setOnClickListener {
|
||||||
callBack?.autoPageStop()
|
callBack?.autoPageStop()
|
||||||
dismissAllowingStateLoss()
|
binding.llAutoPageStop.post {
|
||||||
|
dismissAllowingStateLoss()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package io.legado.app.utils
|
||||||
|
|
||||||
|
import android.view.Choreographer
|
||||||
|
|
||||||
|
class SyncedRenderer(val doFrame: (frameTime: Double) -> Unit) {
|
||||||
|
|
||||||
|
private var callback: (Long) -> Unit = {}
|
||||||
|
|
||||||
|
fun start() {
|
||||||
|
var currTime = System.nanoTime() / 1000000.0
|
||||||
|
callback = {
|
||||||
|
val currTimeMs = it / 1000000.0
|
||||||
|
val frameTime = currTimeMs - currTime
|
||||||
|
currTime = currTimeMs
|
||||||
|
doFrame(frameTime)
|
||||||
|
Choreographer.getInstance().postFrameCallback(callback)
|
||||||
|
}
|
||||||
|
Choreographer.getInstance().postFrameCallback(callback)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun stop() {
|
||||||
|
Choreographer.getInstance().removeFrameCallback(callback)
|
||||||
|
callback = {}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user