diff --git a/.github/workflows/autoupdatefork.yml b/.github/workflows/autoupdatefork.yml index 5503fa8de..4206fd2b7 100644 --- a/.github/workflows/autoupdatefork.yml +++ b/.github/workflows/autoupdatefork.yml @@ -11,7 +11,7 @@ jobs: if: ${{ github.event.repository.owner.id == github.event.sender.id && github.actor != 'gedoor' }} steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set env run: | git config --global user.email "github-actions@github.com" diff --git a/.github/workflows/cronet.yml b/.github/workflows/cronet.yml index 668d2a389..6885d52ba 100644 --- a/.github/workflows/cronet.yml +++ b/.github/workflows/cronet.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest if: ${{ github.repository == 'gedoor/legado' }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Check Cronet Updates run: source .github/scripts/cronet.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 93c48b938..e69ae0688 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -42,7 +42,7 @@ jobs: VERSION: ${{ needs.prepare.outputs.version }} play: ${{ needs.prepare.outputs.play }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up JDK 17 uses: actions/setup-java@v3 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cfefcb930..e1de9b1a8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -53,7 +53,7 @@ jobs: VERSION: ${{ needs.prepare.outputs.version }} VERSIONL: ${{ needs.prepare.outputs.versionL }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up JDK 17 @@ -113,7 +113,7 @@ jobs: # 蓝奏云里的文件夹ID(阅读3测试版:2670621) LANZOU_FOLDER_ID: '2670621' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/download-artifact@v3 with: path: apk/ @@ -131,7 +131,7 @@ jobs: runs-on: ubuntu-latest if: ${{ github.event_name != 'pull_request' && github.actor == 'gedoor' }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/download-artifact@v3 with: path: apk/ @@ -157,7 +157,7 @@ jobs: CHANNEL_ID: ${{ secrets.CHANNEL_ID }} BOT_TOKEN: ${{ secrets.BOT_TOKEN }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/download-artifact@v3 with: path: apk/ diff --git a/.github/workflows/web.yml b/.github/workflows/web.yml index b24afb196..bb8953bfe 100644 --- a/.github/workflows/web.yml +++ b/.github/workflows/web.yml @@ -20,7 +20,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install Node.js uses: actions/setup-node@v3 diff --git a/app/build.gradle b/app/build.gradle index edf73ba99..54ccea8e4 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -184,7 +184,7 @@ dependencies { implementation('com.google.code.gson:gson:2.10.1') //lifecycle - def lifecycle_version = '2.6.1' + def lifecycle_version = '2.6.2' implementation("androidx.lifecycle:lifecycle-common-java8:$lifecycle_version") implementation("androidx.lifecycle:lifecycle-service:$lifecycle_version") diff --git a/app/cronetlib/cronet_api.jar b/app/cronetlib/cronet_api.jar index 2030f5e79..a239c2f74 100644 Binary files a/app/cronetlib/cronet_api.jar and b/app/cronetlib/cronet_api.jar differ diff --git a/app/cronetlib/cronet_impl_common_java.jar b/app/cronetlib/cronet_impl_common_java.jar index 853040e38..38bfc008d 100644 Binary files a/app/cronetlib/cronet_impl_common_java.jar and b/app/cronetlib/cronet_impl_common_java.jar differ diff --git a/app/cronetlib/cronet_impl_native_java.jar b/app/cronetlib/cronet_impl_native_java.jar index 22bb50f3a..22a104eab 100644 Binary files a/app/cronetlib/cronet_impl_native_java.jar and b/app/cronetlib/cronet_impl_native_java.jar differ diff --git a/app/cronetlib/cronet_impl_platform_java.jar b/app/cronetlib/cronet_impl_platform_java.jar index 37f881951..81849e737 100644 Binary files a/app/cronetlib/cronet_impl_platform_java.jar and b/app/cronetlib/cronet_impl_platform_java.jar differ diff --git a/app/src/main/assets/cronet.json b/app/src/main/assets/cronet.json index 684d5bcb0..54d8f7f24 100644 --- a/app/src/main/assets/cronet.json +++ b/app/src/main/assets/cronet.json @@ -1 +1 @@ -{"arm64-v8a":"d1d80901d4237fa0af5abc83ac6a7419","armeabi-v7a":"21923acaea2ec3fa03943b2466ab6f4e","x86":"0f90e0244c417bd86d11d0eefdb39773","x86_64":"3cb944b2bf0a1abab4e2bd2f3c6e05d0","version":"115.0.5790.138"} \ No newline at end of file +{"armeabi-v7a":"af4e0909b1c9b4c1b22037ca6ca1d6ec","arm64-v8a":"7b57dc697f55653f3f7de33338dc9dcf","x86_64":"a91196950841eb45b8dda49da256b188","x86":"a639c96f5c352bab109e1ba48fec57bc","version":"117.0.5938.60"} \ No newline at end of file diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index a2d7e9f97..a32db23b8 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -13,6 +13,7 @@ * 漫画源看书显示乱码,**阅读与其他软件的源并不通用**,请导入阅读的支持的漫画源! **2023/08/02** +* 更新cronet: 117.0.5938.60 * 书签导出md格式 * 优化进度同步,减少webDav下载次数 diff --git a/app/src/main/java/io/legado/app/constant/PreferKey.kt b/app/src/main/java/io/legado/app/constant/PreferKey.kt index a94d433e9..e16ac6879 100644 --- a/app/src/main/java/io/legado/app/constant/PreferKey.kt +++ b/app/src/main/java/io/legado/app/constant/PreferKey.kt @@ -137,6 +137,7 @@ object PreferKey { const val batchChangeSourceDelay = "batchChangeSourceDelay" const val openBookInfoByClickTitle = "openBookInfoByClickTitle" const val defaultHomePage = "defaultHomePage" + const val showBookshelfFastScroller = "showBookshelfFastScroller" const val cPrimary = "colorPrimary" const val cAccent = "colorAccent" diff --git a/app/src/main/java/io/legado/app/help/config/AppConfig.kt b/app/src/main/java/io/legado/app/help/config/AppConfig.kt index 804d53794..10c98ef02 100644 --- a/app/src/main/java/io/legado/app/help/config/AppConfig.kt +++ b/app/src/main/java/io/legado/app/help/config/AppConfig.kt @@ -403,6 +403,12 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener { appCtx.putPrefBoolean(PreferKey.openBookInfoByClickTitle, value) } + var showBookshelfFastScroller: Boolean + get() = appCtx.getPrefBoolean(PreferKey.showBookshelfFastScroller, false) + set(value) { + appCtx.putPrefBoolean(PreferKey.showBookshelfFastScroller, value) + } + var contentSelectSpeakMod: Int get() = appCtx.getPrefInt(PreferKey.contentSelectSpeakMod) set(value) { diff --git a/app/src/main/java/io/legado/app/help/coroutine/Coroutine.kt b/app/src/main/java/io/legado/app/help/coroutine/Coroutine.kt index 4a0965f7c..4610ae334 100644 --- a/app/src/main/java/io/legado/app/help/coroutine/Coroutine.kt +++ b/app/src/main/java/io/legado/app/help/coroutine/Coroutine.kt @@ -138,7 +138,7 @@ class Coroutine( job.cancel(cause) } cancel?.let { - MainScope().launch { + MainScope().launch(executeContext) { if (null == it.context) { it.block.invoke(scope) } else { diff --git a/app/src/main/java/io/legado/app/help/http/OkHttpExceptionInterceptor.kt b/app/src/main/java/io/legado/app/help/http/OkHttpExceptionInterceptor.kt index c1111a77d..018044274 100644 --- a/app/src/main/java/io/legado/app/help/http/OkHttpExceptionInterceptor.kt +++ b/app/src/main/java/io/legado/app/help/http/OkHttpExceptionInterceptor.kt @@ -1,6 +1,5 @@ package io.legado.app.help.http -import io.legado.app.utils.asIOException import okhttp3.Interceptor import okhttp3.Response import java.io.IOException diff --git a/app/src/main/java/io/legado/app/model/ReadBook.kt b/app/src/main/java/io/legado/app/model/ReadBook.kt index 8b7e9b7fc..e360c7e2a 100644 --- a/app/src/main/java/io/legado/app/model/ReadBook.kt +++ b/app/src/main/java/io/legado/app/model/ReadBook.kt @@ -20,6 +20,7 @@ import io.legado.app.utils.toastOnUi import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers.IO import kotlinx.coroutines.MainScope +import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.delay import kotlinx.coroutines.launch import splitties.init.appCtx @@ -55,6 +56,7 @@ object ReadBook : CoroutineScope by MainScope() { var preDownloadTask: Coroutine<*>? = null val downloadedChapters = hashSetOf() var contentProcessor: ContentProcessor? = null + val downloadScope = CoroutineScope(SupervisorJob() + IO) //暂时保存跳转前进度 fun saveCurrentBookProcess() { @@ -355,7 +357,7 @@ object ReadBook : CoroutineScope by MainScope() { success?.invoke() } } ?: download( - this, + downloadScope, chapter, resetPageOffset = resetPageOffset, pageChanged = pageChanged @@ -386,7 +388,12 @@ object ReadBook : CoroutineScope by MainScope() { downloadedChapters.add(chapter.index) } else { delay(1000) - download(this, chapter, resetPageOffset = false, pageChanged = false) + download( + downloadScope, + chapter, + resetPageOffset = false, + pageChanged = false + ) } } ?: removeLoading(index) } catch (e: Exception) { @@ -503,7 +510,7 @@ object ReadBook : CoroutineScope by MainScope() { ) { appDb.bookChapterDao.insert(*cList.toTypedArray()) chapterSize = cList.size - nextTextChapter ?: loadContent(1) + nextTextChapter ?: loadContent(durChapterIndex + 1) } } } @@ -521,16 +528,19 @@ object ReadBook : CoroutineScope by MainScope() { } fun saveRead() { - Coroutine.async { + Coroutine.async(executeContext = IO) { val book = book ?: return@async book.lastCheckCount = 0 book.durChapterTime = System.currentTimeMillis() + val chapterChanged = book.durChapterIndex != durChapterIndex book.durChapterIndex = durChapterIndex book.durChapterPos = durChapterPos - appDb.bookChapterDao.getChapter(book.bookUrl, durChapterIndex)?.let { - book.durChapterTitle = it.getDisplayTitle( - ContentProcessor.get(book.name, book.origin).getTitleReplaceRules() - ) + if (chapterChanged) { + appDb.bookChapterDao.getChapter(book.bookUrl, durChapterIndex)?.let { + book.durChapterTitle = it.getDisplayTitle( + ContentProcessor.get(book.name, book.origin).getTitleReplaceRules() + ) + } } appDb.bookDao.update(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 5057da78b..ca89af7c5 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 @@ -215,12 +215,16 @@ class ReadBookActivity : BaseReadBookActivity(), override fun onPostCreate(savedInstanceState: Bundle?) { super.onPostCreate(savedInstanceState) - viewModel.initData(intent) + viewModel.initData(intent) { + upMenu() + } } override fun onNewIntent(intent: Intent?) { super.onNewIntent(intent) - viewModel.initData(intent ?: return) + viewModel.initData(intent ?: return) { + upMenu() + } } override fun onWindowFocusChanged(hasFocus: Boolean) { @@ -244,7 +248,9 @@ class ReadBookActivity : BaseReadBookActivity(), if (bookChanged) { bookChanged = false ReadBook.callBack = this - viewModel.initData(intent) + viewModel.initData(intent) { + upMenu() + } } else { //web端阅读时,app处于阅读界面,本地记录会覆盖web保存的进度,在此处恢复 ReadBook.webBookProgress?.let { @@ -1368,6 +1374,8 @@ class ReadBookActivity : BaseReadBookActivity(), ReadBook.callBack = null } ReadBook.preDownloadTask?.cancel() + ReadBook.downloadScope.coroutineContext.cancelChildren() + ReadBook.coroutineContext.cancelChildren() ReadBook.downloadedChapters.clear() if (!BuildConfig.DEBUG) { Backup.autoBack(this) diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt index 79053a54a..eabf7592a 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt @@ -56,7 +56,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { /** * 初始化 */ - fun initData(intent: Intent) { + fun initData(intent: Intent, success: (() -> Unit)? = null) { execute { ReadBook.inBookshelf = intent.getBooleanExtra("inBookshelf", true) ReadBook.tocChanged = intent.getBooleanExtra("tocChanged", false) @@ -70,6 +70,8 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { book != null -> initBook(book) else -> ReadBook.upMsg(context.getString(R.string.no_book)) } + }.onSuccess { + success?.invoke() }.onError { val msg = "初始化数据失败\n${it.localizedMessage}" ReadBook.upMsg(msg) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt index b293f5686..0a5cdb78d 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt @@ -285,14 +285,14 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at val offset = (ChapterProvider.visibleHeight - textPage.height).toInt() pageOffset = min(0, offset) } else if (pageOffset > 0) { - pageFactory.moveToPrev(false) + pageFactory.moveToPrev(true) textPage = pageFactory.curPage pageOffset -= textPage.height.toInt() upView?.invoke(textPage) contentDescription = textPage.text } else if (pageOffset < -textPage.height) { pageOffset += textPage.height.toInt() - pageFactory.moveToNext(false) + pageFactory.moveToNext(true) textPage = pageFactory.curPage upView?.invoke(textPage) contentDescription = textPage.text diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/provider/TextPageFactory.kt b/app/src/main/java/io/legado/app/ui/book/read/page/provider/TextPageFactory.kt index 1bceccd6a..c38a62cbd 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/provider/TextPageFactory.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/provider/TextPageFactory.kt @@ -39,8 +39,8 @@ class TextPageFactory(dataSource: DataSource) : PageFactory(dataSource ReadBook.moveToNextChapter(upContent) } else { ReadBook.setPageIndex(pageIndex.plus(1)) + if (upContent) upContent(resetPageOffset = false) } - if (upContent) upContent(resetPageOffset = false) true } else false @@ -52,8 +52,8 @@ class TextPageFactory(dataSource: DataSource) : PageFactory(dataSource ReadBook.moveToPrevChapter(upContent) } else { ReadBook.setPageIndex(pageIndex.minus(1)) + if (upContent) upContent(resetPageOffset = false) } - if (upContent) upContent(resetPageOffset = false) true } else false diff --git a/app/src/main/java/io/legado/app/ui/main/MainViewModel.kt b/app/src/main/java/io/legado/app/ui/main/MainViewModel.kt index a5637b599..cea73eeea 100644 --- a/app/src/main/java/io/legado/app/ui/main/MainViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/main/MainViewModel.kt @@ -138,7 +138,7 @@ class MainViewModel(application: Application) : BaseViewModel(application) { } waitUpTocBooks.remove(bookUrl) upTocAdd(bookUrl) - execute(context = upTocPool, executeContext = IO) { + execute(context = upTocPool, executeContext = upTocPool) { kotlin.runCatching { val oldBook = book.copy() WebBook.runPreUpdateJs(source, book) @@ -170,10 +170,10 @@ class MainViewModel(application: Application) : BaseViewModel(application) { appDb.bookDao.update(book) } } - }.onCancel(upTocPool) { + }.onCancel { upTocCancel(bookUrl) upTocCancel(book.bookUrl) - }.onFinally(upTocPool) { + }.onFinally { upTocFinally(bookUrl) upTocFinally(book.bookUrl) postUpBooksLiveData() diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/BaseBookshelfFragment.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/BaseBookshelfFragment.kt index 9fe85cf18..c4a18d6fa 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/BaseBookshelfFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/BaseBookshelfFragment.kt @@ -146,6 +146,7 @@ abstract class BaseBookshelfFragment(layoutId: Int) : VMBaseFragment(EventBus.BOOKSHELF_REFRESH) { booksAdapter.notifyDataSetChanged() startLastUpdateTimeJob() + upFastScrollerBar() } } -} \ No newline at end of file +} diff --git a/app/src/main/res/layout/dialog_bookshelf_config.xml b/app/src/main/res/layout/dialog_bookshelf_config.xml index 53d3ced61..a417e1290 100644 --- a/app/src/main/res/layout/dialog_bookshelf_config.xml +++ b/app/src/main/res/layout/dialog_bookshelf_config.xml @@ -58,13 +58,22 @@ app:layout_constraintTop_toBottomOf="@+id/sw_show_last_update_time" tools:ignore="TouchTargetSizeCheck" /> + + diff --git a/app/src/main/res/values-es-rES/strings.xml b/app/src/main/res/values-es-rES/strings.xml index d525779a1..4dc5ffab7 100644 --- a/app/src/main/res/values-es-rES/strings.xml +++ b/app/src/main/res/values-es-rES/strings.xml @@ -1131,4 +1131,5 @@ 默认主页 Use LibArchive Using libarchive to extract files, it supports extracting RAR5. + 显示快速滚动条 diff --git a/app/src/main/res/values-ja-rJP/strings.xml b/app/src/main/res/values-ja-rJP/strings.xml index 081095035..52712cf10 100644 --- a/app/src/main/res/values-ja-rJP/strings.xml +++ b/app/src/main/res/values-ja-rJP/strings.xml @@ -1134,4 +1134,5 @@ 默认主页 Use LibArchive Using libarchive to extract files, it supports extracting RAR5. + 显示快速滚动条 diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index 1d70d5cd9..70c79d84a 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -1134,4 +1134,5 @@ 默认主页 Use LibArchive Using libarchive to extract files, it supports extracting RAR5. + 显示快速滚动条 diff --git a/app/src/main/res/values-vi/strings.xml b/app/src/main/res/values-vi/strings.xml index 2454a780d..d713759b5 100644 --- a/app/src/main/res/values-vi/strings.xml +++ b/app/src/main/res/values-vi/strings.xml @@ -1129,4 +1129,5 @@ Còn 等待导出 Use LibArchive Using libarchive to extract files, it supports extracting RAR5. + 显示快速滚动条 \ No newline at end of file diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index 2fab1ce4b..b0c5a3b01 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -1130,4 +1130,5 @@ 等待导出 使用LibArchive 使用libarchive解壓檔案,支持解壓RAR5。 + 显示快速滚动条 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 638162291..bd3c7c431 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -1132,4 +1132,5 @@ 等待导出 使用LibArchive 使用libarchive解壓檔案,支持解壓RAR5。 + 显示快速滚动条 diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index 879bf5f66..f74d00a26 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -1132,4 +1132,5 @@ 等待导出 使用LibArchive 使用libarchive解压文件,支持解压RAR5。 + 显示快速滚动条 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d4b2a000b..3b65dd984 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1134,4 +1134,5 @@ 默认主页 Use LibArchive Using libarchive to extract files, it supports extracting RAR5. + 显示快速滚动条 diff --git a/build.gradle b/build.gradle index d6a614998..2d54a9a85 100644 --- a/build.gradle +++ b/build.gradle @@ -18,7 +18,7 @@ plugins { id 'com.android.library' version "$agp_version" apply false id 'org.jetbrains.kotlin.android' version "$kotlin_version" apply false id 'com.google.devtools.ksp' version "$kotlin_version-$ksp_version" apply false - id "de.undercouch.download" version "5.4.0" apply false + id "de.undercouch.download" version "5.5.0" apply false id "com.google.gms.google-services" version "4.3.15" apply false } diff --git a/gradle.properties b/gradle.properties index 7b7d413f4..5534f79a1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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=115.0.5790.138 -CronetMainVersion=115.0.0.0 +CronetVersion=117.0.5938.60 +CronetMainVersion=117.0.0.0 android.injected.testOnly=false android.nonFinalResIds=true \ No newline at end of file