mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2025-01-23 17:51:13 +01:00
Actually show nav overlay on switch of invert tap
This commit is contained in:
parent
fe066de262
commit
db4eca90e9
@ -22,7 +22,7 @@ class ReaderNavigationOverlayView(context: Context, attributeSet: AttributeSet)
|
|||||||
var isLTR = true
|
var isLTR = true
|
||||||
|
|
||||||
fun setNavigation(navigation: ViewerNavigation, showOnStart: Boolean) {
|
fun setNavigation(navigation: ViewerNavigation, showOnStart: Boolean) {
|
||||||
if (!showOnStart && (this.navigation == null || this.navigation === navigation) && !forceShowOverlay) {
|
if (!showOnStart && (this.navigation == null || this.navigation === navigation)) {
|
||||||
if (this.navigation == null) {
|
if (this.navigation == null) {
|
||||||
this.navigation = navigation
|
this.navigation = navigation
|
||||||
isVisible = false
|
isVisible = false
|
||||||
@ -30,8 +30,11 @@ class ReaderNavigationOverlayView(context: Context, attributeSet: AttributeSet)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
forceShowOverlay = false
|
|
||||||
this.navigation = navigation
|
this.navigation = navigation
|
||||||
|
showNavigationAgain()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun showNavigationAgain() {
|
||||||
invalidate()
|
invalidate()
|
||||||
|
|
||||||
if (isVisible) return
|
if (isVisible) return
|
||||||
@ -121,10 +124,6 @@ class ReaderNavigationOverlayView(context: Context, attributeSet: AttributeSet)
|
|||||||
performClick()
|
performClick()
|
||||||
return super.onTouchEvent(event)
|
return super.onTouchEvent(event)
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
|
||||||
var forceShowOverlay = false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private const val FADE_DURATION = 1000L
|
private const val FADE_DURATION = 1000L
|
||||||
|
@ -4,7 +4,6 @@ import android.content.Context
|
|||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
||||||
import eu.kanade.tachiyomi.ui.reader.ReaderNavigationOverlayView
|
|
||||||
import eu.kanade.tachiyomi.util.bindToPreference
|
import eu.kanade.tachiyomi.util.bindToPreference
|
||||||
import eu.kanade.tachiyomi.util.view.visibleIf
|
import eu.kanade.tachiyomi.util.view.visibleIf
|
||||||
import eu.kanade.tachiyomi.widget.BaseReaderSettingsView
|
import eu.kanade.tachiyomi.widget.BaseReaderSettingsView
|
||||||
@ -19,20 +18,16 @@ class ReaderPagedView @JvmOverloads constructor(context: Context, attrs: Attribu
|
|||||||
crop_borders.bindToPreference(preferences.cropBorders())
|
crop_borders.bindToPreference(preferences.cropBorders())
|
||||||
page_transitions.bindToPreference(preferences.pageTransitions())
|
page_transitions.bindToPreference(preferences.pageTransitions())
|
||||||
pager_nav.bindToPreference(preferences.navigationModePager())
|
pager_nav.bindToPreference(preferences.navigationModePager())
|
||||||
pager_invert.bindToPreference(preferences.pagerNavInverted()) {
|
pager_invert.bindToPreference(preferences.pagerNavInverted())
|
||||||
ReaderNavigationOverlayView.forceShowOverlay = true
|
|
||||||
}
|
|
||||||
|
|
||||||
val mangaViewer = (context as ReaderActivity).presenter.getMangaViewer()
|
val mangaViewer = (context as? ReaderActivity)?.presenter?.getMangaViewer() ?: 0
|
||||||
val isWebtoonView = mangaViewer == ReaderActivity.WEBTOON || mangaViewer == ReaderActivity.VERTICAL_PLUS
|
val isWebtoonView = mangaViewer == ReaderActivity.WEBTOON || mangaViewer == ReaderActivity.VERTICAL_PLUS
|
||||||
val hasMargins = mangaViewer == ReaderActivity.VERTICAL_PLUS
|
val hasMargins = mangaViewer == ReaderActivity.VERTICAL_PLUS
|
||||||
crop_borders_webtoon.bindToPreference(if (hasMargins) preferences.cropBorders() else preferences.cropBordersWebtoon())
|
crop_borders_webtoon.bindToPreference(if (hasMargins) preferences.cropBorders() else preferences.cropBordersWebtoon())
|
||||||
webtoon_side_padding.bindToIntPreference(preferences.webtoonSidePadding(), R.array.webtoon_side_padding_values)
|
webtoon_side_padding.bindToIntPreference(preferences.webtoonSidePadding(), R.array.webtoon_side_padding_values)
|
||||||
webtoon_enable_zoom_out.bindToPreference(preferences.webtoonEnableZoomOut())
|
webtoon_enable_zoom_out.bindToPreference(preferences.webtoonEnableZoomOut())
|
||||||
webtoon_nav.bindToPreference(preferences.navigationModeWebtoon())
|
webtoon_nav.bindToPreference(preferences.navigationModeWebtoon())
|
||||||
webtoon_invert.bindToPreference(preferences.webtoonNavInverted()) {
|
webtoon_invert.bindToPreference(preferences.webtoonNavInverted())
|
||||||
ReaderNavigationOverlayView.forceShowOverlay = true
|
|
||||||
}
|
|
||||||
|
|
||||||
updatePagedGroup(!isWebtoonView)
|
updatePagedGroup(!isWebtoonView)
|
||||||
}
|
}
|
||||||
|
@ -80,16 +80,6 @@ class ReaderSpinnerView @JvmOverloads constructor(context: Context, attrs: Attri
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline fun <reified T : Enum<T>> bindToPreference(pref: Preference<T>, crossinline block: ((Int) -> Unit)) {
|
|
||||||
val enumConstants = T::class.java.enumConstants
|
|
||||||
enumConstants?.indexOf(pref.get())?.let { setSelection(it) }
|
|
||||||
val popup = makeSettingsPopup(pref, block)
|
|
||||||
setOnTouchListener(popup.dragToOpenListener)
|
|
||||||
setOnClickListener {
|
|
||||||
popup.show()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun bindToIntPreference(pref: Preference<Int>, @ArrayRes intValuesResource: Int, block: ((Int) -> Unit)? = null) {
|
fun bindToIntPreference(pref: Preference<Int>, @ArrayRes intValuesResource: Int, block: ((Int) -> Unit)? = null) {
|
||||||
setSelection(pref.get())
|
setSelection(pref.get())
|
||||||
this.pref = pref
|
this.pref = pref
|
||||||
@ -121,19 +111,6 @@ class ReaderSpinnerView @JvmOverloads constructor(context: Context, attrs: Attri
|
|||||||
return popup
|
return popup
|
||||||
}
|
}
|
||||||
|
|
||||||
inline fun <reified T : Enum<T>> makeSettingsPopup(preference: Preference<T>, crossinline block: ((Int) -> Unit)): PopupMenu {
|
|
||||||
val popup = popup()
|
|
||||||
// Set a listener so we are notified if a menu item is clicked
|
|
||||||
popup.setOnMenuItemClickListener { menuItem ->
|
|
||||||
val enumConstants = T::class.java.enumConstants
|
|
||||||
val pos = popup.menuClicked(menuItem)
|
|
||||||
enumConstants?.get(pos)?.let { preference.set(it) }
|
|
||||||
block(pos)
|
|
||||||
true
|
|
||||||
}
|
|
||||||
return popup
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun makeSettingsPopup(preference: Preference<Int>, intValues: List<Int?>, block: ((Int) -> Unit)? = null): PopupMenu {
|
private fun makeSettingsPopup(preference: Preference<Int>, intValues: List<Int?>, block: ((Int) -> Unit)? = null): PopupMenu {
|
||||||
val popup = popup()
|
val popup = popup()
|
||||||
// Set a listener so we are notified if a menu item is clicked
|
// Set a listener so we are notified if a menu item is clicked
|
||||||
|
@ -13,11 +13,12 @@ import kotlinx.coroutines.flow.onEach
|
|||||||
*/
|
*/
|
||||||
abstract class ViewerConfig(preferences: PreferencesHelper) {
|
abstract class ViewerConfig(preferences: PreferencesHelper) {
|
||||||
|
|
||||||
private val scope = CoroutineScope(Job() + Dispatchers.Main)
|
protected val scope = CoroutineScope(Job() + Dispatchers.Main)
|
||||||
|
|
||||||
var imagePropertyChangedListener: (() -> Unit)? = null
|
var imagePropertyChangedListener: (() -> Unit)? = null
|
||||||
|
|
||||||
var navigationModeChangedListener: (() -> Unit)? = null
|
var navigationModeChangedListener: (() -> Unit)? = null
|
||||||
|
var navigationModeInvertedListener: (() -> Unit)? = null
|
||||||
|
|
||||||
var tappingEnabled = true
|
var tappingEnabled = true
|
||||||
var tappingInverted = ViewerNavigation.TappingInvertMode.NONE
|
var tappingInverted = ViewerNavigation.TappingInvertMode.NONE
|
||||||
|
@ -7,6 +7,9 @@ import eu.kanade.tachiyomi.ui.reader.viewer.navigation.EdgeNavigation
|
|||||||
import eu.kanade.tachiyomi.ui.reader.viewer.navigation.KindlishNavigation
|
import eu.kanade.tachiyomi.ui.reader.viewer.navigation.KindlishNavigation
|
||||||
import eu.kanade.tachiyomi.ui.reader.viewer.navigation.LNavigation
|
import eu.kanade.tachiyomi.ui.reader.viewer.navigation.LNavigation
|
||||||
import eu.kanade.tachiyomi.ui.reader.viewer.navigation.RightAndLeftNavigation
|
import eu.kanade.tachiyomi.ui.reader.viewer.navigation.RightAndLeftNavigation
|
||||||
|
import kotlinx.coroutines.flow.drop
|
||||||
|
import kotlinx.coroutines.flow.launchIn
|
||||||
|
import kotlinx.coroutines.flow.onEach
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
|
|
||||||
@ -44,9 +47,15 @@ class PagerConfig(private val viewer: PagerViewer, preferences: PreferencesHelpe
|
|||||||
preferences.pagerNavInverted()
|
preferences.pagerNavInverted()
|
||||||
.register({ tappingInverted = it }, {
|
.register({ tappingInverted = it }, {
|
||||||
navigator.invertMode = it
|
navigator.invertMode = it
|
||||||
navigationModeChangedListener?.invoke()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
preferences.pagerNavInverted().asFlow()
|
||||||
|
.drop(1)
|
||||||
|
.onEach {
|
||||||
|
navigationModeInvertedListener?.invoke()
|
||||||
|
}
|
||||||
|
.launchIn(scope)
|
||||||
|
|
||||||
preferences.zoomStart()
|
preferences.zoomStart()
|
||||||
.register({ zoomTypeFromPreference(it) }, { imagePropertyChangedListener?.invoke() })
|
.register({ zoomTypeFromPreference(it) }, { imagePropertyChangedListener?.invoke() })
|
||||||
|
|
||||||
|
@ -109,6 +109,7 @@ abstract class PagerViewer(val activity: ReaderActivity) : BaseViewer {
|
|||||||
val showOnStart = config.navigationOverlayForNewUser
|
val showOnStart = config.navigationOverlayForNewUser
|
||||||
activity.navigation_overlay.setNavigation(config.navigator, showOnStart)
|
activity.navigation_overlay.setNavigation(config.navigator, showOnStart)
|
||||||
}
|
}
|
||||||
|
config.navigationModeInvertedListener = { activity.navigation_overlay.showNavigationAgain() }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -7,6 +7,9 @@ import eu.kanade.tachiyomi.ui.reader.viewer.navigation.EdgeNavigation
|
|||||||
import eu.kanade.tachiyomi.ui.reader.viewer.navigation.KindlishNavigation
|
import eu.kanade.tachiyomi.ui.reader.viewer.navigation.KindlishNavigation
|
||||||
import eu.kanade.tachiyomi.ui.reader.viewer.navigation.LNavigation
|
import eu.kanade.tachiyomi.ui.reader.viewer.navigation.LNavigation
|
||||||
import eu.kanade.tachiyomi.ui.reader.viewer.navigation.RightAndLeftNavigation
|
import eu.kanade.tachiyomi.ui.reader.viewer.navigation.RightAndLeftNavigation
|
||||||
|
import kotlinx.coroutines.flow.drop
|
||||||
|
import kotlinx.coroutines.flow.launchIn
|
||||||
|
import kotlinx.coroutines.flow.onEach
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
|
|
||||||
@ -36,9 +39,15 @@ class WebtoonConfig(preferences: PreferencesHelper = Injekt.get()) : ViewerConfi
|
|||||||
preferences.webtoonNavInverted()
|
preferences.webtoonNavInverted()
|
||||||
.register({ tappingInverted = it }, {
|
.register({ tappingInverted = it }, {
|
||||||
navigator.invertMode = it
|
navigator.invertMode = it
|
||||||
navigationModeChangedListener?.invoke()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
preferences.webtoonNavInverted().asFlow()
|
||||||
|
.drop(1)
|
||||||
|
.onEach {
|
||||||
|
navigationModeInvertedListener?.invoke()
|
||||||
|
}
|
||||||
|
.launchIn(scope)
|
||||||
|
|
||||||
preferences.cropBordersWebtoon()
|
preferences.cropBordersWebtoon()
|
||||||
.register({ webtoonCropBorders = it }, { imagePropertyChangedListener?.invoke() })
|
.register({ webtoonCropBorders = it }, { imagePropertyChangedListener?.invoke() })
|
||||||
|
|
||||||
|
@ -128,6 +128,7 @@ class WebtoonViewer(val activity: ReaderActivity, val hasMargins: Boolean = fals
|
|||||||
val showOnStart = config.navigationOverlayForNewUser
|
val showOnStart = config.navigationOverlayForNewUser
|
||||||
activity.navigation_overlay.setNavigation(config.navigator, showOnStart)
|
activity.navigation_overlay.setNavigation(config.navigator, showOnStart)
|
||||||
}
|
}
|
||||||
|
config.navigationModeInvertedListener = { activity.navigation_overlay.showNavigationAgain() }
|
||||||
|
|
||||||
frame.layoutParams = ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT)
|
frame.layoutParams = ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT)
|
||||||
frame.addView(recycler)
|
frame.addView(recycler)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user