1package org.libreoffice.overlay;
3import android.content.Context;
4import android.graphics.Canvas;
5import android.graphics.PointF;
6import android.graphics.RectF;
7import androidx.core.view.GestureDetectorCompat;
8import android.util.AttributeSet;
9import android.view.GestureDetector.SimpleOnGestureListener;
10import android.view.MotionEvent;
11import android.view.View;
12import android.widget.PopupWindow;
14import org.json.JSONException;
15import org.json.JSONObject;
24import java.util.ArrayList;
25import java.util.Collections;
48 super(context, attrs);
52 super(context, attrs, defStyleAttr);
67 setOnTouchListener(
new View.OnTouchListener() {
69 public boolean onTouch(View v, MotionEvent event) {
70 if (event.getActionMasked() == MotionEvent.ACTION_UP) {
71 mPrevScrollIndex = -1;
73 return mDetector.onTouchEvent(event);
84 if (mInitialized && mDimens !=
null && mLabels !=
null) {
95 boolean inRangeOfVisibleHeaders =
false;
97 for (
int i = 1;
i < mLabels.size();
i++) {
98 if (mDimens.get(
i).equals(mDimens.get(
i-1)))
continue;
100 top = -origin.y + zoom*mDimens.get(
i-1);
101 bottom = -origin.y + zoom*mDimens.get(
i);
103 inRangeOfVisibleHeaders =
true;
104 boolean isSelected = mCellCursorRect !=
null &&
bottom > mCellCursorRect.top - origin.y &&
top < mCellCursorRect.bottom - origin.y;
107 if (inRangeOfVisibleHeaders) {
112 left = -origin.x + zoom*mDimens.get(
i-1);
113 right = -origin.x + zoom*mDimens.get(
i);
115 boolean isSelected = mCellCursorRect !=
null &&
right > mCellCursorRect.left - origin.x &&
left < mCellCursorRect.right - origin.x;
118 if (inRangeOfVisibleHeaders) {
133 JSONObject rootJson =
new JSONObject();
135 addProperty(rootJson,
"Modifier",
"unsigned short",
138 addProperty(rootJson,
"Modifier",
"unsigned short",
"0");
141 addProperty(rootJson,
"Row",
"unsigned short",
String.valueOf(
index));
144 addProperty(rootJson,
"Col",
"unsigned short",
String.valueOf(
index));
147 }
catch (JSONException e) {
154 setPendingRowOrColumnSelectionToShowUp(
true);
158 int searchedIndex,
index;
163 searchedIndex = Collections.binarySearch(mDimens, (
point.y+origin.y)/zoom);
165 searchedIndex = Collections.binarySearch(mDimens, (
point.x+origin.x)/zoom);
168 if (searchedIndex < 0) {
169 index = - searchedIndex - 2;
171 index = searchedIndex;
177 mPendingRowOrColumnSelectionToShowUp = b;
181 return mPendingRowOrColumnSelectionToShowUp;
184 public void setHeaders(ArrayList<String> labels, ArrayList<Float> dimens) {
190 mCellCursorRect = cellCursorRect;
194 if (mPopupWindow ==
null ||
197 mPopupWindow.showAsDropDown(
this, getWidth()*3/2, -getHeight()+(
int)
point.y);
199 mPopupWindow.showAsDropDown(
this, (
int)
point.x, getHeight()/2);
204 if (mPopupWindow ==
null)
return;
205 mPopupWindow.dismiss();
209 if (mPopupWindow !=
null)
return;
210 mPopupWindow = popupWindow;
214 JSONObject rootJson =
new JSONObject();
217 addProperty(rootJson,
"aExtraHeight",
"unsigned short",
text);
219 }
catch (JSONException
ex) {
220 ex.printStackTrace();
224 addProperty(rootJson,
"aExtraWidth",
"unsigned short",
text);
226 }
catch (JSONException
ex) {
227 ex.printStackTrace();
241 PointF pointOfTouch =
new PointF(e.getX(), e.getY());
242 highlightRowOrColumn(pointOfTouch,
false);
243 showHeaderPopup(pointOfTouch);
248 public boolean onScroll(MotionEvent e1, MotionEvent e2,
float distanceX,
float distanceY) {
249 PointF point2 =
new PointF(e2.getX(), e2.getY());
250 if (mPrevScrollIndex != getIndexFromPointOfTouch(point2)) {
251 mPrevScrollIndex = getIndexFromPointOfTouch(point2);
252 highlightRowOrColumn(point2,
true);
253 dismissPopupWindow();
254 showHeaderPopup(point2);
261 PointF pointOfTouch =
new PointF(e.getX(), e.getY());
262 highlightRowOrColumn(pointOfTouch,
false);
264 JSONObject rootJson =
new JSONObject();
266 addProperty(rootJson,
"aExtraHeight",
"unsigned short",
String.valueOf(0));
267 }
catch (JSONException
ex) {
268 ex.printStackTrace();
274 showHeaderPopup(pointOfTouch);
Events and data that is queued and processed by LOKitThread.
static final int UNO_COMMAND
Common static LOKit functions, functions to send events.
static void sendEvent(LOEvent event)
Make sure LOKitThread is running and send event to it.
static Handler getMainHandler()
Main activity of the LibreOffice App.
static boolean isExperimentalMode()
static void addProperty(JSONObject json, String parentValue, String type, String value)
ImmutableViewportMetrics are used to store the viewport metrics in way that we can access a version o...
A view rendered by the layer compositor.
def run(arg=None, arg2=-1)