Disable reading mode for webtoons in settings

Comes with a popup to say change manga type if anything
This commit is contained in:
Jays2Kings 2021-04-14 20:50:28 -04:00
parent eabf5e2a8b
commit 3cd5043e67
4 changed files with 22 additions and 0 deletions

View File

@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.ui.reader.settings
import android.content.Context
import android.util.AttributeSet
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.databinding.ReaderGeneralLayoutBinding
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
import eu.kanade.tachiyomi.util.bindToPreference
@ -32,6 +33,12 @@ class ReaderGeneralView @JvmOverloads constructor(context: Context, attrs: Attri
binding.alwaysShowChapterTransition.bindToPreference(preferences.alwaysShowChapterTransition())
}
fun checkIfShouldDisableReadingMode() {
if (activity.presenter.manga?.isLongStrip() == true) {
binding.viewerSeries.setDisabledState(R.string.webtoon_cannot_change)
}
}
/**
* Init the preferences for the webtoon reader.
*/

View File

@ -60,6 +60,7 @@ class TabbedReaderSettingsSheet(val readerActivity: ReaderActivity) :
generalView.activity = readerActivity
pagedView.activity = readerActivity
filterView.activity = readerActivity
generalView.checkIfShouldDisableReadingMode()
filterView.window = window
generalView.sheet = this

View File

@ -9,6 +9,7 @@ import android.view.LayoutInflater
import android.view.MenuItem
import android.widget.FrameLayout
import androidx.annotation.ArrayRes
import androidx.annotation.StringRes
import androidx.appcompat.view.menu.MenuBuilder
import androidx.appcompat.widget.PopupMenu
import androidx.core.content.ContextCompat
@ -19,6 +20,7 @@ import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.databinding.MaterialSpinnerViewBinding
import eu.kanade.tachiyomi.util.lang.tintText
import eu.kanade.tachiyomi.util.system.getResourceColor
import eu.kanade.tachiyomi.util.system.toast
import kotlin.math.max
class MaterialSpinnerView @JvmOverloads constructor(context: Context, attrs: AttributeSet?) :
@ -86,6 +88,17 @@ class MaterialSpinnerView @JvmOverloads constructor(context: Context, attrs: Att
binding.detailView.text = entries.getOrNull(selection).orEmpty()
}
fun setDisabledState(@StringRes messageRes: Int = 0) {
alpha = 0.5f
popup = null
setOnTouchListener(null)
setOnClickListener {
if (messageRes != 0) {
context.toast(messageRes)
}
}
}
fun bindToPreference(pref: Preference<Int>, offset: Int = 0, block: ((Int) -> Unit)? = null) {
setSelection(pref.get() - offset)
this.pref = pref

View File

@ -406,6 +406,7 @@
<string name="page_layout">Page layout</string>
<string name="automatic_can_still_switch">While using automatic page layout, you can still switch between layouts while reading without overriding this setting</string>
<string name="automatic_orientation">Automatic (based on orientation)</string>
<string name="webtoon_cannot_change">Cannot change reading mode from webtoon. Edit the series type first to change.</string>
<plurals name="pages_plural">
<item quantity="one">%1$d page</item>
<item quantity="other">%1$d pages</item>