mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Hook up wesj's long press code (40e3d6b1122d) again
This commit is contained in:
parent
00fed2a2bb
commit
8e424a3459
@ -1,96 +0,0 @@
|
||||
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Android code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2011
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Wes Johnston <wjohnston@mozilla.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
package org.mozilla.gecko;
|
||||
|
||||
import android.view.GestureDetector;
|
||||
import android.view.MotionEvent;
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import android.util.Log;
|
||||
|
||||
class GeckoGestureDetector implements GestureDetector.OnGestureListener {
|
||||
private GestureDetector mDetector;
|
||||
private static final String LOG_FILE_NAME = "GeckoGestureDetector";
|
||||
public GeckoGestureDetector(Context aContext) {
|
||||
mDetector = new GestureDetector(aContext, this);
|
||||
}
|
||||
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
return mDetector.onTouchEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onDown(MotionEvent e) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLongPress(MotionEvent motionEvent) {
|
||||
JSONObject ret = new JSONObject();
|
||||
try {
|
||||
ret.put("x", motionEvent.getX());
|
||||
ret.put("y", motionEvent.getY());
|
||||
} catch(Exception ex) {
|
||||
Log.w(LOG_FILE_NAME, "Error building return: " + ex);
|
||||
}
|
||||
|
||||
GeckoEvent e = new GeckoEvent("Gesture:LongPress", ret.toString());
|
||||
GeckoAppShell.sendEventToGecko(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onShowPress(MotionEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSingleTapUp(MotionEvent e) {
|
||||
return true;
|
||||
}
|
||||
}
|
@ -61,7 +61,6 @@ JAVAFILES = \
|
||||
GeckoEventListener.java \
|
||||
GeckoInputConnection.java \
|
||||
GeckoPreferences.java \
|
||||
GeckoGestureDetector.java \
|
||||
GlobalHistory.java \
|
||||
PromptService.java \
|
||||
SurfaceInfo.java \
|
||||
|
@ -49,6 +49,7 @@ import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.util.Log;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.GestureDetector;
|
||||
import android.view.ScaleGestureDetector;
|
||||
import android.view.View.OnTouchListener;
|
||||
import java.util.ArrayList;
|
||||
@ -121,6 +122,7 @@ public class LayerController {
|
||||
public Bitmap getCheckerboardPattern() { return getDrawable("checkerboard"); }
|
||||
public Bitmap getShadowPattern() { return getDrawable("shadow"); }
|
||||
|
||||
public GestureDetector.OnGestureListener getGestureListener() { return mPanZoomController; }
|
||||
public ScaleGestureDetector.OnScaleGestureListener getScaleGestureListener() { return mPanZoomController; }
|
||||
|
||||
private Bitmap getDrawable(String name) {
|
||||
|
@ -59,6 +59,7 @@ public class LayerView extends GLSurfaceView {
|
||||
private LayerController mController;
|
||||
private InputConnectionHandler mInputConnectionHandler;
|
||||
private LayerRenderer mRenderer;
|
||||
private GestureDetector mGestureDetector;
|
||||
private ScaleGestureDetector mScaleGestureDetector;
|
||||
|
||||
public LayerView(Context context, LayerController controller) {
|
||||
@ -68,6 +69,7 @@ public class LayerView extends GLSurfaceView {
|
||||
mController = controller;
|
||||
mRenderer = new LayerRenderer(this);
|
||||
setRenderer(mRenderer);
|
||||
mGestureDetector = new GestureDetector(context, controller.getGestureListener());
|
||||
mScaleGestureDetector = new ScaleGestureDetector(context, controller.getScaleGestureListener());
|
||||
mInputConnectionHandler = null;
|
||||
|
||||
@ -77,6 +79,8 @@ public class LayerView extends GLSurfaceView {
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
if (mGestureDetector.onTouchEvent(event))
|
||||
return true;
|
||||
mScaleGestureDetector.onTouchEvent(event);
|
||||
if (mScaleGestureDetector.isInProgress())
|
||||
return true;
|
||||
|
@ -37,11 +37,15 @@
|
||||
|
||||
package org.mozilla.fennec.ui;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.mozilla.fennec.gfx.IntPoint;
|
||||
import org.mozilla.fennec.gfx.IntRect;
|
||||
import org.mozilla.fennec.gfx.IntSize;
|
||||
import org.mozilla.fennec.gfx.LayerController;
|
||||
import org.mozilla.gecko.GeckoAppShell;
|
||||
import org.mozilla.gecko.GeckoEvent;
|
||||
import android.util.Log;
|
||||
import android.view.GestureDetector;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.ScaleGestureDetector;
|
||||
import java.util.Timer;
|
||||
@ -53,7 +57,12 @@ import java.util.TimerTask;
|
||||
* Many ideas are from Joe Hewitt's Scrollability:
|
||||
* https://github.com/joehewitt/scrollability/
|
||||
*/
|
||||
public class PanZoomController implements ScaleGestureDetector.OnScaleGestureListener {
|
||||
public class PanZoomController
|
||||
extends GestureDetector.SimpleOnGestureListener
|
||||
implements ScaleGestureDetector.OnScaleGestureListener
|
||||
{
|
||||
private static final String LOG_NAME = "PanZoomController";
|
||||
|
||||
private LayerController mController;
|
||||
|
||||
private static final float FRICTION = 0.97f;
|
||||
@ -507,5 +516,22 @@ public class PanZoomController implements ScaleGestureDetector.OnScaleGestureLis
|
||||
public void onScaleEnd(ScaleGestureDetector detector) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLongPress(MotionEvent motionEvent) {
|
||||
JSONObject ret = new JSONObject();
|
||||
try {
|
||||
IntPoint point = new IntPoint((int)Math.round(motionEvent.getX()),
|
||||
(int)Math.round(motionEvent.getY()));
|
||||
point = mController.convertViewPointToLayerPoint(point);
|
||||
ret.put("x", point.x);
|
||||
ret.put("y", point.y);
|
||||
Log.e(LOG_NAME, "Long press at " + motionEvent.getX() + ", " + motionEvent.getY());
|
||||
} catch(Exception ex) {
|
||||
Log.w(LOG_NAME, "Error building return: " + ex);
|
||||
}
|
||||
|
||||
GeckoEvent e = new GeckoEvent("Gesture:LongPress", ret.toString());
|
||||
GeckoAppShell.sendEventToGecko(e);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user