From 58445b80cee19eafd5436d8a5cf6df6fcec4af12 Mon Sep 17 00:00:00 2001 From: Eugene Popovich Date: Fri, 26 Oct 2012 16:02:19 +0300 Subject: [PATCH 1/2] - added isZoomed feature --- main/project.properties | 2 +- main/src/com/polites/android/GestureImageView.java | 8 ++++++++ .../polites/android/GestureImageViewTouchListener.java | 7 +++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/main/project.properties b/main/project.properties index 337e8f3..acfc74e 100644 --- a/main/project.properties +++ b/main/project.properties @@ -8,5 +8,5 @@ # project structure. # Project target. -target=android-7 +target=android-16 android.library=true diff --git a/main/src/com/polites/android/GestureImageView.java b/main/src/com/polites/android/GestureImageView.java index d39d0e1..2f375c4 100644 --- a/main/src/com/polites/android/GestureImageView.java +++ b/main/src/com/polites/android/GestureImageView.java @@ -18,6 +18,7 @@ import java.io.InputStream; import java.util.concurrent.Semaphore; import java.util.concurrent.TimeUnit; + import android.content.Context; import android.content.res.Configuration; import android.database.Cursor; @@ -709,4 +710,11 @@ else if(deviceOrientation == Configuration.ORIENTATION_PORTRAIT) { public int getDeviceOrientation() { return deviceOrientation; } + + public boolean isZoomed() { + if (gestureImageViewTouchListener != null) { + return gestureImageViewTouchListener.isZoomed(); + } + return false; + } } diff --git a/main/src/com/polites/android/GestureImageViewTouchListener.java b/main/src/com/polites/android/GestureImageViewTouchListener.java index 42e6cda..dc22b13 100644 --- a/main/src/com/polites/android/GestureImageViewTouchListener.java +++ b/main/src/com/polites/android/GestureImageViewTouchListener.java @@ -39,6 +39,7 @@ public class GestureImageViewTouchListener implements OnTouchListener { private boolean touched = false; private boolean inZoom = false; + private boolean isZoomed = false; private float initialDistance; private float lastScale = 1.0f; @@ -136,6 +137,7 @@ public void onZoom(float scale, float x, float y) { public void onComplete() { inZoom = false; handleUp(); + isZoomed = zoomAnimation.getZoom() > 1.0; } }); @@ -279,6 +281,7 @@ public boolean onTouch(View v, MotionEvent event) { if(event.getAction() == MotionEvent.ACTION_UP) { handleUp(); + isZoomed = !(lastScale == startingScale); } else if(event.getAction() == MotionEvent.ACTION_DOWN) { stopAnimations(); @@ -537,4 +540,8 @@ protected void calculateBoundaries() { boundaryBottom = centerY + diff; } } + + public boolean isZoomed() { + return isZoomed; + } } From a25fa8a95a3502945849be43f72a8995cf579fd6 Mon Sep 17 00:00:00 2001 From: Eugene Popovich Date: Mon, 29 Oct 2012 09:43:10 +0200 Subject: [PATCH 2/2] #24 - fixed Center inside starting scale --- main/.classpath | 16 ++++++++-------- .../com/polites/android/GestureImageView.java | 14 +++++++------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/main/.classpath b/main/.classpath index a4763d1..a662f00 100644 --- a/main/.classpath +++ b/main/.classpath @@ -1,8 +1,8 @@ - - - - - - - - + + + + + + + + diff --git a/main/src/com/polites/android/GestureImageView.java b/main/src/com/polites/android/GestureImageView.java index 2f375c4..6dcd082 100644 --- a/main/src/com/polites/android/GestureImageView.java +++ b/main/src/com/polites/android/GestureImageView.java @@ -264,12 +264,8 @@ protected void computeStartingScale(int imageWidth, int imageHeight, int measure break; case CENTER_INSIDE: - if(isLandscape()) { - startingScale = fitScaleHorizontal; - } - else { - startingScale = fitScaleVertical; - } + // FIX center inside should not crop the image + startingScale = Math.min(fitScaleHorizontal, fitScaleVertical); break; } } @@ -374,11 +370,15 @@ protected void initImage() { if(colorFilter != null) { this.drawable.setColorFilter(colorFilter); } + // Keppel.Cao + layout = false; + startingScale = -1.0f; } if(!layout) { requestLayout(); - redraw(); + // redraw(); + reset(); } }