From bfaecc7eb5a31e87b5a09423fd525f7b228c8faa Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 6 Feb 2019 21:52:42 +0100 Subject: [PATCH] improving some double tap related things --- app/build.gradle | 2 +- .../gallery/pro/fragments/PhotoFragment.kt | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index dbee20658..40ed7965c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -75,7 +75,7 @@ dependencies { implementation 'com.squareup.picasso:picasso:2.71828' implementation 'com.caverock:androidsvg-aar:1.3' implementation 'com.github.tibbi:gestureviews:985ba285fb' - implementation 'com.github.tibbi:subsampling-scale-image-view:7be04d9b93' + implementation 'com.github.tibbi:subsampling-scale-image-view:89c16d24c5' kapt 'com.github.bumptech.glide:compiler:4.8.0' // keep it here too, not just in Commons, else loading SVGs wont work kapt 'androidx.room:room-compiler:2.0.0' diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/PhotoFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/PhotoFragment.kt index 23f1aca8c..90ed11a08 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/PhotoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/PhotoFragment.kt @@ -65,14 +65,12 @@ class PhotoFragment : ViewPagerFragment() { ) var mCurrentRotationDegrees = 0 - private var mOriginalRotationDegrees = 0 private var mIsFragmentVisible = false private var mIsFullscreen = false private var mWasInit = false private var mIsPanorama = false private var mIsSubsamplingVisible = false // checking view.visibility is unreliable, use an extra variable for it private var mImageOrientation = -1 - private var mOriginalSubsamplingScale = 0f private var mLoadZoomableViewHandler = Handler() private var mScreenWidth = 0 private var mScreenHeight = 0 @@ -132,7 +130,7 @@ class PhotoFragment : ViewPagerFragment() { } subsampling_view.setOnTouchListener { v, event -> - if (subsampling_view.scale == mOriginalSubsamplingScale) { + if (subsampling_view.isZoomedOut()) { handleEvent(event) } false @@ -468,7 +466,6 @@ class PhotoFragment : ViewPagerFragment() { val useWidth = if (mImageOrientation == ORIENTATION_ROTATE_90 || mImageOrientation == ORIENTATION_ROTATE_270) sHeight else sWidth val useHeight = if (mImageOrientation == ORIENTATION_ROTATE_90 || mImageOrientation == ORIENTATION_ROTATE_270) sWidth else sHeight doubleTapZoomScale = getDoubleTapZoomScale(useWidth, useHeight) - mOriginalSubsamplingScale = scale } override fun onImageLoadError(e: Exception) { @@ -480,6 +477,10 @@ class PhotoFragment : ViewPagerFragment() { override fun onImageRotation(degrees: Int) { if (mCurrentRotationDegrees != degrees) { + val fullRotation = rotation + degrees + val useWidth = if (fullRotation == 90 || fullRotation == 270) sHeight else sWidth + val useHeight = if (fullRotation == 90 || fullRotation == 270) sWidth else sHeight + doubleTapZoomScale = getDoubleTapZoomScale(useWidth, useHeight) loadBitmap(degrees, false) activity?.invalidateOptionsMenu() }