mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-11-04 08:08:55 +01:00 
			
		
		
		
	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:
		
				
					committed by
					
						
						Bram van de Kerkhof
					
				
			
			
				
	
			
			
			
						parent
						
							a65a71df5d
						
					
				
				
					commit
					f88dd28c51
				
			@@ -11,6 +11,8 @@ object PreferenceKeys {
 | 
			
		||||
 | 
			
		||||
    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 fullscreen = "fullscreen"
 | 
			
		||||
 
 | 
			
		||||
@@ -39,6 +39,8 @@ class PreferencesHelper(val context: Context) {
 | 
			
		||||
 | 
			
		||||
    fun pageTransitions() = rxPrefs.getBoolean(Keys.enableTransitions, true)
 | 
			
		||||
 | 
			
		||||
    fun doubleTapAnimSpeed() = rxPrefs.getInteger(Keys.doubleTapAnimationSpeed, 500)
 | 
			
		||||
 | 
			
		||||
    fun showPageNumber() = rxPrefs.getBoolean(Keys.showPageNumber, true)
 | 
			
		||||
 | 
			
		||||
    fun fullscreen() = rxPrefs.getBoolean(Keys.fullscreen, true)
 | 
			
		||||
 
 | 
			
		||||
@@ -62,6 +62,7 @@ class PageView @JvmOverloads constructor(context: Context, attrs: AttributeSet?
 | 
			
		||||
        with(image_view) {
 | 
			
		||||
            setMaxTileSize((reader.activity as ReaderActivity).maxBitmapSize)
 | 
			
		||||
            setDoubleTapZoomStyle(SubsamplingScaleImageView.ZOOM_FOCUS_FIXED)
 | 
			
		||||
            setDoubleTapZoomDuration(reader.doubleTapAnimDuration.toInt())
 | 
			
		||||
            setPanLimit(SubsamplingScaleImageView.PAN_LIMIT_INSIDE)
 | 
			
		||||
            setMinimumScaleType(reader.scaleType)
 | 
			
		||||
            setMinimumDpi(90)
 | 
			
		||||
 
 | 
			
		||||
@@ -85,6 +85,12 @@ abstract class PagerReader : BaseReader() {
 | 
			
		||||
    var cropBorders: Boolean = false
 | 
			
		||||
        private set
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Duration of the double tap animation
 | 
			
		||||
     */
 | 
			
		||||
    var doubleTapAnimDuration = 500
 | 
			
		||||
        private set
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Scale type (fit width, fit screen, etc).
 | 
			
		||||
     */
 | 
			
		||||
@@ -166,6 +172,10 @@ abstract class PagerReader : BaseReader() {
 | 
			
		||||
                    .skip(1)
 | 
			
		||||
                    .distinctUntilChanged()
 | 
			
		||||
                    .subscribe { refreshAdapter() })
 | 
			
		||||
 | 
			
		||||
            add(preferences.doubleTapAnimSpeed()
 | 
			
		||||
                    .asObservable()
 | 
			
		||||
                    .subscribe { doubleTapAnimDuration = it })
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        setPagesOnAdapter()
 | 
			
		||||
 
 | 
			
		||||
@@ -57,6 +57,7 @@ class WebtoonHolder(private val view: View, private val adapter: WebtoonAdapter)
 | 
			
		||||
        with(image_view) {
 | 
			
		||||
            setMaxTileSize(readerActivity.maxBitmapSize)
 | 
			
		||||
            setDoubleTapZoomStyle(SubsamplingScaleImageView.ZOOM_FOCUS_FIXED)
 | 
			
		||||
            setDoubleTapZoomDuration(webtoonReader.doubleTapAnimDuration.toInt())
 | 
			
		||||
            setPanLimit(SubsamplingScaleImageView.PAN_LIMIT_INSIDE)
 | 
			
		||||
            setMinimumScaleType(SubsamplingScaleImageView.SCALE_TYPE_FIT_WIDTH)
 | 
			
		||||
            setMinimumDpi(90)
 | 
			
		||||
 
 | 
			
		||||
@@ -59,6 +59,12 @@ class WebtoonReader : BaseReader() {
 | 
			
		||||
    var cropBorders: Boolean = false
 | 
			
		||||
        private set
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Duration of the double tap animation
 | 
			
		||||
     */
 | 
			
		||||
    var doubleTapAnimDuration = 500
 | 
			
		||||
        private set
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Gesture detector for image touch events.
 | 
			
		||||
     */
 | 
			
		||||
@@ -124,6 +130,10 @@ class WebtoonReader : BaseReader() {
 | 
			
		||||
                .distinctUntilChanged()
 | 
			
		||||
                .subscribe { refreshAdapter() })
 | 
			
		||||
 | 
			
		||||
        subscriptions.add(readerActivity.preferences.doubleTapAnimSpeed()
 | 
			
		||||
                .asObservable()
 | 
			
		||||
                .subscribe { doubleTapAnimDuration = it })
 | 
			
		||||
 | 
			
		||||
        setPagesOnAdapter()
 | 
			
		||||
        return recycler
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -62,6 +62,14 @@ class SettingsReaderController : SettingsController() {
 | 
			
		||||
            defaultValue = "0"
 | 
			
		||||
            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 {
 | 
			
		||||
            key = Keys.fullscreen
 | 
			
		||||
            titleRes = R.string.pref_fullscreen
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user