From 82d4c0de030e70c89c3a4939548e6b6b0e5612bf Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 21 Nov 2021 21:22:46 +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/build.gradle | 8 ++++---- app/src/main/java/io/legado/app/base/BaseActivity.kt | 6 +++--- .../java/io/legado/app/ui/book/toc/TocActivityResult.kt | 2 +- .../java/io/legado/app/ui/document/HandleFileContract.kt | 6 ++---- .../legado/app/ui/main/bookshelf/BaseBookshelfFragment.kt | 8 ++------ app/src/main/java/io/legado/app/ui/qrcode/QrCodeResult.kt | 2 +- .../java/io/legado/app/utils/ActivityResultContracts.kt | 2 +- 7 files changed, 14 insertions(+), 20 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 0eca8db42..a4a60eba1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -137,12 +137,12 @@ dependencies { implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version") //androidX + implementation('androidx.core:core-ktx:1.7.0') implementation('androidx.appcompat:appcompat:1.3.1') - implementation('androidx.core:core-ktx:1.6.0') - implementation("androidx.activity:activity-ktx:1.3.1") - implementation("androidx.fragment:fragment-ktx:1.3.6") + implementation('androidx.activity:activity-ktx:1.4.0') + implementation('androidx.fragment:fragment-ktx:1.3.6') implementation('androidx.preference:preference-ktx:1.1.1') - implementation('androidx.constraintlayout:constraintlayout:2.1.0') + implementation('androidx.constraintlayout:constraintlayout:2.1.1') implementation('androidx.swiperefreshlayout:swiperefreshlayout:1.1.0') implementation('androidx.viewpager2:viewpager2:1.0.0') implementation('com.google.android.material:material:1.4.0') diff --git a/app/src/main/java/io/legado/app/base/BaseActivity.kt b/app/src/main/java/io/legado/app/base/BaseActivity.kt index 469cc6e40..0c1c153d8 100644 --- a/app/src/main/java/io/legado/app/base/BaseActivity.kt +++ b/app/src/main/java/io/legado/app/base/BaseActivity.kt @@ -98,12 +98,12 @@ abstract class BaseActivity( abstract fun onActivityCreated(savedInstanceState: Bundle?) - final override fun onCreateOptionsMenu(menu: Menu?): Boolean { - return menu?.let { + final override fun onCreateOptionsMenu(menu: Menu): Boolean { + return menu.let { val bool = onCompatCreateOptionsMenu(it) it.applyTint(this, toolBarTheme) bool - } ?: super.onCreateOptionsMenu(menu) + } } override fun onMenuOpened(featureId: Int, menu: Menu): Boolean { diff --git a/app/src/main/java/io/legado/app/ui/book/toc/TocActivityResult.kt b/app/src/main/java/io/legado/app/ui/book/toc/TocActivityResult.kt index e727de0b2..4cdd2ad4c 100644 --- a/app/src/main/java/io/legado/app/ui/book/toc/TocActivityResult.kt +++ b/app/src/main/java/io/legado/app/ui/book/toc/TocActivityResult.kt @@ -7,7 +7,7 @@ import androidx.activity.result.contract.ActivityResultContract class TocActivityResult : ActivityResultContract?>() { - override fun createIntent(context: Context, input: String?): Intent { + override fun createIntent(context: Context, input: String): Intent { return Intent(context, TocActivity::class.java) .putExtra("bookUrl", input) } diff --git a/app/src/main/java/io/legado/app/ui/document/HandleFileContract.kt b/app/src/main/java/io/legado/app/ui/document/HandleFileContract.kt index af2dda346..f60c6e312 100644 --- a/app/src/main/java/io/legado/app/ui/document/HandleFileContract.kt +++ b/app/src/main/java/io/legado/app/ui/document/HandleFileContract.kt @@ -15,12 +15,10 @@ class HandleFileContract : private var requestCode: Int = 0 - override fun createIntent(context: Context, input: (HandleFileParam.() -> Unit)?): Intent { + override fun createIntent(context: Context, input: (HandleFileParam.() -> Unit)): Intent { val intent = Intent(context, HandleFileActivity::class.java) val handleFileParam = HandleFileParam() - input?.let { - handleFileParam.apply(input) - } + handleFileParam.apply(input) handleFileParam.let { requestCode = it.requestCode intent.putExtra("mode", it.mode) 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 1b14f43d6..a5715cfa9 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 @@ -82,14 +82,10 @@ abstract class BaseBookshelfFragment(layoutId: Int) : VMBaseFragment startActivity { putExtra("groupId", groupId) } - R.id.menu_export_bookshelf -> viewModel.exportBookshelf(books) { + R.id.menu_export_bookshelf -> viewModel.exportBookshelf(books) { file -> exportResult.launch { mode = HandleFileContract.EXPORT - fileData = Triple( - "bookshelf.json", - it.toByteArray(), - "application/json" - ) + fileData = Triple("bookshelf.json", file, "application/json") } } R.id.menu_import_bookshelf -> importBookshelfAlert(groupId) diff --git a/app/src/main/java/io/legado/app/ui/qrcode/QrCodeResult.kt b/app/src/main/java/io/legado/app/ui/qrcode/QrCodeResult.kt index b39f09791..e98d0c249 100644 --- a/app/src/main/java/io/legado/app/ui/qrcode/QrCodeResult.kt +++ b/app/src/main/java/io/legado/app/ui/qrcode/QrCodeResult.kt @@ -7,7 +7,7 @@ import androidx.activity.result.contract.ActivityResultContract class QrCodeResult : ActivityResultContract() { - override fun createIntent(context: Context, input: Unit?): Intent { + override fun createIntent(context: Context, input: Unit): Intent { return Intent(context, QrCodeActivity::class.java) } diff --git a/app/src/main/java/io/legado/app/utils/ActivityResultContracts.kt b/app/src/main/java/io/legado/app/utils/ActivityResultContracts.kt index 3c3a89b75..9291dca05 100644 --- a/app/src/main/java/io/legado/app/utils/ActivityResultContracts.kt +++ b/app/src/main/java/io/legado/app/utils/ActivityResultContracts.kt @@ -11,7 +11,7 @@ class SelectImageContract : ActivityResultContract