diff --git a/app/build.gradle b/app/build.gradle
index bd0304b1a..fabbc02f3 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -32,8 +32,8 @@ dependencies {
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.github.bumptech.glide:glide:3.7.0'
- compile 'com.davemorrissey.labs:subsampling-scale-image-view:3.5.0'
compile 'com.jakewharton:butterknife:8.0.1'
+ compile 'com.github.chrisbanes:PhotoView:1.2.6'
apt 'com.jakewharton:butterknife-compiler:8.0.1'
}
diff --git a/app/src/main/java/com/simplemobiletools/gallery/activities/LicenseActivity.java b/app/src/main/java/com/simplemobiletools/gallery/activities/LicenseActivity.java
index 6d90229de..816fc3606 100644
--- a/app/src/main/java/com/simplemobiletools/gallery/activities/LicenseActivity.java
+++ b/app/src/main/java/com/simplemobiletools/gallery/activities/LicenseActivity.java
@@ -24,9 +24,9 @@ public class LicenseActivity extends AppCompatActivity {
openUrl(R.string.butterknife_url);
}
- @OnClick(R.id.license_subsampling_title)
- public void subsamplingClicked() {
- openUrl(R.string.subsampling_url);
+ @OnClick(R.id.license_photoview_title)
+ public void photoViewClicked() {
+ openUrl(R.string.photoview_url);
}
private void openUrl(int id) {
diff --git a/app/src/main/java/com/simplemobiletools/gallery/fragments/PhotoFragment.java b/app/src/main/java/com/simplemobiletools/gallery/fragments/PhotoFragment.java
index d68c0dbfe..706678de4 100644
--- a/app/src/main/java/com/simplemobiletools/gallery/fragments/PhotoFragment.java
+++ b/app/src/main/java/com/simplemobiletools/gallery/fragments/PhotoFragment.java
@@ -1,17 +1,21 @@
package com.simplemobiletools.gallery.fragments;
+import android.animation.ObjectAnimator;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
-import com.davemorrissey.labs.subscaleview.ImageSource;
-import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView;
+import com.bumptech.glide.Glide;
+import com.bumptech.glide.request.animation.ViewPropertyAnimation;
import com.simplemobiletools.gallery.Constants;
import com.simplemobiletools.gallery.R;
import com.simplemobiletools.gallery.models.Medium;
-public class PhotoFragment extends ViewPagerFragment implements View.OnClickListener {
+import uk.co.senab.photoview.PhotoView;
+import uk.co.senab.photoview.PhotoViewAttacher;
+
+public class PhotoFragment extends ViewPagerFragment implements PhotoViewAttacher.OnPhotoTapListener {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
@@ -21,28 +25,28 @@ public class PhotoFragment extends ViewPagerFragment implements View.OnClickList
if (medium == null)
return view;
- final SubsamplingScaleImageView imageView = (SubsamplingScaleImageView) view.findViewById(R.id.photo_view);
- imageView.setOrientation(SubsamplingScaleImageView.ORIENTATION_USE_EXIF);
- imageView.setImage(ImageSource.uri(medium.getPath()));
- imageView.setMaxScale(5f);
- imageView.setOnClickListener(this);
+ final PhotoView photoView = (PhotoView) view.findViewById(R.id.photo_view);
+ Glide.with(getContext()).load(medium.getPath()).asBitmap().thumbnail(0.2f).animate(fadeInAnimator).into(photoView);
+ new PhotoViewAttacher(photoView).setOnPhotoTapListener(this);
return view;
}
+ ViewPropertyAnimation.Animator fadeInAnimator = new ViewPropertyAnimation.Animator() {
+ @Override
+ public void animate(View view) {
+ view.setAlpha(0f);
+ ObjectAnimator fadeAnim = ObjectAnimator.ofFloat(view, "alpha", 0f, 1f);
+ fadeAnim.setDuration(250);
+ fadeAnim.start();
+ }
+ };
+
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
}
- @Override
- public void onClick(View v) {
- if (mListener == null)
- mListener = (FragmentClickListener) getActivity();
-
- mListener.fragmentClicked();
- }
-
@Override
public void itemDragged() {
@@ -52,4 +56,21 @@ public class PhotoFragment extends ViewPagerFragment implements View.OnClickList
public void systemUiVisibilityChanged(boolean toFullscreen) {
}
+
+ @Override
+ public void onPhotoTap(View view, float v, float v1) {
+ photoClicked();
+ }
+
+ @Override
+ public void onOutsidePhotoTap() {
+ photoClicked();
+ }
+
+ private void photoClicked() {
+ if (mListener == null)
+ mListener = (FragmentClickListener) getActivity();
+
+ mListener.fragmentClicked();
+ }
}
diff --git a/app/src/main/res/layout/activity_license.xml b/app/src/main/res/layout/activity_license.xml
index ad064c85f..c914621f8 100644
--- a/app/src/main/res/layout/activity_license.xml
+++ b/app/src/main/res/layout/activity_license.xml
@@ -32,18 +32,18 @@
android:text="@string/butterknife_text"/>
+ android:text="@string/photoview_text"/>
-Butter Knife (view injector)
Copyright 2013 Jake Wharton\n\nLicensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.You may obtain a copy of the License at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions and limitations under the License.
https://github.com/JakeWharton/butterknife
- Subsampling Scale Image View (zoomable imageviews)
- Copyright 2016 davemorrissey\n\nLicensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.You may obtain a copy of the License at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions and limitations under the License.
- https://github.com/davemorrissey/subsampling-scale-image-view
+ PhotoView (zoomable imageviews)
+ Copyright 2011,2012 Chris Banes\n\nLicensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.You may obtain a copy of the License at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions and limitations under the License.
+ https://github.com/chrisbanes/PhotoView
Glide (image loading and caching)
Copyright 2014 Google, Inc. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n\n1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n\n2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\n\nTHIS SOFTWARE IS PROVIDED BY GOOGLE, INC. ``AS IS\'\' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE, INC. OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
https://github.com/bumptech/glide
diff --git a/build.gradle b/build.gradle
index 165abe551..bf9a165bd 100644
--- a/build.gradle
+++ b/build.gradle
@@ -16,6 +16,7 @@ buildscript {
allprojects {
repositories {
jcenter()
+ maven { url "https://jitpack.io" }
}
}