diff options
Diffstat (limited to 'android')
4 files changed, 49 insertions, 27 deletions
diff --git a/android/Bootstrap/src/org/libreoffice/android/AppSupport.java b/android/Bootstrap/src/org/libreoffice/android/AppSupport.java new file mode 100644 index 000000000000..ef37f183e074 --- /dev/null +++ b/android/Bootstrap/src/org/libreoffice/android/AppSupport.java @@ -0,0 +1,31 @@ +// -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- +// +// This file is part of the LibreOffice project. +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +// Native functions that are used by "desktop" approach apps. That means apps +// that have a "real" LibreOffice "main loop" running (headless). + +package org.libreoffice.android; + +import android.graphics.Bitmap; + +public final class AppSupport +{ + /* In desktop */ + public static native void runMain(); + + /* In vcl */ + public static native void renderVCL(Bitmap bitmap); + public static native void registerForDamageCallback(Class destinationClass); + public static native void setViewSize(int width, int height); + public static native void key(char c); + public static native void touch(int action, int x, int y); + public static native void zoom(float scale, int x, int y); + public static native void scroll(int x, int y); +} + +// vim:set shiftwidth=4 softtabstop=4 expandtab: diff --git a/android/experimental/desktop/native-code.cxx b/android/experimental/desktop/native-code.cxx index ca80bdfd7b4f..3b86d464bb60 100644 --- a/android/experimental/desktop/native-code.cxx +++ b/android/experimental/desktop/native-code.cxx @@ -151,11 +151,11 @@ lo_get_libmap(void) // Guard against possible function-level link-time pruning of // "unused" code. We need to pull these in, too, as they aren't in // any of the libs we link with -Wl,--whole-archive. Is this necessary? - extern void Java_org_libreoffice_experimental_desktop_Desktop_runMain(); - volatile void *p = (void *) Java_org_libreoffice_experimental_desktop_Desktop_runMain; + extern void Java_org_libreoffice_android_AppSupport_runMain(); + volatile void *p = (void *) Java_org_libreoffice_android_AppSupport_runMain; - extern void Java_org_libreoffice_experimental_desktop_Desktop_renderVCL(); - p = (void *) Java_org_libreoffice_experimental_desktop_Desktop_renderVCL; + extern void Java_org_libreoffice_android_AppSupport_renderVCL(); + p = (void *) Java_org_libreoffice_android_AppSupport_renderVCL; return map; } diff --git a/android/experimental/desktop/project.properties b/android/experimental/desktop/project.properties index 06b2d880c3d4..cffbf1ffe426 100644 --- a/android/experimental/desktop/project.properties +++ b/android/experimental/desktop/project.properties @@ -10,5 +10,4 @@ # Project target. target=android-14 -# Use the Bootstrap class android.library.reference.1=../../Bootstrap diff --git a/android/experimental/desktop/src/org/libreoffice/experimental/desktop/Desktop.java b/android/experimental/desktop/src/org/libreoffice/experimental/desktop/Desktop.java index 59e59943d0e4..b24b0d70665e 100644 --- a/android/experimental/desktop/src/org/libreoffice/experimental/desktop/Desktop.java +++ b/android/experimental/desktop/src/org/libreoffice/experimental/desktop/Desktop.java @@ -34,6 +34,7 @@ import android.view.inputmethod.InputMethodManager; import com.sun.star.awt.Key; +import org.libreoffice.android.AppSupport; import org.libreoffice.android.Bootstrap; public class Desktop @@ -41,17 +42,6 @@ public class Desktop { private static final String TAG = "LODesktop"; - /* In desktop */ - private static native void runMain(); - - /* In vcl */ - public static native void renderVCL(Bitmap bitmap); - public static native void setViewSize(int width, int height); - public static native void key(char c); - public static native void touch(int action, int x, int y); - public static native void zoom(float scale, int x, int y); - public static native void scroll(int x, int y); - /** * This class contains the state that is initialized once and never changes * (not specific to a document or a view). @@ -142,6 +132,8 @@ public class Desktop theView = new BitmapView(); setContentView(theView); + AppSupport.registerForDamageCallback(getClass()); + // Start a Java thread to run soffice_main(). We don't // want to start the thread from native code becauce // native threads apparently have no Java class loaders in @@ -152,7 +144,7 @@ public class Desktop new Thread(new Runnable() { @Override public void run() { - runMain(); + AppSupport.runMain(); } }).start(); } @@ -223,7 +215,7 @@ public class Desktop @Override public void onScaleEnd(ScaleGestureDetector detector) { accumulatedScale *= detector.getScaleFactor(); - Desktop.zoom(accumulatedScale, (int) pivotX, (int) pivotY); + AppSupport.zoom(accumulatedScale, (int) pivotX, (int) pivotY); accumulatedScale = 1; pivotX = pivotY = 0; scalingInProgress = false; @@ -237,9 +229,9 @@ public class Desktop if (mBitmap == null) { Log.i(TAG, "calling Bitmap.createBitmap(" + getWidth() + ", " + getHeight() + ", Bitmap.Config.ARGB_8888)"); mBitmap = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.ARGB_8888); - setViewSize(getWidth(), getHeight()); + AppSupport.setViewSize(getWidth(), getHeight()); } - renderVCL(mBitmap); + AppSupport.renderVCL(mBitmap); if (scrollInProgress) { canvas.save(); canvas.translate(translateX, translateY); @@ -269,16 +261,16 @@ public class Desktop case KeyEvent.KEYCODE_7: case KeyEvent.KEYCODE_8: case KeyEvent.KEYCODE_9: - Desktop.key((char) ('0' + keyCode - KeyEvent.KEYCODE_0)); + AppSupport.key((char) ('0' + keyCode - KeyEvent.KEYCODE_0)); return true; case KeyEvent.KEYCODE_DEL: - Desktop.key((char) Key.BACKSPACE); + AppSupport.key((char) Key.BACKSPACE); return true; case KeyEvent.KEYCODE_ENTER: - Desktop.key((char) Key.RETURN); + AppSupport.key((char) Key.RETURN); return true; case KeyEvent.KEYCODE_TAB: - Desktop.key((char) Key.TAB); + AppSupport.key((char) Key.TAB); return true; default: return false; @@ -301,7 +293,7 @@ public class Desktop // the scroll must have ended. if (scrollInProgress) { - Desktop.scroll((int) translateX, (int) translateY); + AppSupport.scroll((int) translateX, (int) translateY); translateX = translateY = 0; scrollInProgress = false; scrollJustEnded = true; @@ -339,7 +331,7 @@ public class Desktop case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_UP: case MotionEvent.ACTION_MOVE: - Desktop.touch(event.getActionMasked(), (int) event.getX(), (int) event.getY()); + AppSupport.touch(event.getActionMasked(), (int) event.getX(), (int) event.getY()); break; } } @@ -370,7 +362,7 @@ public class Desktop @Override public boolean commitText(CharSequence text, int newCursorPosition) { for (int i = 0; i < text.length(); i++) { - Desktop.key(text.charAt(i)); + AppSupport.key(text.charAt(i)); } return true; } |