diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt index 7da479343f..14246b57e6 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt @@ -51,6 +51,8 @@ object PreferenceKeys { const val cropBorders = "crop_borders" + const val cropBordersWebtoon = "crop_borders_webtoon" + const val readWithTapping = "reader_tap" const val readWithTappingInverted = "reader_tapping_inverted" diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt index d0ed3ea27c..401951f667 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt @@ -119,6 +119,8 @@ class PreferencesHelper(val context: Context) { fun cropBorders() = flowPrefs.getBoolean(Keys.cropBorders, false) + fun cropBordersWebtoon() = flowPrefs.getBoolean(Keys.cropBordersWebtoon, false) + fun webtoonSidePadding() = flowPrefs.getInt(Keys.webtoonSidePadding, 0) fun readWithTapping() = flowPrefs.getBoolean(Keys.readWithTapping, true) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderSettingsSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderSettingsSheet.kt index 7a3bc31ea7..698660553f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderSettingsSheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderSettingsSheet.kt @@ -71,7 +71,6 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) : BottomSheetDia binding.keepscreen.bindToPreference(preferences.keepScreenOn()) binding.longTap.bindToPreference(preferences.readWithLongTap()) binding.alwaysShowChapterTransition.bindToPreference(preferences.alwaysShowChapterTransition()) - binding.cropBorders.bindToPreference(preferences.cropBorders()) binding.pageTransitions.bindToPreference(preferences.pageTransitions()) // If the preference is explicitly disabled, that means the setting was configured since there is a cutout @@ -90,6 +89,7 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) : BottomSheetDia binding.scaleType.bindToPreference(preferences.imageScaleType(), 1) binding.zoomStart.bindToPreference(preferences.zoomStart(), 1) + binding.cropBorders.bindToPreference(preferences.cropBorders()) } /** @@ -99,6 +99,7 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) : BottomSheetDia binding.pagerPrefsGroup.isInvisible = true binding.webtoonPrefsGroup.isVisible = true + binding.cropBordersWebtoon.bindToPreference(preferences.cropBordersWebtoon()) binding.webtoonSidePadding.bindToIntPreference(preferences.webtoonSidePadding(), R.array.webtoon_side_padding_values) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ViewerConfig.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ViewerConfig.kt index 8726b35ce8..1f076f6e92 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ViewerConfig.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ViewerConfig.kt @@ -27,7 +27,6 @@ abstract class ViewerConfig(preferences: PreferencesHelper) { var volumeKeysEnabled = false var volumeKeysInverted = false var trueColor = false - var imageCropBorders = false var alwaysShowChapterTransition = true init { @@ -55,9 +54,6 @@ abstract class ViewerConfig(preferences: PreferencesHelper) { preferences.trueColor() .register({ trueColor = it }, { imagePropertyChangedListener?.invoke() }) - preferences.cropBorders() - .register({ imageCropBorders = it }, { imagePropertyChangedListener?.invoke() }) - preferences.alwaysShowChapterTransition() .register({ alwaysShowChapterTransition = it }) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerConfig.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerConfig.kt index 7bbd233c9c..e4dee7643c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerConfig.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerConfig.kt @@ -17,12 +17,18 @@ class PagerConfig(private val viewer: PagerViewer, preferences: PreferencesHelpe var imageZoomType = ZoomType.Left private set + var imageCropBorders = false + private set + init { preferences.imageScaleType() .register({ imageScaleType = it }, { imagePropertyChangedListener?.invoke() }) preferences.zoomStart() .register({ zoomTypeFromPreference(it) }, { imagePropertyChangedListener?.invoke() }) + + preferences.cropBorders() + .register({ imageCropBorders = it }, { imagePropertyChangedListener?.invoke() }) } private fun zoomTypeFromPreference(value: Int) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonConfig.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonConfig.kt index 246a926a6f..6f108b892c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonConfig.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonConfig.kt @@ -10,10 +10,16 @@ import uy.kohesive.injekt.api.get */ class WebtoonConfig(preferences: PreferencesHelper = Injekt.get()) : ViewerConfig(preferences) { + var imageCropBorders = false + private set + var sidePadding = 0 private set init { + preferences.cropBordersWebtoon() + .register({ imageCropBorders = it }, { imagePropertyChangedListener?.invoke() }) + preferences.webtoonSidePadding() .register({ sidePadding = it }, { imagePropertyChangedListener?.invoke() }) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsReaderController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsReaderController.kt index 616ed32a8e..e35f49666b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsReaderController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsReaderController.kt @@ -55,11 +55,6 @@ class SettingsReaderController : SettingsController() { defaultValue = false } } - switchPreference { - key = Keys.cropBorders - titleRes = R.string.pref_crop_borders - defaultValue = false - } switchPreference { key = Keys.enableTransitions titleRes = R.string.pref_page_transitions @@ -160,6 +155,11 @@ class SettingsReaderController : SettingsController() { defaultValue = "1" summary = "%s" } + switchPreference { + key = Keys.cropBorders + titleRes = R.string.pref_crop_borders + defaultValue = false + } } preferenceCategory { @@ -179,6 +179,11 @@ class SettingsReaderController : SettingsController() { defaultValue = "0" summary = "%s" } + switchPreference { + key = Keys.cropBordersWebtoon + titleRes = R.string.pref_crop_borders + defaultValue = false + } } preferenceCategory { diff --git a/app/src/main/res/layout/reader_settings_sheet.xml b/app/src/main/res/layout/reader_settings_sheet.xml index e6712e46ff..8e8c056217 100644 --- a/app/src/main/res/layout/reader_settings_sheet.xml +++ b/app/src/main/res/layout/reader_settings_sheet.xml @@ -73,21 +73,13 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/viewer" /> - - + app:layout_constraintTop_toBottomOf="@id/general_prefs" /> @@ -249,11 +241,20 @@ app:layout_constraintStart_toEndOf="@id/verticalcenter" app:layout_constraintTop_toBottomOf="@id/scale_type" /> + + + + + app:constraint_referenced_ids="webtoon_prefs,crop_borders_webtoon,webtoon_side_padding_text,webtoon_side_padding" />