android: rename TextCursorLayer{View} -> DocumentOverlay{View}
Change-Id: I53a55e2d30c298e7c34f18b7713de91f3c77d5f2
This commit is contained in:
committed by
Miklos Vajna
parent
4fb38c6f66
commit
5707813c07
@@ -144,9 +144,9 @@ Overlay
|
|||||||
|
|
||||||
Overlay elements like cursor and selections aren't drawn by the LO core, instead the core
|
Overlay elements like cursor and selections aren't drawn by the LO core, instead the core
|
||||||
only provides data (cursor position, selection rectangles) and the app needs to draw them.
|
only provides data (cursor position, selection rectangles) and the app needs to draw them.
|
||||||
TextCursorView (org.libreoffice.overlay.TextCursorView) and TextCursorLayer
|
DocumentOverlay (org.libreoffice.overlay.DocumentOverlay) and DocumentOverlayView
|
||||||
(org.libreoffice.overlay.TextCursorLayer) are the classes that provide the overlay over the
|
(org.libreoffice.overlay.DocumentOverlayView) are the classes that provide the overlay over
|
||||||
document, where selections and the cursor is drawn.
|
the document, where selections and the cursor is drawn.
|
||||||
|
|
||||||
Emulator and debugging notes
|
Emulator and debugging notes
|
||||||
****************************
|
****************************
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:gecko="http://schemas.android.com/apk/res-auto">
|
xmlns:gecko="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
<org.libreoffice.overlay.TextCursorView
|
<org.libreoffice.overlay.DocumentOverlayView
|
||||||
android:id="@+id/text_cursor_view"
|
android:id="@+id/text_cursor_view"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="fill_parent"/>
|
android:layout_height="fill_parent"/>
|
||||||
|
@@ -6,7 +6,7 @@ import android.net.Uri;
|
|||||||
|
|
||||||
import org.libreoffice.canvas.SelectionHandle;
|
import org.libreoffice.canvas.SelectionHandle;
|
||||||
import org.libreoffice.kit.Document;
|
import org.libreoffice.kit.Document;
|
||||||
import org.libreoffice.overlay.TextCursorLayer;
|
import org.libreoffice.overlay.DocumentOverlay;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -17,11 +17,11 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class InvalidationHandler implements Document.MessageCallback {
|
public class InvalidationHandler implements Document.MessageCallback {
|
||||||
private static String LOGTAG = InvalidationHandler.class.getSimpleName();
|
private static String LOGTAG = InvalidationHandler.class.getSimpleName();
|
||||||
private final TextCursorLayer mTextCursorLayer;
|
private final DocumentOverlay mDocumentOverlay;
|
||||||
private OverlayState mState;
|
private OverlayState mState;
|
||||||
|
|
||||||
public InvalidationHandler(LibreOfficeMainActivity mainActivity) {
|
public InvalidationHandler(LibreOfficeMainActivity mainActivity) {
|
||||||
mTextCursorLayer = mainActivity.getTextCursorLayer();
|
mDocumentOverlay = mainActivity.getDocumentOverlay();
|
||||||
mState = OverlayState.NONE;
|
mState = OverlayState.NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,8 +147,8 @@ public class InvalidationHandler implements Document.MessageCallback {
|
|||||||
private synchronized void invalidateCursor(String payload) {
|
private synchronized void invalidateCursor(String payload) {
|
||||||
RectF cursorRectangle = convertPayloadToRectangle(payload);
|
RectF cursorRectangle = convertPayloadToRectangle(payload);
|
||||||
if (cursorRectangle != null) {
|
if (cursorRectangle != null) {
|
||||||
mTextCursorLayer.positionCursor(cursorRectangle);
|
mDocumentOverlay.positionCursor(cursorRectangle);
|
||||||
mTextCursorLayer.positionHandle(SelectionHandle.HandleType.MIDDLE, cursorRectangle);
|
mDocumentOverlay.positionHandle(SelectionHandle.HandleType.MIDDLE, cursorRectangle);
|
||||||
|
|
||||||
if (mState == OverlayState.TRANSITION || mState == OverlayState.CURSOR) {
|
if (mState == OverlayState.TRANSITION || mState == OverlayState.CURSOR) {
|
||||||
changeStateTo(OverlayState.CURSOR);
|
changeStateTo(OverlayState.CURSOR);
|
||||||
@@ -164,7 +164,7 @@ public class InvalidationHandler implements Document.MessageCallback {
|
|||||||
private synchronized void textSelectionStart(String payload) {
|
private synchronized void textSelectionStart(String payload) {
|
||||||
RectF selectionRect = convertPayloadToRectangle(payload);
|
RectF selectionRect = convertPayloadToRectangle(payload);
|
||||||
if (selectionRect != null) {
|
if (selectionRect != null) {
|
||||||
mTextCursorLayer.positionHandle(SelectionHandle.HandleType.START, selectionRect);
|
mDocumentOverlay.positionHandle(SelectionHandle.HandleType.START, selectionRect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,7 +176,7 @@ public class InvalidationHandler implements Document.MessageCallback {
|
|||||||
private synchronized void textSelectionEnd(String payload) {
|
private synchronized void textSelectionEnd(String payload) {
|
||||||
RectF selectionRect = convertPayloadToRectangle(payload);
|
RectF selectionRect = convertPayloadToRectangle(payload);
|
||||||
if (selectionRect != null) {
|
if (selectionRect != null) {
|
||||||
mTextCursorLayer.positionHandle(SelectionHandle.HandleType.END, selectionRect);
|
mDocumentOverlay.positionHandle(SelectionHandle.HandleType.END, selectionRect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,14 +190,14 @@ public class InvalidationHandler implements Document.MessageCallback {
|
|||||||
if (mState == OverlayState.SELECTION) {
|
if (mState == OverlayState.SELECTION) {
|
||||||
changeStateTo(OverlayState.TRANSITION);
|
changeStateTo(OverlayState.TRANSITION);
|
||||||
}
|
}
|
||||||
mTextCursorLayer.changeSelections(Collections.EMPTY_LIST);
|
mDocumentOverlay.changeSelections(Collections.EMPTY_LIST);
|
||||||
} else {
|
} else {
|
||||||
List<RectF> rectangles = convertPayloadToRectangles(payload);
|
List<RectF> rectangles = convertPayloadToRectangles(payload);
|
||||||
if (mState != OverlayState.SELECTION) {
|
if (mState != OverlayState.SELECTION) {
|
||||||
changeStateTo(OverlayState.TRANSITION);
|
changeStateTo(OverlayState.TRANSITION);
|
||||||
}
|
}
|
||||||
changeStateTo(OverlayState.SELECTION);
|
changeStateTo(OverlayState.SELECTION);
|
||||||
mTextCursorLayer.changeSelections(rectangles);
|
mDocumentOverlay.changeSelections(rectangles);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -208,13 +208,13 @@ public class InvalidationHandler implements Document.MessageCallback {
|
|||||||
*/
|
*/
|
||||||
private synchronized void cursorVisibility(String payload) {
|
private synchronized void cursorVisibility(String payload) {
|
||||||
if (payload.equals("true")) {
|
if (payload.equals("true")) {
|
||||||
mTextCursorLayer.showCursor();
|
mDocumentOverlay.showCursor();
|
||||||
if (mState != OverlayState.SELECTION) {
|
if (mState != OverlayState.SELECTION) {
|
||||||
mTextCursorLayer.showHandle(SelectionHandle.HandleType.MIDDLE);
|
mDocumentOverlay.showHandle(SelectionHandle.HandleType.MIDDLE);
|
||||||
}
|
}
|
||||||
} else if (payload.equals("false")) {
|
} else if (payload.equals("false")) {
|
||||||
mTextCursorLayer.hideCursor();
|
mDocumentOverlay.hideCursor();
|
||||||
mTextCursorLayer.hideHandle(SelectionHandle.HandleType.MIDDLE);
|
mDocumentOverlay.hideHandle(SelectionHandle.HandleType.MIDDLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,7 +230,7 @@ public class InvalidationHandler implements Document.MessageCallback {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
RectF rectangle = convertPayloadToRectangle(payload);
|
RectF rectangle = convertPayloadToRectangle(payload);
|
||||||
mTextCursorLayer.changeGraphicSelection(rectangle);
|
mDocumentOverlay.changeGraphicSelection(rectangle);
|
||||||
if (mState != OverlayState.GRAPHIC_SELECTION) {
|
if (mState != OverlayState.GRAPHIC_SELECTION) {
|
||||||
changeStateTo(OverlayState.TRANSITION);
|
changeStateTo(OverlayState.TRANSITION);
|
||||||
}
|
}
|
||||||
@@ -293,12 +293,12 @@ public class InvalidationHandler implements Document.MessageCallback {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Just hide everything
|
// Just hide everything
|
||||||
mTextCursorLayer.hideHandle(SelectionHandle.HandleType.START);
|
mDocumentOverlay.hideHandle(SelectionHandle.HandleType.START);
|
||||||
mTextCursorLayer.hideHandle(SelectionHandle.HandleType.END);
|
mDocumentOverlay.hideHandle(SelectionHandle.HandleType.END);
|
||||||
mTextCursorLayer.hideHandle(SelectionHandle.HandleType.MIDDLE);
|
mDocumentOverlay.hideHandle(SelectionHandle.HandleType.MIDDLE);
|
||||||
mTextCursorLayer.hideSelections();
|
mDocumentOverlay.hideSelections();
|
||||||
mTextCursorLayer.hideCursor();
|
mDocumentOverlay.hideCursor();
|
||||||
mTextCursorLayer.hideGraphicSelection();
|
mDocumentOverlay.hideGraphicSelection();
|
||||||
LibreOfficeMainActivity.mAppContext.hideSoftKeyboard();
|
LibreOfficeMainActivity.mAppContext.hideSoftKeyboard();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -306,9 +306,9 @@ public class InvalidationHandler implements Document.MessageCallback {
|
|||||||
* Handle a transition to OverlayState.SELECTION state.
|
* Handle a transition to OverlayState.SELECTION state.
|
||||||
*/
|
*/
|
||||||
private void handleSelectionState(OverlayState previous) {
|
private void handleSelectionState(OverlayState previous) {
|
||||||
mTextCursorLayer.showHandle(SelectionHandle.HandleType.START);
|
mDocumentOverlay.showHandle(SelectionHandle.HandleType.START);
|
||||||
mTextCursorLayer.showHandle(SelectionHandle.HandleType.END);
|
mDocumentOverlay.showHandle(SelectionHandle.HandleType.END);
|
||||||
mTextCursorLayer.showSelections();
|
mDocumentOverlay.showSelections();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -317,8 +317,8 @@ public class InvalidationHandler implements Document.MessageCallback {
|
|||||||
private void handleCursorState(OverlayState previous) {
|
private void handleCursorState(OverlayState previous) {
|
||||||
LibreOfficeMainActivity.mAppContext.showSoftKeyboard();
|
LibreOfficeMainActivity.mAppContext.showSoftKeyboard();
|
||||||
if (previous == OverlayState.TRANSITION) {
|
if (previous == OverlayState.TRANSITION) {
|
||||||
mTextCursorLayer.showHandle(SelectionHandle.HandleType.MIDDLE);
|
mDocumentOverlay.showHandle(SelectionHandle.HandleType.MIDDLE);
|
||||||
mTextCursorLayer.showCursor();
|
mDocumentOverlay.showCursor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -327,13 +327,13 @@ public class InvalidationHandler implements Document.MessageCallback {
|
|||||||
*/
|
*/
|
||||||
private void handleTransitionState(OverlayState previous) {
|
private void handleTransitionState(OverlayState previous) {
|
||||||
if (previous == OverlayState.SELECTION) {
|
if (previous == OverlayState.SELECTION) {
|
||||||
mTextCursorLayer.hideHandle(SelectionHandle.HandleType.START);
|
mDocumentOverlay.hideHandle(SelectionHandle.HandleType.START);
|
||||||
mTextCursorLayer.hideHandle(SelectionHandle.HandleType.END);
|
mDocumentOverlay.hideHandle(SelectionHandle.HandleType.END);
|
||||||
mTextCursorLayer.hideSelections();
|
mDocumentOverlay.hideSelections();
|
||||||
} else if (previous == OverlayState.CURSOR) {
|
} else if (previous == OverlayState.CURSOR) {
|
||||||
mTextCursorLayer.hideHandle(SelectionHandle.HandleType.MIDDLE);
|
mDocumentOverlay.hideHandle(SelectionHandle.HandleType.MIDDLE);
|
||||||
} else if (previous == OverlayState.GRAPHIC_SELECTION) {
|
} else if (previous == OverlayState.GRAPHIC_SELECTION) {
|
||||||
mTextCursorLayer.hideGraphicSelection();
|
mDocumentOverlay.hideGraphicSelection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -341,7 +341,7 @@ public class InvalidationHandler implements Document.MessageCallback {
|
|||||||
* Handle a transition to OverlayState.GRAPHIC_SELECTION state.
|
* Handle a transition to OverlayState.GRAPHIC_SELECTION state.
|
||||||
*/
|
*/
|
||||||
private void handleGraphicSelectionState(OverlayState previous) {
|
private void handleGraphicSelectionState(OverlayState previous) {
|
||||||
mTextCursorLayer.showGraphicSelection();
|
mDocumentOverlay.showGraphicSelection();
|
||||||
LibreOfficeMainActivity.mAppContext.hideSoftKeyboard();
|
LibreOfficeMainActivity.mAppContext.hideSoftKeyboard();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -18,7 +18,7 @@ import android.widget.AdapterView;
|
|||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import org.libreoffice.overlay.TextCursorLayer;
|
import org.libreoffice.overlay.DocumentOverlay;
|
||||||
import org.mozilla.gecko.ZoomConstraints;
|
import org.mozilla.gecko.ZoomConstraints;
|
||||||
import org.mozilla.gecko.gfx.GeckoLayerClient;
|
import org.mozilla.gecko.gfx.GeckoLayerClient;
|
||||||
import org.mozilla.gecko.gfx.LayerView;
|
import org.mozilla.gecko.gfx.LayerView;
|
||||||
@@ -52,7 +52,7 @@ public class LibreOfficeMainActivity extends ActionBarActivity {
|
|||||||
private List<DocumentPartView> mDocumentPartView = new ArrayList<DocumentPartView>();
|
private List<DocumentPartView> mDocumentPartView = new ArrayList<DocumentPartView>();
|
||||||
private DocumentPartViewListAdapter mDocumentPartViewListAdapter;
|
private DocumentPartViewListAdapter mDocumentPartViewListAdapter;
|
||||||
private String mInputFile;
|
private String mInputFile;
|
||||||
private TextCursorLayer mTextCursorLayer;
|
private DocumentOverlay mDocumentOverlay;
|
||||||
private File mTempFile = null;
|
private File mTempFile = null;
|
||||||
private LOAbout mAbout;
|
private LOAbout mAbout;
|
||||||
private ToolbarController mToolbarController;
|
private ToolbarController mToolbarController;
|
||||||
@@ -175,7 +175,7 @@ public class LibreOfficeMainActivity extends ActionBarActivity {
|
|||||||
mLayerClient.notifyReady();
|
mLayerClient.notifyReady();
|
||||||
|
|
||||||
// create TextCursorLayer
|
// create TextCursorLayer
|
||||||
mTextCursorLayer = new TextCursorLayer(mAppContext, layerView);
|
mDocumentOverlay = new DocumentOverlay(mAppContext, layerView);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean copyFileToTemp() {
|
private boolean copyFileToTemp() {
|
||||||
@@ -342,8 +342,8 @@ public class LibreOfficeMainActivity extends ActionBarActivity {
|
|||||||
alertDialog.show();
|
alertDialog.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
public TextCursorLayer getTextCursorLayer() {
|
public DocumentOverlay getDocumentOverlay() {
|
||||||
return mTextCursorLayer;
|
return mDocumentOverlay;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ToolbarController getToolbarController() {
|
public ToolbarController getToolbarController() {
|
||||||
|
@@ -22,19 +22,20 @@ import org.mozilla.gecko.util.FloatUtils;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The TextCursorLayer is a layer which is responsible for showing the cursor and
|
* The DocumentOverlay is an overlay over the document. This class is responsible
|
||||||
* controls its position, height and visibility.
|
* to setup the document overlay view, report visibility and position of its elements
|
||||||
|
* when they change and report any changes to the viewport.
|
||||||
*/
|
*/
|
||||||
public class TextCursorLayer extends Layer {
|
public class DocumentOverlay extends Layer {
|
||||||
private static final String LOGTAG = TextCursorLayer.class.getSimpleName();
|
private static final String LOGTAG = DocumentOverlay.class.getSimpleName();
|
||||||
|
|
||||||
private final TextCursorView mCursorView;
|
private final DocumentOverlayView mCursorView;
|
||||||
private float mViewLeft;
|
private float mViewLeft;
|
||||||
private float mViewTop;
|
private float mViewTop;
|
||||||
private float mViewZoom;
|
private float mViewZoom;
|
||||||
|
|
||||||
public TextCursorLayer(Activity context, LayerView layerView) {
|
public DocumentOverlay(Activity context, LayerView layerView) {
|
||||||
mCursorView = (TextCursorView) context.findViewById(R.id.text_cursor_view);
|
mCursorView = (DocumentOverlayView) context.findViewById(R.id.text_cursor_view);
|
||||||
if (mCursorView == null) {
|
if (mCursorView == null) {
|
||||||
Log.e(LOGTAG, "Failed to initialize TextCursorLayer - CursorView is null");
|
Log.e(LOGTAG, "Failed to initialize TextCursorLayer - CursorView is null");
|
||||||
}
|
}
|
@@ -9,20 +9,15 @@
|
|||||||
package org.libreoffice.overlay;
|
package org.libreoffice.overlay;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Bitmap;
|
|
||||||
import android.graphics.BitmapFactory;
|
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.graphics.PointF;
|
import android.graphics.PointF;
|
||||||
import android.graphics.RectF;
|
import android.graphics.RectF;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import org.libreoffice.LOKitShell;
|
|
||||||
import org.libreoffice.R;
|
|
||||||
import org.libreoffice.canvas.Cursor;
|
import org.libreoffice.canvas.Cursor;
|
||||||
import org.libreoffice.canvas.GraphicSelection;
|
import org.libreoffice.canvas.GraphicSelection;
|
||||||
import org.libreoffice.canvas.SelectionHandle;
|
import org.libreoffice.canvas.SelectionHandle;
|
||||||
@@ -37,10 +32,11 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Text cursor view responsible to show the cursor drawable on the screen.
|
* Document overlay view is responsible for showing the client drawn overlay
|
||||||
|
* elements like cursor, selection and graphic selection, and manipulate them.
|
||||||
*/
|
*/
|
||||||
public class TextCursorView extends View implements View.OnTouchListener {
|
public class DocumentOverlayView extends View implements View.OnTouchListener {
|
||||||
private static final String LOGTAG = TextCursorView.class.getSimpleName();
|
private static final String LOGTAG = DocumentOverlayView.class.getSimpleName();
|
||||||
|
|
||||||
private static final int CURSOR_BLINK_TIME = 500;
|
private static final int CURSOR_BLINK_TIME = 500;
|
||||||
|
|
||||||
@@ -65,15 +61,15 @@ public class TextCursorView extends View implements View.OnTouchListener {
|
|||||||
|
|
||||||
private SelectionHandle mDragHandle = null;
|
private SelectionHandle mDragHandle = null;
|
||||||
|
|
||||||
public TextCursorView(Context context) {
|
public DocumentOverlayView(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TextCursorView(Context context, AttributeSet attrs) {
|
public DocumentOverlayView(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TextCursorView(Context context, AttributeSet attrs, int defStyleAttr) {
|
public DocumentOverlayView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||||
super(context, attrs, defStyleAttr);
|
super(context, attrs, defStyleAttr);
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue
Block a user