mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-23 20:51:48 +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.hasSideNavBar
|
||||||
import eu.kanade.tachiyomi.util.system.isBottomTappable
|
import eu.kanade.tachiyomi.util.system.isBottomTappable
|
||||||
import eu.kanade.tachiyomi.util.system.isLTR
|
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.launchIO
|
||||||
import eu.kanade.tachiyomi.util.system.launchUI
|
import eu.kanade.tachiyomi.util.system.launchUI
|
||||||
import eu.kanade.tachiyomi.util.system.openInBrowser
|
import eu.kanade.tachiyomi.util.system.openInBrowser
|
||||||
@ -310,12 +311,15 @@ class ReaderActivity :
|
|||||||
|
|
||||||
override fun onPrepareOptionsMenu(menu: Menu?): Boolean {
|
override fun onPrepareOptionsMenu(menu: Menu?): Boolean {
|
||||||
val splitItem = menu?.findItem(R.id.action_shift_double_page)
|
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 ->
|
(viewer as? PagerViewer)?.config?.let { config ->
|
||||||
splitItem?.icon = ContextCompat.getDrawable(
|
val icon = ContextCompat.getDrawable(
|
||||||
this,
|
this,
|
||||||
if ((!config.shiftDoublePage).xor(viewer is R2LPagerViewer)) R.drawable.ic_page_previous_outline_24dp else R.drawable.ic_page_next_outline_24dp
|
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())
|
setBottomNavButtons(preferences.pageLayout().get())
|
||||||
(binding.toolbar.background as? LayerDrawable)?.let { layerDrawable ->
|
(binding.toolbar.background as? LayerDrawable)?.let { layerDrawable ->
|
||||||
@ -353,20 +357,24 @@ class ReaderActivity :
|
|||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
when (item.itemId) {
|
when (item.itemId) {
|
||||||
R.id.action_shift_double_page -> {
|
R.id.action_shift_double_page -> {
|
||||||
(viewer as? PagerViewer)?.config?.let { config ->
|
shiftDoublePages()
|
||||||
config.shiftDoublePage = !config.shiftDoublePage
|
|
||||||
presenter.viewerChapters?.let {
|
|
||||||
(viewer as? PagerViewer)?.updateShifting()
|
|
||||||
(viewer as? PagerViewer)?.setChaptersDoubleShift(it)
|
|
||||||
invalidateOptionsMenu()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else -> return super.onOptionsItemSelected(item)
|
else -> return super.onOptionsItemSelected(item)
|
||||||
}
|
}
|
||||||
return true
|
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() {
|
private fun popToMain() {
|
||||||
presenter.onBackPressed()
|
presenter.onBackPressed()
|
||||||
if (fromUrl) {
|
if (fromUrl) {
|
||||||
@ -483,6 +491,9 @@ class ReaderActivity :
|
|||||||
preferences.pageLayout().set(1 - preferences.pageLayout().get())
|
preferences.pageLayout().set(1 - preferences.pageLayout().get())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
binding.chaptersSheet.shiftPageButton.setOnClickListener {
|
||||||
|
shiftDoublePages()
|
||||||
|
}
|
||||||
binding.readerNav.leftChapter.setOnClickListener {
|
binding.readerNav.leftChapter.setOnClickListener {
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
return@setOnClickListener
|
return@setOnClickListener
|
||||||
|
@ -148,6 +148,8 @@ val Float.dpToPxEnd: Float
|
|||||||
val Resources.isLTR
|
val Resources.isLTR
|
||||||
get() = configuration.layoutDirection == View.LAYOUT_DIRECTION_LTR
|
get() = configuration.layoutDirection == View.LAYOUT_DIRECTION_LTR
|
||||||
|
|
||||||
|
fun Context.isTablet() = resources.getBoolean(R.bool.isTablet)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method to create a notification builder.
|
* Helper method to create a notification builder.
|
||||||
*
|
*
|
||||||
@ -155,7 +157,10 @@ val Resources.isLTR
|
|||||||
* @param block the function that will execute inside the builder.
|
* @param block the function that will execute inside the builder.
|
||||||
* @return a notification to be displayed or updated.
|
* @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)
|
val builder = NotificationCompat.Builder(this, channelId)
|
||||||
.setColor(ContextCompat.getColor(this, R.color.colorAccent))
|
.setColor(ContextCompat.getColor(this, R.color.colorAccent))
|
||||||
if (block != null) {
|
if (block != null) {
|
||||||
@ -197,7 +202,9 @@ val Context.powerManager: PowerManager
|
|||||||
* @param intent intent that contains broadcast information
|
* @param intent intent that contains broadcast information
|
||||||
*/
|
*/
|
||||||
fun Context.sendLocalBroadcast(intent: Intent) {
|
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
|
* @param intent intent that contains broadcast information
|
||||||
*/
|
*/
|
||||||
fun Context.sendLocalBroadcastSync(intent: Intent) {
|
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.
|
* @param receiver receiver that gets registered.
|
||||||
*/
|
*/
|
||||||
fun Context.registerLocalReceiver(receiver: BroadcastReceiver, filter: IntentFilter) {
|
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.
|
* @param receiver receiver that gets unregistered.
|
||||||
*/
|
*/
|
||||||
fun Context.unregisterLocalReceiver(receiver: BroadcastReceiver) {
|
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_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintStart_toEndOf="@id/webview_button"
|
app:layout_constraintStart_toEndOf="@id/webview_button"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
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" />
|
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
|
<ImageButton
|
||||||
android:id="@+id/display_options"
|
android:id="@+id/display_options"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@ -90,7 +107,7 @@
|
|||||||
app:layout_constraintHorizontal_chainStyle="spread"
|
app:layout_constraintHorizontal_chainStyle="spread"
|
||||||
android:tooltipText="@string/display_options"
|
android:tooltipText="@string/display_options"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
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_constraintTop_toTopOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:srcCompat="@drawable/ic_tune_24dp" />
|
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="android:entries"/>
|
||||||
<attr name="summary" format="reference|string" />
|
<attr name="summary" format="reference|string" />
|
||||||
</declare-styleable>
|
</declare-styleable>
|
||||||
|
|
||||||
|
<bool name="isTablet">false</bool>
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user