mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 14:37:59 +01:00
allow closing fullscreen with down gesture, if deep zoomable image is visible
This commit is contained in:
parent
70f5a23575
commit
df03f39b94
1 changed files with 36 additions and 0 deletions
|
@ -15,6 +15,7 @@ import android.os.Bundle
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.util.DisplayMetrics
|
import android.util.DisplayMetrics
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
|
import android.view.MotionEvent
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
|
@ -75,6 +76,12 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
private var storedAllowOneFingerZoom = false
|
private var storedAllowOneFingerZoom = false
|
||||||
private var storedExtendedDetails = 0
|
private var storedExtendedDetails = 0
|
||||||
|
|
||||||
|
private var mTouchDownX = 0f
|
||||||
|
private var mTouchDownY = 0f
|
||||||
|
private var mOriginalSubsamplingScale = 0f
|
||||||
|
private var mCloseDownThreshold = 100f
|
||||||
|
private var mIgnoreCloseDown = false
|
||||||
|
|
||||||
lateinit var view: ViewGroup
|
lateinit var view: ViewGroup
|
||||||
lateinit var medium: Medium
|
lateinit var medium: Medium
|
||||||
|
|
||||||
|
@ -99,6 +106,11 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
subsampling_view.setOnTouchListener { v, event ->
|
||||||
|
handleEvent(event)
|
||||||
|
false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ViewPagerActivity.screenWidth == 0 || ViewPagerActivity.screenHeight == 0) {
|
if (ViewPagerActivity.screenWidth == 0 || ViewPagerActivity.screenHeight == 0) {
|
||||||
|
@ -383,6 +395,7 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
val useWidth = if (imageOrientation == ORIENTATION_ROTATE_90 || imageOrientation == ORIENTATION_ROTATE_270) sHeight else sWidth
|
val useWidth = if (imageOrientation == ORIENTATION_ROTATE_90 || imageOrientation == ORIENTATION_ROTATE_270) sHeight else sWidth
|
||||||
val useHeight = if (imageOrientation == ORIENTATION_ROTATE_90 || imageOrientation == ORIENTATION_ROTATE_270) sWidth else sHeight
|
val useHeight = if (imageOrientation == ORIENTATION_ROTATE_90 || imageOrientation == ORIENTATION_ROTATE_270) sWidth else sHeight
|
||||||
setDoubleTapZoomScale(getDoubleTapZoomScale(useWidth, useHeight))
|
setDoubleTapZoomScale(getDoubleTapZoomScale(useWidth, useHeight))
|
||||||
|
mOriginalSubsamplingScale = scale
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onTileLoadError(e: Exception?) {
|
override fun onTileLoadError(e: Exception?) {
|
||||||
|
@ -541,6 +554,29 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
listener?.fragmentClicked()
|
listener?.fragmentClicked()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun handleEvent(event: MotionEvent) {
|
||||||
|
if (view.subsampling_view.scale != mOriginalSubsamplingScale) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
when (event.actionMasked) {
|
||||||
|
MotionEvent.ACTION_DOWN -> {
|
||||||
|
mTouchDownX = event.x
|
||||||
|
mTouchDownY = event.y
|
||||||
|
}
|
||||||
|
MotionEvent.ACTION_POINTER_DOWN -> mIgnoreCloseDown = true
|
||||||
|
MotionEvent.ACTION_UP -> {
|
||||||
|
val diffX = mTouchDownX - event.x
|
||||||
|
val diffY = mTouchDownY - event.y
|
||||||
|
|
||||||
|
if (!mIgnoreCloseDown && Math.abs(diffY) > Math.abs(diffX) && diffY < -mCloseDownThreshold) {
|
||||||
|
activity?.supportFinishAfterTransition()
|
||||||
|
}
|
||||||
|
mIgnoreCloseDown = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun fullscreenToggled(isFullscreen: Boolean) {
|
override fun fullscreenToggled(isFullscreen: Boolean) {
|
||||||
this.isFullscreen = isFullscreen
|
this.isFullscreen = isFullscreen
|
||||||
view.photo_details.apply {
|
view.photo_details.apply {
|
||||||
|
|
Loading…
Reference in a new issue