summaryrefslogtreecommitdiff
path: root/android/qa
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@suse.com>2012-12-14 14:06:26 +0000
committerMichael Meeks <michael.meeks@suse.com>2013-02-15 11:41:04 +0000
commit44db691206bf8b413dd04ffb6c762a539d3f2dc1 (patch)
tree4429155dfa31b7b205c371c57371e784e718e86b /android/qa
parent6aef5e7807a0b1ebb48da82556e9e53096c9753d (diff)
android: get the desktop demo building again.
Diffstat (limited to 'android/qa')
-rw-r--r--android/qa/desktop/AndroidManifest.xml23
-rw-r--r--android/qa/desktop/Makefile281
-rw-r--r--android/qa/desktop/fonts.conf14
-rw-r--r--android/qa/desktop/src/dummyfile0
-rw-r--r--android/qa/desktop/src/org/libreoffice/android/examples/LODesktop.java285
5 files changed, 417 insertions, 186 deletions
diff --git a/android/qa/desktop/AndroidManifest.xml b/android/qa/desktop/AndroidManifest.xml
index c76425eae532..c5a6cc0927ac 100644
--- a/android/qa/desktop/AndroidManifest.xml
+++ b/android/qa/desktop/AndroidManifest.xml
@@ -1,23 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="org.libreoffice.android.libo"
+ package="org.libreoffice.android.examples"
android:versionCode="1"
android:versionName="1.0">
- <uses-sdk android:minSdkVersion="9" />
-
- <application android:label="@string/app_name"
- android:debuggable="true">
- <!-- Bootstrap is the subclass of android.app.NativeActivity -->
- <activity android:name="org.libreoffice.android.Bootstrap"
- android:label="LibreOffice Viewer test"
- android:configChanges="orientation|keyboardHidden">
- <!-- Tell NativeActivity the name of our .so -->
- <meta-data android:name="android.app.lib_name"
- android:value="lo-bootstrap" />
+ <uses-sdk android:minSdkVersion="9"
+ android:targetSdkVersion="14"/>
+ <application android:label="LO Desktop App"
+ android:debuggable="true"
+ android:largeHeap="true"
+ android:hardwareAccelerated="true">
+ <activity android:name=".LODesktop"
+ android:label="LO Desktop App"
+ android:configChanges="keyboardHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
- <extra android:name="lo-main-library" android:value="libmergedlo" />
</intent-filter>
</activity>
</application>
diff --git a/android/qa/desktop/Makefile b/android/qa/desktop/Makefile
index f90a4220172c..d6c7ef1f941e 100644
--- a/android/qa/desktop/Makefile
+++ b/android/qa/desktop/Makefile
@@ -3,178 +3,127 @@
include ../../../config_host.mk
-BOOTSTRAPDIR=../../Bootstrap
-include $(BOOTSTRAPDIR)/Makefile.shared
+# The default target just builds.
+all: build-ant
# The package of this app
-APP_PACKAGE=org.libreoffice.android.libo
+APP_PACKAGE=org.libreoffice.android.examples
+
+BOOTSTRAPDIR=../../Bootstrap
+include $(BOOTSTRAPDIR)/Makefile.shared
# The name of the Bootstrap activity class
BOOTSTRAP=org.libreoffice.android.Bootstrap
# The default target just builds.
-all: build-ant
-
-buildrcs:
-# main sofficerc ini ...
- mkdir -p assets/program/
- echo "[Bootstrap]" > assets/program/lofficerc
- echo "Logo=1" >> assets/program/lofficerc
- echo "NativeProgress=1" >> assets/program/lofficerc
- echo "URE_BOOTSTRAP=file:///assets/program/fundamentalrc" >> assets/program/lofficerc
-# echo "RTL_LOGFILE=file:///dev/log/main" >> assets/program/lofficerc
- echo "HOME=$(APP_DATA_PATH)/files" >> assets/program/lofficerc
- echo "OSL_SOCKET_PATH=$(APP_DATA_PATH)/files" >> assets/program/lofficerc
-# - this looks useful but breaks more than it fixes ...
-# echo "DISABLE_EXTENSION_SYNCHRONIZATION=1" >> assets/program/lofficerc
-
-# fundamentalrc ini ...
- echo "[Bootstrap]" > assets/program/fundamentalrc
- echo "LO_LIB_DIR=file://$(APP_DATA_PATH)/lib/" >> assets/program/fundamentalrc
+copy-stuff:
+# Then "assets". Let the directory structure under assets mimic
+# that under solver for now.
+#
+# Please note that I have no idea what all of this is really necessary and for
+# much of this stuff being copied, no idea whether it makes any sense at all.
+# Much of this is copy-pasted from android/qa/sc/Makefile (where a couple of
+# unit tests for sc are built, and those do seem to mostly work) and
+# android/qa/desktop/Makefile (mmeeks's desktop demo, also works to some
+# extent).
+#
+ mkdir -p assets/gz.unpack/program/ure assets/lib assets/program assets/xml/ure assets/ComponentTarget/i18npool/util
+ gzip -9 <$(OUTDIR)/bin/offapi.rdb >assets/gz.unpack/program/offapi.rdb
+ gzip -9 <$(OUTDIR)/bin/oovbaapi.rdb >assets/gz.unpack/program/oovbaapi.rdb
+ gzip -9 <$(OUTDIR)/bin/types.rdb >assets/gz.unpack/program/types.rdb
+ gzip -9 <$(OUTDIR)/bin/ure/types.rdb >assets/gz.unpack/program/ure/types.rdb
+# For some reason the vnd.sun.star.expand:$LO_LIB_DIR doesn't seem to work, it expands to empty!?
+# So just hardcode the known APP_DATA_PATH for now...
+ for F in xml/services xml/ure/services; do \
+ sed -e 's!uri="vnd.sun.star.expand:$$LO_LIB_DIR/!uri="file://$(APP_DATA_PATH)/lib/!g' <$(OUTDIR)/$$F.rdb >assets/$$F.rdb; \
+ done
+ cp $(SRC_ROOT)/odk/examples/java/DocumentHandling/test/test1.odt \
+ $(SRC_ROOT)/sc/qa/unit/data/xls/border.xls \
+ $(SRC_ROOT)/sw/qa/core/data/odt/test.odt \
+ $(SRC_ROOT)/sw/qa/core/data/doc/testVba.doc \
+ assets
+ cp $(WORKDIR)/ComponentTarget/i18npool/util/i18npool.component assets/ComponentTarget/i18npool/util
+#
+ mkdir -p assets/ure/share/misc assets/share/registry/res assets/share/config/soffice.cfg
+ cp -R $(OUTDIR)/xml/*.xcd assets/share/registry
+ mv assets/share/registry/fcfg_langpack_en-US.xcd assets/share/registry/res
+ cp -R $(OUTDIR)/xml/uiconfig/* assets/share/config/soffice.cfg
+ cp -R $(OUTDIR)/xml/registry/* assets/share/registry
+#
+# Set up rc, the "inifile". See BootstrapMap::getBaseIni(). As this app
+# doesn't use soffice_main() (at least I think it shouldn't), the
+# rtl::Bootstrap::setIniFilename() call there that hardcodes
+# /assets/program/lofficerc isn't executed. Instead the hardcoding of
+# /assets/rc in BootstrapMap::getBaseIni() gets used.
+ echo '[Bootstrap]' > assets/rc
+ echo 'Logo=1' >> assets/rc
+ echo 'NativeProgress=1' >> assets/rc
+ echo 'URE_BOOTSTRAP=file:///assets/program/fundamentalrc' >> assets/rc
+# echo 'RTL_LOGFILE=file:///dev/log/main' >> assets/rc
+ echo "HOME=$(APP_DATA_PATH)/cache" >> assets/rc
+ echo "OSL_SOCKET_PATH=$(APP_DATA_PATH)/cache" >> assets/rc
+#
+# Set up fundamentalrc
+ echo '[Bootstrap]' > assets/program/fundamentalrc
+ echo "LO_LIB_DIR=file:$(APP_DATA_PATH)/lib/" >> assets/program/fundamentalrc
echo "URE_LIB_DIR=file://$(APP_DATA_PATH)/lib/" >> assets/program/fundamentalrc # checkme - is this used to find configs ?
- echo "BRAND_BASE_DIR=file:///assets" >> assets/program/fundamentalrc
+ echo 'BRAND_BASE_DIR=file:///assets' >> assets/program/fundamentalrc
echo 'CONFIGURATION_LAYERS=xcsxcu:$${BRAND_BASE_DIR}/share/registry module:$${BRAND_BASE_DIR}/share/registry/modules res:$${BRAND_BASE_DIR}/share/registry' >> assets/program/fundamentalrc
echo 'URE_BIN_DIR=file:///assets/ure/bin/dir/not-here/can-we/exec-anyway' >> assets/program/fundamentalrc
- echo 'URE_MORE_TYPES=file:///assets/ure/share/misc/types.rdb file:///assets/program/types/types.rdb' >> assets/program/fundamentalrc
- echo 'URE_MORE_SERVICES= <$$BRAND_BASE_DIR/program/services>*' >> assets/program/fundamentalrc
- echo 'BUNDLED_EXTENSIONS=$$BRAND_BASE_DIR/share/extensions' >> assets/program/fundamentalrc
- echo 'BUNDLED_EXTENSIONS_USER=$${$$BRAND_BASE_DIR/program/bootstraprc:UserInstallation}/user/extensions/bundled' >> assets/program/fundamentalrc
- echo 'TMP_EXTENSIONS=$${$$BRAND_BASE_DIR/program/bootstraprc:UserInstallation}/user/extensions/tmp' >> assets/program/fundamentalrc
- echo 'SHARED_EXTENSIONS_USER=$${$$BRAND_BASE_DIR/program/bootstraprc:UserInstallation}/user/extensions/shared' >> assets/program/fundamentalrc
- echo 'UNO_SHARED_PACKAGES=$$BRAND_BASE_DIR/share/uno_packages' >> assets/program/fundamentalrc
- echo 'UNO_SHARED_PACKAGES_CACHE=$$UNO_SHARED_PACKAGES/cache' >> assets/program/fundamentalrc
- echo 'UNO_USER_PACKAGES=$${$$BRAND_BASE_DIR/program/bootstraprc:UserInstallation}/user/uno_packages' >> assets/program/fundamentalrc
- echo 'UNO_USER_PACKAGES_CACHE=$$UNO_USER_PACKAGES/cache' >> assets/program/fundamentalrc
- echo 'PKG_BundledUnoFile=$$BUNDLED_EXTENSIONS_USER/registry/com.sun.star.comp.deployment.component.PackageRegistryBackend/unorc' >> assets/program/fundamentalrc
- echo 'PKG_SharedUnoFile=$$SHARED_EXTENSIONS_USER/registry/com.sun.star.comp.deployment.component.PackageRegistryBackend/unorc' >> assets/program/fundamentalrc
- echo 'PKG_UserUnoFile=$$UNO_USER_PACKAGES_CACHE/registry/com.sun.star.comp.deployment.component.PackageRegistryBackend/unorc' >> assets/program/fundamentalrc
-
-# unorc ini ...
- echo "[Bootstrap]" > assets/program/unorc
- echo "URE_INTERNAL_LIB_DIR=file://$(APP_DATA_PATH)/lib/" >> assets/program/unorc
- echo 'UNO_TYPES=file:///assets/ure/share/misc/types.rdb file:///assets/program/types/types.rdb $${URE_MORE_TYPES}' >> assets/program/unorc
- echo 'UNO_SERVICES=file:///assets/ure/share/misc/services.rdb $${URE_MORE_SERVICES}' >> assets/program/unorc
-# bootstraprc ini ...
- echo "[Bootstrap]" > assets/program/bootstraprc
- echo "InstallMode=<installmode>" >> assets/program/bootstraprc
- echo "ProductKey=LibreOffice 3.5" >> assets/program/bootstraprc
- echo "UserInstallation=file://$(APP_DATA_PATH)/files/.libreoffice" >> assets/program/bootstraprc
-
-# versionrc ini ...
- echo "[Version]" > assets/program/versionrc
- echo "AllLanguages=en-US" >> assets/program/versionrc
- echo "BuildVersion=" >> assets/program/versionrc
- echo "buildid=dead-beef" >> assets/program/versionrc
- echo "ExtensionUpdateURL=http://updateexte.libreoffice.org/ExtensionUpdateService/check.Update" >> assets/program/versionrc
- echo "ProductMajor=360" >> assets/program/versionrc
- echo "ProductMinor=1" >> assets/program/versionrc
- echo "ReferenceOOoMajorMinor=3.6" >> assets/program/versionrc
- echo "UpdateID=LibreOffice_3_en-US" >> assets/program/versionrc
- echo "UpdateURL=" >> assets/program/versionrc
- echo "UpdateUserAgent=<PRODUCT> (${buildid}; ${_OS}; ${_ARCH}; BundledLanguages=${AllLanguages})" >> assets/program/versionrc
- echo "Vendor=SelfCompiledGit" >> assets/program/versionrc
-
-copy-stuff: buildrcs
-#
-# Copy shared libraries we need to libs/$(ANDROID_APP_ABI) so that ant will
-# include them in the .apk.
+ echo 'URE_MORE_TYPES=$(APP_DATA_PATH)/program/offapi.rdb $(APP_DATA_PATH)/program/oovbaapi.rdb' >> assets/program/fundamentalrc
+ echo 'URE_MORE_SERVICES=file:///assets/xml/services.rdb <$$BRAND_BASE_DIR/program/services>*' >> assets/program/fundamentalrc
#
-# Copy them to obj/local/$(ANDROID_APP_ABI), too, where gdb will look for
-# them.
+# Set up unorc
+ echo '[Bootstrap]' > assets/program/unorc
+ echo "URE_INTERNAL_LIB_DIR=file://$(APP_DATA_PATH)/lib/" >> assets/program/unorc
+ echo 'UNO_TYPES=$(APP_DATA_PATH)/program/ure/types.rdb $(APP_DATA_PATH)/program/types.rdb $${URE_MORE_TYPES}' >> assets/program/unorc
+ echo 'UNO_SERVICES=file:///assets/xml/ure/services.rdb $${URE_MORE_SERVICES}' >> assets/program/unorc
#
- mkdir -p $(SODEST) $(OBJLOCAL)
+# Set up bootstraprc
+ echo '[Bootstrap]' > assets/program/bootstraprc
+ echo 'InstallMode=<installmode>' >> assets/program/bootstraprc
+ echo 'ProductKey=LibreOffice 3.6' >> assets/program/bootstraprc
+ echo "UserInstallation=file://$(APP_DATA_PATH)" >> assets/program/bootstraprc
#
-# First the most important one, liblo-bootstrap.so
- $(call COPY,$(OUTDIR)/lib/liblo-bootstrap.so)
+# Set up versionrc
+ echo '[Version]' > assets/program/versionrc
+ echo 'AllLanguages=en-US' >> assets/program/versionrc
+ echo 'BuildVersion=' >> assets/program/versionrc
+ echo 'buildid=dead-beef' >> assets/program/versionrc
+ echo 'ProductMajor=360' >> assets/program/versionrc
+ echo 'ProductMinor=1' >> assets/program/versionrc
+ echo 'ReferenceOOoMajorMinor=3.6' >> assets/program/versionrc
#
-# Libs and UNO components that we need.
+# .res files
+ mkdir -p assets/program/resource
+ cp $(OUTDIR)/bin/*en-US.res assets/program/resource
#
- for F in $(strip \
- analysislo \
- basegfxlo \
- bootstrap.uno \
- comphelpgcc3 \
- cppcanvaslo \
- embobj \
- expwrap.uno \
- gcc3_uno \
- i18nisolang1gcc3 \
- icudatalo \
- icui18nlo \
- iculelo \
- icuuclo \
- jvmaccessgcc3 \
- jvmfwk \
- libotouchlo \
- introspection.uno \
- localedata_en \
- localedata_es \
- localedata_euro \
- localedata_others \
- mergedlo \
- msfilterlo \
- ooxlo \
- reflection.uno \
- reg \
- stocservices.uno \
- store \
- test \
- tllo \
- ucbhelper4gcc3 \
- uno_cppu \
- uno_cppuhelpergcc3 \
- uno_sal \
- uno_salhelpergcc3 \
- unordflo \
- unotest \
- unoxmllo \
- vbahelperlo \
- xml2 \
- xmlreader \
- xmlsecurity \
- xslt \
- \
- swlo \
- swuilo \
- swdlo \
- \
- sclo \
- scdlo \
- scnlo \
- scuilo \
- scfiltlo \
- \
- chartcontrollerlo \
- chartcorelo \
- ); do \
- $(call COPYSO,$(OUTDIR)/lib/lib$${F}.so); \
+# Assets that are unpacked at run-time into the app's data directory. These
+# are files read by non-LO code, fontconfig and freetype for now, that doesn't
+# understand "/assets" paths.
+ mkdir -p assets/unpack/etc/fonts
+ cp fonts.conf assets/unpack/etc/fonts
+# $UserInstallation/user/fonts is added to the fontconfig path in
+# vcl/generic/fontmanager/helper.cxx: psp::getFontPath(). UserInstallation is
+# set to the app's data dir above.
+ mkdir -p assets/gz.unpack/user/fonts
+ for F in $(OUTDIR)/pck/Liberation*.ttf $(OUTDIR)/pck/Gen*.ttf $(OUTDIR)/pck/opens___.ttf; do \
+ gzip -9 <$$F >assets/gz.unpack/user/fonts/`basename $$F`; \
done
-
#
-# Then the shared GNU C++ library
- $(call COPYSO,$(ANDROID_NDK_HOME)/sources/cxx-stl/gnu-libstdc++/$(ANDROID_NDK_TOOLCHAIN_VERSION_SUBDIR)libs/$(ANDROID_APP_ABI)/libgnustl_shared.so)
+# Then gdbserver and gdb.setup so that we can debug with ndk-gdb.
#
-# Then other "assets" that can be left in the .apk. Let the directory
-# structure under assets mimic the install set - except for the fact
-# that program/ is renamed to lib/ and we put the ure/lib .so's into
-# the assets/lib directory too.
- mkdir -p assets/program/types assets/program/services
- mkdir -p assets/program/resource
- mkdir -p assets/ure/share/misc assets/share/registry/res
- mkdir -p assets/share/config/soffice.cfg
-# uno types & services
- cp $(OUTDIR)/bin/types.rdb assets/program/types/
- cp $(OUTDIR)/bin/ure/types.rdb assets/ure/share/misc/
- cp $(OUTDIR)/xml/services.rdb assets/program/services
- cp $(OUTDIR)/xml/ure/services.rdb assets/ure/share/misc/
-# config
- cp -R $(OUTDIR)/xml/*.xcd assets/share/registry/
- mv assets/share/registry/fcfg_langpack_en-US.xcd assets/share/registry/res/
- cp -R $(OUTDIR)/xml/uiconfig/* assets/share/config/soffice.cfg
+ mkdir -p $(SODEST)
+ cp $(ANDROID_NDK_GDBSERVER) $(SODEST)
+ echo set solib-search-path ./obj/local/$(ANDROID_APP_ABI) >$(SODEST)/gdb.setup
+# ------------ Pieces not from DocumentLoader ------------
+# tango artwork / icons
+ mkdir -p assets/share/config
cp -R $(OUTDIR)/bin/images_tango.zip assets/share/config/images.zip
-# .res files
- cp $(OUTDIR)/bin/*en-US.res assets/program/resource/
+# shell / splash images
+ mkdir -p assets/program
+ cp -r $(SRC_ROOT)/icon-themes/galaxy/brand/* assets/program
# presets - becomes the users home directory, .stamp forces .zip dir creation
for D in $(strip autocorr autotext backup basic config gallery \
psprint/driver psprint/fontmetric template \
@@ -182,26 +131,28 @@ copy-stuff: buildrcs
mkdir -p assets/presets/$$D ; \
echo "content" > assets/presets/$$D/stamp; \
done
-# shell / splash images
- cp -r $(SRC_ROOT)/icon-themes/galaxy/brand/* assets/program
-# Then assets that are unpacked at run-time into the app's data directory.
- mkdir -p assets/unpack/etc/fonts
- cp fonts.conf assets/unpack/etc/fonts
-# A sample file for fun ...
- mkdir -p assets/demo
- if test -f /opt/libreoffice/tmp/writer.odt; then cp /opt/libreoffice/tmp/writer.odt assets/demo; fi
+
+setup-jars:
#
-# Then gdbserver and gdb.setup so that we can debug with ndk-gdb.
+# Copy jar files we need
#
- cp $(ANDROID_NDK_GDBSERVER) $(SODEST)
- echo set solib-search-path ./obj/local/$(ANDROID_APP_ABI) >$(SODEST)/gdb.setup
+ for F in $(strip \
+ java_uno \
+ juh \
+ jurt \
+ ridl \
+ unoil \
+ unoloader \
+ ); do \
+ $(call COPYJAR,$(OUTDIR)/bin/$${F}.jar); \
+ done
-build-ant: android_version_setup copy-stuff link-so properties
+build-ant: android_version_setup copy-stuff link-so properties setup-jars
unset JAVA_HOME && $(ANT) debug
run:
echo "-env:INIFILENAME=file:///assets/program/sofficerc" > cmdline
# echo "file:///assets/demo/writer.odt" > cmdline
$(ANDROID_SDK_HOME)/platform-tools/adb push cmdline $(APP_DATA_PATH)/cmdline
- $(ANDROID_SDK_HOME)/platform-tools/adb shell am start -n $(APP_PACKAGE)/$(BOOTSTRAP) -e lo-main-delay 20 -e lo-main-indirect-cmdline "$(APP_DATA_PATH)/cmdline"
+ $(ANDROID_SDK_HOME)/platform-tools/adb shell am start -n org.libreoffice.android.exampless/LODesktop -e lo-main-delay 20 -e lo-main-indirect-cmdline "$(APP_DATA_PATH)/cmdline"
# add -e lo-strace yes # if you want that
diff --git a/android/qa/desktop/fonts.conf b/android/qa/desktop/fonts.conf
index 866df8ad776c..699e9d101048 100644
--- a/android/qa/desktop/fonts.conf
+++ b/android/qa/desktop/fonts.conf
@@ -6,26 +6,24 @@
<!-- Font directory list -->
<dir>/system/fonts</dir>
- <dir>/data/data/org.libreoffice.android.libo/fonts</dir>
<alias>
<family>serif</family>
<prefer>
- <family>DroidSerif</family>
- <family>Roboto</family>
+ <family>Droid Serif</family>
</prefer>
</alias>
<alias>
<family>sans-serif</family>
<prefer>
<family>Roboto</family>
- <family>DroidSerif</family>
+ <family>Droid Sans Fallback</family>
</prefer>
</alias>
<alias>
<family>monospace</family>
<prefer>
- <family>DroidSansMono</family>
+ <family>Droid Sans Mono</family>
</prefer>
</alias>
@@ -76,7 +74,7 @@
later to patch in proper code in fontonfig on Android to
find out a good place.
-->
- <cachedir>/data/data/org.libreoffice.android.libo/fontconfig</cachedir>
+ <cachedir>/data/data/org.libreoffice.android.examples/fontconfig</cachedir>
<config>
<!--
@@ -146,10 +144,10 @@
<int>0xFFFB</int> <!-- INTERLINEAR ANNOTATION TERMINATOR -->
</blank>
<!--
- Rescan configuration every 30 seconds when FcFontSetList is called
+ Rescan configuration every 3600 seconds when FcFontSetList is called
-->
<rescan>
- <int>30</int>
+ <int>3600</int>
</rescan>
</config>
diff --git a/android/qa/desktop/src/dummyfile b/android/qa/desktop/src/dummyfile
deleted file mode 100644
index e69de29bb2d1..000000000000
--- a/android/qa/desktop/src/dummyfile
+++ /dev/null
diff --git a/android/qa/desktop/src/org/libreoffice/android/examples/LODesktop.java b/android/qa/desktop/src/org/libreoffice/android/examples/LODesktop.java
new file mode 100644
index 000000000000..c8e79903057b
--- /dev/null
+++ b/android/qa/desktop/src/org/libreoffice/android/examples/LODesktop.java
@@ -0,0 +1,285 @@
+// -*- 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/.
+
+// This is just a testbed for ideas and implementations. (Still, it might turn
+// out to be somewhat useful as such while waiting for "real" apps.)
+
+// Important points:
+
+// Everything that might take a long time should be done asynchronously:
+// - loading the document (loadComponentFromURL())
+// - counting number of pages (getRendererCount())
+// - rendering a page (render())
+
+// Unclear whether pages can be rendered in parallel. Probably best to
+// serialize all the above in the same worker thread. We use
+// AsyncTask.SERIAL_EXECUTOR below.
+
+// While a page is loading ideally should display some animated spinner (but
+// for now just a static "please wait" text).
+
+// ===
+
+// How should we handle re-rendering at higher resolution when zooming in, and
+// then panning around?
+
+// Hopefully when LO is asked to render just a part of a page (i.e. the
+// MapMode of the device rendered to causes significant parts of the page to
+// be outside the device) the code is clever enough to quickly skip stuff that
+// will be clipped. But I don't hold my breath.
+
+// How could we do it?
+
+// 1/ Re-render just the zoomed-in area. Probably not a good idea, as probably
+// the user will almost immediately also pan a bit or zoom out a bit, which
+// would cause a re-render.
+
+// 2/ Some kind of tiled approach. Initially just one tile for the whole
+// page. When zooming in, at some point (2x?) split the currently visible
+// tiles into four sub-tiles, each initially displaying the same resolution as
+// the parent tile. Start asynchronous rendering of visible sub-tiles at
+// double resolution. Keep the "parent" rendered bitmap but don't keep bitmaps
+// that go out of view. (Except perhaps for some caching.) When zooming out,
+// at some point (0.5x?) merge four sub-tiles back into one. Hmm. Is this the
+// right approach?
+
+// In any case, also this rendering at higher resolution should be done
+// asynchronously, of course. If the user zooms in and pans around, the
+// existing bitmap will be shown scaled (and ugly) until required rendering
+// has finished and then the affected tiles are replaced with
+// higher-resolution ones.
+
+package org.libreoffice.android.examples;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.DialogInterface;
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.ColorFilter;
+import android.graphics.Matrix;
+import android.graphics.PixelFormat;
+import android.graphics.Paint;
+import android.graphics.Point;
+import android.graphics.Rect;
+import android.graphics.drawable.BitmapDrawable;
+import android.graphics.drawable.ColorDrawable;
+import android.graphics.drawable.Drawable;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.GestureDetector;
+import android.view.Gravity;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.view.MotionEvent;
+import android.view.ViewGroup;
+import android.view.animation.Animation;
+import android.view.animation.AnimationSet;
+import android.view.animation.TranslateAnimation;
+import android.widget.ImageView;
+import android.widget.NumberPicker;
+import android.widget.TextView;
+import android.widget.ViewFlipper;
+import android.widget.ViewSwitcher;
+
+import junit.framework.Assert;
+
+import com.sun.star.awt.Size;
+import com.sun.star.awt.XBitmap;
+import com.sun.star.awt.XControl;
+import com.sun.star.awt.XDevice;
+import com.sun.star.awt.XToolkitExperimental;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.frame.XComponentLoader;
+import com.sun.star.frame.XController;
+import com.sun.star.frame.XFrame;
+import com.sun.star.frame.XModel;
+import com.sun.star.lang.XEventListener;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.lang.XTypeProvider;
+import com.sun.star.uno.Type;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.view.XRenderable;
+
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.util.ArrayList;
+
+import org.libreoffice.android.Bootstrap;
+
+public class LODesktop
+ extends Activity
+{
+ private static final String TAG = "LODesktop";
+
+ /**
+ * This class contains the state that is initialized once and never changes
+ * (not specific to a document or a view).
+ */
+ class BootstrapContext
+ {
+ public long timingOverhead;
+ public XComponentContext componentContext;
+ public XMultiComponentFactory mcf;
+ public XComponentLoader componentLoader;
+ public XToolkitExperimental toolkit;
+ public XDevice dummySmallDevice;
+ }
+
+ BootstrapContext bootstrapContext;
+ Bundle extras;
+
+ class MyXController
+ implements XController
+ {
+
+ XFrame frame;
+ XModel model;
+
+ public void attachFrame(XFrame frame)
+ {
+ Log.i(TAG, "attachFrame");
+ this.frame = frame;
+ }
+
+ public boolean attachModel(XModel model)
+ {
+ Log.i(TAG, "attachModel");
+ this.model = model;
+ return true;
+ }
+
+ public boolean suspend(boolean doSuspend)
+ {
+ Log.i(TAG, "suspend");
+ return false;
+ }
+
+ public Object getViewData()
+ {
+ Log.i(TAG, "getViewData");
+ return null;
+ }
+
+ public void restoreViewData(Object data)
+ {
+ Log.i(TAG, "restoreViewData");
+ }
+
+ public XModel getModel()
+ {
+ Log.i(TAG, "getModel");
+ return model;
+ }
+
+ public XFrame getFrame()
+ {
+ Log.i(TAG, "getFrame");
+ return frame;
+ }
+
+ public void dispose()
+ {
+ Log.i(TAG, "dispose");
+ }
+
+ public void addEventListener(XEventListener listener)
+ {
+ Log.i(TAG, "addEventListener");
+ }
+
+ public void removeEventListener(XEventListener listener)
+ {
+ Log.i(TAG, "removeEventListener");
+ }
+ }
+
+ // FIXME: we should prolly manage a bitmap buffer here and give it to
+ // VCL to render into ... and pull the WM/stacking pieces up into the Java ...
+ // [ perhaps ;-]
+ // how can we get an event to "create a window" - need a JNI callback I guess ...
+
+ private void initBootstrapContext()
+ {
+ try
+ {
+ bootstrapContext = new BootstrapContext();
+
+ long t0 = System.currentTimeMillis();
+ long t1 = System.currentTimeMillis();
+ bootstrapContext.timingOverhead = t1 - t0;
+
+ Bootstrap.setup(this);
+
+ // Avoid all the old style OSL_TRACE calls especially in vcl
+ Bootstrap.putenv("SAL_LOG=+WARN+INFO");
+
+ // Log.i(TAG, "Sleeping NOW");
+ // Thread.sleep(20000);
+
+ bootstrapContext.componentContext = com.sun.star.comp.helper.Bootstrap.defaultBootstrap_InitialComponentContext();
+
+ Log.i(TAG, "context is" + (bootstrapContext.componentContext!=null ? " not" : "") + " null");
+
+ bootstrapContext.mcf = bootstrapContext.componentContext.getServiceManager();
+
+ Log.i(TAG, "mcf is" + (bootstrapContext.mcf!=null ? " not" : "") + " null");
+
+ Bootstrap.initVCL();
+
+ Object desktop = bootstrapContext.mcf.createInstanceWithContext
+ ("com.sun.star.frame.Desktop", bootstrapContext.componentContext);
+
+ Log.i(TAG, "desktop is" + (desktop!=null ? " not" : "") + " null");
+
+ bootstrapContext.componentLoader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class, desktop);
+
+ Log.i(TAG, "componentLoader is" + (bootstrapContext.componentLoader!=null ? " not" : "") + " null");
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.err);
+ finish();
+ }
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
+
+ try {
+ String input = getIntent().getStringExtra("input");
+ if (input == null)
+ input = "/assets/test1.odt";
+
+ // We need to fake up an argv, and the argv[0] even needs to
+ // point to some file name that we can pretend is the "program".
+ // setCommandArgs() will prefix argv[0] with the app's data
+ // directory.
+
+ String[] argv = { "lo-document-loader", input };
+
+ Bootstrap.setCommandArgs(argv);
+
+ if (bootstrapContext == null)
+ initBootstrapContext();
+
+ }
+ catch (Exception e) {
+ e.printStackTrace(System.err);
+ finish();
+ }
+ }
+}
+
+// vim:set shiftwidth=4 softtabstop=4 expandtab: