From 32aea55f424d77e78be50f288996fe04053db009 Mon Sep 17 00:00:00 2001 From: Jay Date: Sat, 23 May 2020 04:07:36 -0400 Subject: [PATCH] Send manga/chapter/page details when sharing a chapter page closes #443 Also for page_ string, removing the colon in it --- .../java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt | 8 +++++++- .../java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt | 2 +- app/src/main/res/values/strings.xml | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt index 0189a63ea8..d7472371ec 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt @@ -645,9 +645,15 @@ class ReaderActivity : BaseRxActivity(), * Called from the presenter when a page is ready to be shared. It shows Android's default * sharing tool. */ - fun onShareImageResult(file: File) { + fun onShareImageResult(file: File, page: ReaderPage) { + val manga = presenter.manga ?: return + val chapter = page.chapter.chapter + + val text = "${manga.title}: ${chapter.name}, ${getString(R.string.page_, page.number)}" + val stream = file.getUriCompat(this) val intent = Intent(Intent.ACTION_SEND).apply { + putExtra(Intent.EXTRA_TEXT, text) putExtra(Intent.EXTRA_STREAM, stream) flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_GRANT_READ_URI_PERMISSION clipData = ClipData.newRawUri(null, stream) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt index 41ce645e15..ab51de383f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt @@ -572,7 +572,7 @@ class ReaderPresenter( .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribeFirst( - { view, file -> view.onShareImageResult(file) }, + { view, file -> view.onShareImageResult(file, page) }, { _, _ -> /* Empty */ } ) } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d4294d5919..e17b445e62 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -268,7 +268,7 @@ Set as cover Set as default for all Cover updated - Page: %1$d + Page %1$d Next chapter not found The image could not be decoded Use this image as cover art?