diff --git a/.gitignore b/.gitignore index 315f516..e4d1792 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.idea/ bin/ build.xml gen/ @@ -9,5 +10,7 @@ obj/ .gradle/ build/ +*.iml + 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 f835398..dfceb8b 100644 --- a/samples-android/ButtonClicker/build.gradle +++ b/samples-android/ButtonClicker/build.gradle @@ -1,10 +1,5 @@ apply plugin: 'com.android.model.application' -// Retrieve ndk path: ndk.dir MUST be set in file local.properties -Properties properties = new Properties() -properties.load(project.rootProject.file('local.properties').newDataInputStream()) -def ndkDir = properties.getProperty('ndk.dir') - 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"] @@ -24,13 +19,13 @@ model { } } android { - compileSdkVersion=22 - buildToolsVersion="23.0.1" + compileSdkVersion=23 + buildToolsVersion="23.0.2" defaultConfig.with { applicationId="com.google.example.games.ButtonClicker" minSdkVersion.apiLevel = 11 - targetSdkVersion.apiLevel = 22 + targetSdkVersion.apiLevel = 23 } } android.sources { @@ -75,6 +70,8 @@ model { } dependencies { - compile 'com.android.support:support-v4:22.2.1' - compile 'com.google.android.gms:play-services:8.3.0' + compile 'com.google.android.gms:play-services-games:8.4.0' + compile 'com.google.android.gms:play-services-nearby:8.4.0' + compile 'com.google.android.gms:play-services-plus:8.4.0' + compile 'com.android.support:support-v4:23.1.1' } diff --git a/samples-android/CollectAllTheStarsNative/build.gradle b/samples-android/CollectAllTheStarsNative/build.gradle index 7e52480..7c696ca 100644 --- a/samples-android/CollectAllTheStarsNative/build.gradle +++ b/samples-android/CollectAllTheStarsNative/build.gradle @@ -1,8 +1,4 @@ apply plugin: 'com.android.model.application' -// Retrieve ndk path: ndk.dir MUST be set in file local.properties -Properties properties = new Properties() -properties.load(project.rootProject.file('local.properties').newDataInputStream()) -def ndkDir = properties.getProperty('ndk.dir') def gpg_cpp_path = file(project(':Common/gpg-sdk').projectDir).absolutePath + "/gpg-cpp-sdk/android" @@ -23,13 +19,13 @@ model { } } android { - compileSdkVersion = 22 - buildToolsVersion = "23.0.1" + compileSdkVersion = 23 + buildToolsVersion = "23.0.2" defaultConfig.with { applicationId = "com.google.example.games.cats" minSdkVersion.apiLevel = 11 - targetSdkVersion.apiLevel = 19 + targetSdkVersion.apiLevel = 23 versionCode = 1.0 versionName = '1.0' } @@ -76,8 +72,9 @@ model { } } } - dependencies { - compile 'com.android.support:support-v4:22.2.1' - compile 'com.google.android.gms:play-services:8.3.0' + compile 'com.google.android.gms:play-services-games:8.4.0' + compile 'com.google.android.gms:play-services-nearby:8.4.0' + compile 'com.google.android.gms:play-services-plus:8.4.0' + compile 'com.android.support:support-v4:23.1.1' } diff --git a/samples-android/Minimalist/build.gradle b/samples-android/Minimalist/build.gradle index ee8f4c5..7f69d78 100644 --- a/samples-android/Minimalist/build.gradle +++ b/samples-android/Minimalist/build.gradle @@ -1,8 +1,4 @@ apply plugin: 'com.android.model.application' -// Retrieve ndk path: ndk.dir MUST be set in file local.properties -Properties properties = new Properties() -properties.load(project.rootProject.file('local.properties').newDataInputStream()) -def ndkDir = properties.getProperty('ndk.dir') def gpg_cpp_path = file(project(':Common/gpg-sdk').projectDir).absolutePath + "/gpg-cpp-sdk/android" @@ -24,13 +20,13 @@ model { } android { - compileSdkVersion = 22 - buildToolsVersion = "23.0.1" + compileSdkVersion = 23 + buildToolsVersion = "23.0.2" defaultConfig.with { applicationId = "com.google.example.games.Minimalist" minSdkVersion.apiLevel = 11 - targetSdkVersion.apiLevel = 10 + targetSdkVersion.apiLevel = 23 } } @@ -74,6 +70,8 @@ model { } dependencies { - compile 'com.android.support:support-v4:22.2.1' - compile 'com.google.android.gms:play-services:8.3.0' + compile 'com.google.android.gms:play-services-games:8.4.0' + compile 'com.google.android.gms:play-services-nearby:8.4.0' + compile 'com.google.android.gms:play-services-plus:8.4.0' + compile 'com.android.support:support-v4:23.1.1' } diff --git a/samples-android/TbmpSkeletonNative/build.gradle b/samples-android/TbmpSkeletonNative/build.gradle index 84d50f2..a6c2a22 100644 --- a/samples-android/TbmpSkeletonNative/build.gradle +++ b/samples-android/TbmpSkeletonNative/build.gradle @@ -1,8 +1,4 @@ apply plugin: 'com.android.model.application' -// Retrieve ndk path: ndk.dir MUST be set in file local.properties -Properties properties = new Properties() -properties.load(project.rootProject.file('local.properties').newDataInputStream()) -def ndkDir = properties.getProperty('ndk.dir') def gpg_cpp_path = file(project(':Common/gpg-sdk').projectDir).absolutePath + "/gpg-cpp-sdk/android" @@ -24,13 +20,13 @@ model { } android { - compileSdkVersion = 22 - buildToolsVersion = "23.0.1" + compileSdkVersion = 23 + buildToolsVersion = "23.0.2" defaultConfig.with { applicationId= "com.google.example.games.tbmpskel" minSdkVersion.apiLevel = 11 - targetSdkVersion.apiLevel = 22 + targetSdkVersion.apiLevel = 23 versionCode = 1.0 versionName = '1.0' @@ -82,6 +78,8 @@ model { dependencies { - compile 'com.android.support:support-v4:22.2.1' - compile 'com.google.android.gms:play-services:8.3.0' + compile 'com.google.android.gms:play-services-games:8.4.0' + compile 'com.google.android.gms:play-services-nearby:8.4.0' + compile 'com.google.android.gms:play-services-plus:8.4.0' + compile 'com.android.support:support-v4:23.1.1' } diff --git a/samples-android/Teapot/build.gradle b/samples-android/Teapot/build.gradle index 2508c08..987953a 100644 --- a/samples-android/Teapot/build.gradle +++ b/samples-android/Teapot/build.gradle @@ -1,8 +1,4 @@ apply plugin: 'com.android.model.application' -// Retrieve ndk path: ndk.dir MUST be set in file local.properties -Properties properties = new Properties() -properties.load(project.rootProject.file('local.properties').newDataInputStream()) -def ndkDir = properties.getProperty('ndk.dir') def gpg_cpp_path = file(project(':Common/gpg-sdk').projectDir).absolutePath + "/gpg-cpp-sdk/android" @@ -23,13 +19,13 @@ model { } } android { - compileSdkVersion=22 - buildToolsVersion="23.0.1" + compileSdkVersion=23 + buildToolsVersion="23.0.2" defaultConfig.with { applicationId = "com.google.example.nativegame" minSdkVersion.apiLevel = 11 - targetSdkVersion.apiLevel = 19 + targetSdkVersion.apiLevel = 23 } } @@ -73,8 +69,9 @@ model { } } } - dependencies { - compile 'com.android.support:support-v4:22.2.1' - compile 'com.google.android.gms:play-services:8.3.0' + compile 'com.google.android.gms:play-services-games:8.4.0' + compile 'com.google.android.gms:play-services-nearby:8.4.0' + compile 'com.google.android.gms:play-services-plus:8.4.0' + compile 'com.android.support:support-v4:23.1.1' } diff --git a/samples-android/Teapot/src/main/java/com/google/example/nativegame/NativeGameActivity.java b/samples-android/Teapot/src/main/java/com/google/example/nativegame/NativeGameActivity.java index f7c4e68..0e26073 100644 --- a/samples-android/Teapot/src/main/java/com/google/example/nativegame/NativeGameActivity.java +++ b/samples-android/Teapot/src/main/java/com/google/example/nativegame/NativeGameActivity.java @@ -16,7 +16,9 @@ package com.google.example.nativegame; +import android.app.Activity; import android.app.NativeActivity; +import android.content.Intent; import android.os.Bundle; import android.view.Gravity; import android.view.LayoutInflater; @@ -130,26 +132,38 @@ public void run() { }}); } - - protected void onPause() { - super.onPause(); + + protected void onPause() { + super.onPause(); if (_popupWindow != null) { _popupWindow.dismiss(); _popupWindow = null; } // This call is to suppress 'E/WindowManager(): - // android.view.WindowLeaked...' errors. - // Since orientation change events in NativeActivity comes later than - // expected, we can not dismiss - // popupWindow gracefully from NativeActivity. - // So we are releasing popupWindows explicitly triggered from Java - // callback through JNI call. - OnPauseHandler(); - } + // android.view.WindowLeaked...' errors. + // Since orientation change events in NativeActivity comes later than + // expected, we can not dismiss + // popupWindow gracefully from NativeActivity. + // So we are releasing popupWindows explicitly triggered from Java + // callback through JNI call. + OnPauseHandler(); + } + + native public void OnPauseHandler(); - native public void OnPauseHandler(); + /* + * This is needed to foward the onActivityResult call to the games SDK. + * The SDK uses this to manage the display of the standard UI calls. + */ + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + nativeOnActivityResult(this, requestCode,resultCode, data); + } + + // Implemented in C++. + public static native void nativeOnActivityResult(Activity activity, + int requestCode, int resultCode, Intent data); } diff --git a/samples-android/Teapot/src/main/java/com/sample/helper/NDKHelper.java b/samples-android/Teapot/src/main/java/com/sample/helper/NDKHelper.java index 1ca640c..6c98317 100644 --- a/samples-android/Teapot/src/main/java/com/sample/helper/NDKHelper.java +++ b/samples-android/Teapot/src/main/java/com/sample/helper/NDKHelper.java @@ -16,10 +16,6 @@ package com.sample.helper; -import java.io.File; -import java.io.FileInputStream; -import javax.microedition.khronos.opengles.GL10; - import android.annotation.TargetApi; import android.app.NativeActivity; import android.content.Context; @@ -35,6 +31,11 @@ import android.os.Build; import android.util.Log; +import java.io.File; +import java.io.FileInputStream; + +import javax.microedition.khronos.opengles.GL10; + @TargetApi(Build.VERSION_CODES.GINGERBREAD) public class NDKHelper { @@ -210,6 +211,12 @@ public String getApplicationName() { return applicationName; } + public String getStringResource(String resourceName) { + int id = activity.getResources().getIdentifier(resourceName, "string", activity.getPackageName()); + String value = id == 0 ? "" : (String)activity.getResources().getText(id); + return value; + } + // // Audio related helpers // diff --git a/samples-android/Teapot/src/main/jni/NativeGameActivity.cpp b/samples-android/Teapot/src/main/jni/NativeGameActivity.cpp index 8b26543..68d03c9 100644 --- a/samples-android/Teapot/src/main/jni/NativeGameActivity.cpp +++ b/samples-android/Teapot/src/main/jni/NativeGameActivity.cpp @@ -27,6 +27,7 @@ // For GPGS #include "gpg/android_platform_configuration.h" #include "gpg/android_initialization.h" +#include "gpg/android_support.h" #include "JavaUI.h" #include "NDKHelper.h" @@ -605,5 +606,13 @@ Java_com_google_example_nativegame_NativeGameActivity_OnPauseHandler( // through JNI call. jui_helper::JUIWindow::GetInstance()->Suspend(APP_CMD_PAUSE); } + +JNIEXPORT void +Java_com_google_example_nativegame_NativeGameActivity_nativeOnActivityResult( + JNIEnv *env, jobject thiz, jobject activity, jint requestCode, + jint resultCode, jobject data) { + gpg::AndroidSupport::OnActivityResult(env, activity, requestCode, resultCode, + data); +} } // extern "C" diff --git a/samples-android/TrivialQuestNative/build.gradle b/samples-android/TrivialQuestNative/build.gradle index 462f11f..ffd146d 100644 --- a/samples-android/TrivialQuestNative/build.gradle +++ b/samples-android/TrivialQuestNative/build.gradle @@ -1,8 +1,4 @@ apply plugin: 'com.android.model.application' -// Retrieve ndk path: ndk.dir MUST be set in file local.properties -Properties properties = new Properties() -properties.load(project.rootProject.file('local.properties').newDataInputStream()) -def ndkDir = properties.getProperty('ndk.dir') def gpg_cpp_path = file(project(':Common/gpg-sdk').projectDir).absolutePath + "/gpg-cpp-sdk/android" @@ -24,13 +20,13 @@ model { } android { - compileSdkVersion = 22 - buildToolsVersion = "23.0.1" + compileSdkVersion = 23 + buildToolsVersion = "23.0.2" defaultConfig.with { applicationId = "com.google.example.games.tq" minSdkVersion.apiLevel = 11 - targetSdkVersion.apiLevel = 22 + targetSdkVersion.apiLevel = 23 } } @@ -76,6 +72,8 @@ model { } dependencies { - compile 'com.android.support:support-v4:22.1.0' - compile 'com.google.android.gms:play-services:8.3.0' + compile 'com.google.android.gms:play-services-games:8.4.0' + compile 'com.google.android.gms:play-services-nearby:8.4.0' + compile 'com.google.android.gms:play-services-plus:8.4.0' + compile 'com.android.support:support-v4:23.1.1' }