diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseRxActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseRxActivity.kt
index 90dc661713..59aa6b961d 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseRxActivity.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseRxActivity.kt
@@ -3,10 +3,15 @@ package eu.kanade.tachiyomi.ui.base.activity
import android.os.Bundle
import eu.kanade.tachiyomi.App
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter
+import eu.kanade.tachiyomi.util.LocaleHelper
import nucleus.view.NucleusAppCompatActivity
abstract class BaseRxActivity
> : NucleusAppCompatActivity
(), ActivityMixin {
+ init {
+ LocaleHelper.updateCfg(this)
+ }
+
override fun onCreate(savedState: Bundle?) {
val superFactory = presenterFactory
setPresenterFactory {
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 e96ffbccd6..f77aa8f978 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
@@ -227,7 +227,7 @@ class ReaderActivity : BaseRxActivity() {
toast(error.message)
}
- fun onLongPress(page: Page) {
+ fun onLongClick(page: Page) {
MaterialDialog.Builder(this)
.title(getString(R.string.options))
.items(R.array.reader_image_options)
diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/base/BaseReader.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/base/BaseReader.kt
index 85cab74745..46903d038b 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/base/BaseReader.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/base/BaseReader.kt
@@ -212,6 +212,16 @@ abstract class BaseReader : BaseFragment() {
moveLeft()
}
+ /**
+ * Method the implementations can call to show a menu with options for the given page.
+ */
+ fun onLongClick(page: Page?): Boolean {
+ if (isAdded && page != null) {
+ readerActivity.onLongClick(page)
+ }
+ return true
+ }
+
/**
* Sets the active decoder class.
*
diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PageView.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PageView.kt
index 1ffb7f3097..bab6603c12 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PageView.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PageView.kt
@@ -71,6 +71,7 @@ class PageView @JvmOverloads constructor(context: Context, attrs: AttributeSet?
setBitmapDecoderClass(reader.bitmapDecoderClass)
setVerticalScrollingParent(reader is VerticalReader)
setOnTouchListener { v, motionEvent -> reader.gestureDetector.onTouchEvent(motionEvent) }
+ setOnLongClickListener { reader.onLongClick(page) }
setOnImageEventListener(object : SubsamplingScaleImageView.DefaultOnImageEventListener() {
override fun onReady() {
onImageDecoded(reader)
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 a23c2efcf4..5e53aebed7 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
@@ -66,7 +66,7 @@ abstract class PagerReader : BaseReader() {
/**
* Gesture detector for touch events.
*/
- val gestureDetector by lazy { createGestureDetector() }
+ val gestureDetector by lazy { GestureDetector(context, ImageGestureListener()) }
/**
* Subscriptions for reader settings.
@@ -166,37 +166,24 @@ abstract class PagerReader : BaseReader() {
}
/**
- * Creates the gesture detector for the pager.
- *
- * @return a gesture detector.
+ * Gesture detector for Subsampling Scale Image View.
*/
- protected fun createGestureDetector(): GestureDetector {
- return GestureDetector(activity, object : GestureDetector.SimpleOnGestureListener() {
- override fun onSingleTapConfirmed(e: MotionEvent): Boolean {
- if (isAdded) {
- val positionX = e.x
+ inner class ImageGestureListener : GestureDetector.SimpleOnGestureListener() {
- if (positionX < pager.width * LEFT_REGION) {
- if (tappingEnabled) moveLeft()
- } else if (positionX > pager.width * RIGHT_REGION) {
- if (tappingEnabled) moveRight()
- } else {
- readerActivity.toggleMenu()
- }
- }
- return true
- }
+ override fun onSingleTapConfirmed(e: MotionEvent): Boolean {
+ if (isAdded) {
+ val positionX = e.x
- override fun onLongPress(e: MotionEvent?) {
- if (isAdded) {
- val page = adapter.pages.getOrNull(pager.currentItem)
- if (page != null)
- readerActivity.onLongPress(page)
- else
- context.toast(getString(R.string.unknown_error))
+ if (positionX < pager.width * LEFT_REGION) {
+ if (tappingEnabled) moveLeft()
+ } else if (positionX > pager.width * RIGHT_REGION) {
+ if (tappingEnabled) moveRight()
+ } else {
+ readerActivity.toggleMenu()
}
}
- })
+ return true
+ }
}
/**
diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonAdapter.kt
index 145d76ad01..d706540de2 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonAdapter.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonAdapter.kt
@@ -22,12 +22,7 @@ class WebtoonAdapter(val fragment: WebtoonReader) : RecyclerView.Adapter fragment.imageGestureDetector.onTouchEvent(ev) }
-
- /**
- * Touch listener for the other views.
- */
- val viewTouchListener = View.OnTouchListener { v, ev -> fragment.viewGestureDetector.onTouchEvent(ev) }
+ val touchListener = View.OnTouchListener { v, ev -> fragment.imageGestureDetector.onTouchEvent(ev) }
/**
* Returns the number of pages.
diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonHolder.kt
index fd3008da2f..3b25576473 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonHolder.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonHolder.kt
@@ -63,7 +63,8 @@ class WebtoonHolder(private val view: View, private val adapter: WebtoonAdapter)
setRegionDecoderClass(webtoonReader.regionDecoderClass)
setBitmapDecoderClass(webtoonReader.bitmapDecoderClass)
setVerticalScrollingParent(true)
- setOnTouchListener(adapter.imageTouchListener)
+ setOnTouchListener(adapter.touchListener)
+ setOnLongClickListener { webtoonReader.onLongClick(page) }
setOnImageEventListener(object : SubsamplingScaleImageView.DefaultOnImageEventListener() {
override fun onReady() {
onImageDecoded()
@@ -77,7 +78,7 @@ class WebtoonHolder(private val view: View, private val adapter: WebtoonAdapter)
view.progress_container.minimumHeight = view.resources.displayMetrics.heightPixels * 2
- view.setOnTouchListener(adapter.viewTouchListener)
+ view.setOnTouchListener(adapter.touchListener)
view.retry_button.setOnTouchListener { v, event ->
if (event.action == MotionEvent.ACTION_UP) {
readerActivity.presenter.retryPage(page)
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 7b6bca4a5e..391ef68ce5 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
@@ -3,14 +3,11 @@ package eu.kanade.tachiyomi.ui.reader.viewer.webtoon
import android.os.Bundle
import android.support.v7.widget.RecyclerView
import android.view.*
-import android.view.GestureDetector.SimpleOnGestureListener
import android.view.ViewGroup.LayoutParams.MATCH_PARENT
import android.view.ViewGroup.LayoutParams.WRAP_CONTENT
-import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.source.model.Page
import eu.kanade.tachiyomi.ui.reader.ReaderChapter
import eu.kanade.tachiyomi.ui.reader.viewer.base.BaseReader
-import eu.kanade.tachiyomi.util.toast
import eu.kanade.tachiyomi.widget.PreCachingLayoutManager
import rx.subscriptions.CompositeSubscription
@@ -59,11 +56,6 @@ class WebtoonReader : BaseReader() {
*/
val imageGestureDetector by lazy { GestureDetector(context, ImageGestureListener()) }
- /**
- * Gesture detector for other views touch events.
- */
- val viewGestureDetector by lazy { GestureDetector(context, ViewGestureListener()) }
-
/**
* Subscriptions used while the view exists.
*/
@@ -127,14 +119,9 @@ class WebtoonReader : BaseReader() {
}
/**
- * Gesture detector for Subsampling Scale Image View. [onDown] needs to be false or else
- * double tap to zoom doesn't work.
+ * Gesture detector for Subsampling Scale Image View.
*/
- inner open class ImageGestureListener : SimpleOnGestureListener() {
-
- override fun onDown(e: MotionEvent): Boolean {
- return false
- }
+ inner class ImageGestureListener : GestureDetector.SimpleOnGestureListener() {
override fun onSingleTapConfirmed(e: MotionEvent): Boolean {
if (isAdded) {
@@ -150,29 +137,6 @@ class WebtoonReader : BaseReader() {
}
return true
}
-
- override fun onLongPress(e: MotionEvent) {
- if (isAdded) {
- val child = recycler.findChildViewUnder(e.rawX, e.rawY)
- val position = recycler.getChildAdapterPosition(child)
- val page = adapter.pages?.getOrNull(position)
- if (page != null)
- readerActivity.onLongPress(page)
- else
- context.toast(getString(R.string.unknown_error))
- }
- }
- }
-
- /**
- * Gesture detector for other views. [onDown] needs to be true here or it will incorrectly
- * detect events.
- */
- inner class ViewGestureListener : ImageGestureListener() {
-
- override fun onDown(e: MotionEvent): Boolean {
- return true
- }
}
/**