pull/2234/head 3.22.083120
kunfei 2 years ago
parent 4e50e4f53c
commit 3485722321
  1. 2
      app/src/main/java/io/legado/app/api/controller/BookController.kt
  2. 3
      app/src/main/java/io/legado/app/model/webBook/WebBook.kt
  3. 1
      app/src/main/java/io/legado/app/service/CheckSourceService.kt
  4. 2
      app/src/main/java/io/legado/app/ui/book/changesource/ChangeChapterSourceViewModel.kt
  5. 2
      app/src/main/java/io/legado/app/ui/book/read/ContentEditDialog.kt
  6. 1
      app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt
  7. 2
      app/src/main/java/io/legado/app/ui/browser/WebViewActivity.kt
  8. 4
      app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt

@ -180,7 +180,7 @@ object BookController {
?: return returnData.setErrorMsg("未找到书源") ?: return returnData.setErrorMsg("未找到书源")
try { try {
content = runBlocking { content = runBlocking {
WebBook.getContentAwait(this, bookSource, book, chapter).let { WebBook.getContentAwait(bookSource, book, chapter).let {
val contentProcessor = ContentProcessor.get(book.name, book.origin) val contentProcessor = ContentProcessor.get(book.name, book.origin)
contentProcessor.getContent(book, chapter, it, includeTitle = false) contentProcessor.getContent(book, chapter, it, includeTitle = false)
.joinToString("\n") .joinToString("\n")

@ -238,12 +238,11 @@ object WebBook {
context: CoroutineContext = Dispatchers.IO context: CoroutineContext = Dispatchers.IO
): Coroutine<String> { ): Coroutine<String> {
return Coroutine.async(scope, context) { return Coroutine.async(scope, context) {
getContentAwait(scope, bookSource, book, bookChapter, nextChapterUrl, needSave) getContentAwait(bookSource, book, bookChapter, nextChapterUrl, needSave)
} }
} }
suspend fun getContentAwait( suspend fun getContentAwait(
scope: CoroutineScope,
bookSource: BookSource, bookSource: BookSource,
book: Book, book: Book,
bookChapter: BookChapter, bookChapter: BookChapter,

@ -219,7 +219,6 @@ class CheckSourceService : BaseService() {
//校验正文 //校验正文
if (CheckSource.checkContent) { if (CheckSource.checkContent) {
WebBook.getContentAwait( WebBook.getContentAwait(
this,
bookSource = source, bookSource = source,
book = mBook, book = mBook,
bookChapter = toc.first(), bookChapter = toc.first(),

@ -35,7 +35,7 @@ class ChangeChapterSourceViewModel(application: Application) :
execute { execute {
val bookSource = appDb.bookSourceDao.getBookSource(book.origin) val bookSource = appDb.bookSourceDao.getBookSource(book.origin)
?: throw NoStackTraceException("书源不存在") ?: throw NoStackTraceException("书源不存在")
WebBook.getContentAwait(this, bookSource, book, chapter, nextChapterUrl, false) WebBook.getContentAwait(bookSource, book, chapter, nextChapterUrl, false)
}.onSuccess { }.onSuccess {
success.invoke(it) success.invoke(it)
}.onError { }.onError {

@ -126,7 +126,7 @@ class ContentEditDialog : BaseDialogFragment(R.layout.dialog_content_edit) {
content = null content = null
BookHelp.delContent(book, chapter) BookHelp.delContent(book, chapter)
if (!book.isLocalBook()) ReadBook.bookSource?.let { bookSource -> if (!book.isLocalBook()) ReadBook.bookSource?.let { bookSource ->
WebBook.getContentAwait(this, bookSource, book, chapter) WebBook.getContentAwait(bookSource, book, chapter)
} }
} }
return@execute content ?: let { return@execute content ?: let {

@ -216,7 +216,6 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
toc.first() toc.first()
} }
WebBook.getContentAwait( WebBook.getContentAwait(
this,
bookSource = source, bookSource = source,
book = book, book = book,
bookChapter = toc[book.durChapterIndex], bookChapter = toc[book.durChapterIndex],

@ -125,12 +125,14 @@ class WebViewActivity : VMBaseActivity<ActivityWebViewBinding, WebViewModel>() {
private fun upWebViewTheme() { private fun upWebViewTheme() {
if (AppConfig.isNightTheme) { if (AppConfig.isNightTheme) {
if (WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK_STRATEGY)) { if (WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK_STRATEGY)) {
@Suppress("DEPRECATION")
WebSettingsCompat.setForceDarkStrategy( WebSettingsCompat.setForceDarkStrategy(
binding.webView.settings, binding.webView.settings,
WebSettingsCompat.DARK_STRATEGY_PREFER_WEB_THEME_OVER_USER_AGENT_DARKENING WebSettingsCompat.DARK_STRATEGY_PREFER_WEB_THEME_OVER_USER_AGENT_DARKENING
) )
} }
if (WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK)) { if (WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK)) {
@Suppress("DEPRECATION")
WebSettingsCompat.setForceDark( WebSettingsCompat.setForceDark(
binding.webView.settings, binding.webView.settings,
WebSettingsCompat.FORCE_DARK_ON WebSettingsCompat.FORCE_DARK_ON

@ -141,7 +141,7 @@ class ReadRssActivity : VMBaseActivity<ActivityRssReadBinding, ReadRssViewModel>
SelectItem(getString(R.string.action_save), "save"), SelectItem(getString(R.string.action_save), "save"),
SelectItem(getString(R.string.select_folder), "selectFolder") SelectItem(getString(R.string.select_folder), "selectFolder")
) )
) { _, charSequence, i -> ) { _, charSequence, _ ->
when (charSequence.value) { when (charSequence.value) {
"save" -> saveImage(webPic) "save" -> saveImage(webPic)
"selectFolder" -> selectSaveFolder(null) "selectFolder" -> selectSaveFolder(null)
@ -219,12 +219,14 @@ class ReadRssActivity : VMBaseActivity<ActivityRssReadBinding, ReadRssViewModel>
private fun upWebViewTheme() { private fun upWebViewTheme() {
if (AppConfig.isNightTheme) { if (AppConfig.isNightTheme) {
if (WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK_STRATEGY)) { if (WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK_STRATEGY)) {
@Suppress("DEPRECATION")
WebSettingsCompat.setForceDarkStrategy( WebSettingsCompat.setForceDarkStrategy(
binding.webView.settings, binding.webView.settings,
WebSettingsCompat.DARK_STRATEGY_PREFER_WEB_THEME_OVER_USER_AGENT_DARKENING WebSettingsCompat.DARK_STRATEGY_PREFER_WEB_THEME_OVER_USER_AGENT_DARKENING
) )
} }
if (WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK)) { if (WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK)) {
@Suppress("DEPRECATION")
WebSettingsCompat.setForceDark( WebSettingsCompat.setForceDark(
binding.webView.settings, binding.webView.settings,
WebSettingsCompat.FORCE_DARK_ON WebSettingsCompat.FORCE_DARK_ON

Loading…
Cancel
Save