Add option to change double tap animation speed in the reader (#974)

* Add option to change double tap animation speed in the reader

* address requests from review
This commit is contained in:
Joel Shapiro 2018-01-26 13:22:31 -06:00 committed by Bram van de Kerkhof
parent a65a71df5d
commit f88dd28c51
8 changed files with 38 additions and 0 deletions

View File

@ -11,6 +11,8 @@ object PreferenceKeys {
const val enableTransitions = "pref_enable_transitions_key" const val enableTransitions = "pref_enable_transitions_key"
const val doubleTapAnimationSpeed = "pref_double_tap_anim_speed"
const val showPageNumber = "pref_show_page_number_key" const val showPageNumber = "pref_show_page_number_key"
const val fullscreen = "fullscreen" const val fullscreen = "fullscreen"

View File

@ -39,6 +39,8 @@ class PreferencesHelper(val context: Context) {
fun pageTransitions() = rxPrefs.getBoolean(Keys.enableTransitions, true) fun pageTransitions() = rxPrefs.getBoolean(Keys.enableTransitions, true)
fun doubleTapAnimSpeed() = rxPrefs.getInteger(Keys.doubleTapAnimationSpeed, 500)
fun showPageNumber() = rxPrefs.getBoolean(Keys.showPageNumber, true) fun showPageNumber() = rxPrefs.getBoolean(Keys.showPageNumber, true)
fun fullscreen() = rxPrefs.getBoolean(Keys.fullscreen, true) fun fullscreen() = rxPrefs.getBoolean(Keys.fullscreen, true)

View File

@ -62,6 +62,7 @@ class PageView @JvmOverloads constructor(context: Context, attrs: AttributeSet?
with(image_view) { with(image_view) {
setMaxTileSize((reader.activity as ReaderActivity).maxBitmapSize) setMaxTileSize((reader.activity as ReaderActivity).maxBitmapSize)
setDoubleTapZoomStyle(SubsamplingScaleImageView.ZOOM_FOCUS_FIXED) setDoubleTapZoomStyle(SubsamplingScaleImageView.ZOOM_FOCUS_FIXED)
setDoubleTapZoomDuration(reader.doubleTapAnimDuration.toInt())
setPanLimit(SubsamplingScaleImageView.PAN_LIMIT_INSIDE) setPanLimit(SubsamplingScaleImageView.PAN_LIMIT_INSIDE)
setMinimumScaleType(reader.scaleType) setMinimumScaleType(reader.scaleType)
setMinimumDpi(90) setMinimumDpi(90)

View File

@ -85,6 +85,12 @@ abstract class PagerReader : BaseReader() {
var cropBorders: Boolean = false var cropBorders: Boolean = false
private set private set
/**
* Duration of the double tap animation
*/
var doubleTapAnimDuration = 500
private set
/** /**
* Scale type (fit width, fit screen, etc). * Scale type (fit width, fit screen, etc).
*/ */
@ -166,6 +172,10 @@ abstract class PagerReader : BaseReader() {
.skip(1) .skip(1)
.distinctUntilChanged() .distinctUntilChanged()
.subscribe { refreshAdapter() }) .subscribe { refreshAdapter() })
add(preferences.doubleTapAnimSpeed()
.asObservable()
.subscribe { doubleTapAnimDuration = it })
} }
setPagesOnAdapter() setPagesOnAdapter()

View File

@ -57,6 +57,7 @@ class WebtoonHolder(private val view: View, private val adapter: WebtoonAdapter)
with(image_view) { with(image_view) {
setMaxTileSize(readerActivity.maxBitmapSize) setMaxTileSize(readerActivity.maxBitmapSize)
setDoubleTapZoomStyle(SubsamplingScaleImageView.ZOOM_FOCUS_FIXED) setDoubleTapZoomStyle(SubsamplingScaleImageView.ZOOM_FOCUS_FIXED)
setDoubleTapZoomDuration(webtoonReader.doubleTapAnimDuration.toInt())
setPanLimit(SubsamplingScaleImageView.PAN_LIMIT_INSIDE) setPanLimit(SubsamplingScaleImageView.PAN_LIMIT_INSIDE)
setMinimumScaleType(SubsamplingScaleImageView.SCALE_TYPE_FIT_WIDTH) setMinimumScaleType(SubsamplingScaleImageView.SCALE_TYPE_FIT_WIDTH)
setMinimumDpi(90) setMinimumDpi(90)

View File

@ -59,6 +59,12 @@ class WebtoonReader : BaseReader() {
var cropBorders: Boolean = false var cropBorders: Boolean = false
private set private set
/**
* Duration of the double tap animation
*/
var doubleTapAnimDuration = 500
private set
/** /**
* Gesture detector for image touch events. * Gesture detector for image touch events.
*/ */
@ -124,6 +130,10 @@ class WebtoonReader : BaseReader() {
.distinctUntilChanged() .distinctUntilChanged()
.subscribe { refreshAdapter() }) .subscribe { refreshAdapter() })
subscriptions.add(readerActivity.preferences.doubleTapAnimSpeed()
.asObservable()
.subscribe { doubleTapAnimDuration = it })
setPagesOnAdapter() setPagesOnAdapter()
return recycler return recycler
} }

View File

@ -62,6 +62,14 @@ class SettingsReaderController : SettingsController() {
defaultValue = "0" defaultValue = "0"
summary = "%s" summary = "%s"
} }
intListPreference {
key = Keys.doubleTapAnimationSpeed
titleRes = R.string.pref_double_tap_anim_speed
entries = arrayOf(context.getString(R.string.double_tap_anim_speed_0), context.getString(R.string.double_tap_anim_speed_fast), context.getString(R.string.double_tap_anim_speed_normal))
entryValues = arrayOf("1", "250", "500") // using a value of 0 breaks the image viewer, so min is 1
defaultValue = "500"
summary = "%s"
}
switchPreference { switchPreference {
key = Keys.fullscreen key = Keys.fullscreen
titleRes = R.string.pref_fullscreen titleRes = R.string.pref_fullscreen

View File

@ -148,6 +148,7 @@
<string name="pref_fullscreen">Fullscreen</string> <string name="pref_fullscreen">Fullscreen</string>
<string name="pref_lock_orientation">Lock orientation</string> <string name="pref_lock_orientation">Lock orientation</string>
<string name="pref_page_transitions">Page transitions</string> <string name="pref_page_transitions">Page transitions</string>
<string name="pref_double_tap_anim_speed">Double tap animation speed</string>
<string name="pref_show_page_number">Show page number</string> <string name="pref_show_page_number">Show page number</string>
<string name="pref_crop_borders">Crop borders</string> <string name="pref_crop_borders">Crop borders</string>
<string name="pref_custom_brightness">Use custom brightness</string> <string name="pref_custom_brightness">Use custom brightness</string>
@ -179,6 +180,9 @@
<string name="zoom_start_left">Left</string> <string name="zoom_start_left">Left</string>
<string name="zoom_start_right">Right</string> <string name="zoom_start_right">Right</string>
<string name="zoom_start_center">Center</string> <string name="zoom_start_center">Center</string>
<string name="double_tap_anim_speed_0">No animation</string>
<string name="double_tap_anim_speed_normal">Normal</string>
<string name="double_tap_anim_speed_fast">Fast</string>
<string name="pref_rotation_type">Rotation</string> <string name="pref_rotation_type">Rotation</string>
<string name="rotation_free">Free</string> <string name="rotation_free">Free</string>
<string name="rotation_lock">Lock</string> <string name="rotation_lock">Lock</string>