diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/View.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/View.kt new file mode 100644 index 000000000..cf1459c54 --- /dev/null +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/View.kt @@ -0,0 +1,13 @@ +package com.simplemobiletools.gallery.extensions + +import android.os.SystemClock +import android.view.MotionEvent +import android.view.View + +fun View.sendFakeClick(x: Float, y: Float) { + val uptime = SystemClock.uptimeMillis() + val event = MotionEvent.obtain(uptime, uptime, MotionEvent.ACTION_DOWN, x, y, 0) + dispatchTouchEvent(event) + event.action = MotionEvent.ACTION_UP + dispatchTouchEvent(event) +} 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 6c7ac8d6a..18a2d23a3 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt @@ -62,12 +62,12 @@ class PhotoFragment : ViewPagerFragment() { instant_prev_item.parentView = container instant_next_item.parentView = container - photo_brightness_controller.initialize(activity!!, slide_info, true, container) { + photo_brightness_controller.initialize(activity!!, slide_info, true, container) { x, y -> view.apply { if (subsampling_view.isVisible()) { - subsampling_view.performClick() + subsampling_view.sendFakeClick(x, y) } else { - gif_view.performClick() + gif_view.sendFakeClick(x, y) } } } 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 dfd152524..6eb5b4c96 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt @@ -85,12 +85,12 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee mView!!.apply { brightnessSideScroll = video_brightness_controller - brightnessSideScroll.initialize(activity!!, slide_info, true, container) { + brightnessSideScroll.initialize(activity!!, slide_info, true, container) { x, y -> video_holder.performClick() } volumeSideScroll = video_volume_controller - volumeSideScroll.initialize(activity!!, slide_info, false, container) { + volumeSideScroll.initialize(activity!!, slide_info, false, container) { x, y -> video_holder.performClick() } } 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 eca4fb337..91c5f0a3c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaSideScroll.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaSideScroll.kt @@ -33,9 +33,9 @@ class MediaSideScroll(context: Context, attrs: AttributeSet) : RelativeLayout(co private lateinit var activity: Activity private lateinit var slideInfoView: TextView - private lateinit var callback: () -> Unit + private lateinit var callback: (Float, Float) -> Unit - fun initialize(activity: Activity, slideInfoView: TextView, isBrightness: Boolean, parentView: ViewGroup?, callback: () -> Unit) { + fun initialize(activity: Activity, slideInfoView: TextView, isBrightness: Boolean, parentView: ViewGroup?, callback: (x: Float, y: Float) -> Unit) { this.activity = activity this.slideInfoView = slideInfoView this.callback = callback @@ -101,7 +101,7 @@ class MediaSideScroll(context: Context, attrs: AttributeSet) : RelativeLayout(co } MotionEvent.ACTION_UP -> { if (System.currentTimeMillis() - mTouchDownTime < CLICK_MAX_DURATION) { - callback() + callback(event.rawX, event.rawY) } if (mIsBrightnessScroll) {