Compare commits

...

4 Commits

Author SHA1 Message Date
kunfei
35e145b162
Merge 2420c387ad into ad0aeab06e 2024-04-11 06:58:48 +08:00
Horis
ad0aeab06e 优化 2024-04-10 14:31:02 +08:00
Horis
cc75fc9394 优化 2024-04-10 13:58:25 +08:00
Xwite
2420c387ad Bump cronet from 123.0.6312.80 to 123.0.6312.99
- Changes in the [Git log](https://chromium.googlesource.com/chromium/src/+log/123.0.6312.80..123.0.6312.99)
2024-04-08 01:27:41 +00:00
10 changed files with 92 additions and 53 deletions

Binary file not shown.

View File

@ -1 +1 @@
{"arm64-v8a":"bbf2c50d1ebf0763d451b08e290a3244","armeabi-v7a":"ecb872f7b1b5342f4d7c36262bec0600","x86":"4da4832b89e2412d808c5b1ecdc24e3d","x86_64":"62080f051db02ed0e939affb39ce67fb","version":"123.0.6312.80"}
{"x86":"869acc77f5549e35e0826a28ef52140d","x86_64":"636833da59cea3c7c5ff1a7a2288987c","arm64-v8a":"1712aca12448478d48c32a7aaf3304b6","armeabi-v7a":"1dd90679b82d995e0a87138f3251375e","version":"123.0.6312.99"}

View File

@ -13,6 +13,7 @@
* 漫画源看书显示乱码,**阅读与其他软件的源并不通用**,请导入阅读的支持的漫画源!
**2024/02/27**
* 更新cronet: 123.0.6312.99
* 更新cronet: 123.0.6312.80
* 更新cronet: 123.0.6312.40

View File

@ -4,6 +4,7 @@ package io.legado.app.constant
object IntentAction {
const val start = "start"
const val play = "play"
const val playNew = "playNew"
const val stop = "stop"
const val resume = "resume"
const val pause = "pause"

View File

@ -97,10 +97,10 @@ data class ReplaceRule(
AppLog.put("正则语法错误或不支持:${ex.localizedMessage}", ex)
return false
}
}
// Pattern.compile测试通过但是部分情况下会替换超时报错一般发生在修改表达式时漏删了
if (pattern.endsWith('|') and !pattern.endsWith("\\|")) {
return false
// Pattern.compile测试通过但是部分情况下会替换超时报错一般发生在修改表达式时漏删了
if (pattern.endsWith('|') && !pattern.endsWith("\\|")) {
return false
}
}
return true
}

View File

@ -27,9 +27,25 @@ object AudioPlay {
var inBookshelf = false
var bookSource: BookSource? = null
val loadingChapters = arrayListOf<Int>()
var durChapterIndex = 0
fun headers(hasLoginHeader: Boolean): Map<String, String>? {
return bookSource?.getHeaderMap(hasLoginHeader)
fun upData(context: Context, book: Book) {
AudioPlay.book = book
upDurChapter(book)
if (durChapterIndex != book.durChapterIndex) {
durChapterIndex = book.durChapterIndex
playNew(context)
}
}
fun resetData(context: Context, book: Book) {
stop(context)
AudioPlay.book = book
titleData.postValue(book.name)
coverData.postValue(book.getDisplayCover())
bookSource = book.getBookSource()
durChapterIndex = book.durChapterIndex
upDurChapter(book)
}
/**
@ -48,6 +64,22 @@ object AudioPlay {
}
}
/**
* 从头播放新章节
*/
fun playNew(context: Context) {
book?.let {
if (durChapter == null) {
upDurChapter(it)
}
durChapter?.let {
context.startService<AudioPlayService> {
action = IntentAction.playNew
}
}
}
}
/**
* 更新当前章节
*/
@ -105,9 +137,10 @@ object AudioPlay {
book?.let { book ->
book.durChapterIndex = index
book.durChapterPos = 0
durChapterIndex = book.durChapterIndex
durChapter = null
saveRead()
play(context)
playNew(context)
}
}
}
@ -118,6 +151,7 @@ object AudioPlay {
if (book.durChapterIndex > 0) {
book.durChapterIndex -= 1
book.durChapterPos = 0
durChapterIndex = book.durChapterIndex
durChapter = null
saveRead()
play(context)
@ -133,6 +167,7 @@ object AudioPlay {
if (book.durChapterIndex + 1 < book.totalChapterNum) {
book.durChapterIndex += 1
book.durChapterPos = 0
durChapterIndex = book.durChapterIndex
durChapter = null
saveRead()
play(context)

View File

@ -144,11 +144,20 @@ class AudioPlayService : BaseService(),
when (action) {
IntentAction.play -> {
exoPlayer.stop()
upPlayProgressJob?.cancel()
pause = false
position = AudioPlay.book?.durChapterPos ?: 0
loadContent()
}
IntentAction.playNew -> {
exoPlayer.stop()
upPlayProgressJob?.cancel()
pause = false
position = 0
loadContent()
}
IntentAction.pause -> pause()
IntentAction.resume -> resume()
IntentAction.prev -> AudioPlay.prev(this)
@ -160,7 +169,7 @@ class AudioPlayService : BaseService(),
adjustProgress(intent.getIntExtra("position", position))
}
else -> stopSelf()
IntentAction.stop -> stopSelf()
}
}
return super.onStartCommand(intent, flags, startId)
@ -204,7 +213,6 @@ class AudioPlayService : BaseService(),
source = AudioPlay.bookSource,
ruleData = AudioPlay.book,
chapter = AudioPlay.durChapter,
headerMapF = AudioPlay.headers(true),
)
exoPlayer.setMediaItem(analyzeUrl.getMediaItem())
exoPlayer.playWhenReady = true

View File

@ -2,6 +2,7 @@ package io.legado.app.ui.book.audio
import android.app.Application
import android.content.Intent
import androidx.lifecycle.viewModelScope
import io.legado.app.R
import io.legado.app.base.BaseViewModel
import io.legado.app.constant.BookType
@ -12,70 +13,63 @@ import io.legado.app.data.entities.BookChapter
import io.legado.app.data.entities.BookSource
import io.legado.app.help.book.removeType
import io.legado.app.model.AudioPlay
import io.legado.app.model.AudioPlay.durChapter
import io.legado.app.model.webBook.WebBook
import io.legado.app.utils.postEvent
import io.legado.app.utils.toastOnUi
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Dispatchers.IO
class AudioPlayViewModel(application: Application) : BaseViewModel(application) {
fun initData(intent: Intent) = AudioPlay.apply {
execute {
val bookUrl = intent.getStringExtra("bookUrl")
if (bookUrl != null && bookUrl != book?.bookUrl) {
stop(context)
inBookshelf = intent.getBooleanExtra("inBookshelf", true)
book = appDb.bookDao.getBook(bookUrl)
book?.let { book ->
titleData.postValue(book.name)
coverData.postValue(book.getDisplayCover())
durChapter = appDb.bookChapterDao.getChapter(book.bookUrl, book.durChapterIndex)
upDurChapter(book)
bookSource = appDb.bookSourceDao.getBookSource(book.origin)
if (durChapter == null) {
if (book.tocUrl.isEmpty()) {
loadBookInfo(book)
} else {
loadChapterList(book)
}
}
}
}
val bookUrl = intent.getStringExtra("bookUrl") ?: return@execute
val book = appDb.bookDao.getBook(bookUrl) ?: return@execute
inBookshelf = intent.getBooleanExtra("inBookshelf", true)
initBook(book)
}.onFinally {
saveRead()
}
}
private fun loadBookInfo(book: Book) {
execute {
AudioPlay.bookSource?.let {
WebBook.getBookInfo(this, it, book)
.onSuccess {
loadChapterList(book)
}
private fun initBook(book: Book) {
val isSameBook = AudioPlay.book?.bookUrl == book.bookUrl
if (isSameBook) {
AudioPlay.upData(context, book)
} else {
AudioPlay.resetData(context, book)
}
if (durChapter == null) {
if (book.tocUrl.isEmpty()) {
loadBookInfo(book)
} else {
loadChapterList(book)
}
}
}
private fun loadBookInfo(book: Book) {
val bookSource = AudioPlay.bookSource ?: return
WebBook.getBookInfo(viewModelScope, bookSource, book).onSuccess(IO) {
loadChapterList(book)
}
}
private fun loadChapterList(book: Book) {
execute {
AudioPlay.bookSource?.let {
WebBook.getChapterList(this, it, book)
.onSuccess(Dispatchers.IO) { cList ->
book.save()
appDb.bookChapterDao.insert(*cList.toTypedArray())
AudioPlay.upDurChapter(book)
}.onError {
context.toastOnUi(R.string.error_load_toc)
}
}
val bookSource = AudioPlay.bookSource ?: return
WebBook.getChapterList(viewModelScope, bookSource, book).onSuccess(IO) { cList ->
book.save()
appDb.bookChapterDao.insert(*cList.toTypedArray())
AudioPlay.upDurChapter(book)
}.onError {
context.toastOnUi(R.string.error_load_toc)
}
}
fun upSource() {
execute {
AudioPlay.book?.let { book ->
AudioPlay.bookSource = appDb.bookSourceDao.getBookSource(book.origin)
}
val book = AudioPlay.book ?: return@execute
AudioPlay.bookSource = book.getBookSource()
}
}

View File

@ -42,7 +42,7 @@ android.defaults.buildfeatures.shaders=false
# and none from the library's dependencies, thereby reducing the size of the R class for that library.
android.nonTransitiveRClass=true
# https://chromiumdash.appspot.com/releases?platform=Android
CronetVersion=123.0.6312.80
CronetVersion=123.0.6312.99
CronetMainVersion=123.0.0.0
android.injected.testOnly=false
android.nonFinalResIds=true