Browse Source

improved native android support

Denis Muratshin 12 years ago
parent
commit
73775324a4
47 changed files with 692 additions and 153 deletions
  1. 2 2
      .hg_archival.txt
  2. 6 2
      .hgignore
  3. 0 4
      .oxbuild
  4. 28 24
      Android.mk
  5. BIN
      doc.zip
  6. 2 2
      examples/Demo/proj.android/AndroidManifest.xml
  7. 1 1
      examples/Demo/proj.android/build.cmd
  8. 1 1
      examples/Demo/proj.android/install.bat
  9. 5 13
      examples/Demo/proj.android/jni/src/Android.mk
  10. 1 0
      examples/Demo/proj.android/project.properties
  11. 0 0
      examples/Demo/proj.android/src/.empty
  12. 0 1
      examples/Demo/proj.android/src/org/libsdl/app/.readme
  13. 0 9
      examples/Demo/proj.android/src/org/libsdl/app/OxygineActivity.java
  14. 8 0
      examples/Demo/proj.android/src/org/oxygine/example/MainActivity.java
  15. 8 4
      examples/Demo/src/example.cpp
  16. 2 2
      examples/Demo/src/test.cpp
  17. 8 0
      oxygine/SDL/android/lib/AndroidManifest.xml
  18. 17 0
      oxygine/SDL/android/lib/ant.properties
  19. 92 0
      oxygine/SDL/android/lib/build.xml
  20. 10 0
      oxygine/SDL/android/lib/local.properties
  21. 20 0
      oxygine/SDL/android/lib/proguard-project.txt
  22. 15 0
      oxygine/SDL/android/lib/project.properties
  23. BIN
      oxygine/SDL/android/lib/res/drawable-hdpi/ic_launcher.png
  24. BIN
      oxygine/SDL/android/lib/res/drawable-ldpi/ic_launcher.png
  25. BIN
      oxygine/SDL/android/lib/res/drawable-mdpi/ic_launcher.png
  26. BIN
      oxygine/SDL/android/lib/res/drawable-xhdpi/ic_launcher.png
  27. 13 0
      oxygine/SDL/android/lib/res/layout/main.xml
  28. 4 0
      oxygine/SDL/android/lib/res/values/strings.xml
  29. 14 3
      oxygine/SDL/android/lib/src/org/libsdl/app/SDLActivity.java
  30. 22 0
      oxygine/SDL/android/lib/src/org/oxygine/lib/OxygineActivity.java
  31. 30 0
      oxygine/SDL/android/lib/src/org/oxygine/lib/Utils.java
  32. 8 3
      oxygine/SDL/ios/oxygine/oxygine_ios.xcodeproj/project.pbxproj
  33. 6 27
      oxygine/src/core/STDFileSystem.cpp
  34. 54 1
      oxygine/src/core/ZipFileSystem.cpp
  35. 14 0
      oxygine/src/core/android/jniHelper.cpp
  36. 43 0
      oxygine/src/core/android/jniHelper.h
  37. 142 0
      oxygine/src/core/android/jniUtils.cpp
  38. 19 0
      oxygine/src/core/android/jniUtils.h
  39. 24 4
      oxygine/src/core/file.cpp
  40. 5 23
      oxygine/src/core/file.h
  41. 26 3
      oxygine/src/core/oxygine.cpp
  42. 6 4
      oxygine/src/core/oxygine.h
  43. 4 1
      oxygine/src/res/Resources.cpp
  44. 3 1
      oxygine/src/res/Resources.h
  45. 14 7
      oxygine/src/utils/stringUtils.cpp
  46. 14 10
      readme.Android
  47. 1 1
      readme.iOS

+ 2 - 2
.hg_archival.txt

@@ -1,5 +1,5 @@
 repo: b6d71054df5712e643a0685bc3ba54b123db5729
 repo: b6d71054df5712e643a0685bc3ba54b123db5729
-node: 4ab668fe557e28140bdd17c4eee9b9cabcbfad0d
+node: 956b43ecca46035762f87ce4064bceb2a75bbd63
 branch: default
 branch: default
 latesttag: oldrender
 latesttag: oldrender
-latesttagdistance: 119
+latesttagdistance: 134

+ 6 - 2
.hgignore

@@ -24,13 +24,11 @@ oxygine/greenlets/greenlets/greenlets.sdf
 *.ipch
 *.ipch
 *.opensdf
 *.opensdf
 oxygine/greenlets/greenlets_xcode/
 oxygine/greenlets/greenlets_xcode/
-oxygine/cocos2dx/android/obj/
 examples/Match3/build_match3_vc10
 examples/Match3/build_match3_vc10
 oxygine/greenlets/android/obj/
 oxygine/greenlets/android/obj/
 *.sdf
 *.sdf
 oxygine/cocos2dx/win32/Release/
 oxygine/cocos2dx/win32/Release/
 examples/HelloWorld/build_helloworld_vc10/
 examples/HelloWorld/build_helloworld_vc10/
-oxygine/SDL/android/obj/
 examples/SDL/HelloWorld/win32/Debug/
 examples/SDL/HelloWorld/win32/Debug/
 oxygine/SDL/win32/Debug/
 oxygine/SDL/win32/Debug/
 examples/DemoBox2D/box2d/build_box2d_vc10
 examples/DemoBox2D/box2d/build_box2d_vc10
@@ -99,5 +97,11 @@ examples/Demo/data-ram/
 examples/Demo/proj.android/libs/
 examples/Demo/proj.android/libs/
 examples/Demo/proj.android/obj/
 examples/Demo/proj.android/obj/
 obj/
 obj/
+examples/Demo/proj.android/bin/
+examples/Demo/proj.android/gen/
+examples/Demo/proj.android/.idea
+examples/Demo/proj.android/out
+*.iml
+examples/Demo/proj.android/assets/
 syntax: regexp
 syntax: regexp
 ^build/
 ^build/

+ 0 - 4
.oxbuild

@@ -1,4 +0,0 @@
-.hgignore
-.hg_archival.txt
-doc.bat
-doxyfile

+ 28 - 24
Android.mk

@@ -20,43 +20,47 @@ LOCAL_MODULE    := oxygine-framework_static
 LOCAL_MODULE_FILENAME := liboxygine-framework
 LOCAL_MODULE_FILENAME := liboxygine-framework
 LOCAL_CPP_EXTENSION := .cpp
 LOCAL_CPP_EXTENSION := .cpp
 
 
-OXYGINE_SRC := $(LOCAL_PATH)/oxygine/src
+SRC := $(LOCAL_PATH)/oxygine/src
 
 
 LOCAL_SRC_FILES := \
 LOCAL_SRC_FILES := \
 				$(subst $(LOCAL_PATH)/,, \
 				$(subst $(LOCAL_PATH)/,, \
-				$(wildcard $(OXYGINE_SRC)/closure/*.cpp) \
-				$(wildcard $(OXYGINE_SRC)/core/*.cpp) \
-				$(wildcard $(OXYGINE_SRC)/math/*.cpp) \
-				$(wildcard $(OXYGINE_SRC)/pugixml/*.cpp) \
-				$(wildcard $(OXYGINE_SRC)/res/*.cpp) \
-				$(wildcard $(OXYGINE_SRC)/text_utils/*.cpp) \
-				$(wildcard $(OXYGINE_SRC)/dev_tools/*.cpp) \
-				$(wildcard $(OXYGINE_SRC)/utils/*.cpp) \
-				$(wildcard $(OXYGINE_SRC)/winnie_alloc/*.cpp) \
-				$(wildcard $(OXYGINE_SRC)/minizip/*.c) \
-				$(wildcard $(OXYGINE_SRC)/*.cpp) \
+				$(wildcard $(SRC)/closure/*.cpp) \
+				$(wildcard $(SRC)/core/*.cpp) \
+				$(wildcard $(SRC)/math/*.cpp) \
+				$(wildcard $(SRC)/pugixml/*.cpp) \
+				$(wildcard $(SRC)/res/*.cpp) \
+				$(wildcard $(SRC)/text_utils/*.cpp) \
+				$(wildcard $(SRC)/dev_tools/*.cpp) \
+				$(wildcard $(SRC)/utils/*.cpp) \
+				$(wildcard $(SRC)/winnie_alloc/*.cpp) \
+				$(wildcard $(SRC)/minizip/*.c) \
+				$(wildcard $(SRC)/*.cpp) \
 				)
 				)
 
 
-OXYGINE_SRC := oxygine/src
+SRC := oxygine/src
 
 
 LOCAL_SRC_FILES += \
 LOCAL_SRC_FILES += \
 				oxygine/greenlets/src/greenlet.c \
 				oxygine/greenlets/src/greenlet.c \
 
 
 LOCAL_SRC_FILES += \
 LOCAL_SRC_FILES += \
-				$(OXYGINE_SRC)/core/gl/NativeTextureGLES.cpp \
-				$(OXYGINE_SRC)/core/gl/oxgl.cpp \
-				$(OXYGINE_SRC)/core/gl/VertexDeclarationGL.cpp \
-				$(OXYGINE_SRC)/core/gl/ShaderProgramGL.cpp \
-				$(OXYGINE_SRC)/core/gl/VideoDriverGL.cpp \
-				$(OXYGINE_SRC)/core/gl/VideoDriverGLES20.cpp \
-
-SDL_PATH := $(LOCAL_PATH)/../SDL/include/
-THIRD_PARTY := $(LOCAL_PATH)/oxygine/third_party/android/
+				$(SRC)/core/android/jniUtils.cpp \
+				$(SRC)/core/android/jniHelper.cpp \
+
+LOCAL_SRC_FILES += \
+				$(SRC)/core/gl/NativeTextureGLES.cpp \
+				$(SRC)/core/gl/oxgl.cpp \
+				$(SRC)/core/gl/VertexDeclarationGL.cpp \
+				$(SRC)/core/gl/ShaderProgramGL.cpp \
+				$(SRC)/core/gl/VideoDriverGL.cpp \
+				$(SRC)/core/gl/VideoDriverGLES20.cpp \
 
 
+
+THIRD_PARTY := $(LOCAL_PATH)/oxygine/third_party/android/
 OXYGINE_SRC := $(LOCAL_PATH)/oxygine/src
 OXYGINE_SRC := $(LOCAL_PATH)/oxygine/src
+
 LOCAL_C_INCLUDES := $(OXYGINE_SRC)/ \
 LOCAL_C_INCLUDES := $(OXYGINE_SRC)/ \
 					$(OXYGINE_SRC)/../greenlets/src/ \
 					$(OXYGINE_SRC)/../greenlets/src/ \
-					$(SDL_PATH) \
+					$(LOCAL_PATH)/../SDL/include/ \
 					$(THIRD_PARTY)/libjpeg/ \
 					$(THIRD_PARTY)/libjpeg/ \
 					$(THIRD_PARTY)/libpng/
 					$(THIRD_PARTY)/libpng/
 
 
@@ -68,5 +72,5 @@ LOCAL_WHOLE_STATIC_LIBRARIES := ox_libpng_static ox_libjpeg_static
 					
 					
 include $(BUILD_STATIC_LIBRARY)
 include $(BUILD_STATIC_LIBRARY)
 
 
-$(call import-add-path, $(LOCAL_PATH)/../)
+#$(call import-add-path, $(LOCAL_PATH)/../)
 $(call import-module, SDL)
 $(call import-module, SDL)

BIN
doc.zip


+ 2 - 2
examples/Demo/proj.android/AndroidManifest.xml

@@ -3,7 +3,7 @@
      com.gamemaker.game
      com.gamemaker.game
 -->
 -->
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
-      package="org.libsdl.app"
+      package="org.oxygine.example"
       android:versionCode="1"
       android:versionCode="1"
       android:versionName="1.0"
       android:versionName="1.0"
       android:installLocation="auto">
       android:installLocation="auto">
@@ -23,7 +23,7 @@
                  android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
                  android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
                  android:hardwareAccelerated="true" >
                  android:hardwareAccelerated="true" >
 
 
-        <activity android:name="OxygineActivity"
+        <activity android:name="org.oxygine.example.MainActivity"
                   android:label="@string/app_name"
                   android:label="@string/app_name"
                   android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
                   android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
                   android:configChanges="locale|orientation|keyboardHidden" 
                   android:configChanges="locale|orientation|keyboardHidden" 

+ 1 - 1
examples/Demo/proj.android/build.cmd

@@ -1 +1 @@
-ndk-build -C %CD%
+ndk-build NDK_MODULE_PATH=../../../../

+ 1 - 1
examples/Demo/proj.android/install.bat

@@ -1,2 +1,2 @@
 adb install -r bin/OxygineDemoSDL-debug.apk
 adb install -r bin/OxygineDemoSDL-debug.apk
-adb shell am start -n org.libsdl.app/org.libsdl.app.OxygineActivity
+adb shell am start -n org.oxygine.example/org.oxygine.example.MainActivity

+ 5 - 13
examples/Demo/proj.android/jni/src/Android.mk

@@ -3,29 +3,21 @@ include $(CLEAR_VARS)
 
 
 LOCAL_MODULE := main
 LOCAL_MODULE := main
 
 
+#SDK_ROOT points to folder with SDL and oxygine-framework
 SDK_ROOT = /../../../../../../
 SDK_ROOT = /../../../../../../
-OXYGINE_ROOT := $(SDK_ROOT)/oxygine-framework/
-SDL_PATH := $(SDK_ROOT)/SDL
-
-$(warning $(LOCAL_PATH))
 SRC := ../../../src
 SRC := ../../../src
-LOCAL_SRC_FILES :=  ../../../../../../SDL/src/main/android/SDL_android_main.c \
+
+LOCAL_SRC_FILES :=  $(SDK_ROOT)/SDL/src/main/android/SDL_android_main.c \
 					$(SRC)/entry_point.cpp \
 					$(SRC)/entry_point.cpp \
 					$(SRC)/example.cpp \
 					$(SRC)/example.cpp \
 					$(SRC)/test.cpp
 					$(SRC)/test.cpp
 
 
 
 
-OXYGINE_LIBS := $(OXYGINE_ROOT)/oxygine/third_party/android/libraries/$(TARGET_ARCH_ABI)
-
-
 LOCAL_STATIC_LIBRARIES := oxygine-framework_static
 LOCAL_STATIC_LIBRARIES := oxygine-framework_static
 LOCAL_SHARED_LIBRARIES := SDL2
 LOCAL_SHARED_LIBRARIES := SDL2
 
 
 include $(BUILD_SHARED_LIBRARY)
 include $(BUILD_SHARED_LIBRARY)
 
 
 
 
-
-$(call import-add-path, $(LOCAL_PATH)/../../../../../../)
-$(call import-module, oxygine-framework) 
-
-
+#import from NDK_MODULE_PATH defined in build.cmd
+$(call import-module, oxygine-framework)

+ 1 - 0
examples/Demo/proj.android/project.properties

@@ -12,3 +12,4 @@
 
 
 # Project target.
 # Project target.
 target=android-12
 target=android-12
+android.library.reference.1=../../../oxygine/SDL/android/lib

+ 0 - 0
examples/Demo/proj.android/src/.empty


+ 0 - 1
examples/Demo/proj.android/src/org/libsdl/app/.readme

@@ -1 +0,0 @@
-SDLActivity.java should be copied from SDL

+ 0 - 9
examples/Demo/proj.android/src/org/libsdl/app/OxygineActivity.java

@@ -1,9 +0,0 @@
-package org.libsdl.app;
-
-/**
-    OxygineActivity
-*/
-public class OxygineActivity extends SDLActivity 
-{
-
-}

+ 8 - 0
examples/Demo/proj.android/src/org/oxygine/example/MainActivity.java

@@ -0,0 +1,8 @@
+package org.oxygine.example;
+
+import org.oxygine.lib.OxygineActivity;
+
+public class MainActivity extends OxygineActivity
+{
+
+}

+ 8 - 4
examples/Demo/src/example.cpp

@@ -15,6 +15,7 @@
 #include "TestClipRect.h"
 #include "TestClipRect.h"
 #include "TestUserShader.h"
 #include "TestUserShader.h"
 #include "TestMask.h"
 #include "TestMask.h"
+#include "core/STDFileSystem.h"
 
 
 #ifdef __S3E__
 #ifdef __S3E__
 #include "s3eKeyboard.h"
 #include "s3eKeyboard.h"
@@ -147,9 +148,14 @@ void example_preinit()
 	Renderer::setPremultipliedAlphaRender(false);
 	Renderer::setPremultipliedAlphaRender(false);
 }
 }
 
 
+file::STDFileSystem extfs(true);
+
 void example_init()
 void example_init()
 {
 {
-	file::setExtendedFolder("ext");
+	//mount additional file system with inner path "ext"
+	//it would be used for searching path in data/ext
+	extfs.setPath(file::fs().getFullPath("ext").c_str());
+	file::mount(&extfs);
 
 
 	//load xml file with resources definition
 	//load xml file with resources definition
 	resources.loadXML("xmls/res.xml");
 	resources.loadXML("xmls/res.xml");
@@ -182,6 +188,4 @@ void example_destroy()
 	_tests = 0;
 	_tests = 0;
 	resources.free();
 	resources.free();
 	resourcesUI.free();
 	resourcesUI.free();
-}
-
-
+}

+ 2 - 2
examples/Demo/src/test.cpp

@@ -155,7 +155,7 @@ void Test::back(Event *event)
 
 
 void Test::notify(string txt, int time)
 void Test::notify(string txt, int time)
 {
 {
-	int N = 0;
+	size_t N = 0;
 	for (size_t i = 0; i < MAX_NOTIFIES; ++i)
 	for (size_t i = 0; i < MAX_NOTIFIES; ++i)
 	{
 	{
 		if (_notifies[i])
 		if (_notifies[i])
@@ -195,6 +195,6 @@ void Test::notify(string txt, int time)
 
 
 void Test::notifyDone(Event *ev)
 void Test::notifyDone(Event *ev)
 {
 {
-	int N = (int)ev->currentTarget->getUserData();
+	size_t N = size_t(ev->currentTarget->getUserData());
 	_notifies[N] -= 1;
 	_notifies[N] -= 1;
 }
 }

+ 8 - 0
oxygine/SDL/android/lib/AndroidManifest.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+      package="org.oxygine.lib"
+      android:versionCode="1"
+      android:versionName="1.0">
+
+      <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
+</manifest>

+ 17 - 0
oxygine/SDL/android/lib/ant.properties

@@ -0,0 +1,17 @@
+# This file is used to override default values used by the Ant build system.
+#
+# This file must be checked into Version Control Systems, as it is
+# integral to the build system of your project.
+
+# This file is only used by the Ant script.
+
+# You can use this to override default values such as
+#  'source.dir' for the location of your java source folder and
+#  'out.dir' for the location of your output folder.
+
+# You can also use it define how the release builds are signed by declaring
+# the following properties:
+#  'key.store' for the location of your keystore and
+#  'key.alias' for the name of the key to use.
+# The password will be asked during the build when you use the 'release' target.
+

+ 92 - 0
oxygine/SDL/android/lib/build.xml

@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="oxygine" default="help">
+
+    <!-- The local.properties file is created and updated by the 'android' tool.
+         It contains the path to the SDK. It should *NOT* be checked into
+         Version Control Systems. -->
+    <property file="local.properties" />
+
+    <!-- The ant.properties file can be created by you. It is only edited by the
+         'android' tool to add properties to it.
+         This is the place to change some Ant specific build properties.
+         Here are some properties you may want to change/update:
+
+         source.dir
+             The name of the source directory. Default is 'src'.
+         out.dir
+             The name of the output directory. Default is 'bin'.
+
+         For other overridable properties, look at the beginning of the rules
+         files in the SDK, at tools/ant/build.xml
+
+         Properties related to the SDK location or the project target should
+         be updated using the 'android' tool with the 'update' action.
+
+         This file is an integral part of the build system for your
+         application and should be checked into Version Control Systems.
+
+         -->
+    <property file="ant.properties" />
+
+    <!-- if sdk.dir was not set from one of the property file, then
+         get it from the ANDROID_HOME env var.
+         This must be done before we load project.properties since
+         the proguard config can use sdk.dir -->
+    <property environment="env" />
+    <condition property="sdk.dir" value="${env.ANDROID_HOME}">
+        <isset property="env.ANDROID_HOME" />
+    </condition>
+
+    <!-- The project.properties file is created and updated by the 'android'
+         tool, as well as ADT.
+
+         This contains project specific properties such as project target, and library
+         dependencies. Lower level build properties are stored in ant.properties
+         (or in .classpath for Eclipse projects).
+
+         This file is an integral part of the build system for your
+         application and should be checked into Version Control Systems. -->
+    <loadproperties srcFile="project.properties" />
+
+    <!-- quick check on sdk.dir -->
+    <fail
+            message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable."
+            unless="sdk.dir"
+    />
+
+    <!--
+        Import per project custom build rules if present at the root of the project.
+        This is the place to put custom intermediary targets such as:
+            -pre-build
+            -pre-compile
+            -post-compile (This is typically used for code obfuscation.
+                           Compiled code location: ${out.classes.absolute.dir}
+                           If this is not done in place, override ${out.dex.input.absolute.dir})
+            -post-package
+            -post-build
+            -pre-clean
+    -->
+    <import file="custom_rules.xml" optional="true" />
+
+    <!-- Import the actual build file.
+
+         To customize existing targets, there are two options:
+         - Customize only one target:
+             - copy/paste the target into this file, *before* the
+               <import> task.
+             - customize it to your needs.
+         - Customize the whole content of build.xml
+             - copy/paste the content of the rules files (minus the top node)
+               into this file, replacing the <import> task.
+             - customize to your needs.
+
+         ***********************
+         ****** IMPORTANT ******
+         ***********************
+         In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
+         in order to avoid having your file be overridden by tools such as "android update project"
+    -->
+    <!-- version-tag: 1 -->
+    <import file="${sdk.dir}/tools/ant/build.xml" />
+
+</project>

+ 10 - 0
oxygine/SDL/android/lib/local.properties

@@ -0,0 +1,10 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+# 
+# This file must *NOT* be checked in Version Control Systems,
+# as it contains information specific to your local configuration.
+
+# location of the SDK. This is only used by Ant
+# For customization when using a Version Control System, please read the
+# header note.
+sdk.dir=d:/android/android-sdk/

+ 20 - 0
oxygine/SDL/android/lib/proguard-project.txt

@@ -0,0 +1,20 @@
+# To enable ProGuard in your project, edit project.properties
+# to define the proguard.config property as described in that file.
+#
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in ${sdk.dir}/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the ProGuard
+# include property in project.properties.
+#
+# For more details, see
+#   http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+#   public *;
+#}

+ 15 - 0
oxygine/SDL/android/lib/project.properties

@@ -0,0 +1,15 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system edit
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+#
+# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
+#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
+
+android.library=true
+# Project target.
+target=android-12

BIN
oxygine/SDL/android/lib/res/drawable-hdpi/ic_launcher.png


BIN
oxygine/SDL/android/lib/res/drawable-ldpi/ic_launcher.png


BIN
oxygine/SDL/android/lib/res/drawable-mdpi/ic_launcher.png


BIN
oxygine/SDL/android/lib/res/drawable-xhdpi/ic_launcher.png


+ 13 - 0
oxygine/SDL/android/lib/res/layout/main.xml

@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:orientation="vertical"
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent"
+    >
+<TextView
+    android:layout_width="fill_parent"
+    android:layout_height="wrap_content"
+    android:text="Hello World, ACTIVITY_ENTRY_NAME"
+    />
+</LinearLayout>
+

+ 4 - 0
oxygine/SDL/android/lib/res/values/strings.xml

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+    <string name="app_name">ACTIVITY_ENTRY_NAME</string>
+</resources>

+ 14 - 3
examples/Demo/proj.android/src/org/libsdl/app/SDLActivity.java → oxygine/SDL/android/lib/src/org/libsdl/app/SDLActivity.java

@@ -2,6 +2,9 @@ package org.libsdl.app;
 
 
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
 
 
 import android.app.*;
 import android.app.*;
 import android.content.*;
 import android.content.*;
@@ -39,7 +42,6 @@ public class SDLActivity extends Activity {
     protected static Thread mSDLThread;
     protected static Thread mSDLThread;
     
     
     // Audio
     // Audio
-    protected static Thread mAudioThread;
     protected static AudioTrack mAudioTrack;
     protected static AudioTrack mAudioTrack;
 
 
     // Load the .so
     // Load the .so
@@ -922,6 +924,13 @@ class SDLJoystickHandler_API12 extends SDLJoystickHandler {
         public String name;
         public String name;
         public ArrayList<InputDevice.MotionRange> axes;
         public ArrayList<InputDevice.MotionRange> axes;
     }
     }
+    class RangeComparator implements Comparator<InputDevice.MotionRange>
+    {
+        @Override
+        public int compare(InputDevice.MotionRange arg0, InputDevice.MotionRange arg1) {
+            return arg0.getAxis() - arg1.getAxis();
+        }
+    }
     
     
     private ArrayList<SDLJoystick> mJoysticks;
     private ArrayList<SDLJoystick> mJoysticks;
     
     
@@ -948,8 +957,10 @@ class SDLJoystickHandler_API12 extends SDLJoystickHandler {
                     joystick.name = joystickDevice.getName();
                     joystick.name = joystickDevice.getName();
                     joystick.axes = new ArrayList<InputDevice.MotionRange>();
                     joystick.axes = new ArrayList<InputDevice.MotionRange>();
                     
                     
-                    for (InputDevice.MotionRange range : joystickDevice.getMotionRanges()) {
-                         if ( (range.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) {
+                    List<InputDevice.MotionRange> ranges = joystickDevice.getMotionRanges();
+                    Collections.sort(ranges, new RangeComparator());
+                    for (InputDevice.MotionRange range : ranges ) {
+                        if ( (range.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0 ) {
                             joystick.axes.add(range);
                             joystick.axes.add(range);
                          }
                          }
                     }
                     }

+ 22 - 0
oxygine/SDL/android/lib/src/org/oxygine/lib/OxygineActivity.java

@@ -0,0 +1,22 @@
+package org.oxygine.lib;
+
+import android.os.Bundle;
+import org.libsdl.app.SDLActivity;
+/**
+    OxygineActivity
+*/
+public class OxygineActivity extends SDLActivity 
+{
+    protected static OxygineActivity instance;
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState)
+    {
+        super.onCreate(savedInstanceState);
+        instance = this;
+        Utils._context = this;
+        nativeOxygineInit(this);
+    }
+
+    public static native void nativeOxygineInit(OxygineActivity activity);
+}

+ 30 - 0
oxygine/SDL/android/lib/src/org/oxygine/lib/Utils.java

@@ -0,0 +1,30 @@
+package org.oxygine.lib;
+
+import android.content.Context;
+import android.net.ConnectivityManager;
+import android.net.NetworkInfo;
+
+import java.util.Locale;
+
+public class Utils
+{
+    static public Context _context;
+	public static long		getTimeUTCMS()
+	{
+        return System.currentTimeMillis();
+	}
+
+	public static String	getLanguage()
+	{
+		return Locale.getDefault().getLanguage();
+	}
+
+    public static boolean isNetworkAvailable()
+    {
+        if (_context == null)
+            return  false;
+        ConnectivityManager connectivityManager = (ConnectivityManager) _context.getSystemService(Context.CONNECTIVITY_SERVICE);
+        NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
+        return activeNetworkInfo != null;
+    }
+}

+ 8 - 3
oxygine/SDL/ios/oxygine/oxygine_ios.xcodeproj/project.pbxproj

@@ -1012,10 +1012,11 @@
 					"$(THIRD_PARTY)/libpng",
 					"$(THIRD_PARTY)/libpng",
 					"$(THIRD_PARTY)/libjpeg",
 					"$(THIRD_PARTY)/libjpeg",
 				);
 				);
-				MACOSX_DEPLOYMENT_TARGET = 10.8;
-				ONLY_ACTIVE_ARCH = YES;
+				MACOSX_DEPLOYMENT_TARGET = "";
+				ONLY_ACTIVE_ARCH = NO;
 				SDKROOT = iphoneos;
 				SDKROOT = iphoneos;
 				SDL = ../../../../../SDL/;
 				SDL = ../../../../../SDL/;
+				TARGETED_DEVICE_FAMILY = "1,2";
 				THIRD_PARTY = ../../../third_party/macosx/;
 				THIRD_PARTY = ../../../third_party/macosx/;
 			};
 			};
 			name = Debug;
 			name = Debug;
@@ -1044,9 +1045,11 @@
 					"$(THIRD_PARTY)/libpng",
 					"$(THIRD_PARTY)/libpng",
 					"$(THIRD_PARTY)/libjpeg",
 					"$(THIRD_PARTY)/libjpeg",
 				);
 				);
-				MACOSX_DEPLOYMENT_TARGET = 10.8;
+				MACOSX_DEPLOYMENT_TARGET = "";
+				ONLY_ACTIVE_ARCH = NO;
 				SDKROOT = iphoneos;
 				SDKROOT = iphoneos;
 				SDL = ../../../../../SDL/;
 				SDL = ../../../../../SDL/;
+				TARGETED_DEVICE_FAMILY = "1,2";
 				THIRD_PARTY = ../../../third_party/macosx/;
 				THIRD_PARTY = ../../../third_party/macosx/;
 			};
 			};
 			name = Release;
 			name = Release;
@@ -1064,6 +1067,7 @@
 					"$(THIRD_PARTY)/libpng",
 					"$(THIRD_PARTY)/libpng",
 					"$(THIRD_PARTY)/libjpeg",
 					"$(THIRD_PARTY)/libjpeg",
 				);
 				);
+				ONLY_ACTIVE_ARCH = YES;
 				PRODUCT_NAME = oxygine_ios;
 				PRODUCT_NAME = oxygine_ios;
 			};
 			};
 			name = Debug;
 			name = Debug;
@@ -1081,6 +1085,7 @@
 					"$(THIRD_PARTY)/libpng",
 					"$(THIRD_PARTY)/libpng",
 					"$(THIRD_PARTY)/libjpeg",
 					"$(THIRD_PARTY)/libjpeg",
 				);
 				);
+				ONLY_ACTIVE_ARCH = NO;
 				PRODUCT_NAME = oxygine_ios;
 				PRODUCT_NAME = oxygine_ios;
 			};
 			};
 			name = Release;
 			name = Release;

+ 6 - 27
oxygine/src/core/STDFileSystem.cpp

@@ -103,6 +103,7 @@ namespace oxygine
 		int _openedFiles = 0;
 		int _openedFiles = 0;
 		oxHandle* oxFileOpen(const char* filename, const char* mode)
 		oxHandle* oxFileOpen(const char* filename, const char* mode)
 		{
 		{
+			log::messageln("oxFileOpen %s", filename);
 			oxHandle *h = oxFileOpen_(filename, mode);
 			oxHandle *h = oxFileOpen_(filename, mode);
 			if (h)
 			if (h)
 				_openedFiles++;
 				_openedFiles++;
@@ -158,11 +159,13 @@ namespace oxygine
 
 
 			virtual unsigned int getSize() const
 			virtual unsigned int getSize() const
 			{
 			{
+#ifdef __S3E__
 				oxFileSeek(_handle, 0, ox_FILESEEK_END);
 				oxFileSeek(_handle, 0, ox_FILESEEK_END);
 				unsigned int size  = (unsigned int)oxFileTell(_handle);
 				unsigned int size  = (unsigned int)oxFileTell(_handle);
 				oxFileSeek(_handle, 0, ox_FILESEEK_SET);
 				oxFileSeek(_handle, 0, ox_FILESEEK_SET);
-
 				return size;
 				return size;
+#endif
+				return SDL_RWsize((SDL_RWops*)_handle);				
 			}
 			}
 
 
 		private:
 		private:
@@ -171,38 +174,13 @@ namespace oxygine
 
 
 		STDFileSystem::STDFileSystem(bool readonly):FileSystem(readonly)
 		STDFileSystem::STDFileSystem(bool readonly):FileSystem(readonly)
 		{
 		{
-#ifdef WIN32
-			if (!_readonly)
-				_mkdir(getFullPath("").c_str());
-#endif
 		}
 		}
 
 
 		char* STDFileSystem::_getFullPath(const char *path, char buff[512])
 		char* STDFileSystem::_getFullPath(const char *path, char buff[512])
 		{
 		{
 			buff[0] = 0;
 			buff[0] = 0;
 
 
-			if (_readonly)
-			{
-#if __S3E__
-				sprintf(buff, "rom://%s%s", _path.c_str(), path);
-#else
-				sprintf(buff, "%s%s", _path.c_str(), path);
-#endif
-			}
-			else
-			{
-#if __S3E__
-				sprintf(buff, "ram://%s%s", _path.c_str(), path);
-#else
-	#ifdef  WIN32
-				sprintf(buff, "../data-ram/%s%s", _path.c_str(), path);
-	#else
-				strcpy(buff, path);
-				log::warning("not implemented fs");
-	#endif
-#endif
-			}
-
+			sprintf(buff, "%s%s", _path.c_str(), path);
 
 
 			return buff;
 			return buff;
 		}
 		}
@@ -244,6 +222,7 @@ namespace oxygine
 #if __S3E__
 #if __S3E__
 			s3eFileDelete(buff);
 			s3eFileDelete(buff);
 #else
 #else
+			LOGD("STDFileSystem::_deleteFile %s", buff);
 			::remove(buff);
 			::remove(buff);
 #endif
 #endif
 
 

+ 54 - 1
oxygine/src/core/ZipFileSystem.cpp

@@ -88,9 +88,62 @@ namespace file
 		add(zp);
 		add(zp);
 	}
 	}
 
 
+
+	voidpf ZCALLBACK ox_fopen(voidpf opaque, const char* filename, int mode)
+	{
+		return file::open(filename, "rb");
+	}
+
+	uLong ZCALLBACK ox_fread(voidpf opaque, voidpf stream, void* buf, uLong size)
+	{
+		return file::read(stream, buf, size);
+	}
+
+	/*
+	uLong ZCALLBACK ox_fwriteOF(voidpf opaque, voidpf stream, const void* buf, uLong size)
+	{
+
+	}
+	*/
+
+	long ZCALLBACK ox_ftell(voidpf opaque, voidpf stream)
+	{
+		return file::tell(stream);
+	}
+
+	long ZCALLBACK ox_fseek(voidpf opaque, voidpf stream, uLong offset, int origin)
+	{
+		file::seek(stream, offset, origin);
+		return 0;
+	}
+
+	int ZCALLBACK ox_fclose(voidpf opaque, voidpf stream)
+	{
+		file::close(stream);;
+		return 0;
+	}
+
+	int ZCALLBACK ox_ferror(voidpf opaque, voidpf stream)
+	{
+		return 0;
+	}
+
+
+
 	void Zips::add(const char *name)
 	void Zips::add(const char *name)
 	{
 	{
-		unzFile zp = unzOpen(name);
+		zlib_filefunc_def zpfs;
+		memset(&zpfs, 0, sizeof(zpfs));
+
+		zpfs.zopen_file = ox_fopen;
+		zpfs.zread_file = ox_fread;
+		zpfs.zwrite_file= 0;
+		zpfs.ztell_file = ox_ftell;
+		zpfs.zseek_file = ox_fseek;
+		zpfs.zclose_file= ox_fclose;
+		zpfs.zerror_file= ox_ferror;
+
+		unzFile zp = unzOpen2(name, &zpfs);//todo, optimize search in zip
 		OX_ASSERT(zp);
 		OX_ASSERT(zp);
 		if (!zp)
 		if (!zp)
 			return;
 			return;

+ 14 - 0
oxygine/src/core/android/jniHelper.cpp

@@ -0,0 +1,14 @@
+#include "jniHelper.h"
+
+extern "C"
+{
+	JNIEnv* Android_JNI_GetEnv(void);
+}
+
+namespace oxygine
+{
+	JNIEnv* jniGetEnv(void)
+	{
+		return Android_JNI_GetEnv();
+	}
+}

+ 43 - 0
oxygine/src/core/android/jniHelper.h

@@ -0,0 +1,43 @@
+#pragma once
+#include <jni.h> 
+#include <android/log.h>
+namespace oxygine
+{
+	#define STRINGIZE_DETAIL(x) #x
+	#define STRINGIZE(x) STRINGIZE_DETAIL(x)
+
+	template <bool D>
+	class LocalReferenceHolder
+	{
+	public:
+		LocalReferenceHolder(JNIEnv *env, const char *func, const char *line):_env(env), _func(func), _line(line)
+		{
+			if (D)
+		 		__android_log_print(ANDROID_LOG_DEBUG, "SDL", "LocalReferenceHolder enter: %s %s", _func, _line);
+			_env->PushLocalFrame(16);			
+		}
+
+
+		~LocalReferenceHolder()
+		{
+			_env->PopLocalFrame(0);
+
+			if (D)
+				__android_log_print(ANDROID_LOG_DEBUG, "SDL", "LocalReferenceHolder left: %s %s", _func, _line);
+		}
+
+		JNIEnv *_env;
+		const char *_func;
+		const char *_line;
+	};
+
+	#define LOCAL_REF_HOLDER(env) LocalReferenceHolder<false> _lr_(env, __func__, STRINGIZE(__LINE__));
+	#define LOCAL_REF_HOLDER_D(env) LocalReferenceHolder<true> _lr_(env, __func__, STRINGIZE(__LINE__));
+
+	class notFound {};
+
+	#define JNI_NOT_NULL(v) if (!v) { __android_log_print(ANDROID_LOG_DEBUG, "SDL", "NOTNULL! %d %s", __LINE__, __FILE__); throw notFound();}
+
+
+	JNIEnv* jniGetEnv(void);
+}

+ 142 - 0
oxygine/src/core/android/jniUtils.cpp

@@ -0,0 +1,142 @@
+#include "jniUtils.h"
+#include "jnihelper.h"
+
+jobject _jmainActivity = 0;
+jclass _jmainActivityClass = 0;
+jclass _jUtils = 0;
+
+jmethodID _jUtils_getTimeUTCMS = 0;
+jmethodID _jUtils_getLanguage = 0;
+jmethodID _jUtils_isNetworkAvailable = 0;
+
+namespace oxygine
+{
+	using namespace std;
+	
+	jobject			jniGetMainActivity()
+	{
+		return _jmainActivity;
+	}
+
+	jclass			jniGetMainActivityClass()
+	{
+		return _jmainActivityClass;
+	}
+
+	void			jniSetMainActivityClass(jclass c)
+	{		
+		_jmainActivityClass = c;
+	}
+
+	void _jniInit(JNIEnv *env)
+	{
+		try
+		{
+			LOCAL_REF_HOLDER(env);
+
+			_jUtils = (jclass)env->NewGlobalRef(env->FindClass("org/oxygine/lib/Utils"));
+			JNI_NOT_NULL(_jUtils);
+
+			_jUtils_getTimeUTCMS = env->GetStaticMethodID(_jUtils, "getTimeUTCMS", "()J");
+			JNI_NOT_NULL(_jUtils_getTimeUTCMS);
+
+			_jUtils_getLanguage = env->GetStaticMethodID(_jUtils, "getLanguage", "()Ljava/lang/String;");
+			JNI_NOT_NULL(_jUtils_getLanguage);
+
+			_jUtils_isNetworkAvailable = env->GetStaticMethodID(_jUtils, "isNetworkAvailable", "()Z");
+			JNI_NOT_NULL(_jUtils_isNetworkAvailable);
+		}
+		catch(const notFound&)
+		{
+
+		}
+
+	}
+
+	int64 jniGetTimeUTCMS()
+	{
+		try
+		{
+			JNIEnv *env = jniGetEnv();
+			LOCAL_REF_HOLDER(env);
+
+			jlong value = env->CallStaticLongMethod(_jUtils, _jUtils_getTimeUTCMS);
+			return value;
+		}
+		catch(const notFound&)
+		{
+
+		}
+
+		return 0;
+	}
+
+	std::string 	getString(JNIEnv *env, jstring jstr)
+	{
+		const char *cstr = env->GetStringUTFChars(jstr, 0);
+		string str = cstr;
+		env->ReleaseStringUTFChars(jstr, cstr);
+		return str;
+	}
+
+	std::string		jniGetLanguage()
+	{
+		try
+		{
+			JNIEnv *env = jniGetEnv();
+			LOCAL_REF_HOLDER(env);
+
+			jstring jstr = (jstring)env->CallStaticObjectMethod(_jUtils, _jUtils_getLanguage);
+
+			return getString(env, jstr);
+		}
+		catch(const notFound&)
+		{
+
+		}
+
+		return "";
+	}
+
+	bool			jniIsNetworkAvailable()
+	{
+		try
+		{
+			JNIEnv *env = jniGetEnv();
+			LOCAL_REF_HOLDER(env);
+
+			jboolean value = env->CallStaticBooleanMethod(_jUtils, _jUtils_isNetworkAvailable);
+			return value;
+		}
+		catch(const notFound&)
+		{
+
+		}
+
+		return false;
+	}
+}
+
+static void _init(JNIEnv *env)
+{
+	oxygine::_jniInit(env);
+}
+
+extern "C"
+{
+	/*
+	 * Class:     org_oxygine_OxygineActivity
+	 * Method:    nativeOxygineInit
+	 * Signature: (Lorg/oxygine/OxygineActivity;)V
+	 */
+
+
+	JNIEXPORT void JNICALL Java_org_oxygine_lib_OxygineActivity_nativeOxygineInit
+		(JNIEnv *env, jclass clazz, jobject object)
+	{
+		_jmainActivityClass = (jclass)env->NewGlobalRef(clazz);
+		_jmainActivity = env->NewGlobalRef(object);
+
+		_init(env);
+	}
+}

+ 19 - 0
oxygine/src/core/android/jniUtils.h

@@ -0,0 +1,19 @@
+#pragma once
+#include "oxygine_include.h"
+#include "jnihelper.h"
+#include "core/oxygine.h"
+#include <string>
+
+namespace oxygine
+{
+	jobject			jniGetMainActivity();
+	jclass			jniGetMainActivityClass();
+	void			jniSetMainActivityClass(jclass);
+
+	/**returns UTC time in MS*/
+	int64			jniGetTimeUTCMS();
+
+	/**returns locale. ISO 639-1 */
+	std::string		jniGetLanguage();
+	bool			jniIsNetworkAvailable();
+}

+ 24 - 4
oxygine/src/core/file.cpp

@@ -17,6 +17,8 @@
 #else
 #else
 #if WIN32
 #if WIN32
 #include <direct.h>
 #include <direct.h>
+#else
+#include "SDL_system.h"
 #endif
 #endif
 #endif
 #endif
 
 
@@ -46,12 +48,28 @@ namespace oxygine
 		*/
 		*/
 		STDFileSystem _nfs(true);
 		STDFileSystem _nfs(true);
 		STDFileSystem _nfsWrite(false);
 		STDFileSystem _nfsWrite(false);
-		STDFileSystem _nfsExtended(true);
+		//STDFileSystem _nfsExtended(true);
 
 
 		void init()
 		void init()
 		{
 		{
+#ifdef __S3E__
+			_nfs.setPath("rom://");
+			_nfsWrite.setPath("ram://");
+#endif
+
+#ifdef __ANDROID__
+			log::messageln("internal %s", SDL_AndroidGetInternalStoragePath());
+			log::messageln("external %s", SDL_AndroidGetExternalStoragePath());
+			_nfsWrite.setPath(SDL_AndroidGetInternalStoragePath());
+#endif // __ANDROID__
+
+#ifdef WIN32
+			_mkdir("../data-ram/");
+			_nfsWrite.setPath("../data-ram/");			
+#endif
+
 			_nfs.mount(&_nfsWrite);
 			_nfs.mount(&_nfsWrite);
-			_nfs.mount(&_nfsExtended);
+			//_nfs.mount(&_nfsExtended);
 		}
 		}
 
 
 		void mount(FileSystem *fs)
 		void mount(FileSystem *fs)
@@ -196,18 +214,20 @@ namespace oxygine
 				return;
 				return;
 			write(ac.getHandle(), data.getData(), data.getSize());
 			write(ac.getHandle(), data.getData(), data.getSize());
 		}
 		}
+		/*
 
 
 		void setExtendedFolder(const char *folder)
 		void setExtendedFolder(const char *folder)
 		{
 		{
 			_nfsExtended.setPath(folder);			
 			_nfsExtended.setPath(folder);			
 		}
 		}
+		*/
 
 
-		file::FileSystem &fs()
+		file::STDFileSystem &fs()
 		{
 		{
 			return _nfs;
 			return _nfs;
 		}
 		}
 
 
-		file::FileSystem &wfs()
+		file::STDFileSystem &wfs()
 		{
 		{
 			return _nfsWrite;
 			return _nfsWrite;
 		}
 		}

+ 5 - 23
oxygine/src/core/file.h

@@ -7,25 +7,10 @@
 
 
 namespace oxygine
 namespace oxygine
 {
 {
-	/**Input/Output files api.*/
-
-	/**
-	some notes:
-	setExtendedFolder could be used as hook for High Definition art assets.
-		If file is missing in additional folder it would be searched from root resources folder.
-		here is folders structure example:
-	root:
-		images/ \n
-		atlasses\ \n
-		xmls/ \n
-		fonts/ \n
-		HD/images/ \n
-		  /fonts/ \n
-		if you want use HD resources you should add setAdditionalFolder("HD");
-	*/
-
 	namespace file
 	namespace file
 	{
 	{
+		class STDFileSystem;
+
 		class buffer
 		class buffer
 		{
 		{
 		public:		
 		public:		
@@ -69,14 +54,11 @@ namespace oxygine
 		bool rename(const char *src, const char *dest, error_policy ep = ep_show_warning);
 		bool rename(const char *src, const char *dest, error_policy ep = ep_show_warning);
 		bool makeDirectory(const char *path);
 		bool makeDirectory(const char *path);
 		void deleteDirectory(const char *path);
 		void deleteDirectory(const char *path);
-
-		/**setExtendedFolder sets additional "hook" folder where files would be searched initially.*/
-		void setExtendedFolder(const char *folder);
-
+		
 		//returns main fs
 		//returns main fs
-		file::FileSystem &fs();
+		file::STDFileSystem &fs();
 		//returns writable fs
 		//returns writable fs
-		file::FileSystem &wfs();
+		file::STDFileSystem &wfs();
 
 
 		class autoClose
 		class autoClose
 		{
 		{

+ 26 - 3
oxygine/src/core/oxygine.cpp

@@ -49,6 +49,9 @@ using namespace AS3::ui;
 #include "gl/VideoDriverGLES20.h"
 #include "gl/VideoDriverGLES20.h"
 #endif
 #endif
 
 
+#ifdef __ANDROID__
+#include "core/android/jniUtils.h"
+#endif
 
 
 #ifdef OXYGINE_SDL
 #ifdef OXYGINE_SDL
 #include "coroutines.h"
 #include "coroutines.h"
@@ -799,18 +802,38 @@ namespace oxygine
 		int64 t = tm.dwLowDateTime + (int64(tm.dwHighDateTime) << 32);
 		int64 t = tm.dwLowDateTime + (int64(tm.dwHighDateTime) << 32);
 		int64 utc = (t - 116444736000000000LL)/10000;
 		int64 utc = (t - 116444736000000000LL)/10000;
 		return utc;		
 		return utc;		
+#endif
+#ifdef __ANDROID__
+		return jniGetTimeUTCMS();
 #endif
 #endif
 		return getTimeMS();
 		return getTimeMS();
 	}
 	}
 
 
+	bool	isNetworkAvaible()
+	{
+#ifdef __S3E__
+		return s3eSocketGetInt(S3E_SOCKET_NETWORK_AVAILABLE) == 1;
+#endif
+#ifdef __ANDROID__
+		return jniIsNetworkAvailable();
+#endif		
+		return true;
+	}
+
+	std::string		getLanguage()
+	{
+#ifdef __ANDROID__
+		return jniGetLanguage();
+#endif		
+		return "unknown";
+	}
+
 	void	sleep(timeMS time)
 	void	sleep(timeMS time)
 	{
 	{
 #if __S3E__
 #if __S3E__
 		s3eDeviceYield(time);
 		s3eDeviceYield(time);
-#elif OXYGINE_SDL
-		SDL_Delay(time);
 #else
 #else
-		OX_ASSERT(0);
+		SDL_Delay(time);
 #endif
 #endif
 	}
 	}
 }
 }

+ 6 - 4
oxygine/src/core/oxygine.h

@@ -11,6 +11,7 @@
 #include "log.h"
 #include "log.h"
 #include "ox_debug.h"
 #include "ox_debug.h"
 #include "ThreadMessages.h"
 #include "ThreadMessages.h"
+#include <string>
 
 
 #ifndef __S3E__
 #ifndef __S3E__
 #if defined(_MSC_VER) || defined(__BORLANDC__)
 #if defined(_MSC_VER) || defined(__BORLANDC__)
@@ -63,11 +64,12 @@ namespace oxygine
 	}
 	}
 
 
 	/** returns local app time in milliseconds (1sec = 1000ms). Counting starts from zero*/	
 	/** returns local app time in milliseconds (1sec = 1000ms). Counting starts from zero*/	
-	timeMS getTimeMS();
+	timeMS			getTimeMS();
+	int64			getTimeUTCMS();
+	bool			isNetworkAvaible();
+	/**returns locale. ISO 639-1 */
+	std::string		getLanguage();
 
 
-	/**return UTC time in seconds*/
-	int		getTimeUTC();//deprecated
-	int64	getTimeUTCMS();
 
 
 
 
 	void	sleep(timeMS);
 	void	sleep(timeMS);

+ 4 - 1
oxygine/src/res/Resources.cpp

@@ -129,7 +129,10 @@ namespace oxygine
 		return Resource::comparePred(*ob1, *ob2);
 		return Resource::comparePred(*ob1, *ob2);
 	}
 	}
 
 
-	void Resources::loadXML(const string &xml_name, LoadResourcesContext *load_context, bool load_completely, bool use_load_counter, const string &prebuilt_folder_)
+	void Resources::loadXML(const string &xml_name, 
+		LoadResourcesContext *load_context, 
+		bool load_completely, bool use_load_counter, 
+		const string &prebuilt_folder_)
 	{
 	{
 		_name = xml_name;
 		_name = xml_name;
 
 

+ 3 - 1
oxygine/src/res/Resources.h

@@ -48,7 +48,9 @@ namespace oxygine
 		@param use load counter internally
 		@param use load counter internally
 		@param use not standard folder with prebuilt resources (atlasses, fonts, etc)
 		@param use not standard folder with prebuilt resources (atlasses, fonts, etc)
 		*/
 		*/
-		void loadXML(const string &file, LoadResourcesContext *load_context = 0, bool load_completely = true, bool use_load_counter = false, const string &prebuilt_folder = "");
+		void loadXML(const string &file, LoadResourcesContext *load_context = 0, 
+			bool load_completely = true, bool use_load_counter = false,
+			const string &prebuilt_folder = "");
 
 
 		/**Adds your own Resource and becomes resource owner. Added resource will be deleted from destructor by calling 'delete'.*/
 		/**Adds your own Resource and becomes resource owner. Added resource will be deleted from destructor by calling 'delete'.*/
 		void add(Resource *r);
 		void add(Resource *r);

+ 14 - 7
oxygine/src/utils/stringUtils.cpp

@@ -24,7 +24,7 @@ namespace oxygine
 			//OX_ASSERT(strcmp(dest, "/") == 0);
 			//OX_ASSERT(strcmp(dest, "/") == 0);
 
 
 			normalize("/../", dest);
 			normalize("/../", dest);
-			OX_ASSERT(strcmp(dest, "../") == 0);
+			OX_ASSERT(strcmp(dest, "/../") == 0);
 
 
 			normalize("../c\\", dest);
 			normalize("../c\\", dest);
 			OX_ASSERT(strcmp(dest, "../c/") == 0);
 			OX_ASSERT(strcmp(dest, "../c/") == 0);
@@ -34,7 +34,7 @@ namespace oxygine
 
 
 
 
 			normalize("\\/\\///\\/", dest);// \n
 			normalize("\\/\\///\\/", dest);// \n
-			OX_ASSERT(strcmp(dest, "") == 0);
+			OX_ASSERT(strcmp(dest, "/") == 0);
 
 
 			normalize("a/b/..\\//..///\\/../c\\\\/", dest);
 			normalize("a/b/..\\//..///\\/../c\\\\/", dest);
 			OX_ASSERT(strcmp(dest, "../c/") == 0);
 			OX_ASSERT(strcmp(dest, "../c/") == 0);
@@ -121,12 +121,19 @@ namespace oxygine
 		}
 		}
 
 
 		void normalize(const char *src, char *dest)
 		void normalize(const char *src, char *dest)
-		{
-			char *copy = dest;
+		{			
 			OX_ASSERT(src != dest);
 			OX_ASSERT(src != dest);
 
 
-			char last = 0;
-			
+			//const char *srccopy = src;
+			if (*src == '/' || *src == '\\')
+			{
+				*dest = '/';
+				++src;
+				++dest;
+			}		
+			char *copy = dest;
+
+			char last = 0;		
 
 
 			*dest = 0;
 			*dest = 0;
 			while(*src)
 			while(*src)
@@ -137,7 +144,7 @@ namespace oxygine
 
 
 				if (c == '\\')
 				if (c == '\\')
 					c = '/';
 					c = '/';
-				if (c == '/' && last == '.' && last_last == '.' && dest > copy + 2)
+				if (c == '/' && last == '.' && last_last == '.' && (dest > copy + 2))
 				{
 				{
 					dest -= 3;
 					dest -= 3;
 					while (dest > copy)
 					while (dest > copy)

+ 14 - 10
readme.Android

@@ -2,19 +2,23 @@
 2. Example 'Demo' has configured android project
 2. Example 'Demo' has configured android project
 how to build. Steps:
 how to build. Steps:
 - make sure that you have android-12 SDK, NDK apache-ant installed and all ENVIRONMENT variables configured properly
 - make sure that you have android-12 SDK, NDK apache-ant installed and all ENVIRONMENT variables configured properly
-- goto oxygine-framework/examples/demo/proj.android/
-- check local.properties and path to android sdk
-- check that you have Android-12 sdk installed
+
+- goto oxygine-framework/examples/demo/proj.android and oxygine-framework/oxygine/SDL/android/lib
+- open local.properties and fix path to android sdk
+- check that you have Android-12 sdk installed or change it in project.properties to your version
+
 - copy latest source code 
 - copy latest source code 
-	from SDL/android-project/src/org/libsdl/app/
-	to oxygine-framework/examples/demo/proj.android/src/org/libsdl/app/
-- copy assets from oxygine's Demo example:
+	from SDL/android-project/src/
+	to oxygine-framework/oxygine/SDL/android/lib/src/
+
+- copy all assets (files and folders) from assets from oxygine's Demo example:
   from oxygine-framework\examples\Demo\data\
   from oxygine-framework\examples\Demo\data\
   to oxygine-framework\examples\Demo\proj.android\assets\
   to oxygine-framework\examples\Demo\proj.android\assets\
 - application is ready to build
 - application is ready to build
 
 
-you could use this batch files
 
 
-- run build.cmd
-- run ant_debug.bat
-- apk is ready
+try to build it using these shell commands:
+ndk-build
+ant debug
+
+apk is ready!

+ 1 - 1
readme.iOS

@@ -5,5 +5,5 @@
   
   
 - open xcode 5 project from:
 - open xcode 5 project from:
   examples\Demo\proj.ios\
   examples\Demo\proj.ios\
-- select correct scheme: demo_ios-> iOS Simulator or real device
+- select correct scheme: demo_ios-> iOS Simulator or real device (But not 64bits!)
 - build and run!
 - build and run!