[Libreoffice-commits] core.git: Branch 'feature/tiled-editing' - 6 commits - android/experimental

Tomaž Vajngerl tomaz.vajngerl at collabora.co.uk
Fri Jan 23 07:10:52 PST 2015


 android/experimental/LOAndroid3/src/java/org/libreoffice/LOEvent.java                     |    5 -
 android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java                  |    5 -
 android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java                 |    7 +
 android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java           |   16 +++
 android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java            |   13 ++-
 android/experimental/LOAndroid3/src/java/org/libreoffice/TileProvider.java                |   43 ++++++++++
 android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java      |   25 -----
 android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/JavaPanZoomController.java |   15 ++-
 8 files changed, 96 insertions(+), 33 deletions(-)

New commits:
commit 9c0eb2ef3c1d83837a00eadf7c8306792db03a10
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Sat Jan 24 00:06:56 2015 +0900

    android: touch pop-ups keyboard and sends mousebuttondown event
    
    Change-Id: I98bf7c5ae4d31ab1a48321d1c5a3a4858cd3e00b

diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
index f274cf3..a185d79 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
@@ -164,6 +164,9 @@ public class LOKitThread extends Thread implements TileProvider.TileInvalidation
 
     private void touch(String touchType, MotionEvent motionEvent, PointF mDocumentTouchCoordinate) {
         LibreOfficeMainActivity.mAppContext.showSoftKeyboard();
+        float x = motionEvent.getX();
+        float y = motionEvent.getY();
+        mTileProvider.mouseButtonDown(mDocumentTouchCoordinate);
     }
 
     private void createThumbnail(final ThumbnailCreator.ThumbnailCreationTask task) {
commit a062315711ad37e08a6a614bf20db75d5f629987
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Sat Jan 24 00:05:23 2015 +0900

    android: convert to document coor. and send it with touch event
    
    Change-Id: I11286f73d23b21ee1e35e332b64b8bb37f7aaae8

diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/JavaPanZoomController.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/JavaPanZoomController.java
index 9440091..595657f 100644
--- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/JavaPanZoomController.java
+++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/JavaPanZoomController.java
@@ -12,7 +12,6 @@ import android.util.Log;
 import android.view.GestureDetector;
 import android.view.MotionEvent;
 
-import org.libreoffice.LOEventFactory;
 import org.libreoffice.LOKitShell;
 import org.libreoffice.LibreOfficeMainActivity;
 import org.mozilla.gecko.ZoomConstraints;
@@ -901,9 +900,15 @@ public class JavaPanZoomController
         mWaitForDoubleTap = false;
     }
 
+    private PointF getMotionInDocumentCoordinates(MotionEvent motionEvent) {
+        RectF viewport = getValidViewportMetrics().getViewport();
+        PointF viewPoint = new PointF(motionEvent.getX(0), motionEvent.getY(0));
+        return mTarget.convertViewPointToLayerPoint(viewPoint);
+    }
+
     @Override
     public void onLongPress(MotionEvent motionEvent) {
-        LOKitShell.sentTouchEvent("LongPress", motionEvent);
+        LOKitShell.sentTouchEvent("LongPress", motionEvent, getMotionInDocumentCoordinates(motionEvent));
     }
 
     @Override
@@ -911,7 +916,7 @@ public class JavaPanZoomController
         // When double-tapping is allowed, we have to wait to see if this is
         // going to be a double-tap.
         if (!mWaitForDoubleTap) {
-            LOKitShell.sentTouchEvent("SingleTap", motionEvent);
+            LOKitShell.sentTouchEvent("SingleTap", motionEvent, getMotionInDocumentCoordinates(motionEvent));
         }
         // return false because we still want to get the ACTION_UP event that triggers this
         return false;
@@ -921,14 +926,14 @@ public class JavaPanZoomController
     public boolean onSingleTapConfirmed(MotionEvent motionEvent) {
         // In cases where we don't wait for double-tap, we handle this in onSingleTapUp.
         if (mWaitForDoubleTap) {
-            LOKitShell.sentTouchEvent("SingleTap", motionEvent);
+            LOKitShell.sentTouchEvent("SingleTap", motionEvent, getMotionInDocumentCoordinates(motionEvent));
         }
         return true;
     }
 
     @Override
     public boolean onDoubleTap(MotionEvent motionEvent) {
-        LOKitShell.sentTouchEvent("DoubleTap", motionEvent);
+        LOKitShell.sentTouchEvent("DoubleTap", motionEvent, getMotionInDocumentCoordinates(motionEvent));
         return true;
     }
 
commit 5116fab171487037708860602c8e24937f3ff6fb
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Sat Jan 24 00:00:56 2015 +0900

    android: view point to document point conversion updated
    
    Change-Id: Ie8a712f3fa24d0ffeef3ef524c02e97acdb1237e

diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java
index 9ec1c98..db21554 100644
--- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java
+++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java
@@ -398,33 +398,14 @@ public class GeckoLayerClient implements PanZoomTarget, LayerView.Listener {
         return this;
     }
 
-    /** Implementation of PanZoomTarget
-     * Converts a point from layer view coordinates to layer coordinates. In other words, given a
-     * point measured in pixels from the top left corner of the layer view, returns the point in
-     * pixels measured from the last scroll position we sent to Gecko, in CSS pixels. Assuming the
-     * events being sent to Gecko are processed in FIFO order, this calculation should always be
-     * correct.
-     */
     public PointF convertViewPointToLayerPoint(PointF viewPoint) {
-        if (!mGeckoIsReady) {
-            return null;
-        }
-
         ImmutableViewportMetrics viewportMetrics = mViewportMetrics;
         PointF origin = viewportMetrics.getOrigin();
         float zoom = viewportMetrics.zoomFactor;
-        ImmutableViewportMetrics geckoViewport = mGeckoViewport;
-        PointF geckoOrigin = geckoViewport.getOrigin();
-        float geckoZoom = geckoViewport.zoomFactor;
-
-        // viewPoint + origin gives the coordinate in device pixels from the top-left corner of the page.
-        // Divided by zoom, this gives us the coordinate in CSS pixels from the top-left corner of the page.
-        // geckoOrigin / geckoZoom is where Gecko thinks it is (scrollTo position) in CSS pixels from
-        // the top-left corner of the page. Subtracting the two gives us the offset of the viewPoint from
-        // the current Gecko coordinate in CSS pixels.
+
         PointF layerPoint = new PointF(
-                ((viewPoint.x + origin.x) / zoom) - (geckoOrigin.x / geckoZoom),
-                ((viewPoint.y + origin.y) / zoom) - (geckoOrigin.y / geckoZoom));
+                ((viewPoint.x + origin.x) / zoom),
+                ((viewPoint.y + origin.y) / zoom));
 
         return layerPoint;
     }
commit 2305e19d679c57e66ab7e4d8f548f0906db8659e
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Fri Jan 23 23:58:28 2015 +0900

    android: extend touch event with transformed document coordinate
    
    Change-Id: I17e48bd39b799dc41b8d0402652f70d33ba002d7

diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOEvent.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOEvent.java
index 809988d..11bd72d 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOEvent.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOEvent.java
@@ -1,5 +1,6 @@
 package org.libreoffice;
 
+import android.graphics.PointF;
 import android.view.KeyEvent;
 import android.view.MotionEvent;
 
@@ -33,6 +34,7 @@ public class LOEvent implements Comparable<LOEvent> {
     public SubTile mTile;
     public String mTouchType;
     public MotionEvent mMotionEvent;
+    public PointF mDocumentTouchCoordinate;
     public KeyEvent mKeyEvent;
 
     public LOEvent(int type) {
@@ -81,11 +83,12 @@ public class LOEvent implements Comparable<LOEvent> {
         mTile = tile;
     }
 
-    public LOEvent(int type, String touchType, MotionEvent motionEvent) {
+    public LOEvent(int type, String touchType, MotionEvent motionEvent, PointF documentTouchCoordinate) {
         mType = type;
         mTypeString = "Touch";
         mTouchType = touchType;
         mMotionEvent = motionEvent;
+        mDocumentTouchCoordinate = documentTouchCoordinate;
     }
 
     public LOEvent(int type, KeyEvent keyEvent) {
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java
index 49da6b4..0f606ed 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java
@@ -3,6 +3,7 @@ package org.libreoffice;
 
 import android.app.ActivityManager;
 import android.content.Context;
+import android.graphics.PointF;
 import android.os.Handler;
 import android.util.DisplayMetrics;
 import android.view.KeyEvent;
@@ -72,8 +73,8 @@ public class LOKitShell {
     /**
      * Send touch event to LOKitThread.
      */
-    public static void sentTouchEvent(String touchType, MotionEvent motionEvent) {
-        LOKitShell.sendEvent(new LOEvent(LOEvent.TOUCH, "SingleTap", motionEvent));
+    public static void sentTouchEvent(String touchType, MotionEvent motionEvent, PointF pointF) {
+        LOKitShell.sendEvent(new LOEvent(LOEvent.TOUCH, "SingleTap", motionEvent, pointF));
     }
 
     /**
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
index fd88f1c..f274cf3 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
@@ -151,7 +151,7 @@ public class LOKitThread extends Thread implements TileProvider.TileInvalidation
                 if (!LOKitShell.isEditingEnabled()) {
                     return;
                 }
-                touch(event.mTouchType, event.mMotionEvent);
+                touch(event.mTouchType, event.mMotionEvent, event.mDocumentTouchCoordinate);
                 break;
             case LOEvent.KEY_PRESS:
                 if (!LOKitShell.isEditingEnabled()) {
@@ -162,7 +162,7 @@ public class LOKitThread extends Thread implements TileProvider.TileInvalidation
         }
     }
 
-    private void touch(String touchType, MotionEvent motionEvent) {
+    private void touch(String touchType, MotionEvent motionEvent, PointF mDocumentTouchCoordinate) {
         LibreOfficeMainActivity.mAppContext.showSoftKeyboard();
     }
 
commit b275a925cfeac37f47d10067345d58c16ddd8706
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Fri Jan 23 23:55:20 2015 +0900

    android: add mouseButtonDown(Up) to TileProvider + impl.
    
    Change-Id: I1ca2242d2bc7ee7d2d48a4a5f5bcc6e77edfaa2d

diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
index 08561d8..1ace50f 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
@@ -1,6 +1,7 @@
 package org.libreoffice;
 
 import android.graphics.Bitmap;
+import android.graphics.PointF;
 import android.graphics.RectF;
 import android.util.Log;
 import android.view.KeyEvent;
@@ -294,6 +295,21 @@ public class LOKitTileProvider implements TileProvider, Document.MessageCallback
         mOffice.postKeyEvent(Office.KEY_PRESS, code);
     }
 
+    private void mouseButton(int type, PointF inDocument) {
+        int x = (int) pixelToTwip(inDocument.x, mDPI);
+        int y = (int) pixelToTwip(inDocument.y, mDPI);
+        mDocument.postMouseEvent(type, x, y);
+    }
+
+    @Override
+    public void mouseButtonDown(PointF inDocument) {
+        mouseButton(Document.MOUSE_BUTTON_DOWN, inDocument);
+    }
+
+    @Override
+    public void mouseButtonUp(PointF inDocument) {
+        mouseButton(Document.MOUSE_BUTTON_UP, inDocument);
+    }
 
     @Override
     protected void finalize() throws Throwable {
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java
index 15332a7..f68678a 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java
@@ -1,6 +1,7 @@
 package org.libreoffice;
 
 import android.graphics.Bitmap;
+import android.graphics.PointF;
 import android.view.KeyEvent;
 
 import org.mozilla.gecko.gfx.BufferedCairoImage;
@@ -23,7 +24,7 @@ public class MockTileProvider implements TileProvider {
             LibreOfficeMainActivity.mAppContext.mMainHandler.post(new Runnable() {
                 @Override
                 public void run() {
-                LibreOfficeMainActivity.mAppContext.getDocumentPartViewListAdapter().add(partView);
+                    LibreOfficeMainActivity.mAppContext.getDocumentPartViewListAdapter().add(partView);
                 }
             });
         }
@@ -92,6 +93,16 @@ public class MockTileProvider implements TileProvider {
     }
 
     @Override
+    public void mouseButtonDown(PointF inDocument) {
+
+    }
+
+    @Override
+    public void mouseButtonUp(PointF inDocument) {
+
+    }
+
+    @Override
     public void changePart(int partIndex) {
     }
 
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/TileProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/TileProvider.java
index ed9682f..a411879 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/TileProvider.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/TileProvider.java
@@ -2,6 +2,7 @@ package org.libreoffice;
 
 
 import android.graphics.Bitmap;
+import android.graphics.PointF;
 import android.graphics.RectF;
 import android.view.KeyEvent;
 
@@ -67,6 +68,18 @@ public interface TileProvider {
     void keyPress(KeyEvent keyEvent);
 
     /**
+     * Trigger a mouse button down event.
+     * @param documentCoordinate - coordinate relative to the document where the mouse button should be triggered
+     */
+    void mouseButtonDown(PointF documentCoordinate);
+
+    /**
+     * Trigger a mouse button up event.
+     * @param documentCoordinate - coordinate relative to the document where the mouse button should be triggered
+     */
+    void mouseButtonUp(PointF documentCoordinate);
+
+    /**
      * Callback to retrieve invalidation calls
      */
     public interface TileInvalidationCallback {
commit 1bce9dd7d2eff40e3198b4761eb7f2d9989d2de1
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Fri Jan 23 23:48:14 2015 +0900

    android: add some comments to TileProvider interface
    
    Change-Id: I1c6f7bccda2392235242f5c26af1437f1365f728

diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/TileProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/TileProvider.java
index da0d0f4..ed9682f 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/TileProvider.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/TileProvider.java
@@ -9,8 +9,14 @@ import org.mozilla.gecko.gfx.CairoImage;
 import org.mozilla.gecko.gfx.IntSize;
 
 public interface TileProvider {
+    /**
+     * Returns the page width in pixels.
+     */
     int getPageWidth();
 
+    /**
+     * Returns the page height in pixels.
+     */
     int getPageHeight();
 
     boolean isReady();
@@ -22,18 +28,42 @@ public interface TileProvider {
      */
     void rerenderTile(CairoImage image, float x, float y, IntSize tileSize, float zoom);
 
+    /**
+     * Change the document part to the one specified by the partIndex input parameter.
+     * @param partIndex - part index to change to
+     */
     void changePart(int partIndex);
 
+    /**
+     * Get the current document part number.
+     * @return
+     */
     int getCurrentPartNumber();
 
     Bitmap thumbnail(int size);
 
+    /**
+     * Closes the document.
+     */
     void close();
 
+    /**
+     * Returns true if the current open document is a text document.
+     */
     boolean isTextDocument();
 
+    /**
+     * Register a callback that is invoked when a tile invalidation is
+     * required.
+     *
+     * @param tileInvalidationCallback - the tile invalidation callback
+     */
     void registerInvalidationCallback(TileProvider.TileInvalidationCallback tileInvalidationCallback);
 
+    /**
+     * Trigger a key press.
+     * @param keyEvent - contains the
+     */
     void keyPress(KeyEvent keyEvent);
 
     /**


More information about the Libreoffice-commits mailing list