From 81a7640ef95b26550595fad61c091c87f5d8985f Mon Sep 17 00:00:00 2001 From: gedoor Date: Fri, 12 Feb 2021 09:23:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=88=86=E4=BA=AB=E5=86=85?= =?UTF-8?q?=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/ui/book/info/BookInfoActivity.kt | 2 +- .../app/ui/book/source/edit/BookSourceEditActivity.kt | 4 ++-- .../app/ui/rss/source/edit/RssSourceEditActivity.kt | 4 ++-- .../main/java/io/legado/app/utils/ContextExtensions.kt | 8 ++------ 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt b/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt index f5e4c9ff8..114896d6e 100644 --- a/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt @@ -97,7 +97,7 @@ class BookInfoActivity : viewModel.bookData.value?.let { val bookJson = GSON.toJson(it) val shareStr = "${it.bookUrl}#$bookJson" - shareWithQr(it.name, shareStr) + shareWithQr(shareStr, it.name) } } R.id.menu_refresh -> { diff --git a/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt b/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt index b51e6f899..0e6db0c39 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt @@ -101,8 +101,8 @@ class BookSourceEditActivity : R.id.menu_qr_code_camera -> startActivityForResult(qrRequestCode) R.id.menu_share_str -> share(GSON.toJson(getSource())) R.id.menu_share_qr -> shareWithQr( - getString(R.string.share_book_source), - GSON.toJson(getSource()) + GSON.toJson(getSource()), + getString(R.string.share_book_source) ) R.id.menu_help -> showRuleHelp() R.id.menu_login -> getSource().let { diff --git a/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt b/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt index 6ce694321..c70525047 100644 --- a/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt +++ b/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt @@ -111,8 +111,8 @@ class RssSourceEditActivity : R.id.menu_paste_source -> viewModel.pasteSource { upRecyclerView(it) } R.id.menu_share_str -> share(GSON.toJson(getRssSource())) R.id.menu_share_qr -> shareWithQr( - getString(R.string.share_rss_source), - GSON.toJson(getRssSource()) + GSON.toJson(getRssSource()), + getString(R.string.share_rss_source) ) R.id.menu_help -> showRuleHelp() } diff --git a/app/src/main/java/io/legado/app/utils/ContextExtensions.kt b/app/src/main/java/io/legado/app/utils/ContextExtensions.kt index 490ac0f36..259334f3c 100644 --- a/app/src/main/java/io/legado/app/utils/ContextExtensions.kt +++ b/app/src/main/java/io/legado/app/utils/ContextExtensions.kt @@ -138,11 +138,7 @@ val Context.navigationBarHeight: Int return resources.getDimensionPixelSize(resourceId) } -fun Context.share(text: String) { - share(getString(R.string.share), text) -} - -fun Context.share(title: String, text: String) { +fun Context.share(text: String, title: String = getString(R.string.share)) { kotlin.runCatching { val intent = Intent(Intent.ACTION_SEND) intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) @@ -154,7 +150,7 @@ fun Context.share(title: String, text: String) { } @SuppressLint("SetWorldReadable") -fun Context.shareWithQr(title: String, text: String) { +fun Context.shareWithQr(text: String, title: String = getString(R.string.share)) { val bitmap = QRCodeUtils.createQRCode(text) if (bitmap == null) { toastOnUi(R.string.text_too_long_qr_error)