diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt
index 393e12cd03..99da73d4fb 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt
@@ -63,6 +63,7 @@ import eu.kanade.tachiyomi.util.system.getResourceColor
import eu.kanade.tachiyomi.util.system.hasSideNavBar
import eu.kanade.tachiyomi.util.system.isBottomTappable
import eu.kanade.tachiyomi.util.system.isLTR
+import eu.kanade.tachiyomi.util.system.isTablet
import eu.kanade.tachiyomi.util.system.launchIO
import eu.kanade.tachiyomi.util.system.launchUI
import eu.kanade.tachiyomi.util.system.openInBrowser
@@ -310,12 +311,15 @@ class ReaderActivity :
override fun onPrepareOptionsMenu(menu: Menu?): Boolean {
val splitItem = menu?.findItem(R.id.action_shift_double_page)
- splitItem?.isVisible = (viewer as? PagerViewer)?.config?.doublePages ?: false
+ splitItem?.isVisible = ((viewer as? PagerViewer)?.config?.doublePages ?: false) && !isTablet()
+ binding.chaptersSheet.shiftPageButton.isVisible = ((viewer as? PagerViewer)?.config?.doublePages ?: false) && isTablet()
(viewer as? PagerViewer)?.config?.let { config ->
- splitItem?.icon = ContextCompat.getDrawable(
+ val icon = ContextCompat.getDrawable(
this,
if ((!config.shiftDoublePage).xor(viewer is R2LPagerViewer)) R.drawable.ic_page_previous_outline_24dp else R.drawable.ic_page_next_outline_24dp
)
+ splitItem?.icon = icon
+ binding.chaptersSheet.shiftPageButton.setImageDrawable(icon)
}
setBottomNavButtons(preferences.pageLayout().get())
(binding.toolbar.background as? LayerDrawable)?.let { layerDrawable ->
@@ -353,20 +357,24 @@ class ReaderActivity :
override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
R.id.action_shift_double_page -> {
- (viewer as? PagerViewer)?.config?.let { config ->
- config.shiftDoublePage = !config.shiftDoublePage
- presenter.viewerChapters?.let {
- (viewer as? PagerViewer)?.updateShifting()
- (viewer as? PagerViewer)?.setChaptersDoubleShift(it)
- invalidateOptionsMenu()
- }
- }
+ shiftDoublePages()
}
else -> return super.onOptionsItemSelected(item)
}
return true
}
+ fun shiftDoublePages() {
+ (viewer as? PagerViewer)?.config?.let { config ->
+ config.shiftDoublePage = !config.shiftDoublePage
+ presenter.viewerChapters?.let {
+ (viewer as? PagerViewer)?.updateShifting()
+ (viewer as? PagerViewer)?.setChaptersDoubleShift(it)
+ invalidateOptionsMenu()
+ }
+ }
+ }
+
private fun popToMain() {
presenter.onBackPressed()
if (fromUrl) {
@@ -483,6 +491,9 @@ class ReaderActivity :
preferences.pageLayout().set(1 - preferences.pageLayout().get())
}
}
+ binding.chaptersSheet.shiftPageButton.setOnClickListener {
+ shiftDoublePages()
+ }
binding.readerNav.leftChapter.setOnClickListener {
if (isLoading) {
return@setOnClickListener
diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/system/ContextExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/util/system/ContextExtensions.kt
index cbe468f519..ef1c58f22c 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/util/system/ContextExtensions.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/util/system/ContextExtensions.kt
@@ -148,6 +148,8 @@ val Float.dpToPxEnd: Float
val Resources.isLTR
get() = configuration.layoutDirection == View.LAYOUT_DIRECTION_LTR
+fun Context.isTablet() = resources.getBoolean(R.bool.isTablet)
+
/**
* Helper method to create a notification builder.
*
@@ -155,7 +157,10 @@ val Resources.isLTR
* @param block the function that will execute inside the builder.
* @return a notification to be displayed or updated.
*/
-fun Context.notificationBuilder(channelId: String, block: (NotificationCompat.Builder.() -> Unit)? = null): NotificationCompat.Builder {
+fun Context.notificationBuilder(
+ channelId: String,
+ block: (NotificationCompat.Builder.() -> Unit)? = null
+): NotificationCompat.Builder {
val builder = NotificationCompat.Builder(this, channelId)
.setColor(ContextCompat.getColor(this, R.color.colorAccent))
if (block != null) {
@@ -197,7 +202,9 @@ val Context.powerManager: PowerManager
* @param intent intent that contains broadcast information
*/
fun Context.sendLocalBroadcast(intent: Intent) {
- androidx.localbroadcastmanager.content.LocalBroadcastManager.getInstance(this).sendBroadcast(intent)
+ androidx.localbroadcastmanager.content.LocalBroadcastManager.getInstance(this).sendBroadcast(
+ intent
+ )
}
/**
@@ -206,7 +213,9 @@ fun Context.sendLocalBroadcast(intent: Intent) {
* @param intent intent that contains broadcast information
*/
fun Context.sendLocalBroadcastSync(intent: Intent) {
- androidx.localbroadcastmanager.content.LocalBroadcastManager.getInstance(this).sendBroadcastSync(intent)
+ androidx.localbroadcastmanager.content.LocalBroadcastManager.getInstance(this).sendBroadcastSync(
+ intent
+ )
}
/**
@@ -215,7 +224,10 @@ fun Context.sendLocalBroadcastSync(intent: Intent) {
* @param receiver receiver that gets registered.
*/
fun Context.registerLocalReceiver(receiver: BroadcastReceiver, filter: IntentFilter) {
- androidx.localbroadcastmanager.content.LocalBroadcastManager.getInstance(this).registerReceiver(receiver, filter)
+ androidx.localbroadcastmanager.content.LocalBroadcastManager.getInstance(this).registerReceiver(
+ receiver,
+ filter
+ )
}
/**
@@ -224,7 +236,9 @@ fun Context.registerLocalReceiver(receiver: BroadcastReceiver, filter: IntentFil
* @param receiver receiver that gets unregistered.
*/
fun Context.unregisterLocalReceiver(receiver: BroadcastReceiver) {
- androidx.localbroadcastmanager.content.LocalBroadcastManager.getInstance(this).unregisterReceiver(receiver)
+ androidx.localbroadcastmanager.content.LocalBroadcastManager.getInstance(this).unregisterReceiver(
+ receiver
+ )
}
/**
diff --git a/app/src/main/res/layout/reader_chapters_sheet.xml b/app/src/main/res/layout/reader_chapters_sheet.xml
index 70f05bf378..c9340fa3be 100644
--- a/app/src/main/res/layout/reader_chapters_sheet.xml
+++ b/app/src/main/res/layout/reader_chapters_sheet.xml
@@ -76,9 +76,26 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@id/webview_button"
app:layout_constraintTop_toTopOf="parent"
- app:layout_constraintEnd_toStartOf="@id/display_options"
+ app:layout_constraintEnd_toStartOf="@id/shift_page_button"
app:srcCompat="@drawable/ic_book_open_variant_24dp" />
+
+
diff --git a/app/src/main/res/values-sw600dp/attrs.xml b/app/src/main/res/values-sw600dp/attrs.xml
new file mode 100644
index 0000000000..d3a0e92c97
--- /dev/null
+++ b/app/src/main/res/values-sw600dp/attrs.xml
@@ -0,0 +1,4 @@
+
+
+ true
+
\ No newline at end of file
diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml
index 05092b3aa0..45365fe024 100644
--- a/app/src/main/res/values/attrs.xml
+++ b/app/src/main/res/values/attrs.xml
@@ -21,4 +21,6 @@
+
+ false