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

Tomaž Vajngerl tomaz.vajngerl at collabora.co.uk
Fri Apr 3 03:27:38 PDT 2015


 android/experimental/LOAndroid3/res/layout/text_selection_handles.xml                 |   24 ---
 android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/SelectionHandle.java  |    2 
 android/experimental/LOAndroid3/src/java/org/libreoffice/overlay/TextCursorLayer.java |    3 
 android/experimental/LOAndroid3/src/java/org/libreoffice/overlay/TextCursorView.java  |   75 +++++-----
 4 files changed, 45 insertions(+), 59 deletions(-)

New commits:
commit 27c1798ee8ab1178bbef44aea7ee7ce6b7c26a09
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Fri Apr 3 18:25:40 2015 +0900

    android: remove unneeded layerView stuff
    
    Change-Id: Ide81f4b5dd7f71a3dda21ff51d02a12d7fe9a315

diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/SelectionHandle.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/SelectionHandle.java
index bcf22b5..38b5dc1 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/SelectionHandle.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/SelectionHandle.java
@@ -14,8 +14,8 @@ public abstract class SelectionHandle extends BitmapHandle {
     private static final long MINIMUM_HANDLE_UPDATE_TIME = 50 * 1000000;
 
     private final PointF mDragStartPoint = new PointF();
-    private long mLastTime = 0;
     private final PointF mDragDocumentPosition = new PointF();
+    private long mLastTime = 0;
 
     public SelectionHandle(Bitmap bitmap) {
         super(bitmap);
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/overlay/TextCursorView.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/overlay/TextCursorView.java
index 74a0dc3..44d0d51 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/overlay/TextCursorView.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/overlay/TextCursorView.java
@@ -127,15 +127,9 @@ public class TextCursorView extends View implements View.OnTouchListener {
      * @param selectionRects - list of text selection rectangles
      */
     public void changeSelections(List<RectF> selectionRects) {
-        LayerView layerView = LOKitShell.getLayerView();
-        if (layerView == null) {
-            Log.e(LOGTAG, "Can't position selections because layerView is null");
-            return;
-        }
-
         mSelections = selectionRects;
 
-        ImmutableViewportMetrics metrics = layerView.getViewportMetrics();
+        ImmutableViewportMetrics metrics = mLayerView.getViewportMetrics();
         repositionWithViewport(metrics.viewportRectLeft, metrics.viewportRectTop, metrics.zoomFactor);
     }
 
@@ -147,15 +141,10 @@ public class TextCursorView extends View implements View.OnTouchListener {
         if (RectUtils.fuzzyEquals(mGraphicSelection.mRectangle, rectangle)) {
             return;
         }
-        LayerView layerView = LOKitShell.getLayerView();
-        if (layerView == null) {
-            Log.e(LOGTAG, "Can't position selections because layerView is null");
-            return;
-        }
 
         mGraphicSelection.mRectangle = rectangle;
 
-        ImmutableViewportMetrics metrics = layerView.getViewportMetrics();
+        ImmutableViewportMetrics metrics = mLayerView.getViewportMetrics();
         repositionWithViewport(metrics.viewportRectLeft, metrics.viewportRectTop, metrics.zoomFactor);
     }
 
@@ -348,10 +337,6 @@ public class TextCursorView extends View implements View.OnTouchListener {
         return false;
     }
 
-    public void setLayerView(LayerView layerView) {
-        this.mLayerView = layerView;
-    }
-
     public void positionHandle(SelectionHandle.HandleType type, RectF position) {
         SelectionHandle handle = getHandleForType(type);
         if (RectUtils.fuzzyEquals(handle.mDocumentPosition, position)) {
commit 6a3bbbca6280d1e27126b8fa5488a4130e622840
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Fri Apr 3 18:23:45 2015 +0900

    android: don't modify if the value is same - all in TextCursorView
    
    Change-Id: Ia90458ca037959c07244673fc5521fb940737390

diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/overlay/TextCursorView.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/overlay/TextCursorView.java
index 389cc39..74a0dc3 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/overlay/TextCursorView.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/overlay/TextCursorView.java
@@ -113,6 +113,9 @@ public class TextCursorView extends View implements View.OnTouchListener {
      * @param position - new position of the cursor
      */
     public void changeCursorPosition(RectF position) {
+        if (RectUtils.fuzzyEquals(mCursorPosition, position)) {
+            return;
+        }
         mCursorPosition = position;
 
         ImmutableViewportMetrics metrics = mLayerView.getViewportMetrics();
@@ -141,6 +144,9 @@ public class TextCursorView extends View implements View.OnTouchListener {
      * @param rectangle - new graphic selection rectangle
      */
     public void changeGraphicSelection(RectF rectangle) {
+        if (RectUtils.fuzzyEquals(mGraphicSelection.mRectangle, rectangle)) {
+            return;
+        }
         LayerView layerView = LOKitShell.getLayerView();
         if (layerView == null) {
             Log.e(LOGTAG, "Can't position selections because layerView is null");
@@ -228,50 +234,62 @@ public class TextCursorView extends View implements View.OnTouchListener {
      * Show the cursor on the view.
      */
     public void showCursor() {
-        mCursorVisible = true;
-        invalidate();
+        if (!mCursorVisible) {
+            mCursorVisible = true;
+            invalidate();
+        }
     }
 
     /**
      * Hide the cursor.
      */
     public void hideCursor() {
-        mCursorVisible = false;
-        invalidate();
+        if (mCursorVisible) {
+            mCursorVisible = false;
+            invalidate();
+        }
     }
 
     /**
      * Show text selection rectangles.
      */
     public void showSelections() {
-        mSelectionsVisible = true;
-        invalidate();
+        if (!mSelectionsVisible) {
+            mSelectionsVisible = true;
+            invalidate();
+        }
     }
 
     /**
      * Hide text selection rectangles.
      */
     public void hideSelections() {
-        mSelectionsVisible = false;
-        invalidate();
+        if (mSelectionsVisible) {
+            mSelectionsVisible = false;
+            invalidate();
+        }
     }
 
     /**
      * Show the graphic selection on the view.
      */
     public void showGraphicSelection() {
-        mGraphicSelectionMove = false;
-        mGraphicSelection.reset();
-        mGraphicSelection.setVisible(true);
-        invalidate();
+        if (!mGraphicSelection.isVisible()) {
+            mGraphicSelectionMove = false;
+            mGraphicSelection.reset();
+            mGraphicSelection.setVisible(true);
+            invalidate();
+        }
     }
 
     /**
      * Hide the graphic selection.
      */
     public void hideGraphicSelection() {
-        mGraphicSelection.setVisible(false);
-        invalidate();
+        if (mGraphicSelection.isVisible()) {
+            mGraphicSelection.setVisible(false);
+            invalidate();
+        }
     }
 
     /**
@@ -348,14 +366,18 @@ public class TextCursorView extends View implements View.OnTouchListener {
 
     public void hideHandle(SelectionHandle.HandleType type) {
         SelectionHandle handle = getHandleForType(type);
-        handle.setVisible(false);
-        invalidate();
+        if (handle.isVisible()) {
+            handle.setVisible(false);
+            invalidate();
+        }
     }
 
     public void showHandle(SelectionHandle.HandleType type) {
         SelectionHandle handle = getHandleForType(type);
-        handle.setVisible(true);
-        invalidate();
+        if (!handle.isVisible()) {
+            handle.setVisible(true);
+            invalidate();
+        }
     }
 
     private SelectionHandle getHandleForType(SelectionHandle.HandleType type) {
commit 08fb4953ca6fde1001f5adce5f3ba279c7dcf424
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Fri Apr 3 18:15:07 2015 +0900

    android: don't update position, if it is the same
    
    Change-Id: I8f0759db2c9cc6577ce25bfacb8272f3a5f6db92

diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/overlay/TextCursorView.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/overlay/TextCursorView.java
index 3e83326..389cc39 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/overlay/TextCursorView.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/overlay/TextCursorView.java
@@ -336,6 +336,10 @@ public class TextCursorView extends View implements View.OnTouchListener {
 
     public void positionHandle(SelectionHandle.HandleType type, RectF position) {
         SelectionHandle handle = getHandleForType(type);
+        if (RectUtils.fuzzyEquals(handle.mDocumentPosition, position)) {
+            return;
+        }
+
         RectUtils.assign(handle.mDocumentPosition, position);
 
         ImmutableViewportMetrics metrics = mLayerView.getViewportMetrics();
@@ -345,11 +349,13 @@ public class TextCursorView extends View implements View.OnTouchListener {
     public void hideHandle(SelectionHandle.HandleType type) {
         SelectionHandle handle = getHandleForType(type);
         handle.setVisible(false);
+        invalidate();
     }
 
     public void showHandle(SelectionHandle.HandleType type) {
         SelectionHandle handle = getHandleForType(type);
         handle.setVisible(true);
+        invalidate();
     }
 
     private SelectionHandle getHandleForType(SelectionHandle.HandleType type) {
commit ac91d62b759fd33bb6680f2b05325490f0ee14e9
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Fri Apr 3 18:14:43 2015 +0900

    android: don't reset position at showCursor
    
    Change-Id: I9a8eb1df0821e357ed268ad7730be98b69b5f249

diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/overlay/TextCursorLayer.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/overlay/TextCursorLayer.java
index 0662271..55ebfde 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/overlay/TextCursorLayer.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/overlay/TextCursorLayer.java
@@ -70,9 +70,6 @@ public class TextCursorLayer extends Layer {
     public void showCursor() {
         LOKitShell.getMainHandler().post(new Runnable() {
             public void run() {
-                mViewLeft = 0.0f;
-                mViewTop = 0.0f;
-                mViewZoom = 0.0f;
                 mCursorView.showCursor();
             }
         });
commit 8f955035096259019ea854770430815b5403d7e9
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Fri Apr 3 18:10:05 2015 +0900

    android: remove selection handles from xml definition
    
    Change-Id: I41d1d121f9d2d805624c4c8380a7c67bcd12f856

diff --git a/android/experimental/LOAndroid3/res/layout/text_selection_handles.xml b/android/experimental/LOAndroid3/res/layout/text_selection_handles.xml
index 0ee1048..b75ffd9 100644
--- a/android/experimental/LOAndroid3/res/layout/text_selection_handles.xml
+++ b/android/experimental/LOAndroid3/res/layout/text_selection_handles.xml
@@ -6,30 +6,6 @@
 <merge xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:gecko="http://schemas.android.com/apk/res-auto">
 
-    <org.mozilla.gecko.TextSelectionHandle
-        android:id="@+id/start_handle"
-        android:layout_width="@dimen/text_selection_handle_width"
-        android:layout_height="@dimen/text_selection_handle_height"
-        android:src="@drawable/handle_start_level"
-        android:visibility="gone"
-        gecko:handleType="start"/>
-
-    <org.mozilla.gecko.TextSelectionHandle
-        android:id="@+id/middle_handle"
-        android:layout_width="@dimen/text_selection_handle_width"
-        android:layout_height="@dimen/text_selection_handle_height"
-        android:src="@drawable/handle_middle"
-        android:visibility="gone"
-        gecko:handleType="middle"/>
-
-    <org.mozilla.gecko.TextSelectionHandle
-        android:id="@+id/end_handle"
-        android:layout_width="@dimen/text_selection_handle_width"
-        android:layout_height="@dimen/text_selection_handle_height"
-        android:src="@drawable/handle_end_level"
-        android:visibility="gone"
-        gecko:handleType="end"/>
-
     <org.libreoffice.overlay.TextCursorView
         android:id="@+id/text_cursor_view"
         android:layout_width="fill_parent"


More information about the Libreoffice-commits mailing list