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 63d795c2e..2d881aac5 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt @@ -50,7 +50,7 @@ class PhotoFragment : ViewPagerFragment() { private var storedHideExtendedDetails = false private var storedExtendedDetails = 0 - private lateinit var mediaSideScroll: MediaSideScroll + private lateinit var brightnessSideScroll: MediaSideScroll lateinit var view: ViewGroup lateinit var medium: Medium @@ -66,7 +66,7 @@ class PhotoFragment : ViewPagerFragment() { instant_next_item.parentView = container photo_brightness_controller.setOnTouchListener { v, event -> - mediaSideScroll.handleBrightnessTouched(event) + brightnessSideScroll.handleBrightnessTouched(event) true } } @@ -118,7 +118,8 @@ class PhotoFragment : ViewPagerFragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - mediaSideScroll = MediaSideScroll(activity!!, view.slide_info) { + brightnessSideScroll = view.photo_brightness_controller + brightnessSideScroll.initialize(activity!!, view.slide_info) { view.apply { if (subsampling_view.isVisible()) { subsampling_view.performClick() 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 01cea5817..3af74be26 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt @@ -54,7 +54,8 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee private var mStoredHideExtendedDetails = false private var mStoredExtendedDetails = 0 - private lateinit var mediaSideScroll: MediaSideScroll + private lateinit var brightnessSideScroll: MediaSideScroll + private lateinit var volumeSideScroll: MediaSideScroll lateinit var medium: Medium @@ -87,7 +88,13 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - mediaSideScroll = MediaSideScroll(activity!!, view.slide_info) { + brightnessSideScroll = view.video_brightness_controller + brightnessSideScroll.initialize(activity!!, view.slide_info) { + view.video_holder.performClick() + } + + volumeSideScroll = view.video_volume_controller + volumeSideScroll.initialize(activity!!, view.slide_info) { view.video_holder.performClick() } } @@ -145,12 +152,12 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee mView!!.video_holder.setOnClickListener { toggleFullscreen() } mView!!.video_volume_controller.setOnTouchListener { v, event -> - mediaSideScroll.handleVolumeTouched(event) + volumeSideScroll.handleVolumeTouched(event) true } mView!!.video_brightness_controller.setOnTouchListener { v, event -> - mediaSideScroll.handleBrightnessTouched(event) + volumeSideScroll.handleBrightnessTouched(event) true } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaSideScroll.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaSideScroll.kt index 7af072a4b..f6f964461 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaSideScroll.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaSideScroll.kt @@ -1,16 +1,19 @@ package com.simplemobiletools.gallery.helpers import android.app.Activity +import android.content.Context import android.media.AudioManager import android.os.Handler import android.provider.Settings +import android.util.AttributeSet import android.view.MotionEvent +import android.widget.RelativeLayout import android.widget.TextView import com.simplemobiletools.gallery.R import com.simplemobiletools.gallery.activities.ViewPagerActivity import com.simplemobiletools.gallery.extensions.audioManager -class MediaSideScroll(val activity: Activity, val slideInfoView: TextView, val callback: () -> Unit) { +class MediaSideScroll(context: Context, attrs: AttributeSet) : RelativeLayout(context, attrs) { private val SLIDE_INFO_FADE_DELAY = 1000L private var mTouchDownX = 0f private var mTouchDownY = 0f @@ -23,6 +26,16 @@ class MediaSideScroll(val activity: Activity, val slideInfoView: TextView, val c private var mSlideInfoText = "" private var mSlideInfoFadeHandler = Handler() + private lateinit var activity: Activity + private lateinit var slideInfoView: TextView + private lateinit var callback: () -> Unit + + fun initialize(activity: Activity, slideInfoView: TextView, callback: () -> Unit) { + this.activity = activity + this.slideInfoView = slideInfoView + this.callback = callback + } + fun handleVolumeTouched(event: MotionEvent) { when (event.action) { MotionEvent.ACTION_DOWN -> { diff --git a/app/src/main/res/layout/pager_photo_item.xml b/app/src/main/res/layout/pager_photo_item.xml index 095783b21..bf3b9eb2d 100644 --- a/app/src/main/res/layout/pager_photo_item.xml +++ b/app/src/main/res/layout/pager_photo_item.xml @@ -31,7 +31,7 @@ android:visibility="gone" tools:text="My image\nAnother line"/> - - -