修复分享内容

pull/854/head
gedoor 4 years ago
parent 4913f399d3
commit 81a7640ef9
  1. 2
      app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt
  2. 4
      app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt
  3. 4
      app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt
  4. 8
      app/src/main/java/io/legado/app/utils/ContextExtensions.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 -> {

@ -101,8 +101,8 @@ class BookSourceEditActivity :
R.id.menu_qr_code_camera -> startActivityForResult<QrCodeActivity>(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 {

@ -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()
}

@ -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)

Loading…
Cancel
Save