diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/ImageNotifier.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/ImageNotifier.kt index 1f413c5cb..f2da096aa 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/ImageNotifier.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/ImageNotifier.kt @@ -64,7 +64,7 @@ class ImageNotifier(private val context: Context) { } setContentTitle(context.getString(R.string.picture_saved)) setSmallIcon(R.drawable.ic_insert_photo_black_24dp) - Glide.with(context).load(file).asBitmap().into(object : SimpleTarget(100, 100) { + Glide.with(context).load(file).asBitmap().into(object : SimpleTarget(96, 96) { /** * The method that will be called when the resource load has finished. * @param resource the loaded resource. @@ -74,7 +74,7 @@ class ImageNotifier(private val context: Context) { context.notificationManager.notify(notificationId, notificationBuilder.build()) } }) - Glide.with(context).load(file).asBitmap().into(object : SimpleTarget(512, 384) { + Glide.with(context).load(file).asBitmap().into(object : SimpleTarget(720, 1280) { /** * The method that will be called when the resource load has finished. * @param resource the loaded resource. 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 69c4ab3d8..ef1a8820b 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 @@ -228,16 +228,16 @@ class ReaderActivity : BaseRxActivity() { // Ignore } - fun onLongPress() { + fun onLongPress(page: Page) { MaterialDialog.Builder(this).apply { title = "Choose" items(R.array.reader_image_options) .itemsIds(R.array.reader_image_options_values) itemsCallback { materialDialog, view, i, charSequence -> when (i) { - 0 -> presenter.setCover() - 1 -> presenter.shareImage() - 2 -> presenter.savePage() + 0 -> presenter.setCover(page) + 1 -> presenter.shareImage(page) + 2 -> presenter.savePage(page) } }.show() 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 073888a9c..fde3321b2 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 @@ -547,11 +547,10 @@ class ReaderPresenter : BasePresenter() { /** * Update cover with page file. */ - internal fun setCover() { - chapter.pages?.get(chapter.last_page_read)?.let { + internal fun setCover(page: Page) { // Update cover to selected file, show error if something went wrong try { - if (editCoverWithStream(File(it.imagePath).inputStream(), manga)) { + if (editCoverWithStream(File(page.imagePath).inputStream(), manga)) { context.toast(R.string.cover_updated) } else { throw Exception("Stream copy failed") @@ -560,7 +559,6 @@ class ReaderPresenter : BasePresenter() { context.toast(R.string.notification_manga_update_failed) Timber.e(e.message) } - } } /** @@ -578,8 +576,7 @@ class ReaderPresenter : BasePresenter() { return false } - fun shareImage() { - chapter.pages?.get(chapter.last_page_read)?.let { page -> + fun shareImage(page: Page) { val shareIntent = Intent().apply { action = Intent.ACTION_SEND putExtra(Intent.EXTRA_STREAM, Uri.parse(page.imagePath)) @@ -588,7 +585,6 @@ class ReaderPresenter : BasePresenter() { } context.startActivity(Intent.createChooser(shareIntent, context.resources.getText(R.string.action_share)) .apply { flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_MULTIPLE_TASK }) - } } /** @@ -596,34 +592,32 @@ class ReaderPresenter : BasePresenter() { * @throws IOException */ @Throws(IOException::class) - internal fun savePage() { - chapter.pages?.get(chapter.last_page_read)?.let { page -> - // Location of image file. - val inputFile = File(page.imagePath) + internal fun savePage(page: Page) { + // Location of image file. + val inputFile = File(page.imagePath) - // File where the image will be saved. - val destFile = File(pictureDirectory, manga.title + " - " + chapter.name + - " - " + downloadManager.getImageFilename(page)) + // File where the image will be saved. + val destFile = File(pictureDirectory, manga.title + " - " + chapter.name + + " - " + downloadManager.getImageFilename(page)) - //Remove the notification if already exist (user feedback) - imageNotifier.onClear() + //Remove the notification if already exist (user feedback) + imageNotifier.onClear() - //Check if file doesn't already exist - if (destFile.exists()) { - imageNotifier.onComplete(destFile) - } else { - if (inputFile.exists()) { - // Copy file - Observable.fromCallable { inputFile.copyTo(destFile) } - .observeOn(AndroidSchedulers.mainThread()) - .subscribeOn(Schedulers.io()) - .subscribe( - { imageNotifier.onComplete(it) }, - { error -> - Timber.e(error.message) - imageNotifier.onError(error.message) - }) - } + //Check if file doesn't already exist + if (destFile.exists()) { + imageNotifier.onComplete(destFile) + } else { + if (inputFile.exists()) { + // Copy file + Observable.fromCallable { inputFile.copyTo(destFile) } + .observeOn(AndroidSchedulers.mainThread()) + .subscribeOn(Schedulers.io()) + .subscribe( + { imageNotifier.onComplete(it) }, + { error -> + Timber.e(error.message) + imageNotifier.onError(error.message) + }) } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerReader.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerReader.kt index 4220ece00..b7d56bbec 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerReader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerReader.kt @@ -188,7 +188,7 @@ abstract class PagerReader : BaseReader() { override fun onLongPress(e: MotionEvent?) { super.onLongPress(e) - readerActivity.onLongPress() + readerActivity.onLongPress(adapter.pages!![pager.currentItem]) } }) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonReader.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonReader.kt index 3041b1791..8dd7bf8d9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonReader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonReader.kt @@ -141,9 +141,11 @@ class WebtoonReader : BaseReader() { return true } - override fun onLongPress(e: MotionEvent?) { + override fun onLongPress(e: MotionEvent) { super.onLongPress(e) - readerActivity.onLongPress() + val a = recycler.findChildViewUnder(e.rawX, e.rawY) + val i = recycler.getChildAdapterPosition(a) + readerActivity.onLongPress(adapter.getItem(i)) } }) }