diff options
Diffstat (limited to 'platform/android')
30 files changed, 291 insertions, 109 deletions
diff --git a/platform/android/AndroidManifest.xml.template b/platform/android/AndroidManifest.xml.template index d31bdbfa53..c95c86c060 100644 --- a/platform/android/AndroidManifest.xml.template +++ b/platform/android/AndroidManifest.xml.template @@ -7,7 +7,7 @@ > <supports-screens android:smallScreens="true" android:normalScreens="true" - android:largeScreens="true" + android:largeScreens="false" android:xlargeScreens="true"/> <application android:label="@string/godot_project_name_string" android:icon="@drawable/icon" android:allowBackup="false" $$ADD_APPATTRIBUTE_CHUNKS$$ > @@ -15,7 +15,7 @@ android:label="@string/godot_project_name_string" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:launchMode="singleTask" - android:screenOrientation="portrait" + android:screenOrientation="landscape" android:configChanges="orientation|keyboardHidden|screenSize|smallestScreenSize"> <intent-filter> @@ -200,6 +200,6 @@ $$ADD_PERMISSION_CHUNKS$$ <uses-permission android:name="godot.custom.18"/> <uses-permission android:name="godot.custom.19"/> -<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="15"/> +<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="19"/> </manifest> diff --git a/platform/android/android_native_app_glue.h b/platform/android/android_native_app_glue.h index fe8684b5d2..f5ba27ae66 100644 --- a/platform/android/android_native_app_glue.h +++ b/platform/android/android_native_app_glue.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -26,7 +26,7 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ - * Copyright (C) 2010 The Android Open Source Project +/* Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/android/audio_driver_jandroid.cpp b/platform/android/audio_driver_jandroid.cpp index 6e3f6f9505..1a3a1cb563 100644 --- a/platform/android/audio_driver_jandroid.cpp +++ b/platform/android/audio_driver_jandroid.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/platform/android/audio_driver_jandroid.h b/platform/android/audio_driver_jandroid.h index f102acf154..bf8584051d 100644 --- a/platform/android/audio_driver_jandroid.h +++ b/platform/android/audio_driver_jandroid.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/platform/android/audio_driver_opensl.cpp b/platform/android/audio_driver_opensl.cpp index 4c0c095e10..a08bc8943c 100644 --- a/platform/android/audio_driver_opensl.cpp +++ b/platform/android/audio_driver_opensl.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/platform/android/audio_driver_opensl.h b/platform/android/audio_driver_opensl.h index d852928ab8..e9d7c7a7ea 100644 --- a/platform/android/audio_driver_opensl.h +++ b/platform/android/audio_driver_opensl.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/platform/android/detect.py b/platform/android/detect.py index 86743fc370..5ef405f7b6 100644 --- a/platform/android/detect.py +++ b/platform/android/detect.py @@ -24,7 +24,7 @@ def get_opts(): ('NDK_TOOLCHAIN', 'toolchain to use for the NDK',"arm-eabi-4.4.0"), #android 2.3 ('ndk_platform', 'compile for platform: (2.2,2.3)',"2.2"), - ('NDK_TARGET', 'toolchain to use for the NDK',"arm-linux-androideabi-4.9"), + ('NDK_TARGET', 'toolchain to use for the NDK',"arm-linux-androideabi-4.8"), ('android_stl','enable STL support in android port (for modules)','no'), ('armv6','compile for older phones running arm v6 (instead of v7+neon+smp)','no'), ('x86','Xompile for Android-x86','no') diff --git a/platform/android/dir_access_android.cpp b/platform/android/dir_access_android.cpp index 80311e5a08..ca1e58da3f 100644 --- a/platform/android/dir_access_android.cpp +++ b/platform/android/dir_access_android.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/platform/android/dir_access_android.h b/platform/android/dir_access_android.h index 57683542fa..cbbcdb71bb 100644 --- a/platform/android/dir_access_android.h +++ b/platform/android/dir_access_android.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/platform/android/dir_access_jandroid.cpp b/platform/android/dir_access_jandroid.cpp index 98f20b2636..2b5fc6a50a 100644 --- a/platform/android/dir_access_jandroid.cpp +++ b/platform/android/dir_access_jandroid.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -31,11 +31,15 @@ #include "dir_access_jandroid.h" #include "file_access_jandroid.h" #include "thread_jandroid.h" +#include "print_string.h" + + jobject DirAccessJAndroid::io=NULL; jclass DirAccessJAndroid::cls=NULL; jmethodID DirAccessJAndroid::_dir_open=NULL; jmethodID DirAccessJAndroid::_dir_next=NULL; jmethodID DirAccessJAndroid::_dir_close=NULL; +jmethodID DirAccessJAndroid::_dir_is_dir=NULL; DirAccess *DirAccessJAndroid::create_fs() { @@ -67,43 +71,18 @@ String DirAccessJAndroid::get_next(){ if (!str) return ""; - int sl = env->GetStringLength(str); - if (sl==0) { - env->DeleteLocalRef((jobject)str); - return ""; - } - - CharString cs; - cs.resize(sl+1); - env->GetStringRegion(str,0,sl,(jchar*)&cs[0]); - cs[sl]=0; - - String ret; - ret.parse_utf8(&cs[0]); + String ret = String::utf8(env->GetStringUTFChars( (jstring)str, NULL )); env->DeleteLocalRef((jobject)str); - return ret; } bool DirAccessJAndroid::current_is_dir() const{ - JNIEnv *env = ThreadAndroid::get_env(); - String sd; - if (current_dir=="") - sd=current; - else - sd=current_dir+"/"+current; - - jstring js = env->NewStringUTF(sd.utf8().get_data()); - - int res = env->CallIntMethod(io,_dir_open,js); - if (res<=0) - return false; - env->CallObjectMethod(io,_dir_close,res); + JNIEnv *env = ThreadAndroid::get_env(); + return env->CallBooleanMethod(io,_dir_is_dir,id); - return true; } bool DirAccessJAndroid::current_is_hidden() const { @@ -142,24 +121,31 @@ Error DirAccessJAndroid::change_dir(String p_dir){ String new_dir; + if (p_dir!="res://" && p_dir.length()>1 && p_dir.ends_with("/")) + p_dir=p_dir.substr(0,p_dir.length()-1); + if (p_dir.begins_with("/")) new_dir=p_dir.substr(1,p_dir.length()); else if (p_dir.begins_with("res://")) new_dir=p_dir.substr(6,p_dir.length()); - else //relative - new_dir=new_dir+"/"+p_dir; + else if (current_dir=="") + new_dir=p_dir; + else + new_dir=current_dir.plus_file(p_dir); + //print_line("new dir is: "+new_dir); //test if newdir exists new_dir=new_dir.simplify_path(); jstring js = env->NewStringUTF(new_dir.utf8().get_data()); int res = env->CallIntMethod(io,_dir_open,js); + env->DeleteLocalRef(js); if (res<=0) return ERR_INVALID_PARAMETER; env->CallObjectMethod(io,_dir_close,res); - + current_dir=new_dir; return OK; } @@ -176,7 +162,7 @@ bool DirAccessJAndroid::file_exists(String p_file){ if (current_dir=="") sd=p_file; else - sd=current_dir+"/"+p_file; + sd=current_dir.plus_file(p_file); FileAccessJAndroid *f = memnew(FileAccessJAndroid); bool exists = f->file_exists(sd); @@ -190,12 +176,19 @@ bool DirAccessJAndroid::dir_exists(String p_dir) { JNIEnv *env = ThreadAndroid::get_env(); String sd; + + if (current_dir=="") sd=p_dir; - else - sd=current_dir+"/"+p_dir; + else { + if (p_dir.is_rel_path()) + sd=current_dir.plus_file(p_dir); + else + sd=fix_path(p_dir); + } + + String path=sd.simplify_path(); - String path=fix_path(sd).simplify_path(); if (path.begins_with("/")) path=path.substr(1,path.length()); else if (path.begins_with("res://")) @@ -203,6 +196,7 @@ bool DirAccessJAndroid::dir_exists(String p_dir) { jstring js = env->NewStringUTF(path.utf8().get_data()); int res = env->CallIntMethod(io,_dir_open,js); + env->DeleteLocalRef(js); if (res<=0) return false; @@ -256,6 +250,10 @@ void DirAccessJAndroid::setup( jobject p_io) { if(_dir_close != 0) { __android_log_print(ANDROID_LOG_INFO,"godot","*******GOT METHOD _dir_close ok!!"); } + _dir_is_dir = env->GetMethodID(cls, "dir_is_dir", "(I)Z"); + if(_dir_is_dir != 0) { + __android_log_print(ANDROID_LOG_INFO,"godot","*******GOT METHOD _dir_is_dir ok!!"); + } // (*env)->CallVoidMethod(env,obj,aMethodID, myvar); } diff --git a/platform/android/dir_access_jandroid.h b/platform/android/dir_access_jandroid.h index 0a696506e6..7b6242ca32 100644 --- a/platform/android/dir_access_jandroid.h +++ b/platform/android/dir_access_jandroid.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -47,6 +47,7 @@ class DirAccessJAndroid : public DirAccess { static jmethodID _dir_open; static jmethodID _dir_next; static jmethodID _dir_close; + static jmethodID _dir_is_dir; int id; diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index 3e4ea8a4e0..d169ec51d5 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -185,6 +185,10 @@ class EditorExportPlatformAndroid : public EditorExportPlatform { bool _signed; bool apk_expansion; bool remove_prev; + bool use_32_fb; + bool immersive; + bool export_arm; + bool export_x86; String apk_expansion_salt; String apk_expansion_pkey; int orientation; @@ -221,6 +225,8 @@ class EditorExportPlatformAndroid : public EditorExportPlatform { static void _device_poll_thread(void *ud); + String get_package_name(); + String get_project_name() const; void _fix_manifest(Vector<uint8_t>& p_manifest); void _fix_resources(Vector<uint8_t>& p_manifest); @@ -279,6 +285,14 @@ bool EditorExportPlatformAndroid::_set(const StringName& p_name, const Variant& icon=p_value; else if (n=="package/signed") _signed=p_value; + else if (n=="architecture/arm") + export_arm=p_value; + else if (n=="architecture/x86") + export_x86=p_value; + else if (n=="screen/use_32_bits_view") + use_32_fb=p_value; + else if (n=="screen/immersive_mode") + immersive=p_value; else if (n=="screen/orientation") orientation=p_value; else if (n=="screen/support_small") @@ -344,6 +358,14 @@ bool EditorExportPlatformAndroid::_get(const StringName& p_name,Variant &r_ret) r_ret=icon; else if (n=="package/signed") r_ret=_signed; + else if (n=="architecture/arm") + r_ret=export_arm; + else if (n=="architecture/x86") + r_ret=export_x86; + else if (n=="screen/use_32_bits_view") + r_ret=use_32_fb; + else if (n=="screen/immersive_mode") + r_ret=immersive; else if (n=="screen/orientation") r_ret=orientation; else if (n=="screen/support_small") @@ -393,6 +415,10 @@ void EditorExportPlatformAndroid::_get_property_list( List<PropertyInfo> *p_list p_list->push_back( PropertyInfo( Variant::STRING, "package/name") ); p_list->push_back( PropertyInfo( Variant::STRING, "package/icon",PROPERTY_HINT_FILE,"png") ); p_list->push_back( PropertyInfo( Variant::BOOL, "package/signed") ); + p_list->push_back( PropertyInfo( Variant::BOOL, "architecture/arm") ); + p_list->push_back( PropertyInfo( Variant::BOOL, "architecture/x86") ); + p_list->push_back( PropertyInfo( Variant::BOOL, "screen/use_32_bits_view") ); + p_list->push_back( PropertyInfo( Variant::BOOL, "screen/immersive_mode") ); p_list->push_back( PropertyInfo( Variant::INT, "screen/orientation",PROPERTY_HINT_ENUM,"Landscape,Portrait") ); p_list->push_back( PropertyInfo( Variant::BOOL, "screen/support_small") ); p_list->push_back( PropertyInfo( Variant::BOOL, "screen/support_normal") ); @@ -629,11 +655,11 @@ void EditorExportPlatformAndroid::_fix_manifest(Vector<uint8_t>& p_manifest) { int iofs=ofs+8; - uint32_t string_count=decode_uint32(&p_manifest[iofs]); - uint32_t styles_count=decode_uint32(&p_manifest[iofs+4]); + string_count=decode_uint32(&p_manifest[iofs]); + styles_count=decode_uint32(&p_manifest[iofs+4]); uint32_t string_flags=decode_uint32(&p_manifest[iofs+8]); - uint32_t string_data_offset=decode_uint32(&p_manifest[iofs+12]); - uint32_t styles_offset=decode_uint32(&p_manifest[iofs+16]); + string_data_offset=decode_uint32(&p_manifest[iofs+12]); + styles_offset=decode_uint32(&p_manifest[iofs+16]); /* printf("string count: %i\n",string_count); printf("flags: %i\n",string_flags); @@ -732,7 +758,7 @@ void EditorExportPlatformAndroid::_fix_manifest(Vector<uint8_t>& p_manifest) { if (tname=="manifest" && attrname=="package") { print_line("FOUND PACKAGE"); - string_table[attr_value]=package; + string_table[attr_value]=get_package_name(); } //print_line("tname: "+tname); @@ -756,19 +782,21 @@ void EditorExportPlatformAndroid::_fix_manifest(Vector<uint8_t>& p_manifest) { if (tname=="activity" && /*nspace=="android" &&*/ attrname=="screenOrientation") { + encode_uint32(orientation==0?0:1,&p_manifest[iofs+16]); + /* print_line("FOUND screen orientation"); if (attr_value==0xFFFFFFFF) { WARN_PRINT("Version name in a resource, should be plaintext") } else { string_table[attr_value]=(orientation==0?"landscape":"portrait"); - } + }*/ } if (tname=="application" && /*nspace=="android" &&*/ attrname=="label") { print_line("FOUND application"); if (attr_value==0xFFFFFFFF) { - WARN_PRINT("Application name in a resource, should be plaintext.") + WARN_PRINT("Application name in a resource, should be plaintext (but you can ignore this).") } else { String aname = get_project_name(); @@ -779,7 +807,7 @@ void EditorExportPlatformAndroid::_fix_manifest(Vector<uint8_t>& p_manifest) { print_line("FOUND activity name"); if (attr_value==0xFFFFFFFF) { - WARN_PRINT("Activity name in a resource, should be plaintext") + WARN_PRINT("Activity name in a resource, should be plaintext (but you can ignore this)") } else { String aname; if (this->name!="") { @@ -823,23 +851,19 @@ void EditorExportPlatformAndroid::_fix_manifest(Vector<uint8_t>& p_manifest) { WARN_PRINT("Screen res name in a resource, should be plaintext") } else if (attrname=="smallScreens") { - print_line("SMALLSCREEN"); - string_table[attr_value]=screen_support[SCREEN_SMALL]?"true":"false"; + encode_uint32(screen_support[SCREEN_SMALL]?0xFFFFFFFF:0,&p_manifest[iofs+16]); } else if (attrname=="mediumScreens") { - print_line("MEDSCREEN"); - string_table[attr_value]=screen_support[SCREEN_NORMAL]?"true":"false"; + encode_uint32(screen_support[SCREEN_NORMAL]?0xFFFFFFFF:0,&p_manifest[iofs+16]); } else if (attrname=="largeScreens") { - print_line("LARGECREEN"); - string_table[attr_value]=screen_support[SCREEN_LARGE]?"true":"false"; + encode_uint32(screen_support[SCREEN_LARGE]?0xFFFFFFFF:0,&p_manifest[iofs+16]); } else if (attrname=="xlargeScreens") { - print_line("XLARGECREEN"); - string_table[attr_value]=screen_support[SCREEN_XLARGE]?"true":"false"; + encode_uint32(screen_support[SCREEN_XLARGE]?0xFFFFFFFF:0,&p_manifest[iofs+16]); } } @@ -1035,6 +1059,8 @@ Error EditorExportPlatformAndroid::export_project(const String& p_path, bool p_d char fname[16384]; ret = unzGetCurrentFileInfo(pkg,&info,fname,16384,NULL,0,NULL,0); + bool skip=false; + String file=fname; Vector<uint8_t> data; @@ -1087,20 +1113,31 @@ Error EditorExportPlatformAndroid::export_project(const String& p_path, bool p_d } } + if (file=="lib/x86/libgodot_android.so" && !export_x86) { + skip=true; + } + + if (file=="lib/armeabi/libgodot_android.so" && !export_arm) { + skip=true; + } + print_line("ADDING: "+file); - zipOpenNewFileInZip(apk, - file.utf8().get_data(), - NULL, - NULL, - 0, - NULL, - 0, - NULL, - Z_DEFLATED, - Z_DEFAULT_COMPRESSION); - zipWriteInFileInZip(apk,data.ptr(),data.size()); - zipCloseFileInZip(apk); + if (!skip) { + zipOpenNewFileInZip(apk, + file.utf8().get_data(), + NULL, + NULL, + 0, + NULL, + 0, + NULL, + Z_DEFLATED, + Z_DEFAULT_COMPRESSION); + + zipWriteInFileInZip(apk,data.ptr(),data.size()); + zipCloseFileInZip(apk); + } ret = unzGoToNextFile(pkg); } @@ -1134,7 +1171,7 @@ Error EditorExportPlatformAndroid::export_project(const String& p_path, bool p_d if (apk_expansion) { - String apkfname="main."+itos(version_code)+"."+package+".obb"; + String apkfname="main."+itos(version_code)+"."+get_package_name()+".obb"; String fullpath=p_path.get_base_dir().plus_file(apkfname); FileAccess *pf = FileAccess::open(fullpath,FileAccess::WRITE); if (!pf) { @@ -1158,8 +1195,16 @@ Error EditorExportPlatformAndroid::export_project(const String& p_path, bool p_d err = export_project_files(save_apk_file,&ed,false); } + + } + if (use_32_fb) + cl.push_back("-use_depth_32"); + + if (immersive) + cl.push_back("-use_immersive"); + if (cl.size()) { //add comandline Vector<uint8_t> clf; @@ -1471,7 +1516,7 @@ Error EditorExportPlatformAndroid::run(int p_device, bool p_dumb) { args.push_back("-s"); args.push_back(devices[p_device].id); args.push_back("uninstall"); - args.push_back(package); + args.push_back(get_package_name()); err = OS::get_singleton()->execute(adb,args,true,NULL,NULL,&rv); #if 0 @@ -1509,7 +1554,7 @@ Error EditorExportPlatformAndroid::run(int p_device, bool p_dumb) { args.push_back("-a"); args.push_back("android.intent.action.MAIN"); args.push_back("-n"); - args.push_back(package+"/com.android.godot.Godot"); + args.push_back(get_package_name()+"/com.android.godot.Godot"); err = OS::get_singleton()->execute(adb,args,true,NULL,NULL,&rv); if (err || rv!=0) { @@ -1521,12 +1566,37 @@ Error EditorExportPlatformAndroid::run(int p_device, bool p_dumb) { return OK; } +String EditorExportPlatformAndroid::get_package_name() { + + String pname = package; + String basename = Globals::get_singleton()->get("application/name"); + basename=basename.to_lower(); + + String name; + bool first=true; + for(int i=0;i<basename.length();i++) { + CharType c = basename[i]; + if (c>='0' && c<='9' && first) { + continue; + } + if ((c>='a' && c<='z') || (c>='A' && c<='Z') || (c>='0' && c<='9')) { + name+=String::chr(c); + first=false; + } + } + if (name=="") + name="noname"; + + pname=pname.replace("$genname",name); + return pname; + +} EditorExportPlatformAndroid::EditorExportPlatformAndroid() { version_code=1; version_name="1.0"; - package="com.android.noname"; + package="org.godotengine.$genname"; name=""; _signed=true; apk_expansion=false; @@ -1534,6 +1604,12 @@ EditorExportPlatformAndroid::EditorExportPlatformAndroid() { quit_request=false; orientation=0; remove_prev=true; + use_32_fb=true; + immersive=true; + + export_arm=true; + export_x86=false; + device_thread=Thread::create(_device_poll_thread,this); devices_changed=true; @@ -1613,8 +1689,11 @@ bool EditorExportPlatformAndroid::can_export(String *r_error) const { EditorExportPlatformAndroid::~EditorExportPlatformAndroid() { + quit_request=true; Thread::wait_to_finish(device_thread); + memdelete(device_lock); + memdelete(device_thread); } diff --git a/platform/android/file_access_android.cpp b/platform/android/file_access_android.cpp index f1a2bf5882..da3a37fb42 100644 --- a/platform/android/file_access_android.cpp +++ b/platform/android/file_access_android.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/platform/android/file_access_android.h b/platform/android/file_access_android.h index 080ab1a6ce..f477920ae9 100644 --- a/platform/android/file_access_android.h +++ b/platform/android/file_access_android.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/platform/android/file_access_jandroid.cpp b/platform/android/file_access_jandroid.cpp index e1dec4f601..971d4f84ab 100644 --- a/platform/android/file_access_jandroid.cpp +++ b/platform/android/file_access_jandroid.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -67,7 +67,6 @@ Error FileAccessJAndroid::_open(const String& p_path, int p_mode_flags) { jstring js = env->NewStringUTF(path.utf8().get_data()); int res = env->CallIntMethod(io,_file_open,js,p_mode_flags&WRITE?true:false); - env->DeleteLocalRef(js); if (res<=0) diff --git a/platform/android/file_access_jandroid.h b/platform/android/file_access_jandroid.h index 3cbeab5ffc..13ac4e17b8 100644 --- a/platform/android/file_access_jandroid.h +++ b/platform/android/file_access_jandroid.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/platform/android/godot_android.cpp b/platform/android/godot_android.cpp index 673ff91641..388ff06c10 100644 --- a/platform/android/godot_android.cpp +++ b/platform/android/godot_android.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/platform/android/java/res/drawable/icon.png b/platform/android/java/res/drawable/icon.png Binary files differindex 050a1cf930..78757e9035 100644 --- a/platform/android/java/res/drawable/icon.png +++ b/platform/android/java/res/drawable/icon.png diff --git a/platform/android/java/src/com/android/godot/Godot.java b/platform/android/java/src/com/android/godot/Godot.java index 1a7659a473..e0ac6b0f12 100644 --- a/platform/android/java/src/com/android/godot/Godot.java +++ b/platform/android/java/src/com/android/godot/Godot.java @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -109,6 +109,8 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC private Button mPauseButton; private Button mWiFiSettingsButton; + private boolean use_32_bits=false; + private boolean use_immersive=false; private boolean mStatePaused; private int mState; @@ -255,7 +257,7 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC // ...add to FrameLayout layout.addView(edittext); - mView = new GodotView(getApplication(),io,use_gl2, this); + mView = new GodotView(getApplication(),io,use_gl2,use_32_bits, this); layout.addView(mView,new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT)); mView.setKeepScreenOn(true); @@ -373,6 +375,8 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC mRemoteService.onClientUpdated(mDownloaderClientStub.getMessenger()); } + + @Override protected void onCreate(Bundle icicle) { @@ -399,7 +403,22 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC for(int i=0;i<command_line.length;i++) { boolean has_extra = i< command_line.length -1; - if (command_line[i].equals("-use_apk_expansion")) { + if (command_line[i].equals("-use_depth_32")) { + use_32_bits=true; + } else if (command_line[i].equals("-use_immersive")) { + use_immersive=true; + if(Build.VERSION.SDK_INT >= 19.0){ // check if the application runs on an android 4.4+ + window.getDecorView().setSystemUiVisibility( + View.SYSTEM_UI_FLAG_LAYOUT_STABLE + | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN + | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar + | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar + | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); + + UiChangeListener(); + } + } else if (command_line[i].equals("-use_apk_expansion")) { use_apk_expansion=true; } else if (has_extra && command_line[i].equals("-apk_expansion_md5")) { main_pack_md5=command_line[i+1]; @@ -557,6 +576,16 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC mView.onResume(); mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_NORMAL); GodotLib.focusin(); + if(use_immersive && Build.VERSION.SDK_INT >= 19.0){ // check if the application runs on an android 4.4+ + Window window = getWindow(); + window.getDecorView().setSystemUiVisibility( + View.SYSTEM_UI_FLAG_LAYOUT_STABLE + | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN + | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar + | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar + | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); + } for(int i=0;i<singleton_count;i++) { @@ -567,10 +596,43 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC } + public void UiChangeListener() { + final View decorView = getWindow().getDecorView(); + decorView.setOnSystemUiVisibilityChangeListener (new View.OnSystemUiVisibilityChangeListener() { + @Override + public void onSystemUiVisibilityChange(int visibility) { + if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) { + decorView.setSystemUiVisibility( + View.SYSTEM_UI_FLAG_LAYOUT_STABLE + | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN + | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_FULLSCREEN + | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); + } + } + }); + } + @Override public void onSensorChanged(SensorEvent event) { - float x = event.values[0]; - float y = event.values[1]; - float z = event.values[2]; + Display display = ((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay(); + int displayRotation = display.getRotation(); + + float[] adjustedValues = new float[3]; + final int axisSwap[][] = { + { 1, -1, 0, 1 }, // ROTATION_0 + {-1, -1, 1, 0 }, // ROTATION_90 + {-1, 1, 0, 1 }, // ROTATION_180 + { 1, 1, 1, 0 } }; // ROTATION_270 + + final int[] as = axisSwap[displayRotation]; + adjustedValues[0] = (float)as[0] * event.values[ as[2] ]; + adjustedValues[1] = (float)as[1] * event.values[ as[3] ]; + adjustedValues[2] = event.values[2]; + + float x = adjustedValues[0]; + float y = adjustedValues[1]; + float z = adjustedValues[2]; GodotLib.accelerometer(x,y,z); } diff --git a/platform/android/java/src/com/android/godot/GodotIO.java b/platform/android/java/src/com/android/godot/GodotIO.java index ff0eb5edcc..addceb1528 100644 --- a/platform/android/java/src/com/android/godot/GodotIO.java +++ b/platform/android/java/src/com/android/godot/GodotIO.java @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -271,6 +271,7 @@ public class GodotIO { public String[] files; public int current; + public String path; } public int last_dir_id=1; @@ -281,6 +282,7 @@ public class GodotIO { AssetDir ad = new AssetDir(); ad.current=0; + ad.path=path; try { ad.files = am.list(path); @@ -290,6 +292,7 @@ public class GodotIO { return -1; } + //System.out.printf("Opened dir: %s\n",path); ++last_dir_id; dirs.put(last_dir_id,ad); @@ -297,6 +300,32 @@ public class GodotIO { } + public boolean dir_is_dir(int id) { + if (!dirs.containsKey(id)) { + System.out.printf("dir_next: invalid dir id: %d\n",id); + return false; + } + AssetDir ad = dirs.get(id); + //System.out.printf("go next: %d,%d\n",ad.current,ad.files.length); + int idx = ad.current; + if (idx>0) + idx--; + + if (idx>=ad.files.length) + return false; + String fname = ad.files[idx]; + + try { + if (ad.path.equals("")) + am.open(fname); + else + am.open(ad.path+"/"+fname); + return false; + } catch (Exception e) { + return true; + } + } + public String dir_next(int id) { if (!dirs.containsKey(id)) { @@ -305,8 +334,12 @@ public class GodotIO { } AssetDir ad = dirs.get(id); - if (ad.current>=ad.files.length) + //System.out.printf("go next: %d,%d\n",ad.current,ad.files.length); + + if (ad.current>=ad.files.length) { + ad.current++; return ""; + } String r = ad.files[ad.current]; ad.current++; return r; diff --git a/platform/android/java/src/com/android/godot/GodotLib.java b/platform/android/java/src/com/android/godot/GodotLib.java index 6e2462b4f1..71c31e9f83 100644 --- a/platform/android/java/src/com/android/godot/GodotLib.java +++ b/platform/android/java/src/com/android/godot/GodotLib.java @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/platform/android/java/src/com/android/godot/GodotView.java b/platform/android/java/src/com/android/godot/GodotView.java index f62431b94b..ad0354e624 100644 --- a/platform/android/java/src/com/android/godot/GodotView.java +++ b/platform/android/java/src/com/android/godot/GodotView.java @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -71,14 +71,16 @@ public class GodotView extends GLSurfaceView { private static GodotIO io; private static boolean firsttime=true; private static boolean use_gl2=false; + private static boolean use_32=false; private Godot activity; - public GodotView(Context context,GodotIO p_io,boolean p_use_gl2, Godot p_activity) { + public GodotView(Context context,GodotIO p_io,boolean p_use_gl2, boolean p_use_32_bits, Godot p_activity) { super(context); ctx=context; io=p_io; use_gl2=p_use_gl2; + use_32=p_use_32_bits; activity = p_activity; @@ -366,9 +368,17 @@ public class GodotView extends GLSurfaceView { * custom config chooser. See ConfigChooser class definition * below. */ - setEGLConfigChooser( translucent ? - new ConfigChooser(8, 8, 8, 8, depth, stencil) : - new ConfigChooser(5, 6, 5, 0, depth, stencil) ); + + if (use_32) { + setEGLConfigChooser( translucent ? + new ConfigChooser(8, 8, 8, 8, 24, stencil) : + new ConfigChooser(8, 8, 8, 8, 24, stencil) ); + + } else { + setEGLConfigChooser( translucent ? + new ConfigChooser(8, 8, 8, 8, 16, stencil) : + new ConfigChooser(5, 6, 5, 0, 16, stencil) ); + } /* Set the renderer responsible for frame rendering */ setRenderer(new Renderer()); diff --git a/platform/android/java_glue.cpp b/platform/android/java_glue.cpp index 349db08e36..6ce62bfae2 100644 --- a/platform/android/java_glue.cpp +++ b/platform/android/java_glue.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/platform/android/java_glue.h b/platform/android/java_glue.h index 379718a23e..57a4cc8651 100644 --- a/platform/android/java_glue.h +++ b/platform/android/java_glue.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp index f00e9c2d77..80953df85f 100644 --- a/platform/android/os_android.cpp +++ b/platform/android/os_android.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/platform/android/os_android.h b/platform/android/os_android.h index bea5371bbc..41892d23b4 100644 --- a/platform/android/os_android.h +++ b/platform/android/os_android.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/platform/android/platform_config.h b/platform/android/platform_config.h index 38fc934ae4..1e7d066bb9 100644 --- a/platform/android/platform_config.h +++ b/platform/android/platform_config.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/platform/android/project.properties.template b/platform/android/project.properties.template index d81b72b525..00cacd72bc 100644 --- a/platform/android/project.properties.template +++ b/platform/android/project.properties.template @@ -12,4 +12,4 @@ # Project target. #android.library=true -target=android-15 +target=android-19 diff --git a/platform/android/thread_jandroid.cpp b/platform/android/thread_jandroid.cpp index ec6bef89a0..9314a1c013 100644 --- a/platform/android/thread_jandroid.cpp +++ b/platform/android/thread_jandroid.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/platform/android/thread_jandroid.h b/platform/android/thread_jandroid.h index 38b4be01ec..051f4e2c3d 100644 --- a/platform/android/thread_jandroid.h +++ b/platform/android/thread_jandroid.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ |