fix #141, properly handle extended details view at toggling fullscreen

This commit is contained in:
tibbi 2017-10-19 15:49:27 +02:00
parent bb9b194d2c
commit 7fe9a27b84
4 changed files with 37 additions and 16 deletions

View file

@ -12,7 +12,6 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.RelativeLayout
import com.bumptech.glide.Glide
import com.bumptech.glide.Priority
import com.bumptech.glide.load.DataSource
@ -25,9 +24,7 @@ import com.bumptech.glide.request.RequestOptions
import com.bumptech.glide.request.target.Target
import com.davemorrissey.labs.subscaleview.ImageSource
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
import com.simplemobiletools.commons.extensions.beGone
import com.simplemobiletools.commons.extensions.beVisible
import com.simplemobiletools.commons.extensions.toast
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.gallery.R
import com.simplemobiletools.gallery.activities.ViewPagerActivity
import com.simplemobiletools.gallery.extensions.*
@ -276,10 +273,15 @@ class PhotoFragment : ViewPagerFragment() {
private fun checkExtendedDetails() {
if (context.config.showExtendedDetails) {
view.photo_details.apply {
beVisible()
setTextColor(context.config.textColor)
text = getMediumExtendedDetails(medium)
(layoutParams as RelativeLayout.LayoutParams).bottomMargin = (resources.getDimension(R.dimen.small_margin) + context.navigationBarHeight).toInt()
setTextColor(context.config.textColor)
beVisible()
onGlobalLayout {
if (height != 0) {
val smallMargin = resources.getDimension(R.dimen.small_margin)
y = context.usableScreenSize.y - height - if (context.navigationBarHeight == 0) smallMargin else 0f
}
}
}
} else {
view.photo_details.beGone()
@ -288,6 +290,7 @@ class PhotoFragment : ViewPagerFragment() {
override fun onDestroyView() {
super.onDestroyView()
context.isKitkatPlus()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && !activity.isDestroyed) {
Glide.with(context).clear(view.photo_view)
}
@ -304,6 +307,13 @@ class PhotoFragment : ViewPagerFragment() {
}
override fun fullscreenToggled(isFullscreen: Boolean) {
view.photo_details.apply {
if (visibility == View.VISIBLE) {
val smallMargin = resources.getDimension(R.dimen.small_margin)
val fullscreenOffset = context.navigationBarHeight.toFloat() - smallMargin
val newY = context.usableScreenSize.y - height + if (isFullscreen) fullscreenOffset else -(if (context.navigationBarHeight == 0) smallMargin else 0f)
animate().y(newY)
}
}
}
}

View file

@ -17,10 +17,7 @@ import android.widget.TextView
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.gallery.R
import com.simplemobiletools.gallery.activities.ViewPagerActivity
import com.simplemobiletools.gallery.extensions.audioManager
import com.simplemobiletools.gallery.extensions.config
import com.simplemobiletools.gallery.extensions.hasNavBar
import com.simplemobiletools.gallery.extensions.navigationBarHeight
import com.simplemobiletools.gallery.extensions.*
import com.simplemobiletools.gallery.helpers.MEDIUM
import com.simplemobiletools.gallery.models.Medium
import kotlinx.android.synthetic.main.pager_video_item.view.*
@ -507,9 +504,16 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
private fun checkExtendedDetails() {
if (context.config.showExtendedDetails) {
mView.video_details.apply {
beVisible()
setTextColor(context.config.textColor)
text = getMediumExtendedDetails(medium)
setTextColor(context.config.textColor)
beVisible()
onGlobalLayout {
if (height != 0) {
val smallMargin = resources.getDimension(R.dimen.small_margin)
val timeHolderHeight = mTimeHolder.height - context.navigationBarHeight
y = context.usableScreenSize.y - height - timeHolderHeight - if (context.navigationBarHeight == 0) smallMargin else 0f
}
}
}
} else {
mView.video_details.beGone()
@ -544,5 +548,14 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
override fun fullscreenToggled(isFullscreen: Boolean) {
mIsFullscreen = isFullscreen
checkFullscreen()
mView.video_details.apply {
if (visibility == View.VISIBLE) {
val smallMargin = resources.getDimension(R.dimen.small_margin)
val timeHolderHeight = mTimeHolder.height - context.navigationBarHeight.toFloat()
val fullscreenOffset = context.navigationBarHeight.toFloat() - smallMargin
val newY = context.usableScreenSize.y - height + if (mIsFullscreen) fullscreenOffset else -(timeHolderHeight + if (context.navigationBarHeight == 0) smallMargin else 0f)
animate().y(newY)
}
}
}
}

View file

@ -21,7 +21,6 @@
android:id="@+id/photo_details"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginLeft="@dimen/small_margin"
android:layout_marginRight="@dimen/small_margin"

View file

@ -55,7 +55,6 @@
android:id="@+id/video_details"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/video_time_holder"
android:layout_alignParentLeft="true"
android:layout_marginLeft="@dimen/small_margin"
android:layout_marginRight="@dimen/small_margin"