mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-11 06:20:48 +01:00
Fixed webtoon page
This commit is contained in:
parent
414b8c9f21
commit
8ff8ab4f27
5 changed files with 37 additions and 41 deletions
|
@ -64,7 +64,7 @@ class ImageNotifier(private val context: Context) {
|
||||||
}
|
}
|
||||||
setContentTitle(context.getString(R.string.picture_saved))
|
setContentTitle(context.getString(R.string.picture_saved))
|
||||||
setSmallIcon(R.drawable.ic_insert_photo_black_24dp)
|
setSmallIcon(R.drawable.ic_insert_photo_black_24dp)
|
||||||
Glide.with(context).load(file).asBitmap().into(object : SimpleTarget<Bitmap>(100, 100) {
|
Glide.with(context).load(file).asBitmap().into(object : SimpleTarget<Bitmap>(96, 96) {
|
||||||
/**
|
/**
|
||||||
* The method that will be called when the resource load has finished.
|
* The method that will be called when the resource load has finished.
|
||||||
* @param resource the loaded resource.
|
* @param resource the loaded resource.
|
||||||
|
@ -74,7 +74,7 @@ class ImageNotifier(private val context: Context) {
|
||||||
context.notificationManager.notify(notificationId, notificationBuilder.build())
|
context.notificationManager.notify(notificationId, notificationBuilder.build())
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
Glide.with(context).load(file).asBitmap().into(object : SimpleTarget<Bitmap>(512, 384) {
|
Glide.with(context).load(file).asBitmap().into(object : SimpleTarget<Bitmap>(720, 1280) {
|
||||||
/**
|
/**
|
||||||
* The method that will be called when the resource load has finished.
|
* The method that will be called when the resource load has finished.
|
||||||
* @param resource the loaded resource.
|
* @param resource the loaded resource.
|
||||||
|
|
|
@ -228,16 +228,16 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
|
||||||
// Ignore
|
// Ignore
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onLongPress() {
|
fun onLongPress(page: Page) {
|
||||||
MaterialDialog.Builder(this).apply {
|
MaterialDialog.Builder(this).apply {
|
||||||
title = "Choose"
|
title = "Choose"
|
||||||
items(R.array.reader_image_options)
|
items(R.array.reader_image_options)
|
||||||
.itemsIds(R.array.reader_image_options_values)
|
.itemsIds(R.array.reader_image_options_values)
|
||||||
itemsCallback { materialDialog, view, i, charSequence ->
|
itemsCallback { materialDialog, view, i, charSequence ->
|
||||||
when (i) {
|
when (i) {
|
||||||
0 -> presenter.setCover()
|
0 -> presenter.setCover(page)
|
||||||
1 -> presenter.shareImage()
|
1 -> presenter.shareImage(page)
|
||||||
2 -> presenter.savePage()
|
2 -> presenter.savePage(page)
|
||||||
}
|
}
|
||||||
|
|
||||||
}.show()
|
}.show()
|
||||||
|
|
|
@ -547,11 +547,10 @@ class ReaderPresenter : BasePresenter<ReaderActivity>() {
|
||||||
/**
|
/**
|
||||||
* Update cover with page file.
|
* Update cover with page file.
|
||||||
*/
|
*/
|
||||||
internal fun setCover() {
|
internal fun setCover(page: Page) {
|
||||||
chapter.pages?.get(chapter.last_page_read)?.let {
|
|
||||||
// Update cover to selected file, show error if something went wrong
|
// Update cover to selected file, show error if something went wrong
|
||||||
try {
|
try {
|
||||||
if (editCoverWithStream(File(it.imagePath).inputStream(), manga)) {
|
if (editCoverWithStream(File(page.imagePath).inputStream(), manga)) {
|
||||||
context.toast(R.string.cover_updated)
|
context.toast(R.string.cover_updated)
|
||||||
} else {
|
} else {
|
||||||
throw Exception("Stream copy failed")
|
throw Exception("Stream copy failed")
|
||||||
|
@ -560,7 +559,6 @@ class ReaderPresenter : BasePresenter<ReaderActivity>() {
|
||||||
context.toast(R.string.notification_manga_update_failed)
|
context.toast(R.string.notification_manga_update_failed)
|
||||||
Timber.e(e.message)
|
Timber.e(e.message)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -578,8 +576,7 @@ class ReaderPresenter : BasePresenter<ReaderActivity>() {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
fun shareImage() {
|
fun shareImage(page: Page) {
|
||||||
chapter.pages?.get(chapter.last_page_read)?.let { page ->
|
|
||||||
val shareIntent = Intent().apply {
|
val shareIntent = Intent().apply {
|
||||||
action = Intent.ACTION_SEND
|
action = Intent.ACTION_SEND
|
||||||
putExtra(Intent.EXTRA_STREAM, Uri.parse(page.imagePath))
|
putExtra(Intent.EXTRA_STREAM, Uri.parse(page.imagePath))
|
||||||
|
@ -588,7 +585,6 @@ class ReaderPresenter : BasePresenter<ReaderActivity>() {
|
||||||
}
|
}
|
||||||
context.startActivity(Intent.createChooser(shareIntent, context.resources.getText(R.string.action_share))
|
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 })
|
.apply { flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_MULTIPLE_TASK })
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -596,34 +592,32 @@ class ReaderPresenter : BasePresenter<ReaderActivity>() {
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
@Throws(IOException::class)
|
@Throws(IOException::class)
|
||||||
internal fun savePage() {
|
internal fun savePage(page: Page) {
|
||||||
chapter.pages?.get(chapter.last_page_read)?.let { page ->
|
// Location of image file.
|
||||||
// Location of image file.
|
val inputFile = File(page.imagePath)
|
||||||
val inputFile = File(page.imagePath)
|
|
||||||
|
|
||||||
// File where the image will be saved.
|
// File where the image will be saved.
|
||||||
val destFile = File(pictureDirectory, manga.title + " - " + chapter.name +
|
val destFile = File(pictureDirectory, manga.title + " - " + chapter.name +
|
||||||
" - " + downloadManager.getImageFilename(page))
|
" - " + downloadManager.getImageFilename(page))
|
||||||
|
|
||||||
//Remove the notification if already exist (user feedback)
|
//Remove the notification if already exist (user feedback)
|
||||||
imageNotifier.onClear()
|
imageNotifier.onClear()
|
||||||
|
|
||||||
//Check if file doesn't already exist
|
//Check if file doesn't already exist
|
||||||
if (destFile.exists()) {
|
if (destFile.exists()) {
|
||||||
imageNotifier.onComplete(destFile)
|
imageNotifier.onComplete(destFile)
|
||||||
} else {
|
} else {
|
||||||
if (inputFile.exists()) {
|
if (inputFile.exists()) {
|
||||||
// Copy file
|
// Copy file
|
||||||
Observable.fromCallable { inputFile.copyTo(destFile) }
|
Observable.fromCallable { inputFile.copyTo(destFile) }
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.subscribe(
|
.subscribe(
|
||||||
{ imageNotifier.onComplete(it) },
|
{ imageNotifier.onComplete(it) },
|
||||||
{ error ->
|
{ error ->
|
||||||
Timber.e(error.message)
|
Timber.e(error.message)
|
||||||
imageNotifier.onError(error.message)
|
imageNotifier.onError(error.message)
|
||||||
})
|
})
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -188,7 +188,7 @@ abstract class PagerReader : BaseReader() {
|
||||||
|
|
||||||
override fun onLongPress(e: MotionEvent?) {
|
override fun onLongPress(e: MotionEvent?) {
|
||||||
super.onLongPress(e)
|
super.onLongPress(e)
|
||||||
readerActivity.onLongPress()
|
readerActivity.onLongPress(adapter.pages!![pager.currentItem])
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,9 +141,11 @@ class WebtoonReader : BaseReader() {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onLongPress(e: MotionEvent?) {
|
override fun onLongPress(e: MotionEvent) {
|
||||||
super.onLongPress(e)
|
super.onLongPress(e)
|
||||||
readerActivity.onLongPress()
|
val a = recycler.findChildViewUnder(e.rawX, e.rawY)
|
||||||
|
val i = recycler.getChildAdapterPosition(a)
|
||||||
|
readerActivity.onLongPress(adapter.getItem(i))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue