adding a double tap listener at the volume/brightness controllers

This commit is contained in:
tibbi 2020-02-18 15:56:16 +01:00
parent c7bc916784
commit 0d7aa81442
4 changed files with 24 additions and 14 deletions

View file

@ -196,13 +196,13 @@ open class VideoPlayerActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListen
video_surface.surfaceTextureListener = this
if (config.allowVideoGestures) {
video_brightness_controller.initialize(this, slide_info, true, video_player_holder) { x, y ->
video_brightness_controller.initialize(this, slide_info, true, video_player_holder, singleTap = { x, y ->
toggleFullscreen()
}
})
video_volume_controller.initialize(this, slide_info, false, video_player_holder) { x, y ->
video_volume_controller.initialize(this, slide_info, false, video_player_holder, singleTap = { x, y ->
toggleFullscreen()
}
})
} else {
video_brightness_controller.beGone()
video_volume_controller.beGone()

View file

@ -111,7 +111,7 @@ class PhotoFragment : ViewPagerFragment() {
instant_prev_item.parentView = container
instant_next_item.parentView = container
photo_brightness_controller.initialize(activity!!, slide_info, true, container) { x, y ->
photo_brightness_controller.initialize(activity!!, slide_info, true, container, singleTap = { x, y ->
mView.apply {
if (subsampling_view.isVisible()) {
subsampling_view.sendFakeClick(x, y)
@ -119,7 +119,7 @@ class PhotoFragment : ViewPagerFragment() {
gestures_view.sendFakeClick(x, y)
}
}
}
})
if (context.config.allowDownGesture) {
gif_view.setOnTouchListener { v, event ->

View file

@ -205,21 +205,21 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S
setVideoSize()
mView.apply {
mBrightnessSideScroll.initialize(activity!!, slide_info, true, container) { x, y ->
mBrightnessSideScroll.initialize(activity!!, slide_info, true, container, singleTap = { x, y ->
if (mConfig.allowInstantChange) {
listener?.goToPrevItem()
} else {
toggleFullscreen()
}
}
})
mVolumeSideScroll.initialize(activity!!, slide_info, false, container) { x, y ->
mVolumeSideScroll.initialize(activity!!, slide_info, false, container, singleTap = { x, y ->
if (mConfig.allowInstantChange) {
listener?.goToNextItem()
} else {
toggleFullscreen()
}
}
})
video_surface.onGlobalLayout {
if (mIsFragmentVisible && mConfig.autoplayVideos && !mConfig.openVideosOnSeparateScreen) {

View file

@ -34,14 +34,17 @@ class MediaSideScroll(context: Context, attrs: AttributeSet) : RelativeLayout(co
private var mSlideInfoFadeHandler = Handler()
private var mParentView: ViewGroup? = null
private var activity: Activity? = null
private var doubleTap: ((Float, Float) -> Unit)? = null
private lateinit var slideInfoView: TextView
private lateinit var callback: (Float, Float) -> Unit
private lateinit var singleTap: (Float, Float) -> Unit
fun initialize(activity: Activity, slideInfoView: TextView, isBrightness: Boolean, parentView: ViewGroup?, callback: (x: Float, y: Float) -> Unit) {
fun initialize(activity: Activity, slideInfoView: TextView, isBrightness: Boolean, parentView: ViewGroup?, singleTap: (x: Float, y: Float) -> Unit,
doubleTap: ((x: Float, y: Float) -> Unit)? = null) {
this.activity = activity
this.slideInfoView = slideInfoView
this.callback = callback
this.singleTap = singleTap
this.doubleTap = doubleTap
mParentView = parentView
mIsBrightnessScroll = isBrightness
mSlideInfoText = activity.getString(if (isBrightness) R.string.brightness else R.string.volume)
@ -53,7 +56,14 @@ class MediaSideScroll(context: Context, attrs: AttributeSet) : RelativeLayout(co
private val gestureDetector = GestureDetector(context, object : GestureDetector.SimpleOnGestureListener() {
override fun onSingleTapConfirmed(e: MotionEvent?): Boolean {
if (e != null) {
callback(e.rawX, e.rawY)
singleTap(e.rawX, e.rawY)
}
return true
}
override fun onDoubleTap(e: MotionEvent?): Boolean {
if (e != null && doubleTap != null) {
doubleTap!!.invoke(e.rawX, e.rawY)
}
return true
}