From c61b68bd22dbcdbfdeb0d3eaf527fe64c7a34630 Mon Sep 17 00:00:00 2001 From: Horis <821938089@qq.com> Date: Sun, 10 Dec 2023 10:14:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/help/IntentHelp.kt | 6 +++--- .../java/io/legado/app/service/DownloadService.kt | 7 +++++-- .../io/legado/app/ui/book/read/ReadBookActivity.kt | 12 ++++++------ 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/IntentHelp.kt b/app/src/main/java/io/legado/app/help/IntentHelp.kt index 2898c490f..9862dfba7 100644 --- a/app/src/main/java/io/legado/app/help/IntentHelp.kt +++ b/app/src/main/java/io/legado/app/help/IntentHelp.kt @@ -17,14 +17,14 @@ object IntentHelp { fun getBrowserIntent(uri: Uri): Intent { val intent = Intent(Intent.ACTION_VIEW) - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) { - intent.`package` = appCtx.packageName - } intent.data = uri intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) if (intent.resolveActivity(appCtx.packageManager) == null) { return Intent.createChooser(intent, "请选择浏览器") } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) { + intent.`package` = appCtx.packageName + } return intent } diff --git a/app/src/main/java/io/legado/app/service/DownloadService.kt b/app/src/main/java/io/legado/app/service/DownloadService.kt index a3cfa8739..e88505ac1 100644 --- a/app/src/main/java/io/legado/app/service/DownloadService.kt +++ b/app/src/main/java/io/legado/app/service/DownloadService.kt @@ -9,6 +9,7 @@ import android.content.IntentFilter import android.net.Uri import android.os.Environment import androidx.core.app.NotificationCompat +import androidx.core.content.ContextCompat import androidx.lifecycle.lifecycleScope import io.legado.app.R import io.legado.app.base.BaseService @@ -45,9 +46,11 @@ class DownloadService : BaseService() { @SuppressLint("UnspecifiedRegisterReceiverFlag") override fun onCreate() { super.onCreate() - registerReceiver( + ContextCompat.registerReceiver( + this, downloadReceiver, - IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE) + IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE), + ContextCompat.RECEIVER_EXPORTED ) } 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 cb067333f..9a3934aba 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 @@ -409,7 +409,7 @@ class ReadBookActivity : BaseReadBookActivity(), upContent() } else { ReadBook.book?.let { - refreshContentDur(it) + refreshContentAll(it) } } } @@ -445,7 +445,7 @@ class ReadBookActivity : BaseReadBookActivity(), } else { it.removeDelTag(Book.rubyTag) } - refreshContentDur(it) + refreshContentAll(it) } R.id.menu_del_h_tag -> ReadBook.book?.let { @@ -455,7 +455,7 @@ class ReadBookActivity : BaseReadBookActivity(), } else { it.removeDelTag(Book.hTag) } - refreshContentDur(it) + refreshContentAll(it) } R.id.menu_page_anim -> showPageAnimConfig { @@ -514,10 +514,10 @@ class ReadBookActivity : BaseReadBookActivity(), return super.onCompatOptionsItemSelected(item) } - private fun refreshContentDur(book: Book) { - ReadBook.curTextChapter = null + private fun refreshContentAll(book: Book) { + ReadBook.clearTextChapter() binding.readView.upContent() - viewModel.refreshContentDur(book) + viewModel.refreshContentAll(book) } override fun onMenuItemClick(item: MenuItem): Boolean {