mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 22:47:59 +01:00
fix #1032, make the instant switch area at landscape mode wider
This commit is contained in:
parent
cb346af279
commit
b53bd52adf
2 changed files with 36 additions and 20 deletions
|
@ -162,6 +162,7 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
initExtendedDetails()
|
initExtendedDetails()
|
||||||
wasInit = true
|
wasInit = true
|
||||||
checkIfPanorama()
|
checkIfPanorama()
|
||||||
|
updateInstantSwitchWidths()
|
||||||
|
|
||||||
return view
|
return view
|
||||||
}
|
}
|
||||||
|
@ -542,6 +543,7 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
initExtendedDetails()
|
initExtendedDetails()
|
||||||
|
updateInstantSwitchWidths()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun hideZoomableView() {
|
private fun hideZoomableView() {
|
||||||
|
@ -557,6 +559,12 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
listener?.fragmentClicked()
|
listener?.fragmentClicked()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun updateInstantSwitchWidths() {
|
||||||
|
val newWidth = resources.getDimension(R.dimen.instant_change_bar_width) + if (activity?.portrait == false) activity!!.navigationBarWidth else 0
|
||||||
|
view.instant_prev_item.layoutParams.width = newWidth.toInt()
|
||||||
|
view.instant_next_item.layoutParams.width = newWidth.toInt()
|
||||||
|
}
|
||||||
|
|
||||||
override fun fullscreenToggled(isFullscreen: Boolean) {
|
override fun fullscreenToggled(isFullscreen: Boolean) {
|
||||||
this.isFullscreen = isFullscreen
|
this.isFullscreen = isFullscreen
|
||||||
view.photo_details.apply {
|
view.photo_details.apply {
|
||||||
|
|
|
@ -43,7 +43,6 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S
|
||||||
private var mTextureView: TextureView? = null
|
private var mTextureView: TextureView? = null
|
||||||
private var mCurrTimeView: TextView? = null
|
private var mCurrTimeView: TextView? = null
|
||||||
private var mSeekBar: SeekBar? = null
|
private var mSeekBar: SeekBar? = null
|
||||||
private var mView: View? = null
|
|
||||||
private var mExoPlayer: SimpleExoPlayer? = null
|
private var mExoPlayer: SimpleExoPlayer? = null
|
||||||
private var mVideoSize = Point(0, 0)
|
private var mVideoSize = Point(0, 0)
|
||||||
private var mTimerHandler = Handler()
|
private var mTimerHandler = Handler()
|
||||||
|
@ -68,6 +67,7 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S
|
||||||
private lateinit var mBrightnessSideScroll: MediaSideScroll
|
private lateinit var mBrightnessSideScroll: MediaSideScroll
|
||||||
private lateinit var mVolumeSideScroll: MediaSideScroll
|
private lateinit var mVolumeSideScroll: MediaSideScroll
|
||||||
|
|
||||||
|
lateinit var mView: View
|
||||||
lateinit var medium: Medium
|
lateinit var medium: Medium
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||||
|
@ -103,7 +103,7 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S
|
||||||
|
|
||||||
storeStateVariables()
|
storeStateVariables()
|
||||||
medium = arguments!!.getSerializable(MEDIUM) as Medium
|
medium = arguments!!.getSerializable(MEDIUM) as Medium
|
||||||
Glide.with(context!!).load(medium.path).into(mView!!.video_preview)
|
Glide.with(context!!).load(medium.path).into(mView.video_preview)
|
||||||
|
|
||||||
// setMenuVisibility is not called at VideoActivity (third party intent)
|
// setMenuVisibility is not called at VideoActivity (third party intent)
|
||||||
if (!mIsFragmentVisible && activity is VideoActivity) {
|
if (!mIsFragmentVisible && activity is VideoActivity) {
|
||||||
|
@ -117,7 +117,7 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S
|
||||||
mVideoSize.y = y
|
mVideoSize.y = y
|
||||||
mIsPanorama = x == y * 2
|
mIsPanorama = x == y * 2
|
||||||
if (mIsPanorama) {
|
if (mIsPanorama) {
|
||||||
mView!!.apply {
|
mView.apply {
|
||||||
panorama_outline.beVisible()
|
panorama_outline.beVisible()
|
||||||
video_play_outline.beGone()
|
video_play_outline.beGone()
|
||||||
mVolumeSideScroll.beGone()
|
mVolumeSideScroll.beGone()
|
||||||
|
@ -144,7 +144,7 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S
|
||||||
setVideoSize()
|
setVideoSize()
|
||||||
}
|
}
|
||||||
|
|
||||||
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()
|
video_holder.performClick()
|
||||||
}
|
}
|
||||||
|
@ -162,17 +162,18 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S
|
||||||
}
|
}
|
||||||
|
|
||||||
setupVideoDuration()
|
setupVideoDuration()
|
||||||
|
updateInstantSwitchWidths()
|
||||||
|
|
||||||
return mView
|
return mView
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
activity!!.updateTextColors(mView!!.video_holder)
|
activity!!.updateTextColors(mView.video_holder)
|
||||||
val config = context!!.config
|
val config = context!!.config
|
||||||
val allowVideoGestures = config.allowVideoGestures
|
val allowVideoGestures = config.allowVideoGestures
|
||||||
val allowInstantChange = config.allowInstantChange
|
val allowInstantChange = config.allowInstantChange
|
||||||
mView!!.apply {
|
mView.apply {
|
||||||
video_volume_controller.beVisibleIf(allowVideoGestures && !mIsPanorama)
|
video_volume_controller.beVisibleIf(allowVideoGestures && !mIsPanorama)
|
||||||
video_brightness_controller.beVisibleIf(allowVideoGestures && !mIsPanorama)
|
video_brightness_controller.beVisibleIf(allowVideoGestures && !mIsPanorama)
|
||||||
|
|
||||||
|
@ -222,6 +223,7 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S
|
||||||
setVideoSize()
|
setVideoSize()
|
||||||
initTimeHolder()
|
initTimeHolder()
|
||||||
checkExtendedDetails()
|
checkExtendedDetails()
|
||||||
|
updateInstantSwitchWidths()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun storeStateVariables() {
|
private fun storeStateVariables() {
|
||||||
|
@ -237,9 +239,9 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S
|
||||||
if (activity == null)
|
if (activity == null)
|
||||||
return
|
return
|
||||||
|
|
||||||
mView!!.video_play_outline.setOnClickListener { togglePlayPause() }
|
mView.video_play_outline.setOnClickListener { togglePlayPause() }
|
||||||
|
|
||||||
mTextureView = mView!!.video_surface
|
mTextureView = mView.video_surface
|
||||||
mTextureView!!.setOnClickListener { toggleFullscreen() }
|
mTextureView!!.setOnClickListener { toggleFullscreen() }
|
||||||
mTextureView!!.surfaceTextureListener = this
|
mTextureView!!.surfaceTextureListener = this
|
||||||
|
|
||||||
|
@ -331,7 +333,7 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S
|
||||||
|
|
||||||
mTimeHolder.setPadding(left, top, right, bottom)
|
mTimeHolder.setPadding(left, top, right, bottom)
|
||||||
|
|
||||||
mSeekBar = mView!!.video_seekbar
|
mSeekBar = mView.video_seekbar
|
||||||
mSeekBar!!.setOnSeekBarChangeListener(this)
|
mSeekBar!!.setOnSeekBarChangeListener(this)
|
||||||
mTimeHolder.beInvisibleIf(mIsFullscreen)
|
mTimeHolder.beInvisibleIf(mIsFullscreen)
|
||||||
}
|
}
|
||||||
|
@ -356,7 +358,7 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S
|
||||||
|
|
||||||
private fun setupTimeHolder() {
|
private fun setupTimeHolder() {
|
||||||
mSeekBar!!.max = mDuration
|
mSeekBar!!.max = mDuration
|
||||||
mView!!.video_duration.text = mDuration.getFormattedDuration()
|
mView.video_duration.text = mDuration.getFormattedDuration()
|
||||||
setupTimer()
|
setupTimer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -417,8 +419,8 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mView!!.video_preview.isVisible()) {
|
if (mView.video_preview.isVisible()) {
|
||||||
mView!!.video_preview.beGone()
|
mView.video_preview.beGone()
|
||||||
initExoPlayer()
|
initExoPlayer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -428,8 +430,8 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S
|
||||||
|
|
||||||
mIsPlaying = true
|
mIsPlaying = true
|
||||||
mExoPlayer?.playWhenReady = true
|
mExoPlayer?.playWhenReady = true
|
||||||
mView!!.video_play_outline.setImageResource(R.drawable.ic_pause)
|
mView.video_play_outline.setImageResource(R.drawable.ic_pause)
|
||||||
mView!!.video_play_outline.alpha = PLAY_PAUSE_VISIBLE_ALPHA
|
mView.video_play_outline.alpha = PLAY_PAUSE_VISIBLE_ALPHA
|
||||||
activity!!.window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
activity!!.window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||||
schedulePlayPauseFadeOut()
|
schedulePlayPauseFadeOut()
|
||||||
}
|
}
|
||||||
|
@ -444,8 +446,8 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S
|
||||||
mExoPlayer?.playWhenReady = false
|
mExoPlayer?.playWhenReady = false
|
||||||
}
|
}
|
||||||
|
|
||||||
mView?.video_play_outline?.setImageResource(R.drawable.ic_play)
|
mView.video_play_outline?.setImageResource(R.drawable.ic_play)
|
||||||
mView?.video_play_outline?.alpha = PLAY_PAUSE_VISIBLE_ALPHA
|
mView.video_play_outline?.alpha = PLAY_PAUSE_VISIBLE_ALPHA
|
||||||
activity?.window?.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
activity?.window?.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||||
schedulePlayPauseFadeOut()
|
schedulePlayPauseFadeOut()
|
||||||
}
|
}
|
||||||
|
@ -453,7 +455,7 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S
|
||||||
private fun schedulePlayPauseFadeOut() {
|
private fun schedulePlayPauseFadeOut() {
|
||||||
mHidePlayPauseHandler.removeCallbacksAndMessages(null)
|
mHidePlayPauseHandler.removeCallbacksAndMessages(null)
|
||||||
mHidePlayPauseHandler.postDelayed({
|
mHidePlayPauseHandler.postDelayed({
|
||||||
mView!!.video_play_outline.animate().alpha(0f).start()
|
mView.video_play_outline.animate().alpha(0f).start()
|
||||||
}, HIDE_PLAY_PAUSE_DELAY)
|
}, HIDE_PLAY_PAUSE_DELAY)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -564,7 +566,7 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S
|
||||||
|
|
||||||
private fun checkExtendedDetails() {
|
private fun checkExtendedDetails() {
|
||||||
if (context!!.config.showExtendedDetails) {
|
if (context!!.config.showExtendedDetails) {
|
||||||
mView!!.video_details.apply {
|
mView.video_details.apply {
|
||||||
beInvisible() // make it invisible so we can measure it, but not show yet
|
beInvisible() // make it invisible so we can measure it, but not show yet
|
||||||
text = getMediumExtendedDetails(medium)
|
text = getMediumExtendedDetails(medium)
|
||||||
onGlobalLayout {
|
onGlobalLayout {
|
||||||
|
@ -579,7 +581,7 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mView!!.video_details.beGone()
|
mView.video_details.beGone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -633,10 +635,16 @@ 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
|
||||||
checkFullscreen()
|
checkFullscreen()
|
||||||
mView!!.video_details.apply {
|
mView.video_details.apply {
|
||||||
if (mStoredShowExtendedDetails && isVisible()) {
|
if (mStoredShowExtendedDetails && isVisible()) {
|
||||||
animate().y(getExtendedDetailsY(height))
|
animate().y(getExtendedDetailsY(height))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue