aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Anton Lundin <glance@acc.umu.se>2014-03-26 23:08:57 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-03-27 10:40:43 -0700
commitdf12944c939d618fe2d2629e990c6355d402545c (patch)
treec7d2d0c0c2df62e4957d06fe7859215a2ef15a4b
parent770bf9afba18a2d50ead56c0068dc07ed8cb63a1 (diff)
downloadsubsurface-df12944c939d618fe2d2629e990c6355d402545c.tar.gz
Introduce android specific file
This contains a first stab at Subsurface platform interfacing code for Android, and surrounding parts. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--android.cpp81
-rw-r--r--subsurface-install.pri3
-rw-r--r--subsurface.pro6
3 files changed, 88 insertions, 2 deletions
diff --git a/android.cpp b/android.cpp
new file mode 100644
index 000000000..15de9e65d
--- /dev/null
+++ b/android.cpp
@@ -0,0 +1,81 @@
+/* implements Android specific functions */
+#include "dive.h"
+#include "display.h"
+#include <string.h>
+#include <sys/types.h>
+#include <dirent.h>
+#include <fcntl.h>
+
+#include <QtAndroidExtras/QtAndroidExtras>
+#include <QtAndroidExtras/QAndroidJniObject>
+
+extern "C" {
+
+const char system_divelist_default_font[] = "Roboto";
+const int system_divelist_default_font_size = 8;
+
+const char *system_default_filename(void)
+{
+ /* Replace this when QtCore/QStandardPaths getExternalStorageDirectory landed */
+ QAndroidJniObject externalStorage = QAndroidJniObject::callStaticObjectMethod("android/os/Environment", "getExternalStorageDirectory", "()Ljava/io/File;");
+ QAndroidJniObject externalStorageAbsolute = externalStorage.callObjectMethod( "getAbsolutePath", "()Ljava/lang/String;" );
+ QString system_default_filename = externalStorageAbsolute.toString()+"/subsurface.xml";
+ QAndroidJniEnvironment env;
+ if (env->ExceptionCheck()) {
+ // FIXME: Handle exception here.
+ env->ExceptionClear();
+ return strdup("/sdcard/subsurface.xml");
+ }
+ return strdup(system_default_filename.toUtf8().data());
+}
+
+int enumerate_devices (device_callback_t callback, void *userdata)
+{
+ /* FIXME: we need to enumerate in some other way on android */
+ /* qtserialport maybee? */
+ return -1;
+}
+
+/* NOP wrappers to comform with windows.c */
+int subsurface_rename(const char *path, const char *newpath)
+{
+ return rename(path, newpath);
+}
+
+int subsurface_open(const char *path, int oflags, mode_t mode)
+{
+ return open(path, oflags, mode);
+}
+
+FILE *subsurface_fopen(const char *path, const char *mode)
+{
+ return fopen(path, mode);
+}
+
+void *subsurface_opendir(const char *path)
+{
+ return (void *)opendir(path);
+}
+
+struct zip *subsurface_zip_open_readonly(const char *path, int flags, int *errorp)
+{
+ return zip_open(path, flags, errorp);
+}
+
+int subsurface_zip_close(struct zip *zip)
+{
+ return zip_close(zip);
+}
+
+/* win32 console */
+void subsurface_console_init(bool dedicated)
+{
+ /* NOP */
+}
+
+void subsurface_console_exit(void)
+{
+ /* NOP */
+}
+
+}
diff --git a/subsurface-install.pri b/subsurface-install.pri
index e4a6e0a53..2dcb98113 100644
--- a/subsurface-install.pri
+++ b/subsurface-install.pri
@@ -120,6 +120,9 @@ mac {
QMAKE_EXTRA_TARGETS = installer nsis
install.depends += dlls
}
+} else: android {
+ # Android install rules
+ QMAKE_BUNDLE_DATA += translation qttranslation
} else {
# Linux install rules
# On Linux, we can count on packagers doing the right thing
diff --git a/subsurface.pro b/subsurface.pro
index 98f23b799..df5f796bf 100644
--- a/subsurface.pro
+++ b/subsurface.pro
@@ -4,7 +4,8 @@ QT = core gui network svg
lessThan(QT_MAJOR_VERSION, 5) {
QT += webkit
} else {
- QT += webkitwidgets
+ !android: QT += webkitwidgets
+ android: QT += androidextras
}
INCLUDEPATH += qt-ui $$PWD
DEPENDPATH += qt-ui
@@ -140,7 +141,8 @@ SOURCES = \
qt-ui/profile/divetooltipitem.cpp \
qt-ui/profile/ruleritem.cpp
-linux*: SOURCES += linux.c
+android: SOURCES += android.cpp
+else: linux*: SOURCES += linux.c
mac: SOURCES += macos.c
win32: SOURCES += windows.c