diff --git a/app/build.gradle b/app/build.gradle index e6d6186ea..3b6f30473 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -37,6 +37,7 @@ dependencies { compile 'com.theartofdev.edmodo:android-image-cropper:2.3.1' compile 'com.bignerdranch.android:recyclerview-multiselect:0.2' compile 'com.google.code.gson:gson:2.8.0' + compile 'com.github.chrisbanes:PhotoView:1.3.1' compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" } 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 1ead87000..b3911eb0b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt @@ -7,7 +7,6 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import android.widget.ImageView import com.bumptech.glide.Glide import com.bumptech.glide.load.DecodeFormat import com.bumptech.glide.load.engine.DiskCacheStrategy @@ -20,11 +19,13 @@ import com.simplemobiletools.gallery.extensions.getRealPathFromURI import com.simplemobiletools.gallery.helpers.MEDIUM import com.simplemobiletools.gallery.models.Medium import kotlinx.android.synthetic.main.pager_photo_item.view.* +import uk.co.senab.photoview.PhotoView +import uk.co.senab.photoview.PhotoViewAttacher class PhotoFragment : ViewPagerFragment() { lateinit var medium: Medium lateinit var subsamplingView: SubsamplingScaleImageView - lateinit var glideView: ImageView + lateinit var glideView: PhotoView override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { val view = inflater.inflate(R.layout.pager_photo_item, container, false) @@ -34,7 +35,17 @@ class PhotoFragment : ViewPagerFragment() { medium.path = context.getRealPathFromURI(Uri.parse(medium.path)) ?: "" subsamplingView = view.photo_view.apply { setOnClickListener({ photoClicked() }) } - glideView = view.glide_view.apply { setOnClickListener({ photoClicked() }) } + glideView = view.glide_view.apply { + setOnPhotoTapListener(object : PhotoViewAttacher.OnPhotoTapListener { + override fun onPhotoTap(view: View?, x: Float, y: Float) { + photoClicked() + } + + override fun onOutsidePhotoTap() { + photoClicked() + } + }) + } loadImage(medium) activity.window.decorView.setOnSystemUiVisibilityChangeListener { visibility -> diff --git a/app/src/main/res/layout/pager_photo_item.xml b/app/src/main/res/layout/pager_photo_item.xml index 94eb1e06a..39ef5f905 100644 --- a/app/src/main/res/layout/pager_photo_item.xml +++ b/app/src/main/res/layout/pager_photo_item.xml @@ -5,7 +5,7 @@ android:layout_width="match_parent" android:layout_height="match_parent"> -