Crop borders for continous viewer now uses the same pref as paged

also renamed the webtoon continous variable because it confused me
This commit is contained in:
Jay 2020-05-23 01:10:13 -04:00
parent e0f639c801
commit 3eb1cc1f17
6 changed files with 19 additions and 12 deletions

View File

@ -441,7 +441,7 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>(),
RIGHT_TO_LEFT -> R2LPagerViewer(this)
VERTICAL -> VerticalPagerViewer(this)
WEBTOON -> WebtoonViewer(this)
VERTICAL_PLUS -> WebtoonViewer(this, isContinuous = false)
VERTICAL_PLUS -> WebtoonViewer(this, hasMargins = true)
else -> L2RPagerViewer(this)
}

View File

@ -87,9 +87,9 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) :
initGeneralPreferences()
when (activity.viewer) {
when (val view = activity.viewer) {
is PagerViewer -> initPagerPreferences()
is WebtoonViewer -> initWebtoonPreferences()
is WebtoonViewer -> initWebtoonPreferences(view.hasMargins)
}
setBottomEdge(constraint_layout, activity)
@ -115,7 +115,7 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) :
val mangaViewer = activity.presenter.getMangaViewer()
if (mangaViewer == ReaderActivity.WEBTOON || mangaViewer == ReaderActivity.VERTICAL_PLUS) {
initWebtoonPreferences()
initWebtoonPreferences(mangaViewer == ReaderActivity.VERTICAL_PLUS)
} else {
initPagerPreferences()
}
@ -145,10 +145,10 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) :
/**
* Init the preferences for the webtoon reader.
*/
private fun initWebtoonPreferences() {
private fun initWebtoonPreferences(hasMargins: Boolean) {
webtoon_prefs_group.visible()
pager_prefs_group.gone()
crop_borders_webtoon.bindToPreference(preferences.cropBordersWebtoon())
crop_borders_webtoon.bindToPreference(if (hasMargins) preferences.cropBorders() else preferences.cropBordersWebtoon())
webtoon_side_padding.bindToIntPreference(preferences.webtoonSidePadding(), R.array.webtoon_side_padding_values)
webtoon_disable_zoom.bindToPreference(preferences.webtoonDisableZoom())
}
@ -157,6 +157,7 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) :
* Binds a checkbox or switch view with a boolean preference.
*/
private fun CompoundButton.bindToPreference(pref: Preference<Boolean>) {
setOnCheckedChangeListener(null)
isChecked = pref.get()
setOnCheckedChangeListener { _, isChecked -> pref.set(isChecked) }
}

View File

@ -10,7 +10,10 @@ import uy.kohesive.injekt.api.get
*/
class WebtoonConfig(preferences: PreferencesHelper = Injekt.get()) : ViewerConfig(preferences) {
var imageCropBorders = false
var webtoonCropBorders = false
private set
var verticalCropBorders = false
private set
var sidePadding = 0
@ -22,7 +25,10 @@ class WebtoonConfig(preferences: PreferencesHelper = Injekt.get()) : ViewerConfi
init {
preferences.cropBordersWebtoon()
.register({ imageCropBorders = it }, { imagePropertyChangedListener?.invoke() })
.register({ webtoonCropBorders = it }, { imagePropertyChangedListener?.invoke() })
preferences.cropBorders()
.register({ verticalCropBorders = it }, { imagePropertyChangedListener?.invoke() })
preferences.webtoonSidePadding()
.register({ sidePadding = it }, { imagePropertyChangedListener?.invoke() })

View File

@ -127,7 +127,7 @@ class WebtoonPageHolder(
marginEnd = margin.toInt()
marginStart = margin.toInt()
}
if (!viewer.isContinuous) {
if (viewer.hasMargins) {
frame.updatePaddingRelative(bottom = 15.dpToPx)
}
}
@ -359,7 +359,7 @@ class WebtoonPageHolder(
setMinimumScaleType(SubsamplingScaleImageView.SCALE_TYPE_FIT_WIDTH)
setMinimumDpi(90)
setMinimumTileDpi(180)
setCropBorders(config.imageCropBorders)
setCropBorders(if (viewer.hasMargins) config.verticalCropBorders else config.webtoonCropBorders)
setOnImageEventListener(object : SubsamplingScaleImageView.DefaultOnImageEventListener() {
override fun onReady() {
onImageDecoded()

View File

@ -22,7 +22,7 @@ import kotlin.math.min
/**
* Implementation of a [BaseViewer] to display pages with a [RecyclerView].
*/
class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = true) : BaseViewer {
class WebtoonViewer(val activity: ReaderActivity, val hasMargins: Boolean = false) : BaseViewer {
/**
* Recycler view used by this viewer.

View File

@ -280,7 +280,7 @@
android:layout_height="wrap_content"
android:visibility="gone"
app:constraint_referenced_ids="pager_prefs,scale_type,scale_type_text,
zoom_start_text,zoom_start,crop_borders,page_transitions,background_color,background_color_label"
zoom_start_text,zoom_start,crop_borders,page_transitions,background_color,background_color_label,background_color_label,background_color"
tools:visibility="visible" />
<androidx.constraintlayout.widget.Group