diff --git a/.gitignore b/.gitignore index d9c0e56..315f516 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,9 @@ libs/ local.properties obj/ .settings/ + +.gradle/ +build/ + +samples-android/Common/gpg-sdk/gpg-cpp-sdk/ +samples-android/Common/gpg-sdk/gpg_cpp_sdk.zip diff --git a/samples-android/ButtonClicker/build.gradle b/samples-android/ButtonClicker/build.gradle index d4d294c..f835398 100644 --- a/samples-android/ButtonClicker/build.gradle +++ b/samples-android/ButtonClicker/build.gradle @@ -5,7 +5,7 @@ Properties properties = new Properties() properties.load(project.rootProject.file('local.properties').newDataInputStream()) def ndkDir = properties.getProperty('ndk.dir') -def gpg_cpp_path = file(project(':gpg-sdk').projectDir).absolutePath + "/gpg-cpp-sdk/android" +def gpg_cpp_path = file(project(':Common/gpg-sdk').projectDir).absolutePath + "/gpg-cpp-sdk/android" // stlport configuration ["c++_static", "c++_shared", "gnustl_static", "gnustl_shared"] // used to set stl and location of libgpg.a @@ -38,8 +38,8 @@ model { jni { dependencies { library "gpg" linkage "static" - project ":cpufeatures" linkage "static" - project ":native_app_glue" linkage "static" + project ":Common/cpufeatures" linkage "static" + project ":Common/native_app_glue" linkage "static" } source { srcDir 'src/main/jni' diff --git a/samples-android/ButtonClicker/src/main/res/values/ids.xml b/samples-android/ButtonClicker/src/main/res/values/ids.xml new file mode 100644 index 0000000..cd729a8 --- /dev/null +++ b/samples-android/ButtonClicker/src/main/res/values/ids.xml @@ -0,0 +1,9 @@ + + + + REPLACE_ME + + diff --git a/samples-android/ButtonClicker/src/main/res/values/strings.xml b/samples-android/ButtonClicker/src/main/res/values/strings.xml index 45c9137..facc182 100644 --- a/samples-android/ButtonClicker/src/main/res/values/strings.xml +++ b/samples-android/ButtonClicker/src/main/res/values/strings.xml @@ -1,6 +1,5 @@ ButtonClicker - REPLACE_ME diff --git a/samples-android/CollectAllTheStarsNative/build.gradle b/samples-android/CollectAllTheStarsNative/build.gradle index 9e624ec..7e52480 100644 --- a/samples-android/CollectAllTheStarsNative/build.gradle +++ b/samples-android/CollectAllTheStarsNative/build.gradle @@ -4,7 +4,7 @@ Properties properties = new Properties() properties.load(project.rootProject.file('local.properties').newDataInputStream()) def ndkDir = properties.getProperty('ndk.dir') -def gpg_cpp_path = file(project(':gpg-sdk').projectDir).absolutePath + "/gpg-cpp-sdk/android" +def gpg_cpp_path = file(project(':Common/gpg-sdk').projectDir).absolutePath + "/gpg-cpp-sdk/android" // stlport configuration ["c++_static", "c++_shared", "gnustl_static", "gnustl_shared"] // used to set stl and location of libgpg.a @@ -39,8 +39,8 @@ model { jni { dependencies { library "gpg" linkage "static" - project ":cpufeatures" linkage "static" - project ":native_app_glue" linkage "static" + project ":Common/cpufeatures" linkage "static" + project ":Common/native_app_glue" linkage "static" } source { srcDir 'src/main/jni' @@ -80,4 +80,4 @@ model { dependencies { compile 'com.android.support:support-v4:22.2.1' compile 'com.google.android.gms:play-services:8.3.0' -} \ No newline at end of file +} diff --git a/samples-android/CollectAllTheStarsNative/src/main/res/values/ids.xml b/samples-android/CollectAllTheStarsNative/src/main/res/values/ids.xml new file mode 100644 index 0000000..b2fc703 --- /dev/null +++ b/samples-android/CollectAllTheStarsNative/src/main/res/values/ids.xml @@ -0,0 +1,9 @@ + + + + REPLACE_ME + + diff --git a/samples-android/CollectAllTheStarsNative/src/main/res/values/strings.xml b/samples-android/CollectAllTheStarsNative/src/main/res/values/strings.xml index 9e09527..4b9c6e2 100644 --- a/samples-android/CollectAllTheStarsNative/src/main/res/values/strings.xml +++ b/samples-android/CollectAllTheStarsNative/src/main/res/values/strings.xml @@ -1,4 +1,3 @@ CollectAllTheStarsNative - REPLACE_ME - \ No newline at end of file + diff --git a/samples-android/Common/native_app_glue/build.gradle b/samples-android/Common/native_app_glue/build.gradle index a93e253..dd9b69f 100644 --- a/samples-android/Common/native_app_glue/build.gradle +++ b/samples-android/Common/native_app_glue/build.gradle @@ -11,9 +11,10 @@ model { } android.ndk { + abiFilters.addAll(["armeabi", "armeabi-v7a", "x86", "arm64-v8a"]) moduleName = "native_app_glue" } - + android.sources { main { jni { @@ -27,3 +28,57 @@ model { } } } + +/* + We are building a static library, so disable all the shared library tasks. +*/ +tasks.whenTaskAdded { task -> + if (task.name == 'linkArmeabi-v7aDebugNative_app_glueSharedLibrary') { + task.enabled = false + } + else if (task.name == 'linkArm64-v8aDebugNative_app_glueSharedLibrary') { + task.enabled = false + } + else if (task.name == 'linkArmeabiDebugNative_app_glueSharedLibrary') { + task.enabled = false + } + else if (task.name == 'linkX86DebugNative_app_glueSharedLibrary') { + task.enabled = false + } + else if (task.name == 'stripSymbolsArmeabi-v7aDebugNative_app_glueSharedLibrary') { + task.enabled = false + } + else if (task.name == 'stripSymbolsArm64-v8aDebugNative_app_glueSharedLibrary') { + task.enabled = false + } + else if (task.name == 'stripSymbolsArmeabiDebugNative_app_glueSharedLibrary') { + task.enabled = false + } + else if (task.name == 'stripSymbolsX86DebugNative_app_glueSharedLibrary') { + task.enabled = false + } + else if (task.name == 'linkArm64-v8aReleaseNative_app_glueSharedLibrary') { + task.enabled = false + } + else if (task.name == 'stripSymbolsArm64-v8aReleaseNative_app_glueSharedLibrary') { + task.enabled = false + } + else if (task.name == 'linkArmeabi-v7aReleaseNative_app_glueSharedLibrary') { + task.enabled = false + } + else if (task.name == 'stripSymbolsArmeabi-v7aReleaseNative_app_glueSharedLibrary') { + task.enabled = false + } + else if (task.name == 'linkArmeabiReleaseNative_app_glueSharedLibrary') { + task.enabled = false + } + else if (task.name == 'stripSymbolsArmeabiReleaseNative_app_glueSharedLibrary') { + task.enabled = false + } + else if (task.name == 'linkX86ReleaseNative_app_glueSharedLibrary') { + task.enabled = false + } + else if (task.name == 'stripSymbolsX86ReleaseNative_app_glueSharedLibrary') { + task.enabled = false + } +} diff --git a/samples-android/Minimalist/build.gradle b/samples-android/Minimalist/build.gradle index cbf2c50..ee8f4c5 100644 --- a/samples-android/Minimalist/build.gradle +++ b/samples-android/Minimalist/build.gradle @@ -4,7 +4,7 @@ Properties properties = new Properties() properties.load(project.rootProject.file('local.properties').newDataInputStream()) def ndkDir = properties.getProperty('ndk.dir') -def gpg_cpp_path = file(project(':gpg-sdk').projectDir).absolutePath + "/gpg-cpp-sdk/android" +def gpg_cpp_path = file(project(':Common/gpg-sdk').projectDir).absolutePath + "/gpg-cpp-sdk/android" // stlport configuration ["c++_static", "c++_shared", "gnustl_static", "gnustl_shared"] // used to set stl and location of libgpg.a @@ -40,7 +40,7 @@ model { jni { dependencies { library "gpg" linkage "static" - project ":native_app_glue" linkage "static" + project ":Common/native_app_glue" linkage "static" } source { srcDir 'src/main/jni' diff --git a/samples-android/TbmpSkeletonNative/build.gradle b/samples-android/TbmpSkeletonNative/build.gradle index ada5f88..84d50f2 100644 --- a/samples-android/TbmpSkeletonNative/build.gradle +++ b/samples-android/TbmpSkeletonNative/build.gradle @@ -4,7 +4,7 @@ Properties properties = new Properties() properties.load(project.rootProject.file('local.properties').newDataInputStream()) def ndkDir = properties.getProperty('ndk.dir') -def gpg_cpp_path = file(project(':gpg-sdk').projectDir).absolutePath + "/gpg-cpp-sdk/android" +def gpg_cpp_path = file(project(':Common/gpg-sdk').projectDir).absolutePath + "/gpg-cpp-sdk/android" // stlport configuration ["c++_static", "c++_shared", "gnustl_static", "gnustl_shared"] // used to set stl and location of libgpg.a @@ -42,8 +42,8 @@ model { jni { dependencies { library "gpg" linkage "static" - project ":cpufeatures" linkage "static" - project ":native_app_glue" linkage "static" + project ":Common/cpufeatures" linkage "static" + project ":Common/native_app_glue" linkage "static" } source { srcDir 'src/main/jni' @@ -84,4 +84,4 @@ model { dependencies { compile 'com.android.support:support-v4:22.2.1' compile 'com.google.android.gms:play-services:8.3.0' -} \ No newline at end of file +} diff --git a/samples-android/TbmpSkeletonNative/src/main/res/values/ids.xml b/samples-android/TbmpSkeletonNative/src/main/res/values/ids.xml new file mode 100644 index 0000000..b2fc703 --- /dev/null +++ b/samples-android/TbmpSkeletonNative/src/main/res/values/ids.xml @@ -0,0 +1,9 @@ + + + + REPLACE_ME + + diff --git a/samples-android/TbmpSkeletonNative/src/main/res/values/strings.xml b/samples-android/TbmpSkeletonNative/src/main/res/values/strings.xml index 8c0decf..6a7c191 100644 --- a/samples-android/TbmpSkeletonNative/src/main/res/values/strings.xml +++ b/samples-android/TbmpSkeletonNative/src/main/res/values/strings.xml @@ -1,6 +1,5 @@ TBMPSkeleton - REPLACE_ME - \ No newline at end of file + diff --git a/samples-android/Teapot/build.gradle b/samples-android/Teapot/build.gradle index e0c4009..2508c08 100644 --- a/samples-android/Teapot/build.gradle +++ b/samples-android/Teapot/build.gradle @@ -4,7 +4,7 @@ Properties properties = new Properties() properties.load(project.rootProject.file('local.properties').newDataInputStream()) def ndkDir = properties.getProperty('ndk.dir') -def gpg_cpp_path = file(project(':gpg-sdk').projectDir).absolutePath + "/gpg-cpp-sdk/android" +def gpg_cpp_path = file(project(':Common/gpg-sdk').projectDir).absolutePath + "/gpg-cpp-sdk/android" // stlport configuration ["c++_static", "c++_shared", "gnustl_static", "gnustl_shared"] // used to set stl and location of libgpg.a @@ -38,8 +38,8 @@ model { jni { dependencies { library "gpg" linkage "static" - project ":cpufeatures" linkage "static" - project ":native_app_glue" linkage "static" + project ":Common/cpufeatures" linkage "static" + project ":Common/native_app_glue" linkage "static" } source { srcDir 'src/main/jni' diff --git a/samples-android/Teapot/src/main/AndroidManifest.xml b/samples-android/Teapot/src/main/AndroidManifest.xml index 563341b..9ef0fef 100644 --- a/samples-android/Teapot/src/main/AndroidManifest.xml +++ b/samples-android/Teapot/src/main/AndroidManifest.xml @@ -2,14 +2,13 @@ package="com.google.example.nativegame" android:versionCode="1" android:versionName="1.0" > - + GetStringResource("achievement_prime"); + if( id == "" || id == "ReplaceMe") { + LOGI("Invalid achievement ID!, please check res/values/ids.xml"); + return; + } + StateManager::UnlockAchievement(id.c_str()); } }); jui_helper::JUIWindow::GetInstance()->AddView(button_achievement); @@ -212,7 +213,12 @@ void Engine::InitUI() { [this](jui_helper::JUIView *view, const int32_t message) { LOGI("Button click: %d", message); if (message == jui_helper::JUICALLBACK_BUTTON_UP) { - StateManager::SubmitHighScore(TEST_LEADERBOARD_ID, current_score_); + std::string id = ndk_helper::JNIHelper::GetInstance()->GetStringResource("leaderboard_easy"); + if( id == "" || id == "ReplaceMe") { + LOGI("Invalid Leaderboard ID!, please check res/values/ids.xml"); + return; + } + StateManager::SubmitHighScore(id.c_str(), current_score_); } }); jui_helper::JUIWindow::GetInstance()->AddView(button_submit_high_score); @@ -229,7 +235,12 @@ void Engine::InitUI() { [this](jui_helper::JUIView *view, const int32_t message) { LOGI("Button click: %d", message); if (message == jui_helper::JUICALLBACK_BUTTON_UP) { - StateManager::ShowLeaderboard(TEST_LEADERBOARD_ID); + std::string id = ndk_helper::JNIHelper::GetInstance()->GetStringResource("leaderboard_easy"); + if( id == "" || id == "ReplaceMe") { + LOGI("Invalid Leaderboard ID!, please check res/values/ids.xml"); + return; + } + StateManager::ShowLeaderboard(id.c_str()); } }); jui_helper::JUIWindow::GetInstance()->AddView(button_show_leaderboard_ui); diff --git a/samples-android/Teapot/src/main/res/values/ids.xml b/samples-android/Teapot/src/main/res/values/ids.xml index e07c9cb..0ce2e3c 100644 --- a/samples-android/Teapot/src/main/res/values/ids.xml +++ b/samples-android/Teapot/src/main/res/values/ids.xml @@ -1,3 +1,10 @@ + + - REPLACE_ME + ReplaceMe + ReplaceMe + ReplaceMe diff --git a/samples-android/TrivialQuestNative/build.gradle b/samples-android/TrivialQuestNative/build.gradle index 6eb45bc..462f11f 100644 --- a/samples-android/TrivialQuestNative/build.gradle +++ b/samples-android/TrivialQuestNative/build.gradle @@ -4,7 +4,7 @@ Properties properties = new Properties() properties.load(project.rootProject.file('local.properties').newDataInputStream()) def ndkDir = properties.getProperty('ndk.dir') -def gpg_cpp_path = file(project(':gpg-sdk').projectDir).absolutePath + "/gpg-cpp-sdk/android" +def gpg_cpp_path = file(project(':Common/gpg-sdk').projectDir).absolutePath + "/gpg-cpp-sdk/android" // stlport configuration ["c++_static", "c++_shared", "gnustl_static", "gnustl_shared"] // used to set stl and location of libgpg.a @@ -39,8 +39,8 @@ model { jni { dependencies { library "gpg" linkage "static" - project ":cpufeatures" linkage "static" - project ":native_app_glue" linkage "static" + project ":Common/cpufeatures" linkage "static" + project ":Common/native_app_glue" linkage "static" } source { srcDir 'src/main/jni' diff --git a/samples-android/TrivialQuestNative/src/main/jni/TrivialQuestNativeActivity.cpp b/samples-android/TrivialQuestNative/src/main/jni/TrivialQuestNativeActivity.cpp index dbea14e..c3502fe 100644 --- a/samples-android/TrivialQuestNative/src/main/jni/TrivialQuestNativeActivity.cpp +++ b/samples-android/TrivialQuestNative/src/main/jni/TrivialQuestNativeActivity.cpp @@ -305,10 +305,10 @@ void Engine::InitUI() { button_green_->SetCallback( [this](jui_helper::JUIView * view, const int32_t message) { if (message == jui_helper::JUICALLBACK_BUTTON_UP) { - std::string id = ndk_helper::JNIHelper::GetInstance()->GetStringResource("green_event_id"); + std::string id = ndk_helper::JNIHelper::GetInstance()->GetStringResource("event_green"); if( id == "" || id == "ReplaceMe") { - LOGI("Invalid Event ID!, please check res/values/strings.xml"); + LOGI("Invalid Event ID!, please check res/values/ids.xml"); return; } service_->Events().Increment(id.c_str()); @@ -328,10 +328,10 @@ void Engine::InitUI() { button_yellow_->SetCallback( [this](jui_helper::JUIView * view, const int32_t message) { if (message == jui_helper::JUICALLBACK_BUTTON_UP) { - std::string id = ndk_helper::JNIHelper::GetInstance()->GetStringResource("yellow_event_id"); + std::string id = ndk_helper::JNIHelper::GetInstance()->GetStringResource("event_yellow"); if( id == "" || id == "ReplaceMe") { - LOGI("Invalid Event ID!, please check res/values/strings.xml"); + LOGI("Invalid Event ID!, please check res/values/ids.xml"); return; } service_->Events().Increment(id.c_str()); @@ -351,10 +351,10 @@ void Engine::InitUI() { button_blue_->SetCallback( [this](jui_helper::JUIView * view, const int32_t message) { if (message == jui_helper::JUICALLBACK_BUTTON_UP) { - std::string id = ndk_helper::JNIHelper::GetInstance()->GetStringResource("blue_event_id"); + std::string id = ndk_helper::JNIHelper::GetInstance()->GetStringResource("event_blue"); if( id == "" || id == "ReplaceMe") { - LOGI("Invalid Event ID!, please check res/values/strings.xml"); + LOGI("Invalid Event ID!, please check res/values/ids.xml"); return; } service_->Events().Increment(id.c_str()); @@ -374,10 +374,10 @@ void Engine::InitUI() { button_red_->SetCallback( [this](jui_helper::JUIView * view, const int32_t message) { if (message == jui_helper::JUICALLBACK_BUTTON_UP) { - std::string id = ndk_helper::JNIHelper::GetInstance()->GetStringResource("red_event_id"); + std::string id = ndk_helper::JNIHelper::GetInstance()->GetStringResource("event_red"); if( id == "" || id == "ReplaceMe") { - LOGI("Invalid Event ID!, please check res/values/strings.xml"); + LOGI("Invalid Event ID!, please check res/values/ids.xml"); return; } service_->Events().Increment(id.c_str()); diff --git a/samples-android/TrivialQuestNative/src/main/res/values/ids.xml b/samples-android/TrivialQuestNative/src/main/res/values/ids.xml new file mode 100644 index 0000000..dab007b --- /dev/null +++ b/samples-android/TrivialQuestNative/src/main/res/values/ids.xml @@ -0,0 +1,13 @@ + + + + ReplaceMe + ReplaceMe + ReplaceMe + ReplaceMe + ReplaceMe + + diff --git a/samples-android/TrivialQuestNative/src/main/res/values/strings.xml b/samples-android/TrivialQuestNative/src/main/res/values/strings.xml index 39c914e..6627251 100644 --- a/samples-android/TrivialQuestNative/src/main/res/values/strings.xml +++ b/samples-android/TrivialQuestNative/src/main/res/values/strings.xml @@ -1,14 +1,3 @@ - TrivialQuest - - - REPLACE_ME - - - ReplaceMe - ReplaceMe - ReplaceMe - ReplaceMe - - \ No newline at end of file + diff --git a/samples-android/settings.gradle b/samples-android/settings.gradle index 530cc02..8167c80 100644 --- a/samples-android/settings.gradle +++ b/samples-android/settings.gradle @@ -1,20 +1,9 @@ include ':ButtonClicker', - ':CollectAllTheStars', + ':CollectAllTheStarsNative', ':Minimalist', - ':TbmpSkeleton', + ':TbmpSkeletonNative', ':Teapot', - ':TrivialQuest', - ':cpufeatures', - ':native_app_glue', - ':gpg-sdk' - -project(':ButtonClicker').projectDir = new File(settingsDir, './ButtonClicker') -project(':CollectAllTheStars').projectDir = new File(settingsDir, './CollectAllTheStarsNative') -project(':Minimalist').projectDir = new File(settingsDir, './Minimalist') -project(':TbmpSkeleton').projectDir = new File(settingsDir, 'TbmpSkeletonNative') -project(':Teapot').projectDir = new File(settingsDir, 'Teapot') -project(':TrivialQuest').projectDir = new File(settingsDir, 'TrivialQuestNative') - -project(':cpufeatures').projectDir = new File(settingsDir, './Common/cpufeatures') -project(':native_app_glue').projectDir = new File(settingsDir, './Common/native_app_glue') -project(':gpg-sdk').projectDir = new File(settingsDir, './Common/gpg-sdk') + ':TrivialQuestNative', + ':Common/cpufeatures', + ':Common/native_app_glue', + ':Common/gpg-sdk'