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
This commit is contained in:
Unlocked 2020-02-23 12:44:50 -05:00 committed by GitHub
parent 275bd44e15
commit ca10356fd9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 33 additions and 1 deletions

View File

@ -47,6 +47,8 @@ object PreferenceKeys {
const val cropBordersWebtoon = "crop_borders_webtoon" const val cropBordersWebtoon = "crop_borders_webtoon"
const val padPagesVertWebtoon = "pad_pages_vert_webtoon"
const val readWithTapping = "reader_tap" const val readWithTapping = "reader_tap"
const val readWithLongTap = "reader_long_tap" const val readWithLongTap = "reader_long_tap"

View File

@ -104,6 +104,8 @@ class PreferencesHelper(val context: Context) {
fun cropBordersWebtoon() = rxPrefs.getBoolean(Keys.cropBordersWebtoon, false) fun cropBordersWebtoon() = rxPrefs.getBoolean(Keys.cropBordersWebtoon, false)
fun padPagesVertWebtoon() = rxPrefs.getBoolean(Keys.padPagesVertWebtoon, false)
fun readWithTapping() = rxPrefs.getBoolean(Keys.readWithTapping, true) fun readWithTapping() = rxPrefs.getBoolean(Keys.readWithTapping, true)
fun readWithLongTap() = rxPrefs.getBoolean(Keys.readWithLongTap, true) fun readWithLongTap() = rxPrefs.getBoolean(Keys.readWithLongTap, true)

View File

@ -79,6 +79,7 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) : BottomSheetDia
scale_type.bindToPreference(preferences.imageScaleType(), 1) scale_type.bindToPreference(preferences.imageScaleType(), 1)
zoom_start.bindToPreference(preferences.zoomStart(), 1) zoom_start.bindToPreference(preferences.zoomStart(), 1)
crop_borders.bindToPreference(preferences.cropBorders()) crop_borders.bindToPreference(preferences.cropBorders())
pad_pages_vert_webtoon.bindToPreference(preferences.padPagesVertWebtoon())
page_transitions.bindToPreference(preferences.pageTransitions()) page_transitions.bindToPreference(preferences.pageTransitions())
} }
@ -88,6 +89,7 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) : BottomSheetDia
private fun initWebtoonPreferences() { private fun initWebtoonPreferences() {
webtoon_prefs_group.visible() webtoon_prefs_group.visible()
crop_borders_webtoon.bindToPreference(preferences.cropBordersWebtoon()) crop_borders_webtoon.bindToPreference(preferences.cropBordersWebtoon())
pad_pages_vert_webtoon.bindToPreference(preferences.padPagesVertWebtoon())
} }
/** /**

View File

@ -31,6 +31,9 @@ class WebtoonConfig(preferences: PreferencesHelper = Injekt.get()) {
var imageCropBorders = false var imageCropBorders = false
private set private set
var padPagesVert = false
private set
var doubleTapAnimDuration = 500 var doubleTapAnimDuration = 500
private set private set
@ -44,6 +47,9 @@ class WebtoonConfig(preferences: PreferencesHelper = Injekt.get()) {
preferences.cropBordersWebtoon() preferences.cropBordersWebtoon()
.register({ imageCropBorders = it }, { imagePropertyChangedListener?.invoke() }) .register({ imageCropBorders = it }, { imagePropertyChangedListener?.invoke() })
preferences.padPagesVertWebtoon()
.register({ padPagesVert = it }, { imagePropertyChangedListener?.invoke() })
preferences.doubleTapAnimSpeed() preferences.doubleTapAnimSpeed()
.register({ doubleTapAnimDuration = it }) .register({ doubleTapAnimDuration = it })

View File

@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.ui.reader.viewer.webtoon
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.content.Intent import android.content.Intent
import android.graphics.Color
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import android.net.Uri import android.net.Uri
import android.view.Gravity 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.ui.reader.viewer.ReaderProgressBar
import eu.kanade.tachiyomi.util.system.ImageUtil import eu.kanade.tachiyomi.util.system.ImageUtil
import eu.kanade.tachiyomi.util.system.dpToPx 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.gone
import eu.kanade.tachiyomi.util.view.visible import eu.kanade.tachiyomi.util.view.visible
import rx.Observable import rx.Observable
@ -112,6 +114,9 @@ class WebtoonPageHolder(
init { init {
frame.layoutParams = FrameLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT) frame.layoutParams = FrameLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT)
if (viewer.config.padPagesVert) {
frame.setPadding(0, 0, 0, 15.dpToPx)
}
} }
/** /**

View File

@ -120,6 +120,11 @@ class SettingsReaderController : SettingsController() {
titleRes = R.string.pref_crop_borders titleRes = R.string.pref_crop_borders
defaultValue = false defaultValue = false
} }
switchPreference {
key = Keys.padPagesVertWebtoon
titleRes = R.string.pref_webtoon_padding_vert
defaultValue = false
}
} }
preferenceCategory { preferenceCategory {
titleRes = R.string.pref_reader_navigation titleRes = R.string.pref_reader_navigation

View File

@ -249,6 +249,15 @@
android:textColor="?android:attr/textColorSecondary" android:textColor="?android:attr/textColorSecondary"
app:layout_constraintTop_toBottomOf="@id/webtoon_prefs" /> app:layout_constraintTop_toBottomOf="@id/webtoon_prefs" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/pad_pages_vert_webtoon"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="@string/pref_webtoon_padding_vert"
android:textColor="?android:attr/textColorSecondary"
app:layout_constraintTop_toBottomOf="@id/crop_borders_webtoon" />
<!-- Groups of preferences --> <!-- Groups of preferences -->
<androidx.constraintlayout.widget.Group <androidx.constraintlayout.widget.Group
@ -264,7 +273,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:visibility="gone" android:visibility="gone"
app:constraint_referenced_ids="webtoon_prefs,crop_borders_webtoon" /> app:constraint_referenced_ids="webtoon_prefs,crop_borders_webtoon,pad_pages_vert_webtoon" />
<androidx.constraintlayout.widget.Guideline <androidx.constraintlayout.widget.Guideline
android:id="@+id/verticalcenter" android:id="@+id/verticalcenter"

View File

@ -207,6 +207,7 @@
<string name="pref_show_page_number">Show page number</string> <string name="pref_show_page_number">Show page number</string>
<string name="pref_true_color">32-bit color</string> <string name="pref_true_color">32-bit color</string>
<string name="pref_crop_borders">Crop borders</string> <string name="pref_crop_borders">Crop borders</string>
<string name="pref_webtoon_padding_vert">Vertical padding between pages</string>
<string name="pref_custom_brightness">Use custom brightness</string> <string name="pref_custom_brightness">Use custom brightness</string>
<string name="pref_custom_color_filter">Use custom color filter</string> <string name="pref_custom_color_filter">Use custom color filter</string>
<string name="pref_color_filter_mode">Color filter blend mode</string> <string name="pref_color_filter_mode">Color filter blend mode</string>