From c857c17f50ce65c58a25cb0fec93d00265c19ca4 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 6 Aug 2017 22:35:19 +0200 Subject: [PATCH] improve the volume slider ux --- .../gallery/fragments/PhotoFragment.kt | 2 +- .../gallery/fragments/VideoFragment.kt | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt index 1667d68c3..3d634a516 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt @@ -273,7 +273,7 @@ class PhotoFragment : ViewPagerFragment() { } } - override fun onConfigurationChanged(newConfig: Configuration?) { + override fun onConfigurationChanged(newConfig: Configuration) { super.onConfigurationChanged(newConfig) loadImage() } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt index dee60aa8e..5914da11f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt @@ -51,6 +51,7 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee private var mTouchDownY = 0f private var mTouchDownTime = 0L private var mTouchDownVolume = 0 + private var mLastTouchY = 0f private var mSlideInfoText = "" private var mSlideInfoFadeHandler = Handler() @@ -118,7 +119,7 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee } } - override fun onConfigurationChanged(newConfig: Configuration?) { + override fun onConfigurationChanged(newConfig: Configuration) { super.onConfigurationChanged(newConfig) setVideoSize() initTimeHolder() @@ -133,6 +134,7 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee MotionEvent.ACTION_DOWN -> { mTouchDownX = event.x mTouchDownY = event.y + mLastTouchY = event.y mTouchDownTime = System.currentTimeMillis() mTouchDownVolume = getCurrentVolume() mSlideInfoText = "${getString(R.string.volume)}:\n" @@ -144,8 +146,15 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee if (Math.abs(diffY) > Math.abs(diffX)) { var percent = ((diffY / ViewPagerActivity.screenHeight) * 100).toInt() * 3 percent = Math.min(100, Math.max(-100, percent)) + + if ((percent == 100 && event.y > mLastTouchY) || (percent == -100 && event.y < mLastTouchY)) { + mTouchDownY = event.y + mTouchDownVolume = getCurrentVolume() + } + volumePercentChanged(percent) } + mLastTouchY = event.y } MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> { if (System.currentTimeMillis() - mTouchDownTime < CLICK_MAX_DURATION) {