[Libreoffice-commits] .: 3 commits - android/experimental
Tor Lillqvist
tml at kemper.freedesktop.org
Wed Jun 27 03:06:32 PDT 2012
android/experimental/DocumentLoader/src/com/polites/android/FlingListener.java | 45 ----------
android/experimental/DocumentLoader/src/com/polites/android/GestureImageView.java | 14 ++-
android/experimental/DocumentLoader/src/com/polites/android/GestureImageViewTouchListener.java | 25 +++++
android/experimental/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java | 22 ++--
4 files changed, 48 insertions(+), 58 deletions(-)
New commits:
commit 0179c9628258f30c41121a1ff3a50fcebe44d776
Author: Tor Lillqvist <tlillqvist at suse.com>
Date: Wed Jun 27 12:54:41 2012 +0300
Adapt page switch animation duration to fling velocity
Change-Id: I30e177b45b0e25d92fd7dea02ffe4e9c0731dce5
diff --git a/android/experimental/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java b/android/experimental/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java
index 2587857..677c6d4 100644
--- a/android/experimental/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java
+++ b/android/experimental/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java
@@ -149,12 +149,13 @@ public class DocumentLoader
Animation inFromRight = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 1, Animation.RELATIVE_TO_SELF, 0,
Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0);
- inFromRight.setDuration(500);
+ int duration = Math.abs((int)((float)flipper.getWidth()/velocityX*1000f));
+ inFromRight.setDuration(duration);
flipper.setInAnimation(inFromRight);
Animation outToLeft = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, -1,
Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0);
- outToLeft.setDuration(500);
+ outToLeft.setDuration(duration);
flipper.setOutAnimation(outToLeft);
flipper.showNext();
@@ -167,12 +168,13 @@ public class DocumentLoader
Animation inFromLeft = new TranslateAnimation(Animation.RELATIVE_TO_SELF, -1, Animation.RELATIVE_TO_SELF, 0,
Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0);
- inFromLeft.setDuration(500);
+ int duration = Math.abs((int)((float)flipper.getWidth()/velocityX*1000f));
+ inFromLeft.setDuration(duration);
flipper.setInAnimation(inFromLeft);
Animation outToRight = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 1,
Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0);
- outToRight.setDuration(500);
+ outToRight.setDuration(duration);
flipper.setOutAnimation(outToRight);
flipper.showPrevious();
commit 5bfb819581bdc9e1f1c59e36a0d7fb21593b382b
Author: Tor Lillqvist <tlillqvist at suse.com>
Date: Wed Jun 27 12:30:32 2012 +0300
Use GestureImageView again but still do handle page changes
Make the GestureImageView constructors take a OnGestureListener, and
store that, Move the FlingListener class into
GestureImageViewTouchListener so that FlingListener has access to the
fields of GestureImageViewTouchListener. If the image is fully zoomed
out and can't be dragged, pass flings on up, to DocumentLoader's
gestureListener.
Change-Id: I574280de23bdab2772a361833f561dff3e182bcd
diff --git a/android/experimental/DocumentLoader/src/com/polites/android/FlingListener.java b/android/experimental/DocumentLoader/src/com/polites/android/FlingListener.java
deleted file mode 100644
index ab3007a..0000000
--- a/android/experimental/DocumentLoader/src/com/polites/android/FlingListener.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2012 Jason Polites
- *
- * Licensed 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
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless 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.
- */
-package com.polites.android;
-
-import android.view.GestureDetector.SimpleOnGestureListener;
-import android.view.MotionEvent;
-
-
-/**
- * @author Jason Polites
- *
- */
-public class FlingListener extends SimpleOnGestureListener {
-
- private float velocityX;
- private float velocityY;
-
- @Override
- public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
- this.velocityX = velocityX;
- this.velocityY = velocityY;
- return true;
- }
-
- public float getVelocityX() {
- return velocityX;
- }
-
- public float getVelocityY() {
- return velocityY;
- }
-}
diff --git a/android/experimental/DocumentLoader/src/com/polites/android/GestureImageView.java b/android/experimental/DocumentLoader/src/com/polites/android/GestureImageView.java
index 1cde6e4..4b9278c 100644
--- a/android/experimental/DocumentLoader/src/com/polites/android/GestureImageView.java
+++ b/android/experimental/DocumentLoader/src/com/polites/android/GestureImageView.java
@@ -32,6 +32,7 @@ import android.net.Uri;
import android.provider.MediaStore;
import android.util.AttributeSet;
import android.util.Log;
+import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
@@ -88,13 +89,16 @@ public class GestureImageView extends ImageView {
private OnTouchListener customOnTouchListener;
private OnClickListener onClickListener;
- public GestureImageView(Context context, AttributeSet attrs, int defStyle) {
- this(context, attrs);
+ GestureDetector.OnGestureListener overflowGestureListener;
+
+ public GestureImageView(Context context, GestureDetector.OnGestureListener overflowGestureListener, AttributeSet attrs, int defStyle) {
+ this(context, overflowGestureListener, attrs);
}
- public GestureImageView(Context context, AttributeSet attrs) {
+ public GestureImageView(Context context, GestureDetector.OnGestureListener overflowGestureListener, AttributeSet attrs) {
super(context, attrs);
+ this.overflowGestureListener = overflowGestureListener;
String scaleType = attrs.getAttributeValue(GLOBAL_NS, "scaleType");
if(scaleType == null || scaleType.trim().length() == 0) {
@@ -121,8 +125,10 @@ public class GestureImageView extends ImageView {
initImage();
}
- public GestureImageView(Context context) {
+ public GestureImageView(Context context, GestureDetector.OnGestureListener overflowGestureListener) {
super(context);
+
+ this.overflowGestureListener = overflowGestureListener;
setScaleType(ScaleType.CENTER_INSIDE);
initImage();
}
diff --git a/android/experimental/DocumentLoader/src/com/polites/android/GestureImageViewTouchListener.java b/android/experimental/DocumentLoader/src/com/polites/android/GestureImageViewTouchListener.java
index 76751d1..f39840b 100644
--- a/android/experimental/DocumentLoader/src/com/polites/android/GestureImageViewTouchListener.java
+++ b/android/experimental/DocumentLoader/src/com/polites/android/GestureImageViewTouchListener.java
@@ -81,6 +81,31 @@ public class GestureImageViewTouchListener implements OnTouchListener {
private GestureDetector flingDetector;
private GestureImageViewListener imageListener;
+ class FlingListener extends SimpleOnGestureListener {
+
+ private float velocityX;
+ private float velocityY;
+
+ @Override
+ public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
+ this.velocityX = velocityX;
+ this.velocityY = velocityY;
+ if (image.overflowGestureListener != null && !canDragX && !canDragY) {
+ return image.overflowGestureListener.onFling(e1, e2, velocityX, velocityY);
+ }
+
+ return true;
+ }
+
+ public float getVelocityX() {
+ return velocityX;
+ }
+
+ public float getVelocityY() {
+ return velocityY;
+ }
+ }
+
public GestureImageViewTouchListener(final GestureImageView image, int displayWidth, int displayHeight) {
super();
diff --git a/android/experimental/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java b/android/experimental/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java
index d407932..2587857 100644
--- a/android/experimental/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java
+++ b/android/experimental/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java
@@ -124,6 +124,7 @@ public class DocumentLoader
int pageCount;
XRenderable renderable;
+ GestureDetector.OnGestureListener gestureListener;
GestureDetector gestureDetector;
ViewGroup.LayoutParams matchParent;
@@ -368,7 +369,7 @@ public class DocumentLoader
if (result == -1)
return;
- ImageView imageView = new ImageView(DocumentLoader.this);
+ GestureImageView imageView = new GestureImageView(DocumentLoader.this, gestureListener);
imageView.setImageBitmap(bm);
imageView.setScaleY(-1);
@@ -541,7 +542,8 @@ public class DocumentLoader
extras = getIntent().getExtras();
- gestureDetector = new GestureDetector(this, new GestureListener());
+ gestureListener = new GestureListener();
+ gestureDetector = new GestureDetector(this, gestureListener);
try {
long t0 = System.currentTimeMillis();
commit 6263315825e01e766668b9ce5d2eb52e71e051a7
Author: Tor Lillqvist <tlillqvist at suse.com>
Date: Tue Jun 26 11:45:13 2012 +0300
Whitespace cleanup
Change-Id: I52590908e6ba59c19aded2771d779c1cfa3a45ea
diff --git a/android/experimental/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java b/android/experimental/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java
index daf42d9..d407932 100644
--- a/android/experimental/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java
+++ b/android/experimental/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java
@@ -129,7 +129,7 @@ public class DocumentLoader
ViewGroup.LayoutParams matchParent;
ViewFlipper flipper;
-
+
Bundle extras;
class GestureListener
@@ -539,7 +539,7 @@ public class DocumentLoader
{
super.onCreate(savedInstanceState);
- extras = getIntent().getExtras();
+ extras = getIntent().getExtras();
gestureDetector = new GestureDetector(this, new GestureListener());
@@ -558,7 +558,7 @@ public class DocumentLoader
Bootstrap.dlopen("libmergedlo.so");
Bootstrap.dlopen("libswdlo.so");
Bootstrap.dlopen("libswlo.so");
-
+
// Log.i(TAG, "Sleeping NOW");
// Thread.sleep(20000);
More information about the Libreoffice-commits
mailing list