tap between manga pages (paged)
This commit is contained in:
parent
5561c003cf
commit
41830dba4d
4 changed files with 74 additions and 7 deletions
|
@ -89,7 +89,7 @@ abstract class BaseImageAdapter(
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
val detector = GestureDetectorCompat(view.context, object : GesturesListener() {
|
val detector = GestureDetectorCompat(view.context, object : GesturesListener() {
|
||||||
override fun onSingleClick(event: MotionEvent) = activity.handleController()
|
override fun onSingleClick(event: MotionEvent) = activity.handleController(event = event)
|
||||||
})
|
})
|
||||||
view.findViewById<View>(R.id.imgProgCover).apply {
|
view.findViewById<View>(R.id.imgProgCover).apply {
|
||||||
setOnTouchListener { _, event ->
|
setOnTouchListener { _, event ->
|
||||||
|
@ -112,6 +112,9 @@ abstract class BaseImageAdapter(
|
||||||
activity.lifecycleScope.launch { loadImage(holder.bindingAdapterPosition, view) }
|
activity.lifecycleScope.launch { loadImage(holder.bindingAdapterPosition, view) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
abstract fun isZoomed(): Boolean
|
||||||
|
abstract fun setZoom(zoom: Float)
|
||||||
|
|
||||||
abstract suspend fun loadImage(position: Int, parent: View): Boolean
|
abstract suspend fun loadImage(position: Int, parent: View): Boolean
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
|
@ -91,4 +91,14 @@ open class ImageAdapter(
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getItemCount(): Int = images.size
|
override fun getItemCount(): Int = images.size
|
||||||
|
|
||||||
|
override fun isZoomed(): Boolean {
|
||||||
|
val imageView = activity.findViewById<SubsamplingScaleImageView>(R.id.imgProgImageNoGestures)
|
||||||
|
return imageView.scale > imageView.minScale
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun setZoom(zoom: Float) {
|
||||||
|
val imageView = activity.findViewById<SubsamplingScaleImageView>(R.id.imgProgImageNoGestures)
|
||||||
|
imageView.setScaleAndCenter(zoom, imageView.center)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import android.app.AlertDialog
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
|
import android.content.res.Resources
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
@ -702,8 +703,60 @@ class MangaReaderActivity : AppCompatActivity() {
|
||||||
goneTimer.schedule(timerTask, controllerDuration)
|
goneTimer.schedule(timerTask, controllerDuration)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun handleController(shouldShow: Boolean? = null) {
|
enum class pressPos {
|
||||||
|
LEFT, RIGHT, CENTER
|
||||||
|
}
|
||||||
|
|
||||||
|
fun handleController(shouldShow: Boolean? = null, event: MotionEvent? = null) {
|
||||||
|
var pressLocation = pressPos.CENTER
|
||||||
if (!sliding) {
|
if (!sliding) {
|
||||||
|
if (event != null && settings.default.layout == PAGED) {
|
||||||
|
if (event.action != MotionEvent.ACTION_UP) return
|
||||||
|
val x = event.rawX.toInt()
|
||||||
|
val y = event.rawY.toInt()
|
||||||
|
val screenWidth = Resources.getSystem().displayMetrics.widthPixels
|
||||||
|
//if in the 1st 1/5th of the screen width, left and lower than 1/5th of the screen height, left
|
||||||
|
if (screenWidth / 5 in (x + 1)..<y) {
|
||||||
|
pressLocation = if (settings.default.direction == RIGHT_TO_LEFT) {
|
||||||
|
pressPos.RIGHT
|
||||||
|
} else {
|
||||||
|
pressPos.LEFT
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//if in the last 1/5th of the screen width, right and lower than 1/5th of the screen height, right
|
||||||
|
else if (x > screenWidth - screenWidth / 5 && y > screenWidth / 5) {
|
||||||
|
pressLocation = if (settings.default.direction == RIGHT_TO_LEFT) {
|
||||||
|
pressPos.LEFT
|
||||||
|
} else {
|
||||||
|
pressPos.RIGHT
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if pressLocation is left or right go to previous or next page (paged mode only)
|
||||||
|
if (pressLocation == pressPos.LEFT) {
|
||||||
|
|
||||||
|
if (binding.mangaReaderPager.currentItem > 0) {
|
||||||
|
//if the current images zoomed in, go back to normal before going to previous page
|
||||||
|
if (imageAdapter?.isZoomed() == true) {
|
||||||
|
imageAdapter?.setZoom(1f)
|
||||||
|
}
|
||||||
|
binding.mangaReaderPager.currentItem -= 1
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (pressLocation == pressPos.RIGHT) {
|
||||||
|
if (binding.mangaReaderPager.currentItem < maxChapterPage - 1) {
|
||||||
|
//if the current images zoomed in, go back to normal before going to next page
|
||||||
|
if (imageAdapter?.isZoomed() == true) {
|
||||||
|
imageAdapter?.setZoom(1f)
|
||||||
|
}
|
||||||
|
//if right to left, go to previous page
|
||||||
|
binding.mangaReaderPager.currentItem += 1
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!settings.showSystemBars) {
|
if (!settings.showSystemBars) {
|
||||||
hideBars()
|
hideBars()
|
||||||
checkNotch()
|
checkNotch()
|
||||||
|
@ -796,7 +849,7 @@ class MangaReaderActivity : AppCompatActivity() {
|
||||||
|
|
||||||
private fun progress(runnable: Runnable) {
|
private fun progress(runnable: Runnable) {
|
||||||
if (maxChapterPage - currentChapterPage <= 1 && Anilist.userid != null) {
|
if (maxChapterPage - currentChapterPage <= 1 && Anilist.userid != null) {
|
||||||
if (showProgressDialog) {
|
if (showProgressDialog) {
|
||||||
|
|
||||||
val dialogView = layoutInflater.inflate(R.layout.item_custom_dialog, null)
|
val dialogView = layoutInflater.inflate(R.layout.item_custom_dialog, null)
|
||||||
val checkbox = dialogView.findViewById<CheckBox>(R.id.dialog_checkbox)
|
val checkbox = dialogView.findViewById<CheckBox>(R.id.dialog_checkbox)
|
||||||
|
@ -805,8 +858,9 @@ class MangaReaderActivity : AppCompatActivity() {
|
||||||
saveData("${media.id}_progressDialog", isChecked)
|
saveData("${media.id}_progressDialog", isChecked)
|
||||||
showProgressDialog = !isChecked
|
showProgressDialog = !isChecked
|
||||||
}
|
}
|
||||||
val incognito = currContext()?.getSharedPreferences("Dantotsu", Context.MODE_PRIVATE)
|
val incognito =
|
||||||
?.getBoolean("incognito", false) ?: false
|
currContext()?.getSharedPreferences("Dantotsu", Context.MODE_PRIVATE)
|
||||||
|
?.getBoolean("incognito", false) ?: false
|
||||||
AlertDialog.Builder(this, R.style.MyPopup)
|
AlertDialog.Builder(this, R.style.MyPopup)
|
||||||
.setTitle(getString(R.string.title_update_progress))
|
.setTitle(getString(R.string.title_update_progress))
|
||||||
.apply {
|
.apply {
|
||||||
|
@ -818,7 +872,7 @@ class MangaReaderActivity : AppCompatActivity() {
|
||||||
.setCancelable(false)
|
.setCancelable(false)
|
||||||
.setPositiveButton(getString(R.string.yes)) { dialog, _ ->
|
.setPositiveButton(getString(R.string.yes)) { dialog, _ ->
|
||||||
saveData("${media.id}_save_progress", true)
|
saveData("${media.id}_save_progress", true)
|
||||||
updateProgress(
|
updateProgress(
|
||||||
media,
|
media,
|
||||||
MangaNameAdapter.findChapterNumber(media.manga!!.selectedChapter!!)
|
MangaNameAdapter.findChapterNumber(media.manga!!.selectedChapter!!)
|
||||||
.toString()
|
.toString()
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
app:gest_disableGestures="true"
|
app:gest_disableGestures="true"
|
||||||
app:gest_rotationEnabled="true"
|
app:gest_rotationEnabled="true"
|
||||||
app:gest_restrictRotation="true"
|
app:gest_restrictRotation="true"
|
||||||
app:gest_doubleTapZoom="3"
|
app:gest_doubleTapZoom="1.5"
|
||||||
app:gest_maxZoom="6">
|
app:gest_maxZoom="6">
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue