diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt
index 7596a6ae5e..259e1fb8c2 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt
@@ -41,6 +41,8 @@ object PreferenceKeys {
const val readWithTapping = "reader_tap"
+ const val readWithLongTap = "reader_long_tap"
+
const val readWithVolumeKeys = "reader_volume_keys"
const val readWithVolumeKeysInverted = "reader_volume_keys_inverted"
diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt
index b9ab93f441..ee5b0b39e5 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt
@@ -69,6 +69,8 @@ class PreferencesHelper(val context: Context) {
fun readWithTapping() = rxPrefs.getBoolean(Keys.readWithTapping, true)
+ fun readWithLongTap() = rxPrefs.getBoolean(Keys.readWithLongTap, true)
+
fun readWithVolumeKeys() = rxPrefs.getBoolean(Keys.readWithVolumeKeys, false)
fun readWithVolumeKeysInverted() = rxPrefs.getBoolean(Keys.readWithVolumeKeysInverted, false)
diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderSettingsSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderSettingsSheet.kt
index 0a726eef3b..b798f3b49b 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderSettingsSheet.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderSettingsSheet.kt
@@ -62,6 +62,7 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) : BottomSheetDia
show_page_number.bindToPreference(preferences.showPageNumber())
fullscreen.bindToPreference(preferences.fullscreen())
keepscreen.bindToPreference(preferences.keepScreenOn())
+ long_tap.bindToPreference(preferences.readWithLongTap())
}
/**
diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/Pager.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/Pager.kt
index ceaf610f1b..0a0114dcc5 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/Pager.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/Pager.kt
@@ -25,7 +25,7 @@ open class Pager(
/**
* Long tap listener function to execute when a long tap is detected.
*/
- var longTapListener: ((MotionEvent) -> Unit)? = null
+ var longTapListener: ((MotionEvent) -> Boolean)? = null
/**
* Gesture listener that implements tap and long tap events.
@@ -38,8 +38,7 @@ open class Pager(
override fun onLongTapConfirmed(ev: MotionEvent) {
val listener = longTapListener
- if (listener != null) {
- listener.invoke(ev)
+ if (listener != null && listener.invoke(ev)) {
performHapticFeedback(HapticFeedbackConstants.LONG_PRESS)
}
}
diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerConfig.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerConfig.kt
index c5ebabc537..c07c7b65fb 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerConfig.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerConfig.kt
@@ -19,6 +19,9 @@ class PagerConfig(private val viewer: PagerViewer, preferences: PreferencesHelpe
var tappingEnabled = true
private set
+ var longTapEnabled = true
+ private set
+
var volumeKeysEnabled = false
private set
@@ -44,6 +47,9 @@ class PagerConfig(private val viewer: PagerViewer, preferences: PreferencesHelpe
preferences.readWithTapping()
.register({ tappingEnabled = it })
+ preferences.readWithLongTap()
+ .register({ longTapEnabled = it })
+
preferences.pageTransitions()
.register({ usePageTransitions = it })
diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerViewer.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerViewer.kt
index 699c8b9b9c..8f37257a5a 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerViewer.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerViewer.kt
@@ -92,11 +92,15 @@ abstract class PagerViewer(val activity: ReaderActivity) : BaseViewer {
else -> activity.toggleMenu()
}
}
- pager.longTapListener = {
- val item = adapter.items.getOrNull(pager.currentItem)
- if (item is ReaderPage) {
- activity.onPageLongTap(item)
+ pager.longTapListener = f@ {
+ if (activity.menuVisible || config.longTapEnabled) {
+ val item = adapter.items.getOrNull(pager.currentItem)
+ if (item is ReaderPage) {
+ activity.onPageLongTap(item)
+ return@f true
+ }
}
+ false
}
config.imagePropertyChangedListener = {
diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonConfig.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonConfig.kt
index f575e4ac47..7ac8a220a6 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonConfig.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonConfig.kt
@@ -19,6 +19,9 @@ class WebtoonConfig(preferences: PreferencesHelper = Injekt.get()) {
var tappingEnabled = true
private set
+ var longTapEnabled = true
+ private set
+
var volumeKeysEnabled = false
private set
@@ -35,6 +38,9 @@ class WebtoonConfig(preferences: PreferencesHelper = Injekt.get()) {
preferences.readWithTapping()
.register({ tappingEnabled = it })
+ preferences.readWithLongTap()
+ .register({ longTapEnabled = it })
+
preferences.cropBordersWebtoon()
.register({ imageCropBorders = it }, { imagePropertyChangedListener?.invoke() })
diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonRecyclerView.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonRecyclerView.kt
index f838e62ed7..eae782c931 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonRecyclerView.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonRecyclerView.kt
@@ -37,7 +37,7 @@ open class WebtoonRecyclerView @JvmOverloads constructor(
private val detector = Detector()
var tapListener: ((MotionEvent) -> Unit)? = null
- var longTapListener: ((MotionEvent) -> Unit)? = null
+ var longTapListener: ((MotionEvent) -> Boolean)? = null
override fun onMeasure(widthSpec: Int, heightSpec: Int) {
halfWidth = MeasureSpec.getSize(widthSpec) / 2
@@ -220,8 +220,7 @@ open class WebtoonRecyclerView @JvmOverloads constructor(
override fun onLongTapConfirmed(ev: MotionEvent) {
val listener = longTapListener
- if (listener != null) {
- listener.invoke(ev)
+ if (listener != null && listener.invoke(ev)) {
performHapticFeedback(HapticFeedbackConstants.LONG_PRESS)
}
}
diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonViewer.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonViewer.kt
index 046c2bde95..6adee83c2f 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonViewer.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonViewer.kt
@@ -95,13 +95,17 @@ class WebtoonViewer(val activity: ReaderActivity) : BaseViewer {
else -> activity.toggleMenu()
}
}
- recycler.longTapListener = { event ->
- val child = recycler.findChildViewUnder(event.x, event.y)
- val position = recycler.getChildAdapterPosition(child)
- val item = adapter.items.getOrNull(position)
- if (item is ReaderPage) {
- activity.onPageLongTap(item)
+ recycler.longTapListener = f@ { event ->
+ if (activity.menuVisible || config.longTapEnabled) {
+ val child = recycler.findChildViewUnder(event.x, event.y)
+ val position = recycler.getChildAdapterPosition(child)
+ val item = adapter.items.getOrNull(position)
+ if (item is ReaderPage) {
+ activity.onPageLongTap(item)
+ return@f true
+ }
}
+ false
}
frame.layoutParams = ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT)
diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsReaderController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsReaderController.kt
index 66dd445977..9439953850 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsReaderController.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsReaderController.kt
@@ -108,6 +108,11 @@ class SettingsReaderController : SettingsController() {
titleRes = R.string.pref_read_with_tapping
defaultValue = true
}
+ switchPreference {
+ key = Keys.readWithLongTap
+ titleRes = R.string.pref_read_with_long_tap
+ defaultValue = true
+ }
switchPreference {
key = Keys.readWithVolumeKeys
titleRes = R.string.pref_read_with_volume_keys
diff --git a/app/src/main/res/layout/reader_settings_sheet.xml b/app/src/main/res/layout/reader_settings_sheet.xml
index 85ab2c975b..8b6354c5bf 100644
--- a/app/src/main/res/layout/reader_settings_sheet.xml
+++ b/app/src/main/res/layout/reader_settings_sheet.xml
@@ -123,11 +123,20 @@
android:textColor="?android:attr/textColorSecondary"
app:layout_constraintTop_toBottomOf="@id/fullscreen" />
+
+
+ app:layout_constraintBottom_toBottomOf="@id/long_tap" />
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 520f70e43d..a41d29aa49 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -180,6 +180,7 @@
Volume keys
Invert volume keys
Tapping
+ Long tap dialog
Background color
White
Black
diff --git a/build.gradle b/build.gradle
index 09b0d46cf3..cef1ec0007 100644
--- a/build.gradle
+++ b/build.gradle
@@ -19,9 +19,9 @@ buildscript {
allprojects {
repositories {
google()
- jcenter()
maven { url "https://jitpack.io" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
- maven { url "https://dl.bintray.com/inorichi/maven" }
+ jcenter()
+ maven { url "https://dl.bintray.com/inorichi/maven" }
}
}