diff --git a/examples/android/android_app.mk b/examples/android/android_app.mk new file mode 100644 index 00000000..94df7c4f --- /dev/null +++ b/examples/android/android_app.mk @@ -0,0 +1,15 @@ +# List application source files here + +# application library name ("app" -> libapp.so) +LOCAL_MODULE=dlangui-activity + +# applicatino source files: put list of your source files here +LOCAL_SRC_FILES="\ +./jni/app.d \ +" + +# Additional libraries to link +LOCAL_LDLIBS="" + +# Android SDK target +ANDROID_TARGET="android-21" diff --git a/examples/android/android_build_config.mk b/examples/android/android_build_config.mk new file mode 100644 index 00000000..d96b0d13 --- /dev/null +++ b/examples/android/android_build_config.mk @@ -0,0 +1,11 @@ +#!/bin/sh + +#========================================================================= +# Modify this file to specify DLANGUI, Android NDK, SDK and LDC2 locations. + +export DLANGUI_DIR=/media/toshiba/dev/ernomon +export NDK=$NDK +export SDK=$ANDROID_HOME +export LDC=$LDC +export NDK_ARCH=x86_64 +export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/ diff --git a/examples/android/jni/app.d b/examples/android/jni/app.d new file mode 100644 index 00000000..71057ba9 --- /dev/null +++ b/examples/android/jni/app.d @@ -0,0 +1,80 @@ +module app; + +import dlangui; + +mixin APP_ENTRY_POINT; + +/// entry point for dlangui based application +extern (C) int UIAppMain(string[] args) { + + // load theme from file "theme_default.xml" + //Platform.instance.uiTheme = "theme_default"; + + // create window + Log.d("Creating window"); + Window window = Platform.instance.createWindow("DlangUI example - HelloWorld", null); + Log.d("Window created"); + + // create some widget to show in window + //window.mainWidget = (new Button()).text("Hello, world!"d).margins(Rect(20,20,20,20)); + window.mainWidget = parseML(q{ + VerticalLayout { + margins: 10pt + padding: 10pt + layoutWidth: fill + // red bold text with size = 150% of base style size and font face Arial + TextWidget { text: "Hello World example for DlangUI"; textColor: "red"; fontSize: 150%; fontWeight: 800; fontFace: "Arial" } + // arrange controls as form - table with two columns + TableLayout { + colCount: 2 + layoutWidth: fill + TextWidget { text: "param 1" } + EditLine { id: edit1; text: "some text"; layoutWidth: fill } + TextWidget { text: "param 2" } + EditLine { id: edit2; text: "some text for param2"; layoutWidth: fill } + TextWidget { text: "some radio buttons" } + // arrange some radio buttons vertically + VerticalLayout { + layoutWidth: fill + RadioButton { id: rb1; text: "Item 1" } + RadioButton { id: rb2; text: "Item 2" } + RadioButton { id: rb3; text: "Item 3" } + } + TextWidget { text: "and checkboxes" } + // arrange some checkboxes horizontally + HorizontalLayout { + layoutWidth: fill + CheckBox { id: cb1; text: "checkbox 1" } + CheckBox { id: cb2; text: "checkbox 2" } + ComboEdit { id: ce1; text: "some text"; minWidth: 20pt; items: ["Item 1", "Item 2", "Additional item"] } + } + } + EditBox { layoutWidth: 20pt; layoutHeight: 10pt } + HorizontalLayout { + Button { id: btnOk; text: "Ok" } + Button { id: btnCancel; text: "Cancel" } + } + } + }); + // you can access loaded items by id - e.g. to assign signal listeners + auto edit1 = window.mainWidget.childById!EditLine("edit1"); + auto edit2 = window.mainWidget.childById!EditLine("edit2"); + // close window on Cancel button click + window.mainWidget.childById!Button("btnCancel").click = delegate(Widget w) { + window.close(); + return true; + }; + // show message box with content of editors + window.mainWidget.childById!Button("btnOk").click = delegate(Widget w) { + window.showMessageBox(UIString.fromRaw("Ok button pressed"d), + UIString.fromRaw("Editors content\nEdit1: "d ~ edit1.text ~ "\nEdit2: "d ~ edit2.text)); + return true; + }; + + // show window + window.show(); + + // run message loop + return Platform.instance.enterMessageLoop(); +} + diff --git a/examples/android/libs/armeabi-v7a/libdlangui-activity.so b/examples/android/libs/armeabi-v7a/libdlangui-activity.so deleted file mode 100755 index af26f2d5..00000000 Binary files a/examples/android/libs/armeabi-v7a/libdlangui-activity.so and /dev/null differ