Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
gedoor committed Sep 19, 2023
2 parents 4592ee4 + 3bf2204 commit 4860b0d
Show file tree
Hide file tree
Showing 36 changed files with 100 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/autoupdatefork.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cronet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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/
Expand All @@ -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/
Expand All @@ -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/
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
Binary file modified app/cronetlib/cronet_api.jar
Binary file not shown.
Binary file modified app/cronetlib/cronet_impl_common_java.jar
Binary file not shown.
Binary file modified app/cronetlib/cronet_impl_native_java.jar
Binary file not shown.
Binary file modified app/cronetlib/cronet_impl_platform_java.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion app/src/main/assets/cronet.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"arm64-v8a":"d1d80901d4237fa0af5abc83ac6a7419","armeabi-v7a":"21923acaea2ec3fa03943b2466ab6f4e","x86":"0f90e0244c417bd86d11d0eefdb39773","x86_64":"3cb944b2bf0a1abab4e2bd2f3c6e05d0","version":"115.0.5790.138"}
{"armeabi-v7a":"af4e0909b1c9b4c1b22037ca6ca1d6ec","arm64-v8a":"7b57dc697f55653f3f7de33338dc9dcf","x86_64":"a91196950841eb45b8dda49da256b188","x86":"a639c96f5c352bab109e1ba48fec57bc","version":"117.0.5938.60"}
1 change: 1 addition & 0 deletions app/src/main/assets/updateLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* 漫画源看书显示乱码,**阅读与其他软件的源并不通用**,请导入阅读的支持的漫画源!

**2023/08/02**
* 更新cronet: 117.0.5938.60

* 书签导出md格式
* 优化进度同步,减少webDav下载次数
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/io/legado/app/constant/PreferKey.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/java/io/legado/app/help/config/AppConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class Coroutine<T>(
job.cancel(cause)
}
cancel?.let {
MainScope().launch {
MainScope().launch(executeContext) {
if (null == it.context) {
it.block.invoke(scope)
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
26 changes: 18 additions & 8 deletions app/src/main/java/io/legado/app/model/ReadBook.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -55,6 +56,7 @@ object ReadBook : CoroutineScope by MainScope() {
var preDownloadTask: Coroutine<*>? = null
val downloadedChapters = hashSetOf<Int>()
var contentProcessor: ContentProcessor? = null
val downloadScope = CoroutineScope(SupervisorJob() + IO)

//暂时保存跳转前进度
fun saveCurrentBookProcess() {
Expand Down Expand Up @@ -355,7 +357,7 @@ object ReadBook : CoroutineScope by MainScope() {
success?.invoke()
}
} ?: download(
this,
downloadScope,
chapter,
resetPageOffset = resetPageOffset,
pageChanged = pageChanged
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -503,7 +510,7 @@ object ReadBook : CoroutineScope by MainScope() {
) {
appDb.bookChapterDao.insert(*cList.toTypedArray())
chapterSize = cList.size
nextTextChapter ?: loadContent(1)
nextTextChapter ?: loadContent(durChapterIndex + 1)
}
}
}
Expand All @@ -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)
}
Expand Down
14 changes: 11 additions & 3 deletions app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ class TextPageFactory(dataSource: DataSource) : PageFactory<TextPage>(dataSource
ReadBook.moveToNextChapter(upContent)
} else {
ReadBook.setPageIndex(pageIndex.plus(1))
if (upContent) upContent(resetPageOffset = false)
}
if (upContent) upContent(resetPageOffset = false)
true
} else
false
Expand All @@ -52,8 +52,8 @@ class TextPageFactory(dataSource: DataSource) : PageFactory<TextPage>(dataSource
ReadBook.moveToPrevChapter(upContent)
} else {
ReadBook.setPageIndex(pageIndex.minus(1))
if (upContent) upContent(resetPageOffset = false)
}
if (upContent) upContent(resetPageOffset = false)
true
} else
false
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/io/legado/app/ui/main/MainViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ abstract class BaseBookshelfFragment(layoutId: Int) : VMBaseFragment<BookshelfVi
swShowUnread.isChecked = AppConfig.showUnread
swShowLastUpdateTime.isChecked = AppConfig.showLastUpdateTime
swShowWaitUpBooks.isChecked = AppConfig.showWaitUpCount
swShowBookshelfFastScroller.isChecked = AppConfig.showBookshelfFastScroller
rgLayout.checkByIndex(bookshelfLayout)
rgSort.checkByIndex(bookshelfSort)
}
Expand All @@ -168,6 +169,10 @@ abstract class BaseBookshelfFragment(layoutId: Int) : VMBaseFragment<BookshelfVi
AppConfig.showWaitUpCount = swShowWaitUpBooks.isChecked
activityViewModel.postUpBooksLiveData(true)
}
if (AppConfig.showBookshelfFastScroller != swShowBookshelfFastScroller.isChecked) {
AppConfig.showBookshelfFastScroller = swShowBookshelfFastScroller.isChecked
postEvent(EventBus.BOOKSHELF_REFRESH, "")
}
if (bookshelfSort != rgSort.getCheckedIndex()) {
AppConfig.bookshelfSort = rgSort.getCheckedIndex()
upSort()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class BooksFragment() : BaseFragment(R.layout.fragment_books),
var bookSort = 0
private set
private var upLastUpdateTimeJob: Job? = null
private var defaultScrollBarSize = 0

override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
this.savedInstanceState = savedInstanceState
Expand All @@ -86,6 +87,8 @@ class BooksFragment() : BaseFragment(R.layout.fragment_books),

private fun initRecyclerView() {
binding.rvBookshelf.setEdgeEffectColor(primaryColor)
defaultScrollBarSize = binding.rvBookshelf.scrollBarSize
upFastScrollerBar()
binding.refreshLayout.setColorSchemeColors(accentColor)
binding.refreshLayout.setOnRefreshListener {
binding.refreshLayout.isRefreshing = false
Expand Down Expand Up @@ -117,6 +120,16 @@ class BooksFragment() : BaseFragment(R.layout.fragment_books),
startLastUpdateTimeJob()
}

private fun upFastScrollerBar() {
val showBookshelfFastScroller = AppConfig.showBookshelfFastScroller
binding.rvBookshelf.setFastScrollEnabled(showBookshelfFastScroller)
if (showBookshelfFastScroller) {
binding.rvBookshelf.scrollBarSize = 0
} else {
binding.rvBookshelf.scrollBarSize = defaultScrollBarSize
}
}

fun upBookSort(sort: Int) {
binding.root.post {
arguments?.putInt("bookSort", sort)
Expand Down Expand Up @@ -275,6 +288,7 @@ class BooksFragment() : BaseFragment(R.layout.fragment_books),
observeEvent<String>(EventBus.BOOKSHELF_REFRESH) {
booksAdapter.notifyDataSetChanged()
startLastUpdateTimeJob()
upFastScrollerBar()
}
}
}
}
Loading

0 comments on commit 4860b0d

Please sign in to comment.