From 1920568057eee522a7e77f523a5ebe322ee43249 Mon Sep 17 00:00:00 2001 From: arkon Date: Fri, 10 Jul 2020 22:19:08 -0400 Subject: [PATCH] Unify crop borders settings --- .../data/preference/PreferenceKeys.kt | 2 - .../data/preference/PreferencesHelper.kt | 2 - .../ui/reader/ReaderSettingsSheet.kt | 4 +- .../ui/reader/viewer/ViewerConfig.kt | 4 ++ .../ui/reader/viewer/pager/PagerConfig.kt | 6 --- .../ui/reader/viewer/webtoon/WebtoonConfig.kt | 6 --- .../ui/setting/SettingsReaderController.kt | 16 +++----- .../main/res/layout/reader_settings_sheet.xml | 39 +++++++------------ 8 files changed, 25 insertions(+), 54 deletions(-) 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 14246b57e..7da479343 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,8 +51,6 @@ 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 61c209f2f..e49752ead 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 @@ -115,8 +115,6 @@ 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 87d50f85e..a31df090d 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 @@ -19,7 +19,6 @@ import eu.kanade.tachiyomi.widget.IgnoreFirstSpinnerListener import kotlinx.android.synthetic.main.reader_settings_sheet.always_show_chapter_transition import kotlinx.android.synthetic.main.reader_settings_sheet.background_color import kotlinx.android.synthetic.main.reader_settings_sheet.crop_borders -import kotlinx.android.synthetic.main.reader_settings_sheet.crop_borders_webtoon import kotlinx.android.synthetic.main.reader_settings_sheet.cutout_short import kotlinx.android.synthetic.main.reader_settings_sheet.fullscreen import kotlinx.android.synthetic.main.reader_settings_sheet.keepscreen @@ -92,6 +91,7 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) : BottomSheetDia keepscreen.bindToPreference(preferences.keepScreenOn()) long_tap.bindToPreference(preferences.readWithLongTap()) always_show_chapter_transition.bindToPreference(preferences.alwaysShowChapterTransition()) + crop_borders.bindToPreference(preferences.cropBorders()) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { true_color.visible() @@ -108,7 +108,6 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) : BottomSheetDia scale_type.bindToPreference(preferences.imageScaleType(), 1) zoom_start.bindToPreference(preferences.zoomStart(), 1) - crop_borders.bindToPreference(preferences.cropBorders()) page_transitions.bindToPreference(preferences.pageTransitions()) } @@ -119,7 +118,6 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) : BottomSheetDia pager_prefs_group.invisible() webtoon_prefs_group.visible() - crop_borders_webtoon.bindToPreference(preferences.cropBordersWebtoon()) webtoon_side_padding.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 78590a1c5..e65aa3724 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 @@ -26,6 +26,7 @@ abstract class ViewerConfig(preferences: PreferencesHelper) { var volumeKeysEnabled = false var volumeKeysInverted = false var trueColor = false + var imageCropBorders = false var alwaysShowChapterTransition = true init { @@ -50,6 +51,9 @@ 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 5912aa990..9f09bc728 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 @@ -20,9 +20,6 @@ class PagerConfig(private val viewer: PagerViewer, preferences: PreferencesHelpe var imageZoomType = ZoomType.Left private set - var imageCropBorders = false - private set - init { preferences.pageTransitions() .register({ usePageTransitions = it }) @@ -32,9 +29,6 @@ class PagerConfig(private val viewer: PagerViewer, preferences: PreferencesHelpe 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 6f108b892..246a926a6 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,16 +10,10 @@ 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 499acd106..2034ecff3 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 @@ -101,6 +101,11 @@ class SettingsReaderController : SettingsController() { defaultValue = false } } + switchPreference { + key = Keys.cropBorders + titleRes = R.string.pref_crop_borders + defaultValue = false + } } preferenceCategory { @@ -154,22 +159,11 @@ class SettingsReaderController : SettingsController() { titleRes = R.string.pref_page_transitions defaultValue = true } - switchPreference { - key = Keys.cropBorders - titleRes = R.string.pref_crop_borders - defaultValue = false - } } preferenceCategory { titleRes = R.string.webtoon_viewer - switchPreference { - key = Keys.cropBordersWebtoon - titleRes = R.string.pref_crop_borders - defaultValue = false - } - intListPreference { key = Keys.webtoonSidePadding titleRes = R.string.pref_webtoon_side_padding diff --git a/app/src/main/res/layout/reader_settings_sheet.xml b/app/src/main/res/layout/reader_settings_sheet.xml index 66a793852..ca623f691 100644 --- a/app/src/main/res/layout/reader_settings_sheet.xml +++ b/app/src/main/res/layout/reader_settings_sheet.xml @@ -171,11 +171,19 @@ android:textColor="?android:attr/textColorSecondary" app:layout_constraintTop_toBottomOf="@id/true_color" /> + + + app:layout_constraintBottom_toBottomOf="@id/crop_borders" /> @@ -228,22 +236,14 @@ app:layout_constraintStart_toEndOf="@id/verticalcenter" app:layout_constraintTop_toBottomOf="@id/scale_type" /> - - + app:layout_constraintTop_toBottomOf="@id/zoom_start" /> - - + app:layout_constraintTop_toBottomOf="@id/webtoon_prefs" /> @@ -337,7 +328,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:visibility="gone" - app:constraint_referenced_ids="pager_prefs,scale_type_text,scale_type,zoom_start_text,zoom_start,crop_borders,page_transitions" + app:constraint_referenced_ids="pager_prefs,scale_type_text,scale_type,zoom_start_text,zoom_start,page_transitions" tools:visibility="visible" /> + app:constraint_referenced_ids="webtoon_prefs,webtoon_side_padding_text,webtoon_side_padding" />