From 347959b830ce7fdc295ddd48d179865855e9adb9 Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 14 Jun 2018 11:25:37 +0200 Subject: [PATCH] fix some visual glitches around fullscreen Extended details --- .../gallery/fragments/PhotoFragment.kt | 16 ++++++++++------ .../gallery/fragments/VideoFragment.kt | 16 ++++++++++------ 2 files changed, 20 insertions(+), 12 deletions(-) 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 1c2a1e314..fb1ce093c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt @@ -379,12 +379,16 @@ class PhotoFragment : ViewPagerFragment() { private fun checkExtendedDetails() { if (context!!.config.showExtendedDetails) { view.photo_details.apply { + beInvisible() // make it invisible so we can measure it, but not show yet text = getMediumExtendedDetails(medium) - beVisibleIf(text.isNotEmpty()) - alpha = if (!context!!.config.hideExtendedDetails || !isFullscreen) 1f else 0f onGlobalLayout { - if (height != 0 && isAdded) { - y = getExtendedDetailsY(height) + if (isAdded) { + val realY = getExtendedDetailsY(height) + if (realY > 0) { + y = realY + beVisibleIf(text.isNotEmpty()) + alpha = if (!context!!.config.hideExtendedDetails || !isFullscreen) 1f else 0f + } } } } @@ -414,7 +418,7 @@ class PhotoFragment : ViewPagerFragment() { override fun fullscreenToggled(isFullscreen: Boolean) { this.isFullscreen = isFullscreen view.photo_details.apply { - if (storedShowExtendedDetails) { + if (storedShowExtendedDetails && isVisible()) { animate().y(getExtendedDetailsY(height)) if (storedHideExtendedDetails) { @@ -427,6 +431,6 @@ class PhotoFragment : ViewPagerFragment() { private fun getExtendedDetailsY(height: Int): Float { val smallMargin = resources.getDimension(R.dimen.small_margin) val fullscreenOffset = context!!.navigationBarHeight.toFloat() - smallMargin - return context!!.usableScreenSize.y - height + if (isFullscreen) fullscreenOffset else -(if (context!!.navigationBarHeight == 0) smallMargin else 0f) + return context!!.usableScreenSize.y - height + if (isFullscreen) fullscreenOffset else -smallMargin } } 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 19a9a8c4f..9993663ae 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt @@ -462,12 +462,16 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee private fun checkExtendedDetails() { if (context!!.config.showExtendedDetails) { mView!!.video_details.apply { + beInvisible() // make it invisible so we can measure it, but not show yet text = getMediumExtendedDetails(medium) - beVisibleIf(text.isNotEmpty()) - alpha = if (!context!!.config.hideExtendedDetails || !mIsFullscreen) 1f else 0f onGlobalLayout { - if (height != 0 && isAdded) { - y = getExtendedDetailsY(height) + if (isAdded) { + val realY = getExtendedDetailsY(height) + if (realY > 0) { + y = realY + beVisibleIf(text.isNotEmpty()) + alpha = if (!context!!.config.hideExtendedDetails || !mIsFullscreen) 1f else 0f + } } } } @@ -521,7 +525,7 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee mIsFullscreen = isFullscreen checkFullscreen() mView!!.video_details.apply { - if (mStoredShowExtendedDetails) { + if (mStoredShowExtendedDetails && isVisible()) { animate().y(getExtendedDetailsY(height)) if (mStoredHideExtendedDetails) { @@ -535,6 +539,6 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee val smallMargin = resources.getDimension(R.dimen.small_margin) val timeHolderHeight = mTimeHolder!!.height - context!!.navigationBarHeight.toFloat() val fullscreenOffset = context!!.navigationBarHeight.toFloat() - smallMargin - return context!!.usableScreenSize.y - height + if (mIsFullscreen) fullscreenOffset else -(timeHolderHeight + if (context!!.navigationBarHeight == 0) smallMargin else 0f) + return context!!.usableScreenSize.y - height + if (mIsFullscreen) fullscreenOffset else -(timeHolderHeight + smallMargin) } }