mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-23 04:57:59 +01:00
tweaking instant video changing by screen side clicks, remove some views
This commit is contained in:
parent
8c2ac03591
commit
018ec4b0a5
2 changed files with 33 additions and 28 deletions
|
@ -81,14 +81,12 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S
|
||||||
mMedium = arguments!!.getSerializable(MEDIUM) as Medium
|
mMedium = arguments!!.getSerializable(MEDIUM) as Medium
|
||||||
mConfig = context!!.config
|
mConfig = context!!.config
|
||||||
mView = inflater.inflate(R.layout.pager_video_item, container, false).apply {
|
mView = inflater.inflate(R.layout.pager_video_item, container, false).apply {
|
||||||
instant_prev_item.setOnClickListener { listener?.goToPrevItem() }
|
|
||||||
instant_next_item.setOnClickListener { listener?.goToNextItem() }
|
|
||||||
panorama_outline.setOnClickListener { openPanorama() }
|
panorama_outline.setOnClickListener { openPanorama() }
|
||||||
video_curr_time.setOnClickListener { skip(false) }
|
video_curr_time.setOnClickListener { skip(false) }
|
||||||
video_duration.setOnClickListener { skip(true) }
|
video_duration.setOnClickListener { skip(true) }
|
||||||
video_holder.setOnClickListener { toggleFullscreen() }
|
video_holder.setOnClickListener { toggleFullscreen() }
|
||||||
video_preview.setOnClickListener { toggleFullscreen() }
|
video_preview.setOnClickListener { toggleFullscreen() }
|
||||||
video_surface_frame.setOnClickListener { toggleFullscreen() }
|
|
||||||
video_play_outline.setOnClickListener {
|
video_play_outline.setOnClickListener {
|
||||||
if (mConfig.openVideosOnSeparateScreen) {
|
if (mConfig.openVideosOnSeparateScreen) {
|
||||||
launchVideoPlayer()
|
launchVideoPlayer()
|
||||||
|
@ -114,6 +112,25 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S
|
||||||
mTextureView = video_surface
|
mTextureView = video_surface
|
||||||
mTextureView.surfaceTextureListener = this@VideoFragment
|
mTextureView.surfaceTextureListener = this@VideoFragment
|
||||||
|
|
||||||
|
val gestureDetector = GestureDetector(context, object : GestureDetector.SimpleOnGestureListener() {
|
||||||
|
override fun onSingleTapConfirmed(e: MotionEvent?): Boolean {
|
||||||
|
if (!mConfig.allowInstantChange) {
|
||||||
|
toggleFullscreen()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
val viewWidth = width
|
||||||
|
val twentyPercent = viewWidth / 5
|
||||||
|
val clickedX = e?.rawX ?: 0f
|
||||||
|
when {
|
||||||
|
clickedX <= twentyPercent -> listener?.goToPrevItem()
|
||||||
|
clickedX >= viewWidth - twentyPercent -> listener?.goToNextItem()
|
||||||
|
else -> toggleFullscreen()
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
if (mConfig.allowDownGesture) {
|
if (mConfig.allowDownGesture) {
|
||||||
video_preview.setOnTouchListener { view, event ->
|
video_preview.setOnTouchListener { view, event ->
|
||||||
handleEvent(event)
|
handleEvent(event)
|
||||||
|
@ -124,8 +141,11 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S
|
||||||
if (video_surface_frame.controller.state.zoom == 1f) {
|
if (video_surface_frame.controller.state.zoom == 1f) {
|
||||||
handleEvent(event)
|
handleEvent(event)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gestureDetector.onTouchEvent(event)
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,11 +192,19 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S
|
||||||
|
|
||||||
mView.apply {
|
mView.apply {
|
||||||
mBrightnessSideScroll.initialize(activity!!, slide_info, true, container) { x, y ->
|
mBrightnessSideScroll.initialize(activity!!, slide_info, true, container) { x, y ->
|
||||||
video_holder.performClick()
|
if (mConfig.allowInstantChange) {
|
||||||
|
listener?.goToPrevItem()
|
||||||
|
} else {
|
||||||
|
toggleFullscreen()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mVolumeSideScroll.initialize(activity!!, slide_info, false, container) { x, y ->
|
mVolumeSideScroll.initialize(activity!!, slide_info, false, container) { x, y ->
|
||||||
video_holder.performClick()
|
if (mConfig.allowInstantChange) {
|
||||||
|
listener?.goToNextItem()
|
||||||
|
} else {
|
||||||
|
toggleFullscreen()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
video_surface.onGlobalLayout {
|
video_surface.onGlobalLayout {
|
||||||
|
@ -192,7 +220,6 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S
|
||||||
restoreLastVideoSavedPosition()
|
restoreLastVideoSavedPosition()
|
||||||
}
|
}
|
||||||
|
|
||||||
updateInstantSwitchWidths()
|
|
||||||
return mView
|
return mView
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,16 +228,12 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S
|
||||||
mConfig = context!!.config // make sure we get a new config, in case the user changed something in the app settings
|
mConfig = context!!.config // make sure we get a new config, in case the user changed something in the app settings
|
||||||
activity!!.updateTextColors(mView.video_holder)
|
activity!!.updateTextColors(mView.video_holder)
|
||||||
val allowVideoGestures = mConfig.allowVideoGestures
|
val allowVideoGestures = mConfig.allowVideoGestures
|
||||||
val allowInstantChange = mConfig.allowInstantChange
|
|
||||||
mTextureView.beGoneIf(mConfig.openVideosOnSeparateScreen || mIsPanorama)
|
mTextureView.beGoneIf(mConfig.openVideosOnSeparateScreen || mIsPanorama)
|
||||||
mView.apply {
|
mView.apply {
|
||||||
video_surface_frame.beGoneIf(mTextureView.isGone())
|
video_surface_frame.beGoneIf(mTextureView.isGone())
|
||||||
|
|
||||||
video_volume_controller.beVisibleIf(allowVideoGestures && !mIsPanorama)
|
video_volume_controller.beVisibleIf(allowVideoGestures && !mIsPanorama)
|
||||||
video_brightness_controller.beVisibleIf(allowVideoGestures && !mIsPanorama)
|
video_brightness_controller.beVisibleIf(allowVideoGestures && !mIsPanorama)
|
||||||
|
|
||||||
instant_prev_item.beVisibleIf(allowInstantChange)
|
|
||||||
instant_next_item.beVisibleIf(allowInstantChange)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
checkExtendedDetails()
|
checkExtendedDetails()
|
||||||
|
@ -251,7 +274,6 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S
|
||||||
setVideoSize()
|
setVideoSize()
|
||||||
initTimeHolder()
|
initTimeHolder()
|
||||||
checkExtendedDetails()
|
checkExtendedDetails()
|
||||||
updateInstantSwitchWidths()
|
|
||||||
mView.video_surface_frame.onGlobalLayout {
|
mView.video_surface_frame.onGlobalLayout {
|
||||||
mView.video_surface_frame.controller.resetState()
|
mView.video_surface_frame.controller.resetState()
|
||||||
}
|
}
|
||||||
|
@ -453,12 +475,6 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateInstantSwitchWidths() {
|
|
||||||
val newWidth = resources.getDimension(R.dimen.instant_change_bar_width) + if (activity?.portrait == false) activity!!.navigationBarWidth else 0
|
|
||||||
mView.instant_prev_item.layoutParams.width = newWidth.toInt()
|
|
||||||
mView.instant_next_item.layoutParams.width = newWidth.toInt()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun fullscreenToggled(isFullscreen: Boolean) {
|
override fun fullscreenToggled(isFullscreen: Boolean) {
|
||||||
mIsFullscreen = isFullscreen
|
mIsFullscreen = isFullscreen
|
||||||
val newAlpha = if (isFullscreen) 0f else 1f
|
val newAlpha = if (isFullscreen) 0f else 1f
|
||||||
|
|
|
@ -35,17 +35,6 @@
|
||||||
android:layout_width="@dimen/media_side_slider_width"
|
android:layout_width="@dimen/media_side_slider_width"
|
||||||
android:layout_height="match_parent"/>
|
android:layout_height="match_parent"/>
|
||||||
|
|
||||||
<com.simplemobiletools.gallery.pro.views.InstantItemSwitch
|
|
||||||
android:id="@+id/instant_prev_item"
|
|
||||||
android:layout_width="@dimen/instant_change_bar_width"
|
|
||||||
android:layout_height="match_parent"/>
|
|
||||||
|
|
||||||
<com.simplemobiletools.gallery.pro.views.InstantItemSwitch
|
|
||||||
android:id="@+id/instant_next_item"
|
|
||||||
android:layout_width="@dimen/instant_change_bar_width"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_alignParentEnd="true"/>
|
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/video_play_outline"
|
android:id="@+id/video_play_outline"
|
||||||
android:layout_width="@dimen/play_outline_size_big"
|
android:layout_width="@dimen/play_outline_size_big"
|
||||||
|
|
Loading…
Reference in a new issue