summaryrefslogtreecommitdiff
path: root/android/experimental/LOAndroid3/src/java
diff options
context:
space:
mode:
Diffstat (limited to 'android/experimental/LOAndroid3/src/java')
-rw-r--r--android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java13
-rw-r--r--android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java9
-rw-r--r--android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/JavaPanZoomController.java24
3 files changed, 46 insertions, 0 deletions
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java
index 38c13ca345f6..99f994864234 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java
@@ -156,6 +156,19 @@ public class LOKitShell {
public static void sendNavigationClickEvent() {
LOKitShell.sendEvent(new LOEvent(LOEvent.NAVIGATION_CLICK));
}
+
+ /**
+ * Move the viewport to the desired point, and change the zoom level.
+ * Ensure this runs on the UI thread.
+ */
+ public static void moveViewportTo(final PointF position, final Float zoom) {
+ getLayerView().getLayerClient().post(new Runnable() {
+ @Override
+ public void run() {
+ getLayerView().getLayerClient().moveTo(position, zoom);
+ }
+ });
+ }
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java
index 40fb8bb9c926..bb6e3d04e4fb 100644
--- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java
+++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java
@@ -324,6 +324,15 @@ public class GeckoLayerClient implements PanZoomTarget {
}
}
+ /**
+ * Move the viewport to the desired point, and change the zoom level.
+ */
+ public void moveTo(PointF point, Float zoom) {
+ if (mPanZoomController instanceof JavaPanZoomController) {
+ ((JavaPanZoomController) mPanZoomController).animatedMove(point, zoom);
+ }
+ }
+
public void zoomTo(float pageWidth, float pageHeight) {
zoomTo(new RectF(0, 0, pageWidth, pageHeight));
}
diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/JavaPanZoomController.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/JavaPanZoomController.java
index adae23a428fe..0811c26105a1 100644
--- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/JavaPanZoomController.java
+++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/JavaPanZoomController.java
@@ -1021,6 +1021,30 @@ public class JavaPanZoomController
return true;
}
+ /**
+ * Move to centerPosition and zoom to the desired input zoom factor. Input zoom
+ * factor can be null, in this case leave the zoom unchanged.
+ */
+ public boolean animatedMove(PointF centerPoint, Float zoom) {
+ RectF moveToRect = getMetrics().getCssViewport();
+ moveToRect.offsetTo(
+ centerPoint.x - moveToRect.width() / 2.0f,
+ centerPoint.y - moveToRect.height() / 2.0f);
+
+ ImmutableViewportMetrics finalMetrics = getMetrics();
+ finalMetrics = finalMetrics.setViewportOrigin(
+ moveToRect.left * finalMetrics.zoomFactor,
+ moveToRect.top * finalMetrics.zoomFactor);
+
+ if (zoom != null) {
+ finalMetrics = finalMetrics.scaleTo(zoom, new PointF(0.0f, 0.0f));
+ }
+ finalMetrics = getValidViewportMetrics(finalMetrics);
+
+ bounce(finalMetrics, PanZoomState.ANIMATED_ZOOM);
+ return true;
+ }
+
/** This function must be called from the UI thread. */
public void abortPanning() {
checkMainThread();