mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-23 06:31:47 +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) {
|
||||
compatToolTipText = getString(R.string.page_layout)
|
||||
setOnClickListener {
|
||||
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)
|
||||
if (preferences.pageLayout().get() == PageLayout.AUTOMATIC.value) {
|
||||
(viewer as? PagerViewer)?.config?.let { config ->
|
||||
config.doublePages = !config.doublePages
|
||||
reloadChapters(config.doublePages, true)
|
||||
}
|
||||
} else {
|
||||
showPageLayoutMenu()
|
||||
}
|
||||
}
|
||||
setOnLongClickListener {
|
||||
showPageLayoutMenu()
|
||||
true
|
||||
}
|
||||
}
|
||||
cropBordersSheetButton.setOnClickListener {
|
||||
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
|
||||
* [animate] the views.
|
||||
|
Loading…
Reference in New Issue
Block a user