mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-19 03:59:19 +01:00
Fix #577. Fix language not applied in reader activity.
This commit is contained in:
parent
97e3b5d2ab
commit
816cc17ed3
@ -3,10 +3,15 @@ package eu.kanade.tachiyomi.ui.base.activity
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import eu.kanade.tachiyomi.App
|
import eu.kanade.tachiyomi.App
|
||||||
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter
|
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter
|
||||||
|
import eu.kanade.tachiyomi.util.LocaleHelper
|
||||||
import nucleus.view.NucleusAppCompatActivity
|
import nucleus.view.NucleusAppCompatActivity
|
||||||
|
|
||||||
abstract class BaseRxActivity<P : BasePresenter<*>> : NucleusAppCompatActivity<P>(), ActivityMixin {
|
abstract class BaseRxActivity<P : BasePresenter<*>> : NucleusAppCompatActivity<P>(), ActivityMixin {
|
||||||
|
|
||||||
|
init {
|
||||||
|
LocaleHelper.updateCfg(this)
|
||||||
|
}
|
||||||
|
|
||||||
override fun onCreate(savedState: Bundle?) {
|
override fun onCreate(savedState: Bundle?) {
|
||||||
val superFactory = presenterFactory
|
val superFactory = presenterFactory
|
||||||
setPresenterFactory {
|
setPresenterFactory {
|
||||||
|
@ -227,7 +227,7 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
|
|||||||
toast(error.message)
|
toast(error.message)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onLongPress(page: Page) {
|
fun onLongClick(page: Page) {
|
||||||
MaterialDialog.Builder(this)
|
MaterialDialog.Builder(this)
|
||||||
.title(getString(R.string.options))
|
.title(getString(R.string.options))
|
||||||
.items(R.array.reader_image_options)
|
.items(R.array.reader_image_options)
|
||||||
|
@ -212,6 +212,16 @@ abstract class BaseReader : BaseFragment() {
|
|||||||
moveLeft()
|
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.
|
* Sets the active decoder class.
|
||||||
*
|
*
|
||||||
|
@ -71,6 +71,7 @@ class PageView @JvmOverloads constructor(context: Context, attrs: AttributeSet?
|
|||||||
setBitmapDecoderClass(reader.bitmapDecoderClass)
|
setBitmapDecoderClass(reader.bitmapDecoderClass)
|
||||||
setVerticalScrollingParent(reader is VerticalReader)
|
setVerticalScrollingParent(reader is VerticalReader)
|
||||||
setOnTouchListener { v, motionEvent -> reader.gestureDetector.onTouchEvent(motionEvent) }
|
setOnTouchListener { v, motionEvent -> reader.gestureDetector.onTouchEvent(motionEvent) }
|
||||||
|
setOnLongClickListener { reader.onLongClick(page) }
|
||||||
setOnImageEventListener(object : SubsamplingScaleImageView.DefaultOnImageEventListener() {
|
setOnImageEventListener(object : SubsamplingScaleImageView.DefaultOnImageEventListener() {
|
||||||
override fun onReady() {
|
override fun onReady() {
|
||||||
onImageDecoded(reader)
|
onImageDecoded(reader)
|
||||||
|
@ -66,7 +66,7 @@ abstract class PagerReader : BaseReader() {
|
|||||||
/**
|
/**
|
||||||
* Gesture detector for touch events.
|
* Gesture detector for touch events.
|
||||||
*/
|
*/
|
||||||
val gestureDetector by lazy { createGestureDetector() }
|
val gestureDetector by lazy { GestureDetector(context, ImageGestureListener()) }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subscriptions for reader settings.
|
* Subscriptions for reader settings.
|
||||||
@ -166,12 +166,10 @@ abstract class PagerReader : BaseReader() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the gesture detector for the pager.
|
* Gesture detector for Subsampling Scale Image View.
|
||||||
*
|
|
||||||
* @return a gesture detector.
|
|
||||||
*/
|
*/
|
||||||
protected fun createGestureDetector(): GestureDetector {
|
inner class ImageGestureListener : GestureDetector.SimpleOnGestureListener() {
|
||||||
return GestureDetector(activity, object : GestureDetector.SimpleOnGestureListener() {
|
|
||||||
override fun onSingleTapConfirmed(e: MotionEvent): Boolean {
|
override fun onSingleTapConfirmed(e: MotionEvent): Boolean {
|
||||||
if (isAdded) {
|
if (isAdded) {
|
||||||
val positionX = e.x
|
val positionX = e.x
|
||||||
@ -186,17 +184,6 @@ abstract class PagerReader : BaseReader() {
|
|||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
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))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -22,12 +22,7 @@ class WebtoonAdapter(val fragment: WebtoonReader) : RecyclerView.Adapter<Webtoon
|
|||||||
/**
|
/**
|
||||||
* Touch listener for images in holders.
|
* Touch listener for images in holders.
|
||||||
*/
|
*/
|
||||||
val imageTouchListener = View.OnTouchListener { v, ev -> fragment.imageGestureDetector.onTouchEvent(ev) }
|
val touchListener = View.OnTouchListener { v, ev -> fragment.imageGestureDetector.onTouchEvent(ev) }
|
||||||
|
|
||||||
/**
|
|
||||||
* Touch listener for the other views.
|
|
||||||
*/
|
|
||||||
val viewTouchListener = View.OnTouchListener { v, ev -> fragment.viewGestureDetector.onTouchEvent(ev) }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of pages.
|
* Returns the number of pages.
|
||||||
|
@ -63,7 +63,8 @@ class WebtoonHolder(private val view: View, private val adapter: WebtoonAdapter)
|
|||||||
setRegionDecoderClass(webtoonReader.regionDecoderClass)
|
setRegionDecoderClass(webtoonReader.regionDecoderClass)
|
||||||
setBitmapDecoderClass(webtoonReader.bitmapDecoderClass)
|
setBitmapDecoderClass(webtoonReader.bitmapDecoderClass)
|
||||||
setVerticalScrollingParent(true)
|
setVerticalScrollingParent(true)
|
||||||
setOnTouchListener(adapter.imageTouchListener)
|
setOnTouchListener(adapter.touchListener)
|
||||||
|
setOnLongClickListener { webtoonReader.onLongClick(page) }
|
||||||
setOnImageEventListener(object : SubsamplingScaleImageView.DefaultOnImageEventListener() {
|
setOnImageEventListener(object : SubsamplingScaleImageView.DefaultOnImageEventListener() {
|
||||||
override fun onReady() {
|
override fun onReady() {
|
||||||
onImageDecoded()
|
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.progress_container.minimumHeight = view.resources.displayMetrics.heightPixels * 2
|
||||||
|
|
||||||
view.setOnTouchListener(adapter.viewTouchListener)
|
view.setOnTouchListener(adapter.touchListener)
|
||||||
view.retry_button.setOnTouchListener { v, event ->
|
view.retry_button.setOnTouchListener { v, event ->
|
||||||
if (event.action == MotionEvent.ACTION_UP) {
|
if (event.action == MotionEvent.ACTION_UP) {
|
||||||
readerActivity.presenter.retryPage(page)
|
readerActivity.presenter.retryPage(page)
|
||||||
|
@ -3,14 +3,11 @@ package eu.kanade.tachiyomi.ui.reader.viewer.webtoon
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.support.v7.widget.RecyclerView
|
import android.support.v7.widget.RecyclerView
|
||||||
import android.view.*
|
import android.view.*
|
||||||
import android.view.GestureDetector.SimpleOnGestureListener
|
|
||||||
import android.view.ViewGroup.LayoutParams.MATCH_PARENT
|
import android.view.ViewGroup.LayoutParams.MATCH_PARENT
|
||||||
import android.view.ViewGroup.LayoutParams.WRAP_CONTENT
|
import android.view.ViewGroup.LayoutParams.WRAP_CONTENT
|
||||||
import eu.kanade.tachiyomi.R
|
|
||||||
import eu.kanade.tachiyomi.data.source.model.Page
|
import eu.kanade.tachiyomi.data.source.model.Page
|
||||||
import eu.kanade.tachiyomi.ui.reader.ReaderChapter
|
import eu.kanade.tachiyomi.ui.reader.ReaderChapter
|
||||||
import eu.kanade.tachiyomi.ui.reader.viewer.base.BaseReader
|
import eu.kanade.tachiyomi.ui.reader.viewer.base.BaseReader
|
||||||
import eu.kanade.tachiyomi.util.toast
|
|
||||||
import eu.kanade.tachiyomi.widget.PreCachingLayoutManager
|
import eu.kanade.tachiyomi.widget.PreCachingLayoutManager
|
||||||
import rx.subscriptions.CompositeSubscription
|
import rx.subscriptions.CompositeSubscription
|
||||||
|
|
||||||
@ -59,11 +56,6 @@ class WebtoonReader : BaseReader() {
|
|||||||
*/
|
*/
|
||||||
val imageGestureDetector by lazy { GestureDetector(context, ImageGestureListener()) }
|
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.
|
* 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
|
* Gesture detector for Subsampling Scale Image View.
|
||||||
* double tap to zoom doesn't work.
|
|
||||||
*/
|
*/
|
||||||
inner open class ImageGestureListener : SimpleOnGestureListener() {
|
inner class ImageGestureListener : GestureDetector.SimpleOnGestureListener() {
|
||||||
|
|
||||||
override fun onDown(e: MotionEvent): Boolean {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onSingleTapConfirmed(e: MotionEvent): Boolean {
|
override fun onSingleTapConfirmed(e: MotionEvent): Boolean {
|
||||||
if (isAdded) {
|
if (isAdded) {
|
||||||
@ -150,29 +137,6 @@ class WebtoonReader : BaseReader() {
|
|||||||
}
|
}
|
||||||
return true
|
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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user