mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-24 03:01:50 +01:00
Adding back long tap reader sheet
Hope you missed it
This commit is contained in:
parent
2551024b20
commit
a1e69e7194
@ -51,6 +51,8 @@ object PreferenceKeys {
|
|||||||
|
|
||||||
const val readWithTapping = "reader_tap"
|
const val readWithTapping = "reader_tap"
|
||||||
|
|
||||||
|
const val readWithLongTap = "reader_long_tap"
|
||||||
|
|
||||||
const val readWithVolumeKeys = "reader_volume_keys"
|
const val readWithVolumeKeys = "reader_volume_keys"
|
||||||
|
|
||||||
const val readWithVolumeKeysInverted = "reader_volume_keys_inverted"
|
const val readWithVolumeKeysInverted = "reader_volume_keys_inverted"
|
||||||
|
@ -129,6 +129,8 @@ class PreferencesHelper(val context: Context) {
|
|||||||
|
|
||||||
fun readWithTapping() = flowPrefs.getBoolean(Keys.readWithTapping, true)
|
fun readWithTapping() = flowPrefs.getBoolean(Keys.readWithTapping, true)
|
||||||
|
|
||||||
|
fun readWithLongTap() = flowPrefs.getBoolean(Keys.readWithLongTap, true)
|
||||||
|
|
||||||
fun readWithVolumeKeys() = flowPrefs.getBoolean(Keys.readWithVolumeKeys, false)
|
fun readWithVolumeKeys() = flowPrefs.getBoolean(Keys.readWithVolumeKeys, false)
|
||||||
|
|
||||||
fun readWithVolumeKeysInverted() = flowPrefs.getBoolean(Keys.readWithVolumeKeysInverted, false)
|
fun readWithVolumeKeysInverted() = flowPrefs.getBoolean(Keys.readWithVolumeKeysInverted, false)
|
||||||
|
@ -13,7 +13,6 @@ import android.os.Build
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.KeyEvent
|
import android.view.KeyEvent
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuItem
|
|
||||||
import android.view.MotionEvent
|
import android.view.MotionEvent
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
@ -34,6 +33,7 @@ import eu.kanade.tachiyomi.data.database.models.Manga
|
|||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.databinding.ReaderActivityBinding
|
import eu.kanade.tachiyomi.databinding.ReaderActivityBinding
|
||||||
import eu.kanade.tachiyomi.source.model.Page
|
import eu.kanade.tachiyomi.source.model.Page
|
||||||
|
import eu.kanade.tachiyomi.ui.base.MaterialMenuSheet
|
||||||
import eu.kanade.tachiyomi.ui.base.activity.BaseRxActivity
|
import eu.kanade.tachiyomi.ui.base.activity.BaseRxActivity
|
||||||
import eu.kanade.tachiyomi.ui.main.MainActivity
|
import eu.kanade.tachiyomi.ui.main.MainActivity
|
||||||
import eu.kanade.tachiyomi.ui.main.SearchActivity
|
import eu.kanade.tachiyomi.ui.main.SearchActivity
|
||||||
@ -43,7 +43,6 @@ import eu.kanade.tachiyomi.ui.reader.ReaderPresenter.SetAsCoverResult.Success
|
|||||||
import eu.kanade.tachiyomi.ui.reader.model.ReaderChapter
|
import eu.kanade.tachiyomi.ui.reader.model.ReaderChapter
|
||||||
import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
|
import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
|
||||||
import eu.kanade.tachiyomi.ui.reader.model.ViewerChapters
|
import eu.kanade.tachiyomi.ui.reader.model.ViewerChapters
|
||||||
import eu.kanade.tachiyomi.ui.reader.settings.TabbedReaderSettingsSheet
|
|
||||||
import eu.kanade.tachiyomi.ui.reader.viewer.BaseViewer
|
import eu.kanade.tachiyomi.ui.reader.viewer.BaseViewer
|
||||||
import eu.kanade.tachiyomi.ui.reader.viewer.pager.L2RPagerViewer
|
import eu.kanade.tachiyomi.ui.reader.viewer.pager.L2RPagerViewer
|
||||||
import eu.kanade.tachiyomi.ui.reader.viewer.pager.R2LPagerViewer
|
import eu.kanade.tachiyomi.ui.reader.viewer.pager.R2LPagerViewer
|
||||||
@ -280,27 +279,6 @@ class ReaderActivity :
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when an item of the options menu was clicked. Used to handle clicks on our menu
|
|
||||||
* entries.
|
|
||||||
*/
|
|
||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
|
||||||
coroutine?.cancel()
|
|
||||||
when (item.itemId) {
|
|
||||||
R.id.action_share_page, R.id.action_set_page_as_cover, R.id.action_save_page -> {
|
|
||||||
val currentChapter = presenter.getCurrentChapter() ?: return true
|
|
||||||
val page = currentChapter.pages?.getOrNull(binding.readerNav.pageSeekbar.progress) ?: return true
|
|
||||||
when (item.itemId) {
|
|
||||||
R.id.action_share_page -> shareImage(page)
|
|
||||||
R.id.action_set_page_as_cover -> showSetCoverPrompt(page)
|
|
||||||
R.id.action_save_page -> saveImage(page)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else -> return super.onOptionsItemSelected(item)
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun popToMain() {
|
private fun popToMain() {
|
||||||
presenter.onBackPressed()
|
presenter.onBackPressed()
|
||||||
if (fromUrl) {
|
if (fromUrl) {
|
||||||
@ -643,6 +621,41 @@ class ReaderActivity :
|
|||||||
binding.readerNav.pageSeekbar.progress = page.index
|
binding.readerNav.pageSeekbar.progress = page.index
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called from the viewer whenever a [page] is long clicked. A bottom sheet with a list of
|
||||||
|
* actions to perform is shown.
|
||||||
|
*/
|
||||||
|
fun onPageLongTap(page: ReaderPage) {
|
||||||
|
val items = listOf(
|
||||||
|
MaterialMenuSheet.MenuSheetItem(
|
||||||
|
0,
|
||||||
|
R.drawable.ic_share_24dp,
|
||||||
|
R.string.share
|
||||||
|
),
|
||||||
|
MaterialMenuSheet.MenuSheetItem(
|
||||||
|
1,
|
||||||
|
R.drawable.ic_save_24dp,
|
||||||
|
R.string.save
|
||||||
|
),
|
||||||
|
MaterialMenuSheet.MenuSheetItem(
|
||||||
|
2,
|
||||||
|
R.drawable.ic_photo_24dp,
|
||||||
|
R.string.set_as_cover
|
||||||
|
)
|
||||||
|
)
|
||||||
|
MaterialMenuSheet(this, items) { _, item ->
|
||||||
|
when (item) {
|
||||||
|
0 -> shareImage(page)
|
||||||
|
1 -> saveImage(page)
|
||||||
|
2 -> showSetCoverPrompt(page)
|
||||||
|
}
|
||||||
|
true
|
||||||
|
}.show()
|
||||||
|
if (binding.chaptersSheet.root.sheetBehavior.isExpanded()) {
|
||||||
|
binding.chaptersSheet.root.sheetBehavior?.collapse()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called from the viewer when the given [chapter] should be preloaded. It should be called when
|
* Called from the viewer when the given [chapter] should be preloaded. It should be called when
|
||||||
* the viewer is reaching the beginning or end of a chapter or the transition page is active.
|
* the viewer is reaching the beginning or end of a chapter or the transition page is active.
|
||||||
|
@ -21,6 +21,7 @@ abstract class ViewerConfig(preferences: PreferencesHelper) {
|
|||||||
var navigationModeInvertedListener: (() -> Unit)? = null
|
var navigationModeInvertedListener: (() -> Unit)? = null
|
||||||
|
|
||||||
var tappingEnabled = true
|
var tappingEnabled = true
|
||||||
|
var longTapEnabled = true
|
||||||
var tappingInverted = ViewerNavigation.TappingInvertMode.NONE
|
var tappingInverted = ViewerNavigation.TappingInvertMode.NONE
|
||||||
var doubleTapAnimDuration = 500
|
var doubleTapAnimDuration = 500
|
||||||
var volumeKeysEnabled = false
|
var volumeKeysEnabled = false
|
||||||
@ -38,6 +39,9 @@ abstract class ViewerConfig(preferences: PreferencesHelper) {
|
|||||||
preferences.readWithTapping()
|
preferences.readWithTapping()
|
||||||
.register({ tappingEnabled = it })
|
.register({ tappingEnabled = it })
|
||||||
|
|
||||||
|
preferences.readWithLongTap()
|
||||||
|
.register({ longTapEnabled = it })
|
||||||
|
|
||||||
preferences.doubleTapAnimSpeed()
|
preferences.doubleTapAnimSpeed()
|
||||||
.register({ doubleTapAnimDuration = it })
|
.register({ doubleTapAnimDuration = it })
|
||||||
|
|
||||||
|
@ -99,6 +99,16 @@ abstract class PagerViewer(val activity: ReaderActivity) : BaseViewer {
|
|||||||
ViewerNavigation.NavigationRegion.LEFT -> moveLeft()
|
ViewerNavigation.NavigationRegion.LEFT -> moveLeft()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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 = {
|
config.imagePropertyChangedListener = {
|
||||||
refreshAdapter()
|
refreshAdapter()
|
||||||
|
@ -114,6 +114,20 @@ class WebtoonViewer(val activity: ReaderActivity, val hasMargins: Boolean = fals
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
recycler.longTapListener = f@{ event ->
|
||||||
|
if (activity.menuVisible || config.longTapEnabled) {
|
||||||
|
val child = recycler.findChildViewUnder(event.x, event.y)
|
||||||
|
if (child != null) {
|
||||||
|
val position = recycler.getChildAdapterPosition(child)
|
||||||
|
val item = adapter.items.getOrNull(position)
|
||||||
|
if (item is ReaderPage) {
|
||||||
|
activity.onPageLongTap(item)
|
||||||
|
return@f true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
config.imagePropertyChangedListener = {
|
config.imagePropertyChangedListener = {
|
||||||
refreshAdapter()
|
refreshAdapter()
|
||||||
|
@ -254,6 +254,11 @@ class SettingsReaderController : SettingsController() {
|
|||||||
titleRes = R.string.tapping
|
titleRes = R.string.tapping
|
||||||
defaultValue = true
|
defaultValue = true
|
||||||
}
|
}
|
||||||
|
switchPreference {
|
||||||
|
key = Keys.readWithLongTap
|
||||||
|
titleRes = R.string.long_tap_dialog
|
||||||
|
defaultValue = true
|
||||||
|
}
|
||||||
switchPreference {
|
switchPreference {
|
||||||
key = Keys.readWithVolumeKeys
|
key = Keys.readWithVolumeKeys
|
||||||
titleRes = R.string.volume_keys
|
titleRes = R.string.volume_keys
|
||||||
|
@ -2,21 +2,4 @@
|
|||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
<item
|
|
||||||
android:id="@+id/action_share_page"
|
|
||||||
android:icon="@drawable/ic_share_24dp"
|
|
||||||
android:title="@string/share_page"
|
|
||||||
app:showAsAction="never" />
|
|
||||||
|
|
||||||
<item
|
|
||||||
android:id="@+id/action_save_page"
|
|
||||||
android:icon="@drawable/ic_save_24dp"
|
|
||||||
android:title="@string/save_page"
|
|
||||||
app:showAsAction="never" />
|
|
||||||
|
|
||||||
<item
|
|
||||||
android:id="@+id/action_set_page_as_cover"
|
|
||||||
android:icon="@drawable/ic_photo_24dp"
|
|
||||||
android:title="@string/set_page_as_cover"
|
|
||||||
app:showAsAction="never" />
|
|
||||||
</menu>
|
</menu>
|
||||||
|
Loading…
Reference in New Issue
Block a user