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

Tomaž Vajngerl tomaz.vajngerl at collabora.co.uk
Thu Feb 19 21:59:17 PST 2015


 android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java                  |    5 
 android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java                 |    8 -
 android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java           |   62 ++++++++--
 android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java            |    4 
 android/experimental/LOAndroid3/src/java/org/libreoffice/TileProvider.java                |   20 ---
 android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/DisplayPortCalculator.java |    2 
 6 files changed, 57 insertions(+), 44 deletions(-)

New commits:
commit 3a12ebefb8ed17ccc0308a3ab7b0b1bc5b768a14
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Fri Feb 20 14:56:29 2015 +0900

    android: support selection invalidation, show selection handles
    
    Change-Id: I82909e6426d4e9fd5dc7b9c9e6e1b21259cf9a57

diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
index eb7cb40..1fd1388 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
@@ -398,6 +398,18 @@ public class LOKitTileProvider implements TileProvider, Document.MessageCallback
             case Document.CALLBACK_INVALIDATE_VISIBLE_CURSOR:
                 invalidateCursor(payload);
                 break;
+            case Document.CALLBACK_INVALIDATE_TEXT_SELECTION:
+                Log.i(LOGTAG, "Selection: " + payload);
+                invalidateSelection(payload);
+                break;
+            case Document.CALLBACK_INVALIDATE_TEXT_SELECTION_START:
+                Log.i(LOGTAG, "Selection start: " + payload);
+                invalidateSelectionStart(payload);
+                break;
+            case Document.CALLBACK_INVALIDATE_TEXT_SELECTION_END:
+                Log.i(LOGTAG, "Selection end: " + payload);
+                invalidateSelectionEnd(payload);
+                break;
         }
     }
 
@@ -421,6 +433,44 @@ public class LOKitTileProvider implements TileProvider, Document.MessageCallback
             LOKitShell.sendTileInvalidationRequest(rect);
         }
     }
+
+    private void invalidateSelectionStart(String payload) {
+        RectF rect = convertCallbackMessageStringToRectF(payload);
+        if (rect != null) {
+            RectF underSelection = new RectF(rect.centerX(), rect.bottom, rect.centerX(), rect.bottom);
+            TextSelection textSelection = LibreOfficeMainActivity.mAppContext.getTextSelection();
+            textSelection.positionHandle(TextSelectionHandle.HandleType.START, underSelection);
+            textSelection.showHandle(TextSelectionHandle.HandleType.START);
+
+            textSelection.hideHandle(TextSelectionHandle.HandleType.MIDDLE);
+
+            TextCursorLayer textCursorLayer = LibreOfficeMainActivity.mAppContext.getTextCursorLayer();
+            textCursorLayer.hideCursor();
+        }
+    }
+
+    private void invalidateSelectionEnd(String payload) {
+        RectF rect = convertCallbackMessageStringToRectF(payload);
+        if (rect != null) {
+            RectF underSelection = new RectF(rect.centerX(), rect.bottom, rect.centerX(), rect.bottom);
+            TextSelection textSelection = LibreOfficeMainActivity.mAppContext.getTextSelection();
+            textSelection.positionHandle(TextSelectionHandle.HandleType.END, underSelection);
+            textSelection.showHandle(TextSelectionHandle.HandleType.END);
+
+            textSelection.hideHandle(TextSelectionHandle.HandleType.MIDDLE);
+
+            TextCursorLayer textCursorLayer = LibreOfficeMainActivity.mAppContext.getTextCursorLayer();
+            textCursorLayer.hideCursor();
+        }
+    }
+
+    private void invalidateSelection(String payload) {
+        if (payload.isEmpty()) {
+            TextSelection textSelection = LibreOfficeMainActivity.mAppContext.getTextSelection();
+            textSelection.hideHandle(TextSelectionHandle.HandleType.START);
+            textSelection.hideHandle(TextSelectionHandle.HandleType.END);
+        }
+    }
 }
 
 // vim:set shiftwidth=4 softtabstop=4 expandtab:
commit be2df2148c33b72dbe676c75383c4a5a55cd05ec
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Fri Feb 20 14:54:35 2015 +0900

    android: fix LOGTAG in DisplayPortCalculator
    
    Change-Id: I7895cc8fe70ecf69183ed9261bad4b74af023c8d

diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/DisplayPortCalculator.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/DisplayPortCalculator.java
index 789d5b6..f860cd9 100644
--- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/DisplayPortCalculator.java
+++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/DisplayPortCalculator.java
@@ -17,7 +17,7 @@ import org.mozilla.gecko.util.FloatUtils;
 import java.util.Map;
 
 final class DisplayPortCalculator {
-    private static final String LOGTAG = "GeckoDisplayPortCalculator";
+    private static final String LOGTAG = DisplayPortCalculator.class.getSimpleName();
     private static final PointF ZERO_VELOCITY = new PointF(0, 0);
 
     // Keep this in sync with the TILEDLAYERBUFFER_TILE_SIZE defined in gfx/layers/TiledLayerBuffer.h
commit 9f026266c420283f61b0f7cd0e94444f9b448f85
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Fri Feb 20 14:51:40 2015 +0900

    android: no need for TileInvalidationCallback
    
    We can just handle the tile invalidation messaged directly in
    LOKitTileProvider where we just send a tile invalidation event to
    LOKitThread. This is needed as we aren't in the correct thread.
    
    Change-Id: I62995f2f9abfa7496e0793549b8e02ff47b1ed65

diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java
index 1e3036c..2037e9d 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java
@@ -4,6 +4,7 @@ package org.libreoffice;
 import android.app.ActivityManager;
 import android.content.Context;
 import android.graphics.PointF;
+import android.graphics.RectF;
 import android.os.Handler;
 import android.util.DisplayMetrics;
 import android.view.KeyEvent;
@@ -119,4 +120,8 @@ public class LOKitShell {
     public static void sendTileReevaluationRequest(ComposedTileLayer composedTileLayer) {
         LOKitShell.sendEvent(new LOEvent(LOEvent.TILE_REEVALUATION_REQUEST, composedTileLayer));
     }
+
+    public static void sendTileInvalidationRequest(RectF rect) {
+        LOKitShell.sendEvent(new LOEvent(LOEvent.TILE_INVALIDATION, rect));
+    }
 }
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
index 8ae5749..9ec76be 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
@@ -17,7 +17,7 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.LinkedBlockingQueue;
 
-public class LOKitThread extends Thread implements TileProvider.TileInvalidationCallback {
+public class LOKitThread extends Thread {
     private static final String LOGTAG = LOKitThread.class.getSimpleName();
 
     private LinkedBlockingQueue<LOEvent> mEventQueue = new LinkedBlockingQueue<LOEvent>();
@@ -154,7 +154,6 @@ public class LOKitThread extends Thread implements TileProvider.TileInvalidation
 
         if (mTileProvider.isReady()) {
             LOKitShell.showProgressSpinner();
-            mTileProvider.registerInvalidationCallback(this);
             refresh();
             LOKitShell.hideProgressSpinner();
         } else {
@@ -246,11 +245,6 @@ public class LOKitThread extends Thread implements TileProvider.TileInvalidation
     public void clearQueue() {
         mEventQueue.clear();
     }
-
-    @Override
-    public void invalidate(RectF rect) {
-        queueEvent(new LOEvent(LOEvent.TILE_INVALIDATION, rect));
-    }
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
index d8753de..eb7cb40 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
@@ -32,7 +32,6 @@ public class LOKitTileProvider implements TileProvider, Document.MessageCallback
     private Office mOffice;
     private Document mDocument;
     private boolean mIsReady = false;
-    private TileInvalidationCallback tileInvalidationCallback = null;
 
     private float mDPI;
     private float mWidthTwip;
@@ -279,14 +278,6 @@ public class LOKitTileProvider implements TileProvider, Document.MessageCallback
     }
 
     /**
-     * Register the tile invalidation callback.
-     */
-    @Override
-    public void registerInvalidationCallback(TileInvalidationCallback tileInvalidationCallback) {
-        this.tileInvalidationCallback = tileInvalidationCallback;
-    }
-
-    /**
      * Returns the Unicode character generated by this event or 0.
      */
     private int getCharCode(KeyEvent keyEvent) {
@@ -425,12 +416,9 @@ public class LOKitTileProvider implements TileProvider, Document.MessageCallback
     }
 
     private void invalidateTiles(String payload) {
-        if (tileInvalidationCallback == null) {
-            return;
-        }
         RectF rect = convertCallbackMessageStringToRectF(payload);
         if (rect != null) {
-            tileInvalidationCallback.invalidate(rect);
+            LOKitShell.sendTileInvalidationRequest(rect);
         }
     }
 }
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java
index e6fbcd2..fe934a1 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java
@@ -90,10 +90,6 @@ public class MockTileProvider implements TileProvider {
     }
 
     @Override
-    public void registerInvalidationCallback(TileInvalidationCallback tileInvalidationCallback) {
-    }
-
-    @Override
     public void sendKeyEvent(KeyEvent keyEvent) {
 
     }
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/TileProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/TileProvider.java
index 92dbb3d..ea868bd 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/TileProvider.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/TileProvider.java
@@ -61,14 +61,6 @@ public interface TileProvider {
     boolean isSpreadsheet();
 
     /**
-     * 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 event.
      *
      * @param keyEvent - contains information about key event
@@ -90,16 +82,4 @@ public interface TileProvider {
      * @param numberOfClicks     - number of clicks (1 - single click, 2 - double click)
      */
     void mouseButtonUp(PointF documentCoordinate, int numberOfClicks);
-
-    /**
-     * Callback to retrieve invalidation calls
-     */
-    public interface TileInvalidationCallback {
-        /**
-         * Invoked when a region is invalidated.
-         *
-         * @param rect area in pixels which was invalidated and needs to be redrawn
-         */
-        void invalidate(RectF rect);
-    }
 }


More information about the Libreoffice-commits mailing list