mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-20 06:39:20 +01:00
Switching reader pagelayout button actions
single click: * when using automatic layout: switches between single (or split page) and double page mode * when not: opens popup to switch between the 3 long click: open same popup
This commit is contained in:
parent
04843a6666
commit
c9fbe8f847
@ -556,37 +556,19 @@ class ReaderActivity :
|
|||||||
with(doublePage) {
|
with(doublePage) {
|
||||||
compatToolTipText = getString(R.string.page_layout)
|
compatToolTipText = getString(R.string.page_layout)
|
||||||
setOnClickListener {
|
setOnClickListener {
|
||||||
val config = (viewer as? PagerViewer)?.config
|
if (preferences.pageLayout().get() == PageLayout.AUTOMATIC.value) {
|
||||||
val selectedId = when {
|
(viewer as? PagerViewer)?.config?.let { config ->
|
||||||
config?.doublePages == true -> PageLayout.DOUBLE_PAGES
|
config.doublePages = !config.doublePages
|
||||||
config?.splitPages == true -> PageLayout.SPLIT_PAGES
|
reloadChapters(config.doublePages, true)
|
||||||
else -> PageLayout.SINGLE_PAGE
|
|
||||||
}
|
|
||||||
popupMenu(
|
|
||||||
items = listOf(
|
|
||||||
PageLayout.SINGLE_PAGE,
|
|
||||||
PageLayout.DOUBLE_PAGES,
|
|
||||||
PageLayout.SPLIT_PAGES,
|
|
||||||
).map { it.value to it.stringRes },
|
|
||||||
selectedItemId = selectedId.value,
|
|
||||||
) {
|
|
||||||
val newLayout = PageLayout.fromPreference(itemId)
|
|
||||||
|
|
||||||
if (preferences.pageLayout().get() == PageLayout.AUTOMATIC.value) {
|
|
||||||
(viewer as? PagerViewer)?.config?.let { config ->
|
|
||||||
config.doublePages = newLayout == PageLayout.DOUBLE_PAGES
|
|
||||||
if (newLayout == PageLayout.SINGLE_PAGE) {
|
|
||||||
preferences.automaticSplitsPage().set(false)
|
|
||||||
} else if (newLayout == PageLayout.SPLIT_PAGES) {
|
|
||||||
preferences.automaticSplitsPage().set(true)
|
|
||||||
}
|
|
||||||
reloadChapters(config.doublePages, true)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
preferences.pageLayout().set(newLayout.value)
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
showPageLayoutMenu()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
setOnLongClickListener {
|
||||||
|
showPageLayoutMenu()
|
||||||
|
true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
cropBordersSheetButton.setOnClickListener {
|
cropBordersSheetButton.setOnClickListener {
|
||||||
val pref =
|
val pref =
|
||||||
@ -788,6 +770,41 @@ class ReaderActivity :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun showPageLayoutMenu() {
|
||||||
|
with(binding.chaptersSheet.doublePage) {
|
||||||
|
val config = (viewer as? PagerViewer)?.config
|
||||||
|
val selectedId = when {
|
||||||
|
config?.doublePages == true -> PageLayout.DOUBLE_PAGES
|
||||||
|
config?.splitPages == true -> PageLayout.SPLIT_PAGES
|
||||||
|
else -> PageLayout.SINGLE_PAGE
|
||||||
|
}
|
||||||
|
popupMenu(
|
||||||
|
items = listOf(
|
||||||
|
PageLayout.SINGLE_PAGE,
|
||||||
|
PageLayout.DOUBLE_PAGES,
|
||||||
|
PageLayout.SPLIT_PAGES,
|
||||||
|
).map { it.value to it.stringRes },
|
||||||
|
selectedItemId = selectedId.value,
|
||||||
|
) {
|
||||||
|
val newLayout = PageLayout.fromPreference(itemId)
|
||||||
|
|
||||||
|
if (preferences.pageLayout().get() == PageLayout.AUTOMATIC.value) {
|
||||||
|
(viewer as? PagerViewer)?.config?.let { config ->
|
||||||
|
config.doublePages = newLayout == PageLayout.DOUBLE_PAGES
|
||||||
|
if (newLayout == PageLayout.SINGLE_PAGE) {
|
||||||
|
preferences.automaticSplitsPage().set(false)
|
||||||
|
} else if (newLayout == PageLayout.SPLIT_PAGES) {
|
||||||
|
preferences.automaticSplitsPage().set(true)
|
||||||
|
}
|
||||||
|
reloadChapters(config.doublePages, true)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
preferences.pageLayout().set(newLayout.value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the visibility of the menu according to [visible] and with an optional parameter to
|
* Sets the visibility of the menu according to [visible] and with an optional parameter to
|
||||||
* [animate] the views.
|
* [animate] the views.
|
||||||
|
Loading…
Reference in New Issue
Block a user