Split transition animation setting for webtoon and pager (#230)

* Split transition animation setting for webtoon and pager

* Move variables

* Rename config variables back
This commit is contained in:
scb261 2021-02-26 21:51:51 +02:00 committed by GitHub
parent f78836dac4
commit a4c10394b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 53 additions and 35 deletions

View File

@ -17,7 +17,9 @@ object PreferenceKeys {
const val rotation = "pref_rotation_type_key"
const val enableTransitions = "pref_enable_transitions_key"
const val enableTransitionsPager = "pref_enable_transitions_pager_key"
const val enableTransitionsWebtoon = "pref_enable_transitions_webtoon_key"
const val doubleTapAnimationSpeed = "pref_double_tap_anim_speed"

View File

@ -83,7 +83,9 @@ class PreferencesHelper(val context: Context) {
fun rotation() = flowPrefs.getInt(Keys.rotation, 1)
fun pageTransitions() = flowPrefs.getBoolean(Keys.enableTransitions, true)
fun pageTransitionsPager() = flowPrefs.getBoolean(Keys.enableTransitionsPager, true)
fun pageTransitionsWebtoon() = flowPrefs.getBoolean(Keys.enableTransitionsWebtoon, true)
fun doubleTapAnimSpeed() = flowPrefs.getInt(Keys.doubleTapAnimationSpeed, 500)

View File

@ -72,7 +72,6 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) : BaseBottomShee
binding.keepscreen.bindToPreference(preferences.keepScreenOn())
binding.longTap.bindToPreference(preferences.readWithLongTap())
binding.alwaysShowChapterTransition.bindToPreference(preferences.alwaysShowChapterTransition())
binding.pageTransitions.bindToPreference(preferences.pageTransitions())
// SY -->
binding.autoWebtoonMode.bindToPreference(preferences.useAutoWebtoon())
// SY <--
@ -105,6 +104,10 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) : BaseBottomShee
binding.pagerPrefsGroup.scaleType.bindToPreference(preferences.imageScaleType(), 1)
binding.pagerPrefsGroup.zoomStart.bindToPreference(preferences.zoomStart(), 1)
binding.pagerPrefsGroup.cropBorders.bindToPreference(preferences.cropBorders())
// SY -->
binding.pagerPrefsGroup.pageTransitionsPager.bindToPreference(preferences.pageTransitionsPager())
// SY <--
}
/**
@ -125,6 +128,7 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) : BaseBottomShee
// SY -->
binding.webtoonPrefsGroup.zoomOutWebtoon.bindToPreference(preferences.webtoonEnableZoomOut())
binding.webtoonPrefsGroup.cropBordersContinuesVertical.bindToPreference(preferences.cropBordersContinuesVertical())
binding.webtoonPrefsGroup.pageTransitionsWebtoon.bindToPreference(preferences.pageTransitionsWebtoon())
// SY <--
}

View File

@ -18,7 +18,6 @@ abstract class ViewerConfig(preferences: PreferencesHelper, private val scope: C
var tappingEnabled = true
var tappingInverted = TappingInvertMode.NONE
var longTapEnabled = true
var usePageTransitions = false
var doubleTapAnimDuration = 500
var volumeKeysEnabled = false
var volumeKeysInverted = false
@ -39,9 +38,6 @@ abstract class ViewerConfig(preferences: PreferencesHelper, private val scope: C
preferences.readWithLongTap()
.register({ longTapEnabled = it })
preferences.pageTransitions()
.register({ usePageTransitions = it })
preferences.doubleTapAnimSpeed()
.register({ doubleTapAnimDuration = it })

View File

@ -29,6 +29,10 @@ class PagerConfig(
var imageCropBorders = false
private set
// SY -->
var usePageTransitions = false
// SY <--
init {
preferences.imageScaleType()
.register({ imageScaleType = it }, { imagePropertyChangedListener?.invoke() })
@ -44,6 +48,11 @@ class PagerConfig(
preferences.pagerNavInverted()
.register({ tappingInverted = it }, { navigator.invertMode = it })
// SY -->
preferences.pageTransitionsPager()
.register({ usePageTransitions = it }, { imagePropertyChangedListener?.invoke() })
// SY <--
}
private fun zoomTypeFromPreference(value: Int) {

View File

@ -26,6 +26,8 @@ class WebtoonConfig(
private set
// SY -->
var usePageTransitions = false
var enableZoomOut = false
private set
@ -54,6 +56,9 @@ class WebtoonConfig(
preferences.cropBordersContinuesVertical()
.register({ continuesCropBorders = it }, { imagePropertyChangedListener?.invoke() })
preferences.pageTransitionsWebtoon()
.register({ usePageTransitions = it }, { imagePropertyChangedListener?.invoke() })
// SY <--
}

View File

@ -70,11 +70,6 @@ class SettingsReaderController : SettingsController() {
defaultValue = false
}
}
switchPreference {
key = Keys.enableTransitions
titleRes = R.string.pref_page_transitions
defaultValue = true
}
preferenceCategory {
titleRes = R.string.pref_category_display
@ -319,6 +314,11 @@ class SettingsReaderController : SettingsController() {
titleRes = R.string.pref_crop_borders
defaultValue = false
}
switchPreference {
key = Keys.enableTransitionsPager
titleRes = R.string.pref_page_transitions
defaultValue = true
}
}
preferenceCategory {
@ -374,6 +374,11 @@ class SettingsReaderController : SettingsController() {
titleRes = R.string.pref_crop_borders
defaultValue = false
}
switchPreference {
key = Keys.enableTransitionsWebtoon
titleRes = R.string.pref_page_transitions
defaultValue = true
}
switchPreference {
key = Keys.webtoonEnableZoomOut
titleRes = R.string.enable_zoom_out

View File

@ -82,6 +82,14 @@
android:textColor="?android:attr/textColorSecondary"
app:layout_constraintTop_toBottomOf="@id/zoom_start" />
<com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/page_transitions_pager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/pref_page_transitions"
android:textColor="?android:attr/textColorSecondary"
app:layout_constraintTop_toBottomOf="@+id/crop_borders" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/verticalcenter"
android:layout_width="wrap_content"

View File

@ -61,27 +61,6 @@
app:layout_constraintStart_toEndOf="@id/verticalcenter"
app:layout_constraintTop_toBottomOf="@id/series_prefs" />
<!-- General display preferences -->
<TextView
android:id="@+id/general_prefs"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:text="@string/pref_category_general"
android:textColor="?attr/colorAccent"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/viewer" />
<com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/page_transitions"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/pref_page_transitions"
android:textColor="?android:attr/textColorSecondary"
app:layout_constraintTop_toBottomOf="@id/general_prefs" />
<!-- General reading mode preferences -->
<TextView
@ -93,7 +72,7 @@
android:textColor="?attr/colorAccent"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/page_transitions" />
app:layout_constraintTop_toBottomOf="@+id/viewer" />
<TextView
android:id="@+id/rotation_mode_text"

View File

@ -64,13 +64,21 @@
android:textColor="?android:attr/textColorSecondary"
app:layout_constraintTop_toBottomOf="@+id/webtoon_side_padding" />
<com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/page_transitions_webtoon"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/pref_page_transitions"
android:textColor="?android:attr/textColorSecondary"
app:layout_constraintTop_toBottomOf="@+id/crop_borders_webtoon" />
<com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/zoom_out_webtoon"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/enable_zoom_out"
android:textColor="?android:attr/textColorSecondary"
app:layout_constraintTop_toBottomOf="@+id/crop_borders_webtoon" />
app:layout_constraintTop_toBottomOf="@+id/page_transitions_webtoon" />
<TextView
android:id="@+id/tapping_inverted_text"