From ca10356fd9a51a90c2d9fe0edb9a590dd8c9ad75 Mon Sep 17 00:00:00 2001 From: Unlocked <10186337+TheUnlocked@users.noreply.github.com> Date: Sun, 23 Feb 2020 12:44:50 -0500 Subject: [PATCH] Added Webtoon with Padding viewer (#2618) * Added Webtoon with Padding viewer * Change webtoon padding to be a config option * Removed obselete padded_webtoon * Switch ambiguous padding to vertical padding --- .../tachiyomi/data/preference/PreferenceKeys.kt | 2 ++ .../tachiyomi/data/preference/PreferencesHelper.kt | 2 ++ .../kanade/tachiyomi/ui/reader/ReaderSettingsSheet.kt | 2 ++ .../ui/reader/viewer/webtoon/WebtoonConfig.kt | 6 ++++++ .../ui/reader/viewer/webtoon/WebtoonPageHolder.kt | 5 +++++ .../tachiyomi/ui/setting/SettingsReaderController.kt | 5 +++++ app/src/main/res/layout/reader_settings_sheet.xml | 11 ++++++++++- app/src/main/res/values/strings.xml | 1 + 8 files changed, 33 insertions(+), 1 deletion(-) 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 48b5be4065..722380f0db 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 @@ -47,6 +47,8 @@ object PreferenceKeys { const val cropBordersWebtoon = "crop_borders_webtoon" + const val padPagesVertWebtoon = "pad_pages_vert_webtoon" + const val readWithTapping = "reader_tap" const val readWithLongTap = "reader_long_tap" 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 6dd69a2c86..eb700ba8bf 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 @@ -104,6 +104,8 @@ class PreferencesHelper(val context: Context) { fun cropBordersWebtoon() = rxPrefs.getBoolean(Keys.cropBordersWebtoon, false) + fun padPagesVertWebtoon() = rxPrefs.getBoolean(Keys.padPagesVertWebtoon, false) + fun readWithTapping() = rxPrefs.getBoolean(Keys.readWithTapping, true) fun readWithLongTap() = rxPrefs.getBoolean(Keys.readWithLongTap, 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 d66982af32..84760567fa 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 @@ -79,6 +79,7 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) : BottomSheetDia scale_type.bindToPreference(preferences.imageScaleType(), 1) zoom_start.bindToPreference(preferences.zoomStart(), 1) crop_borders.bindToPreference(preferences.cropBorders()) + pad_pages_vert_webtoon.bindToPreference(preferences.padPagesVertWebtoon()) page_transitions.bindToPreference(preferences.pageTransitions()) } @@ -88,6 +89,7 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) : BottomSheetDia private fun initWebtoonPreferences() { webtoon_prefs_group.visible() crop_borders_webtoon.bindToPreference(preferences.cropBordersWebtoon()) + pad_pages_vert_webtoon.bindToPreference(preferences.padPagesVertWebtoon()) } /** 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 2b18561cf7..0007edc799 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 @@ -31,6 +31,9 @@ class WebtoonConfig(preferences: PreferencesHelper = Injekt.get()) { var imageCropBorders = false private set + var padPagesVert = false + private set + var doubleTapAnimDuration = 500 private set @@ -44,6 +47,9 @@ class WebtoonConfig(preferences: PreferencesHelper = Injekt.get()) { preferences.cropBordersWebtoon() .register({ imageCropBorders = it }, { imagePropertyChangedListener?.invoke() }) + preferences.padPagesVertWebtoon() + .register({ padPagesVert = it }, { imagePropertyChangedListener?.invoke() }) + preferences.doubleTapAnimSpeed() .register({ doubleTapAnimDuration = it }) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonPageHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonPageHolder.kt index 0897ee9014..1414ccf460 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonPageHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonPageHolder.kt @@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.ui.reader.viewer.webtoon import android.annotation.SuppressLint import android.content.Intent +import android.graphics.Color import android.graphics.drawable.Drawable import android.net.Uri import android.view.Gravity @@ -31,6 +32,7 @@ import eu.kanade.tachiyomi.ui.reader.model.ReaderPage import eu.kanade.tachiyomi.ui.reader.viewer.ReaderProgressBar import eu.kanade.tachiyomi.util.system.ImageUtil import eu.kanade.tachiyomi.util.system.dpToPx +import eu.kanade.tachiyomi.util.system.pxToDp import eu.kanade.tachiyomi.util.view.gone import eu.kanade.tachiyomi.util.view.visible import rx.Observable @@ -112,6 +114,9 @@ class WebtoonPageHolder( init { frame.layoutParams = FrameLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT) + if (viewer.config.padPagesVert) { + frame.setPadding(0, 0, 0, 15.dpToPx) + } } /** 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 fc6c234c4e..2cc38d672b 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 @@ -120,6 +120,11 @@ class SettingsReaderController : SettingsController() { titleRes = R.string.pref_crop_borders defaultValue = false } + switchPreference { + key = Keys.padPagesVertWebtoon + titleRes = R.string.pref_webtoon_padding_vert + defaultValue = false + } } preferenceCategory { titleRes = R.string.pref_reader_navigation diff --git a/app/src/main/res/layout/reader_settings_sheet.xml b/app/src/main/res/layout/reader_settings_sheet.xml index cf6e8fb9cc..26fe95b317 100644 --- a/app/src/main/res/layout/reader_settings_sheet.xml +++ b/app/src/main/res/layout/reader_settings_sheet.xml @@ -249,6 +249,15 @@ android:textColor="?android:attr/textColorSecondary" app:layout_constraintTop_toBottomOf="@id/webtoon_prefs" /> + + + app:constraint_referenced_ids="webtoon_prefs,crop_borders_webtoon,pad_pages_vert_webtoon" /> Show page number 32-bit color Crop borders + Vertical padding between pages Use custom brightness Use custom color filter Color filter blend mode