mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-23 17:11:54 +01:00
Shift double pages button moved to bottom of the screen for tablets
Since that's quite a reach in the toolbar
This commit is contained in:
parent
fe6527a449
commit
e0315dda41
@ -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
|
||||
|
@ -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
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/shift_page_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?selectableItemBackgroundBorderless"
|
||||
android:contentDescription="@string/next_title"
|
||||
android:padding="@dimen/material_layout_keylines_screen_edge_margin"
|
||||
app:tint="?actionBarTintColor"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintHorizontal_chainStyle="spread"
|
||||
android:tooltipText="@string/shift_one_page_over"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/double_page"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/display_options"
|
||||
app:srcCompat="@drawable/ic_page_next_outline_24dp" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/display_options"
|
||||
android:layout_width="wrap_content"
|
||||
@ -90,7 +107,7 @@
|
||||
app:layout_constraintHorizontal_chainStyle="spread"
|
||||
android:tooltipText="@string/display_options"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/double_page"
|
||||
app:layout_constraintStart_toEndOf="@id/shift_page_button"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:srcCompat="@drawable/ic_tune_24dp" />
|
||||
|
4
app/src/main/res/values-sw600dp/attrs.xml
Normal file
4
app/src/main/res/values-sw600dp/attrs.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<bool name="isTablet">true</bool>
|
||||
</resources>
|
@ -21,4 +21,6 @@
|
||||
<attr name="android:entries"/>
|
||||
<attr name="summary" format="reference|string" />
|
||||
</declare-styleable>
|
||||
|
||||
<bool name="isTablet">false</bool>
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user