Kaydet (Commit) d5ad8429 authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl Kaydeden (comit) Miklos Vajna

android: send selection/cursor change from TextSelectionHandle

Change-Id: Iac570c890717d8e2dcfde7f29da996c809df81dc
üst b2753b46
...@@ -74,51 +74,33 @@ public class TextSelectionHandle extends ImageView implements View.OnTouchListen ...@@ -74,51 +74,33 @@ public class TextSelectionHandle extends ImageView implements View.OnTouchListen
case MotionEvent.ACTION_UP: { case MotionEvent.ACTION_UP: {
mTouchStartX = 0; mTouchStartX = 0;
mTouchStartY = 0; mTouchStartY = 0;
// Reposition handles to line up with ends of selection
JSONObject args = new JSONObject();
try {
args.put("handleType", mHandleType.toString());
} catch (Exception e) {
Log.e(LOGTAG, "Error building JSON arguments for TextSelection:Position");
}
//GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("TextSelection:Position", args.toString()));
break; break;
} }
case MotionEvent.ACTION_MOVE: { case MotionEvent.ACTION_MOVE: {
move(Math.round(event.getX()), Math.round(event.getY())); move(event.getX(), event.getY());
break; break;
} }
} }
return true; return true;
} }
private void move(int newX, int newY) { private void move(float newX, float newY) {
mLeft = mLeft + newX - mTouchStartX;
mTop = mTop + newY - mTouchStartY;
LayerView layerView = LOKitShell.getLayerView(); LayerView layerView = LOKitShell.getLayerView();
if (layerView == null) { if (layerView == null) {
Log.e(LOGTAG, "Can't move selection because layerView is null"); Log.e(LOGTAG, "Can't move selection because layerView is null");
return; return;
} }
float newLeft = mLeft + newX - mTouchStartX;
float newTop = mTop + newY - mTouchStartY;
// Send x coordinate on the right side of the start handle, left side of the end handle. // Send x coordinate on the right side of the start handle, left side of the end handle.
float left = (float) mLeft + adjustLeftForHandle(); float left = (float) newLeft + adjustLeftForHandle();
PointF geckoPoint = new PointF(left, (float) mTop);
geckoPoint = layerView.getLayerClient().convertViewPointToLayerPoint(geckoPoint);
JSONObject args = new JSONObject();
try {
args.put("handleType", mHandleType.toString());
args.put("x", Math.round(geckoPoint.x));
args.put("y", Math.round(geckoPoint.y));
} catch (Exception e) {
Log.e(LOGTAG, "Error building JSON arguments for TextSelection:Move");
}
//GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("TextSelection:Move", args.toString()));
setLayoutPosition(); PointF documentPoint = new PointF(left, newTop);
documentPoint = layerView.getLayerClient().convertViewPointToLayerPoint(documentPoint);
LOKitShell.sendChangeHandlePositionEvent(mHandleType, documentPoint);
} }
void positionFromGecko(int left, int top, boolean rtl) { void positionFromGecko(int left, int top, boolean rtl) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment