diff --git a/README.md b/README.md
index 11cbff9..ad56f9e 100644
--- a/README.md
+++ b/README.md
@@ -6,10 +6,6 @@ These samples illustrate how to use Google Play Game Services with your Android
* **minimalist**: Demonstrates a minimal use case for the Google Play Game Services API.
-* **TbmpSkeletonNative**: A trivial, turn-based multiplayer game. Many players can play together in this thrilling game, in which they send a shared gamestate string back and forth until someone finishes or cancels, or the second-to-last player leaves. Be the last one standing!
-
-* **Button-Clicker**: Demonstrates real-time multiplayer using invites or quickmatch
-
* **Teapots**: Demonstrates use of the Leaderboard and Achievement APIs.
Pre-requisites
diff --git a/samples-android/ButtonClicker/CMakeLists.txt b/samples-android/ButtonClicker/CMakeLists.txt
deleted file mode 100644
index 1b66741..0000000
--- a/samples-android/ButtonClicker/CMakeLists.txt
+++ /dev/null
@@ -1,89 +0,0 @@
-# Copyright (C) 2017 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-##
-
-# For more information about using CMake with Android Studio, read the
-# documentation: https://d.android.com/studio/projects/add-native-code.html
-
-# Sets the minimum version of CMake required to build the native library.
-
-cmake_minimum_required(VERSION 3.4.1)
-
-#include the native part of JUI Helper
-add_subdirectory (${JUI_HELPER_PATH}
- "${CMAKE_CURRENT_SOURCE_DIR}/libs/${ANDROID_ABI}/libjuihelper")
-
-#include the native part of NDKHelper
-add_subdirectory (${NDK_HELPER_PATH}
- "${CMAKE_CURRENT_SOURCE_DIR}/libs/${ANDROID_ABI}/libndkhelper")
-
-#include the GPG C++ SDK
-add_library(gpg_sdk STATIC IMPORTED)
-set_target_properties(gpg_sdk PROPERTIES IMPORTED_LOCATION
- ${GPG_SDK_PATH}/lib/c++/${ANDROID_ABI}/libgpg.a)
-
-# build native_app_glue as a static lib
-add_library(native_app_glue STATIC
- ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c)
-
-# build cpufeatures as a static lib
-add_library(cpufeatures STATIC
- ${ANDROID_NDK}/sources/android/cpufeatures/cpu-features.c)
-
-# Export ANativeActivity_onCreate(),
-# Refer to: https://github.com/android-ndk/ndk/issues/381.
-set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate")
-
-# Creates and names a library, sets it as either STATIC
-# or SHARED, and provides the relative paths to its source code.
-# You can define multiple libraries, and CMake builds them for you.
-# Gradle automatically packages shared libraries with your APK.
-
-add_library( # Sets the name of the library.
- ButtonClickerNativeActivity
-
- # Sets the library as a shared library.
- SHARED
-
- # Provides a relative path to your source file(s).
- src/main/cpp/ButtonClickerNativeActivity.cpp
- src/main/cpp/ButtonClickerNativeActivity_Engine.cpp
- ${TEAPOT_RENDERER_PATH}/TeapotRenderer.cpp
- )
-
-target_include_directories(ButtonClickerNativeActivity PRIVATE
- ${ANDROID_NDK}/sources/android/native_app_glue
- ${ANDROID_NDK}/sources/android/cpufeatures
- ${GPG_SDK_PATH}/include
- ${juihelper_SOURCE_DIR}/src/main/cpp
- ${ndkhelper_SOURCE_DIR}/src/main/cpp
- ${TEAPOT_RENDERER_PATH}
-)
-
-# Specifies libraries CMake should link to your target library. You
-# can link multiple libraries, such as libraries you define in this
-# build script, prebuilt third-party libraries, or system libraries.
-
-target_link_libraries(ButtonClickerNativeActivity
- gpg_sdk
- native_app_glue
- cpufeatures
- juihelper
- ndkhelper
- log
- android
- EGL
- GLESv2
- z
-)
diff --git a/samples-android/ButtonClicker/README.md b/samples-android/ButtonClicker/README.md
deleted file mode 100644
index 8d6e970..0000000
--- a/samples-android/ButtonClicker/README.md
+++ /dev/null
@@ -1,17 +0,0 @@
-Google Play game services - ButtonClickerNative C++ Samples
-===========================================
-Copyright (C) 2014 Google Inc.
-
-
Contents
-
-ButtonClickerNative: The sample demonstrates how to use real time multiplayer gaming feature with C++ code with Google Play game services native SDK.
-
-How to run a sample
-
-Please follow steps described in [Getting Started for C++](https://developers.google.com/games/services/cpp/GettingStartedNativeClient)
-
-Support
-
-First of all, take a look at our [troubleshooting guide](https://developers.google.com/games/services/android/troubleshooting). Most setup issues can be solved by following this guide.
-
-If your question is not answered by the troubleshooting guide, we encourage you to post your question to [stackoverflow.com](stackoverflow.com) with tag "google-play-games". Our team answers questions there reguarly.
diff --git a/samples-android/ButtonClicker/build.gradle b/samples-android/ButtonClicker/build.gradle
deleted file mode 100644
index 34e85c0..0000000
--- a/samples-android/ButtonClicker/build.gradle
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright 2017 (C) Google LLC
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-apply plugin : 'com.android.application'
-
-android {
- compileSdkVersion 27
- defaultConfig {
- //
- // REPLACE THE APPLICATION ID with your bundle ID
- //
- applicationId "com.google.example.games.ReplaceMe"
- versionCode 1
- versionName "1.0"
-
- minSdkVersion 14
- targetSdkVersion 27
-
- ndk.abiFilters 'x86', 'armeabi-v7a', 'arm64-v8a'
-
- externalNativeBuild {
- cmake {
- cppFlags "-std=c++11 -frtti -Wall -Werror"
- arguments "-DJUI_HELPER_PATH=${project(':Common:JuiHelper').projectDir}",
- "-DNDK_HELPER_PATH=${project(':Common:NDKHelper').projectDir}",
- "-DGPG_SDK_PATH=${project(':Common:gpg-sdk').projectDir}/gpg-cpp-sdk/android",
- "-DTEAPOT_RENDERER_PATH=${project(':Common').projectDir}/TeapotRenderer",
- "-DANDROID_STL=c++_static",
- "-DANDROID_TOOLCHAIN=clang"
- }
- }
- }
-
- externalNativeBuild {
- cmake.path "CMakeLists.txt"
- }
-}
-
-dependencies {
- implementation project(":Common:JuiHelper")
- implementation 'com.google.android.gms:play-services-games:11.8.0'
- implementation 'com.google.android.gms:play-services-nearby:11.8.0'
- implementation 'com.android.support:support-v4:27.0.2'
-}
diff --git a/samples-android/ButtonClicker/proguard-project.txt b/samples-android/ButtonClicker/proguard-project.txt
deleted file mode 100644
index f2fe155..0000000
--- a/samples-android/ButtonClicker/proguard-project.txt
+++ /dev/null
@@ -1,20 +0,0 @@
-# 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 *;
-#}
diff --git a/samples-android/ButtonClicker/src/main/AndroidManifest.xml b/samples-android/ButtonClicker/src/main/AndroidManifest.xml
deleted file mode 100644
index 63831da..0000000
--- a/samples-android/ButtonClicker/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,57 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/samples-android/ButtonClicker/src/main/assets/Shaders/ShaderPlain.fsh b/samples-android/ButtonClicker/src/main/assets/Shaders/ShaderPlain.fsh
deleted file mode 100644
index 75ae290..0000000
--- a/samples-android/ButtonClicker/src/main/assets/Shaders/ShaderPlain.fsh
+++ /dev/null
@@ -1,42 +0,0 @@
-
-//
-// ShaderPlain.fsh
-//
-
-#define USE_PHONG (1)
-
-uniform lowp vec3 vMaterialAmbient;
-uniform mediump vec4 vMaterialSpecular;
-
-varying lowp vec4 colorDiffuse;
-
-#if USE_PHONG
-uniform highp vec3 vLight0;
-varying mediump vec3 position;
-varying mediump vec3 normal;
-#else
-varying lowp vec4 colorSpecular;
-#endif
-
-/*
- Standard phong fragment shader implementation.
- Take object space light position and normal, derive a specular intensity.
-*/
-void main() {
-#if USE_PHONG
- mediump vec3
- halfVector = normalize(-vLight0 + position);
- mediump
- float NdotH = max(dot(normalize(normal), halfVector), 0.0);
- mediump
- float fPower = vMaterialSpecular.w;
- mediump
- float specular = pow(NdotH, fPower);
-
- lowp vec4
- colorSpecular = vec4(vMaterialSpecular.xyz * specular, 1);
- gl_FragColor = colorDiffuse + colorSpecular;
-#else
- gl_FragColor = colorDiffuse + colorSpecular;
-#endif
-}
\ No newline at end of file
diff --git a/samples-android/ButtonClicker/src/main/assets/Shaders/VS_ShaderPlain.vsh b/samples-android/ButtonClicker/src/main/assets/Shaders/VS_ShaderPlain.vsh
deleted file mode 100644
index a62e4a8..0000000
--- a/samples-android/ButtonClicker/src/main/assets/Shaders/VS_ShaderPlain.vsh
+++ /dev/null
@@ -1,64 +0,0 @@
-//
-// ShaderPlain.vsh
-//
-
-#define USE_PHONG (1)
-
-attribute highp vec3 myVertex;
-attribute highp vec3 myNormal;
-attribute mediump vec2 myUV;
-attribute mediump vec4 myBone;
-
-varying mediump vec2 texCoord;
-varying lowp vec4 colorDiffuse;
-
-#if USE_PHONG
-varying mediump vec3 position;
-varying mediump vec3 normal;
-#else
-varying lowp vec4 colorSpecular;
-#endif
-
-uniform highp mat4 uMVMatrix;
-uniform highp mat4 uPMatrix;
-
-uniform highp vec3 vLight0;
-
-uniform lowp vec4 vMaterialDiffuse;
-uniform lowp vec3 vMaterialAmbient;
-uniform lowp vec4 vMaterialSpecular;
-
-/*
- Standard vertex shader shader implementation.
- Transform vertices and normal,
- derive diffuse value and pass object space light source
- position to fragment shader for phong shading.
-*/
-void main(void) {
- highp vec4
- p = vec4(myVertex, 1);
- gl_Position = uPMatrix * p;
-
- texCoord = myUV;
-
- highp vec3
- worldNormal = vec3(
- mat3(uMVMatrix[0].xyz, uMVMatrix[1].xyz, uMVMatrix[2].xyz) * myNormal);
- highp vec3
- ecPosition = p.xyz;
-
- colorDiffuse = dot(worldNormal, normalize(-vLight0 + ecPosition))
- * vMaterialDiffuse + vec4(vMaterialAmbient, 1);
-
-#if USE_PHONG
- normal = worldNormal;
- position = ecPosition;
-#else
- highp vec3 halfVector = normalize(ecPosition - vLight0);
-
- highp float NdotH = max(-dot(worldNormal, halfVector), 0.0);
- float fPower = vMaterialSpecular.w;
- highp float specular = min( pow(NdotH, fPower), 1.0);
- colorSpecular = vec4(vMaterialSpecular.xyz * specular, 1);
-#endif
-}
diff --git a/samples-android/ButtonClicker/src/main/cpp/ButtonClickerNativeActivity.cpp b/samples-android/ButtonClicker/src/main/cpp/ButtonClickerNativeActivity.cpp
deleted file mode 100644
index 49ce929..0000000
--- a/samples-android/ButtonClicker/src/main/cpp/ButtonClickerNativeActivity.cpp
+++ /dev/null
@@ -1,746 +0,0 @@
-// Copyright (c) 2014 Google. All rights reserved.
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-/*
- * This file demonstrates,
- * - How to use RTMP features in C++ code with gpg native client, including
- * - Sign in to gpg service
- * - How to handle RTMP callbacks
- * - How to initiate RTMP matchs via several ways (QuickMatch, Invitation etc)
- * - How to send reliable/unreliable packets to peers
- * - Setup management UI and game UI
- */
-
-/*
- * Include files
- */
-#include "ButtonClickerNativeActivity.h"
-
-/*
- * Initialize GooglePlayGameServices via gpg::GameServices::Builder
- * In the build, it's setting several callbacks such as auth status changes,
- * receiving invitations etc.
- */
-void Engine::InitGooglePlayGameServices() {
- if (service_ != nullptr) {
- return;
- }
-
- gpg::AndroidInitialization::android_main(app_);
-
- // Game Services have not been initialized, create a new Game Services.
- gpg::AndroidPlatformConfiguration platform_configuration;
- platform_configuration.SetActivity(app_->activity->clazz);
-
- gpg::GameServices::Builder builder;
- service_ =
- builder.SetOnAuthActionStarted([this](gpg::AuthOperation op) {
- // This callback is invoked when auth
- // action started
- // While auth action is going on, disable
- // auth and related UI
- OnAuthActionStarted(op);
- })
- .SetOnAuthActionFinished([this](gpg::AuthOperation op,
- gpg::AuthStatus status) {
- // This callback is invoked when auth action finished
- // Check status code and update UI to signed-in state
- OnAuthActionFinished(op, status);
- })
- .SetOnMultiplayerInvitationEvent([this](
- gpg::MultiplayerEvent event, std::string match_id,
- gpg::MultiplayerInvitation invitation) {
- // Invoked when invitation has been received
- // It can be received from the Play Game app, a notification, or
- // live while the app is running.
- // (e.g. Though PlayGam app, while the app is running)
- LOGI("MultiplayerInvitationEvent callback");
-
- if (event ==
- gpg::MultiplayerEvent::UPDATED_FROM_APP_LAUNCH) {
-
- // In this case, an invitation has been accepted already
- // in notification or in Play game app
- gpg::RealTimeMultiplayerManager::RealTimeRoomResponse result =
- service_->RealTimeMultiplayer().AcceptInvitationBlocking(
- invitation, this);
- if (gpg::IsSuccess(result.status)) {
- room_ = result.room;
- service_->RealTimeMultiplayer().ShowWaitingRoomUI(
- room_, MIN_PLAYERS,
- [this](gpg::RealTimeMultiplayerManager::
- WaitingRoomUIResponse const &waitResult) {
- EnableUI(true);
- if (gpg::IsSuccess(waitResult.status)) {
- PlayGame();
- }
- });
- } else {
- LeaveGame();
- }
- } else {
- // Otherwise, show default inbox and let players to accept an
- // invitation
- ShowRoomInbox();
- }
- })
- .Create(platform_configuration);
-}
-
-/*
- * Callback: Authentication action started
- *
- * gpg::AuthOperation op : SIGN_IN = 1, SIGN_OUT = 2
- *
- */
-void Engine::OnAuthActionStarted(gpg::AuthOperation op) {
- if(!initialized_resources_) {
- return;
- }
-
- ndk_helper::JNIHelper::GetInstance()->RunOnUiThread([this, op]() {
- EnableUI(false);
- if (op == gpg::AuthOperation::SIGN_IN) {
- status_text_->SetAttribute("Text", "Signing In...");
- } else {
- status_text_->SetAttribute("Text", "Signing Out...");
- }
- });
-}
-
-/*
- * Callback: Authentication action finishes
- *
- * gpg::AuthOperation op : SIGN_IN = 1, SIGN_OUT = 2
- *
- */
-void Engine::OnAuthActionFinished(gpg::AuthOperation op,
- gpg::AuthStatus status) {
- if (gpg::IsSuccess(status)) {
- service_->Players().FetchSelf([this](
- gpg::PlayerManager::FetchSelfResponse const &response) {
- if (gpg::IsSuccess(response.status)) {
- self_id_ = response.data.Id();
- }
- });
- }
-
- if(!initialized_resources_) {
- return;
- }
-
- ndk_helper::JNIHelper::GetInstance()->RunOnUiThread([this, status]() {
- EnableUI(true);
- button_sign_in_->SetAttribute(
- "Text", gpg::IsSuccess(status) ? "Sign Out" : "Sign In");
-
- status_text_->SetAttribute(
- "Text", gpg::IsSuccess(status) ? "Signed In" : "Signed Out");
- });
-}
-
-/*
- * Show room inbox
- */
-void Engine::ShowRoomInbox() {
- service_->RealTimeMultiplayer().ShowRoomInboxUI([this](
- gpg::RealTimeMultiplayerManager::RoomInboxUIResponse const &response) {
- if (gpg::IsSuccess(response.status)) {
- gpg::RealTimeMultiplayerManager::RealTimeRoomResponse result =
- service_->RealTimeMultiplayer().AcceptInvitationBlocking(
- response.invitation, this);
- if (gpg::IsSuccess(result.status)) {
- room_ = result.room;
- service_->RealTimeMultiplayer().ShowWaitingRoomUI(
- room_, MIN_PLAYERS,
- [this](
- gpg::RealTimeMultiplayerManager::WaitingRoomUIResponse const &
- waitResult) {
- EnableUI(true);
- if (gpg::IsSuccess(waitResult.status)) {
- PlayGame();
- }
- });
- } else
- EnableUI(true); // Go back to original state for retry
- } else {
- LOGI("Invalid response status");
- EnableUI(true); // Go back to original state for retry
- }
- });
- EnableUI(false);
-}
-
-/*
- * Quick match
- * - Create a match with minimal setting and play the game
- */
-void Engine::QuickMatch() {
- gpg::RealTimeRoomConfig config =
- gpg::RealTimeRoomConfig::Builder()
- .SetMinimumAutomatchingPlayers(MIN_PLAYERS)
- .SetMaximumAutomatchingPlayers(MAX_PLAYERS)
- .Create();
-
- service_->RealTimeMultiplayer().CreateRealTimeRoom(
- config, this,
- [this](gpg::RealTimeMultiplayerManager::RealTimeRoomResponse const &
- response) {
- LOGI("created a room %d", response.status);
- if (gpg::IsSuccess(response.status)) {
- room_ = response.room;
- service_->RealTimeMultiplayer().ShowWaitingRoomUI(
- room_, MIN_PLAYERS,
- [this](
- gpg::RealTimeMultiplayerManager::WaitingRoomUIResponse const &
- waitResult) {
- EnableUI(true);
- if (gpg::IsSuccess(waitResult.status)) {
- PlayGame();
- }
- });
- } else
- EnableUI(true); // Go back to original state for retry
- });
- EnableUI(false);
-}
-
-/*
- * Invite friends
- * - Show Player Select UI via ShowPlayerSelectUI,
- * - When the UI is finished, create match and show game UI
- */
-void Engine::InviteFriend() {
- service_->RealTimeMultiplayer().ShowPlayerSelectUI(
- MIN_PLAYERS, MAX_PLAYERS, true,
- [this](gpg::RealTimeMultiplayerManager::PlayerSelectUIResponse const &
- response) {
- LOGI("inviting friends %d", response.status);
- if (gpg::IsSuccess(response.status)) {
- // Create room
- gpg::RealTimeRoomConfig config =
- gpg::RealTimeRoomConfig::Builder()
- .PopulateFromPlayerSelectUIResponse(response)
- .Create();
-
- auto roomResponse =
- service_->RealTimeMultiplayer().CreateRealTimeRoomBlocking(config,
- this);
- if (gpg::IsSuccess(roomResponse.status)) {
- room_ = roomResponse.room;
- service_->RealTimeMultiplayer().ShowWaitingRoomUI(
- room_, MIN_PLAYERS,
- [this](gpg::RealTimeMultiplayerManager::
- WaitingRoomUIResponse const &waitResult) {
- EnableUI(true);
- if (gpg::IsSuccess(waitResult.status)) {
- PlayGame();
- }
- });
- } else
- EnableUI(true); // Go back to original state for retry
- } else
- EnableUI(true); // Go back to original state for retry
- });
- EnableUI(false);
-}
-
-/*
- * Broadcast my score to peers
- */
-void Engine::BroadcastScore(bool bFinal) {
- std::vector v;
- if (!bFinal) {
- v.push_back('U');
- v.push_back(static_cast(score_counter_));
- service_->RealTimeMultiplayer().SendUnreliableMessageToOthers(room_, v);
- } else {
- v.push_back('F');
- v.push_back(static_cast(score_counter_));
-
- const std::vector participants =
- room_.Participants();
- for (gpg::MultiplayerParticipant participant : participants) {
- service_->RealTimeMultiplayer().SendReliableMessage(
- room_, participant, v, [](gpg::MultiplayerStatus const &) {});
- }
- }
-}
-
-/*
- * Got message from peers
- * room : The room which from_participant is in.
- * from_participant : The participant who sent the data.
- * data : The data which was received.
- * is_reliable : Whether the data was sent using the unreliable or
- * reliable mechanism.
- * In this app, packet format is defined as:
- * 1 byte: indicate score type 'F': final score 'U' updating score
- * 1 byte: score
- */
-void Engine::OnDataReceived(gpg::RealTimeRoom const &room,
- gpg::MultiplayerParticipant const &from_participant,
- std::vector data, bool is_reliable) {
- if (data[0] == 'F' && is_reliable) {
- // Got final score
- players_score_[from_participant.Id()].score = data[1];
- players_score_[from_participant.Id()].finished = true;
- LOGI("Got final data from name:%s ID:%s",
- from_participant.DisplayName().c_str(), from_participant.Id().c_str());
- } else if (data[0] == 'U' && !is_reliable) {
- // Got current score
- uint8_t score = players_score_[from_participant.Id()].score;
- players_score_[from_participant.Id()].score = std::max(score, data[1]);
- LOGI("Got data from name:%s ID:%s",
- from_participant.DisplayName().c_str(), from_participant.Id().c_str());
- }
- UpdateScore();
-}
-
-/*
- * Room status change callback
- */
-void Engine::OnRoomStatusChanged(gpg::RealTimeRoom const &room) {
- room_ = room;
-}
-
-/*
- * Invoked when participant status changed
- */
-void Engine::OnParticipantStatusChanged(
- gpg::RealTimeRoom const &room,
- gpg::MultiplayerParticipant const &participant) {
-
- // Update participant status
- LOGI("Participant %s status changed: %d", participant.Id().c_str(),
- participant.Status());
-
- if (participant.Status() != gpg::ParticipantStatus::JOINED) {
- {
- std::lock_guard lock(mutex_);
- if (players_score_.find(participant.Id()) != players_score_.end()) {
- players_score_[participant.Id()].finished = true;
- }
- }
- UpdateScore();
- }
-}
-
-/*
- * Play games UI that is in your turn
- */
-void Engine::PlayGame() {
- ndk_helper::JNIHelper::GetInstance()->RunOnUiThread([this]() {
- LOGI("Playing match");
- if (dialog_) delete dialog_;
-
- // Start game
- InitializeGame();
-
- //
- // Using jui_helper, a support library, to create and bind gameplay buttons.
- //
- dialog_ = new jui_helper::JUIDialog(app_->activity);
-
- // Setting up labels
- time_text_ = new jui_helper::JUITextView("0:00");
- time_text_->AddRule(jui_helper::LAYOUT_PARAMETER_ALIGN_PARENT_TOP,
- jui_helper::LAYOUT_PARAMETER_TRUE);
- time_text_->AddRule(jui_helper::LAYOUT_PARAMETER_CENTER_IN_PARENT,
- jui_helper::LAYOUT_PARAMETER_TRUE);
- time_text_->SetAttribute("TextSize", jui_helper::ATTRIBUTE_UNIT_SP, 18.f);
- time_text_->SetAttribute("Padding", 10, 10, 10, 10);
-
- my_score_text_ = new jui_helper::JUITextView("000");
- my_score_text_->AddRule(jui_helper::LAYOUT_PARAMETER_BELOW, time_text_);
- my_score_text_->AddRule(jui_helper::LAYOUT_PARAMETER_CENTER_IN_PARENT,
- jui_helper::LAYOUT_PARAMETER_TRUE);
- my_score_text_->SetAttribute("TextSize", jui_helper::ATTRIBUTE_UNIT_SP,
- 24.f);
- my_score_text_->SetAttribute("Padding", 10, 10, 10, 10);
-
- // Take Turn Button
- button_play_ = new jui_helper::JUIButton("Click me!");
- button_play_->SetCallback([this](jui_helper::JUIView *view,
- const int32_t message) {
- switch (message) {
- case jui_helper::JUICALLBACK_BUTTON_UP: {
- if (!playing_) return;
- score_counter_++;
- UpdateScore();
- UpdateTime();
-
- // Broadcast my score to others via unreliable protocol
- BroadcastScore(false);
- }
- }
- });
-
- button_play_->AddRule(jui_helper::LAYOUT_PARAMETER_CENTER_IN_PARENT,
- jui_helper::LAYOUT_PARAMETER_TRUE);
- button_play_->AddRule(jui_helper::LAYOUT_PARAMETER_BELOW, my_score_text_);
-
- const int32_t labelWidth = 600;
- const int32_t labelHeight = 300;
- scores_text_ = new jui_helper::JUITextView("0:00");
- scores_text_->AddRule(jui_helper::LAYOUT_PARAMETER_BELOW, button_play_);
- scores_text_->AddRule(jui_helper::LAYOUT_PARAMETER_CENTER_IN_PARENT,
- jui_helper::LAYOUT_PARAMETER_TRUE);
- scores_text_->SetAttribute("TextSize", jui_helper::ATTRIBUTE_UNIT_SP, 18.f);
- scores_text_->SetAttribute("MinimumWidth", labelWidth);
- scores_text_->SetAttribute("MinimumHeight", labelHeight);
- scores_text_->SetAttribute("Padding", 10, 10, 10, 10);
-
- UpdateScore();
-
- dialog_->AddView(my_score_text_);
- dialog_->AddView(button_play_);
- dialog_->AddView(time_text_);
- dialog_->AddView(scores_text_);
-
- dialog_->SetAttribute("Title", "Click the button");
- dialog_->SetCallback(
- jui_helper::JUICALLBACK_DIALOG_DISMISSED,
- [this](jui_helper::JUIDialog *dialog, const int32_t message) {
- LOGI("Dialog dismissed");
- LeaveGame();
- dialog_ = nullptr;
- });
-
- dialog_->Show();
- LOGI("Showing dialog");
-
- //
- // Invoke time counter periodically
- //
- std::thread([this]() {
- ndk_helper::JNIHelper &helper =
- *ndk_helper::JNIHelper::GetInstance();
- helper.AttachCurrentThread();
- while (UpdateTime()) {
- std::chrono::milliseconds d(100);
- std::this_thread::sleep_for(d);
- }
- // Broadcast my score to others via reliable protocol
- BroadcastScore(true);
-
- UpdateScore();
- helper.DetachCurrentThread();
- }).detach();
- });
-}
-
-/*
- * Update game UI when some player's score is updated
- */
-void Engine::UpdateScore() {
- // Lock mutex since this one can be called from multiple thread,
- // gpg callback tread and UI callback thread
- std::lock_guard lock(mutex_);
-
- size_t SIZE = 64;
- char str[SIZE];
- snprintf(str, SIZE, "%03d", score_counter_);
- std::string str_myscore(str);
-
- snprintf(str, SIZE, "My score: %03d %s\n", score_counter_,
- playing_ ? "" : "*");
- std::string allstr(str);
-
- // Append other player
- std::vector participants = room_.Participants();
- for (gpg::MultiplayerParticipant participant : participants) {
- LOGI("Participant name:%s ID:%s", participant.DisplayName().c_str(),
- participant.Id().c_str());
- if (participant.HasPlayer())
- LOGI("self:%s PlayerID:%s", self_id_.c_str(),
- participant.Player().Id().c_str());
-
- if (participant.HasPlayer() &&
- participant.Player().Id().compare(self_id_) == 0)
- continue; // Skip local player
-
- int32_t score = 0;
- bool finished = false;
- if (players_score_.find(participant.Id()) != players_score_.end()) {
- score = players_score_[participant.Id()].score;
- finished = players_score_[participant.Id()].finished;
- }
-
- LOGI("Status %d", participant.Status());
- snprintf(str, SIZE, "%s: %03d %s\n", participant.DisplayName().c_str(),
- score, finished ? "*" : "");
- allstr += str;
- }
-
- // Update game UI, UI update needs to be performed in UI thread
- ndk_helper::JNIHelper::GetInstance()
- ->RunOnUiThread([this, str_myscore, allstr]() {
- my_score_text_->SetAttribute("Text", str_myscore.c_str());
- scores_text_->SetAttribute("Text", allstr.c_str());
- });
-}
-
-/*
- * Update game timer and game UI
- */
-bool Engine::UpdateTime() {
- // UpdateTime() is invoked from other thread asynchronously
- // So need to Lock mutex
- std::lock_guard lock(mutex_);
-
- if (!playing_) return false;
-
- double current_time = monitor_.GetCurrentTime();
- current_time -= start_time_ + 1.0;
-
- if (current_time >= GAME_DURATION) {
- // finish game
- playing_ = false;
- current_time = GAME_DURATION;
- ndk_helper::JNIHelper::GetInstance()->RunOnUiThread([this]() {
- button_play_->SetAttribute("Enabled", false);
- });
- }
-
- // Update game UI, UI update needs to be performed in UI thread
- ndk_helper::JNIHelper::GetInstance()->RunOnUiThread([this, current_time]() {
- size_t SIZE = 64;
- char str[SIZE];
- snprintf(str, SIZE, "0:%02.0f", GAME_DURATION - current_time);
- time_text_->SetAttribute("Text", const_cast(str));
- });
-
- return true;
-}
-
-/*
- * Initialize game state
- */
-void Engine::InitializeGame() {
- // Lock mutex
- std::lock_guard lock(mutex_);
-
- playing_ = true;
-
- start_time_ = monitor_.GetCurrentTime();
- score_counter_ = 0;
- players_score_.clear();
-}
-
-/*
- * Leave game
- */
-void Engine::LeaveGame() {
- // Lock mutex
- std::lock_guard lock(mutex_);
-
- service_->RealTimeMultiplayer().LeaveRoom(
- room_, [](gpg::ResponseStatus const &status) {});
-
- LOGI("Game is over");
- playing_ = false;
-}
-
-/*
- * Initialize game management UI,
- * invoking jui_helper functions to create java UIs
- */
-void Engine::InitUI() {
- // The window initialization
- jui_helper::JUIWindow::Init(app_->activity, JUIHELPER_CLASS_NAME);
-
- // Show toast with app label
- ndk_helper::JNIHelper::GetInstance()->RunOnUiThread([]() {
- if(NULL == jui_helper::JUIWindow::GetInstance()->GetContext()) {
- return;
- }
- jui_helper::JUIToast toast(
- ndk_helper::JNIHelper::GetInstance()->GetAppLabel());
- toast.Show();
- });
-
- //
- // Using jui_helper, a support library, to create and bind game management
- // UIs.
- //
-
- //
- // Buttons
- //
- // Sign in button.
- button_sign_in_ = new jui_helper::JUIButton(
- service_->IsAuthorized() ? "Sign Out" : "Sign In");
- SetParameters(button_sign_in_, nullptr);
- button_sign_in_->AddRule(jui_helper::LAYOUT_PARAMETER_CENTER_IN_PARENT,
- jui_helper::LAYOUT_PARAMETER_TRUE);
- button_sign_in_->SetCallback([this](jui_helper::JUIView *view,
- const int32_t message) {
- if (message == jui_helper::JUICALLBACK_BUTTON_UP) {
- if (service_->IsAuthorized()) {
- service_->SignOut();
- } else {
- service_->StartAuthorizationUI();
- }
- }
- });
- button_sign_in_->SetMargins(0, 0, 0, 50);
-
- jui_helper::JUIWindow::GetInstance()->AddView(button_sign_in_);
-
- button_quick_match_ = new jui_helper::JUIButton("Quick match");
- SetParameters(button_quick_match_, button_sign_in_);
- button_quick_match_->SetCallback([this](jui_helper::JUIView *view,
- const int32_t message) {
- if (message == jui_helper::JUICALLBACK_BUTTON_UP) {
- QuickMatch();
- }
- });
- jui_helper::JUIWindow::GetInstance()->AddView(button_quick_match_);
-
- button_invite_ = new jui_helper::JUIButton("Invite Friends!");
- SetParameters(button_invite_, button_quick_match_);
- button_invite_->SetCallback([this](jui_helper::JUIView *view,
- const int32_t message) {
- if (message == jui_helper::JUICALLBACK_BUTTON_UP) {
- InviteFriend();
- }
- });
- jui_helper::JUIWindow::GetInstance()->AddView(button_invite_);
-
- button_matches_ = new jui_helper::JUIButton("All my invitations");
- SetParameters(button_matches_, button_invite_);
- button_matches_->SetCallback([this](jui_helper::JUIView *view,
- const int32_t message) {
- if (message == jui_helper::JUICALLBACK_BUTTON_UP) {
- ShowRoomInbox();
- }
- });
- jui_helper::JUIWindow::GetInstance()->AddView(button_matches_);
-
- status_text_ = new jui_helper::JUITextView(
- service_->IsAuthorized() ? "Signed In." : "Signed Out.");
- status_text_->AddRule(jui_helper::LAYOUT_PARAMETER_ALIGN_PARENT_BOTTOM,
- jui_helper::LAYOUT_PARAMETER_TRUE);
- status_text_->AddRule(jui_helper::LAYOUT_PARAMETER_CENTER_IN_PARENT,
- jui_helper::LAYOUT_PARAMETER_TRUE);
- jui_helper::JUIWindow::GetInstance()->AddView(status_text_);
-
- textViewFPS_ = new jui_helper::JUITextView("0.0FPS");
- textViewFPS_->SetAttribute("Gravity", jui_helper::ATTRIBUTE_GRAVITY_LEFT);
- textViewFPS_->SetAttribute("TextColor", 0xffffffff);
- textViewFPS_->SetAttribute("TextSize", jui_helper::ATTRIBUTE_UNIT_SP, 18.f);
- textViewFPS_->SetAttribute("Padding", 10, 10, 10, 10);
- jui_helper::JUIWindow::GetInstance()->AddView(textViewFPS_);
-
- // Init play game services
- InitGooglePlayGameServices();
-
- return;
-}
-
-/*
- * Set common parameters to button
- */
-void Engine::SetParameters(jui_helper::JUIButton *button,
- jui_helper::JUIView *below) {
- const int32_t buttonWidth = 600;
- button->AddRule(jui_helper::LAYOUT_PARAMETER_CENTER_IN_PARENT,
- jui_helper::LAYOUT_PARAMETER_TRUE);
- button->SetAttribute("MinimumWidth", buttonWidth);
-
- if (below != nullptr)
- button->AddRule(jui_helper::LAYOUT_PARAMETER_BELOW, below);
-}
-
-/*
- * Enable/Disable management UI
- */
-void Engine::EnableUI(bool enable) {
- ndk_helper::JNIHelper::GetInstance()->RunOnUiThread([this, enable]() {
- button_sign_in_->SetAttribute("Enabled", enable);
-
- bool b = enable;
- if (service_->IsAuthorized() == false) b = false;
- button_quick_match_->SetAttribute("Enabled", b);
- button_invite_->SetAttribute("Enabled", b);
- button_matches_->SetAttribute("Enabled", b);
- });
-}
-
-/*
- * JNI functions those manage activity lifecycle
- */
-extern "C" {
-/*
- * These callbacks are necessary to work Google Play Game Services UIs properly
- *
- * For apps which target Android 2.3 or 3.x devices (API Version prior to 14),
- * Play Game Services has no way to automatically receive Activity lifecycle
- * callbacks. In these cases, Play Game Services relies on the owning Activity
- * to notify it of lifecycle events. Any Activity which owns a GameServices
- * object should call the AndroidSupport::* functions from within their own
- * lifecycle callback functions. The arguments in these functions match those
- * provided by Android, so no additional processing is necessary.
- */
-JNIEXPORT void
-Java_com_google_example_games_ButtonClicker_ButtonClickerNativeActivity_nativeOnActivityResult(
- JNIEnv *env, jobject thiz, jobject activity, jint requestCode,
- jint resultCode, jobject data) {
- gpg::AndroidSupport::OnActivityResult(env, activity, requestCode, resultCode,
- data);
-}
-
-JNIEXPORT void
-Java_com_google_example_games_ButtonClicker_ButtonClickerNativeActivity_nativeOnActivityCreated(
- JNIEnv *env, jobject thiz, jobject activity, jobject saved_instance_state) {
- gpg::AndroidSupport::OnActivityCreated(env, activity, saved_instance_state);
-}
-
-JNIEXPORT void
-Java_com_google_example_games_ButtonClicker_ButtonClickerNativeActivity_nativeOnActivityDestroyed(
- JNIEnv *env, jobject thiz, jobject activity) {
- gpg::AndroidSupport::OnActivityDestroyed(env, activity);
-}
-
-JNIEXPORT void
-Java_com_google_example_games_ButtonClicker_ButtonClickerNativeActivity_nativeOnActivityPaused(
- JNIEnv *env, jobject thiz, jobject activity) {
- gpg::AndroidSupport::OnActivityPaused(env, activity);
-}
-
-JNIEXPORT void
-Java_com_google_example_games_ButtonClicker_ButtonClickerNativeActivity_nativeOnActivityResumed(
- JNIEnv *env, jobject thiz, jobject activity) {
- gpg::AndroidSupport::OnActivityResumed(env, activity);
-}
-
-JNIEXPORT void
-Java_com_google_example_games_ButtonClicker_ButtonClickerNativeActivity_nativeOnActivitySaveInstanceState(
- JNIEnv *env, jobject thiz, jobject activity, jobject out_state) {
- gpg::AndroidSupport::OnActivitySaveInstanceState(env, activity, out_state);
-}
-
-JNIEXPORT void
-Java_com_google_example_games_ButtonClicker_ButtonClickerNativeActivity_nativeOnActivityStarted(
- JNIEnv *env, jobject thiz, jobject activity) {
- gpg::AndroidSupport::OnActivityStarted(env, activity);
-}
-
-JNIEXPORT void
-Java_com_google_example_games_ButtonClicker_ButtonClickerNativeActivity_nativeOnActivityStopped(
- JNIEnv *env, jobject thiz, jobject activity) {
- gpg::AndroidSupport::OnActivityStopped(env, activity);
-}
-}
diff --git a/samples-android/ButtonClicker/src/main/cpp/ButtonClickerNativeActivity.h b/samples-android/ButtonClicker/src/main/cpp/ButtonClickerNativeActivity.h
deleted file mode 100644
index f0f1777..0000000
--- a/samples-android/ButtonClicker/src/main/cpp/ButtonClickerNativeActivity.h
+++ /dev/null
@@ -1,189 +0,0 @@
-// Copyright (c) 2014 Google. All rights reserved.
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-#ifndef TBMPSLEKETONNATIVIACTIVITY_H_
-#define TBMPSLEKETONNATIVIACTIVITY_H_
-
-/*
- * Include files
- */
-#include
-#include
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-// For GPGS
-#include "gpg/gpg.h"
-
-#include "TeapotRenderer.h"
-#include "NDKHelper.h"
-#include "JavaUI.h"
-
-/*
- * Preprocessors
- */
-
-// Class name of helper function
-#define HELPER_CLASS_NAME "com.sample.helper.NDKHelper"
-// Class name of JUIhelper function
-#define JUIHELPER_CLASS_NAME "com.sample.helper.JUIHelper"
-// Share object name of helper function library
-#define HELPER_CLASS_SONAME "ButtonClickerNativeActivity"
-
-//
-// Also set "com.google.android.gms.games.APP_ID" in AndrdoiManifest.xml
-//
-
-const int32_t MIN_PLAYERS = 1;
-const int32_t MAX_PLAYERS = 3;
-const double GAME_DURATION = 20.0;
-
-struct PLAYER_STATUS {
- uint8_t score;
- bool finished;
-};
-/*
- * Engine class of the sample
- */
-struct android_app;
-class Engine : public gpg::IRealTimeEventListener {
- public:
- // GPG-related methods
- void InitGooglePlayGameServices();
- void InviteFriend();
- void ShowRoomInbox();
-
- void InitializeGame();
- void PlayGame();
- void LeaveGame();
- void QuickMatch();
-
- void BroadcastScore(bool bFinal);
-
- // Event handling
- static void HandleCmd(struct android_app *app, int32_t cmd);
- static int32_t HandleInput(android_app *app, AInputEvent *event);
-
- // Engine life cycles
- Engine();
- ~Engine();
- void SetState(android_app *state);
- int InitDisplay(const int32_t cmd);
- void LoadResources();
- void UnloadResources();
- void DrawFrame();
- void TermDisplay(const int32_t cmd);
- void TrimMemory();
- bool IsReady();
-
- // IRealTimeEventListener members
- virtual void OnRoomStatusChanged(gpg::RealTimeRoom const &room);
-
- virtual void OnParticipantStatusChanged(
- gpg::RealTimeRoom const &room,
- gpg::MultiplayerParticipant const &participant);
-
- virtual void OnDataReceived(
- gpg::RealTimeRoom const &room,
- gpg::MultiplayerParticipant const &from_participant,
- std::vector data, bool is_reliable);
-
- // We are not using these callbacks below
- // because the app just waits for the room to become active,
- // no need to inspect individual changes
- virtual void OnConnectedSetChanged(gpg::RealTimeRoom const &room) {}
-
- virtual void OnP2PConnected(gpg::RealTimeRoom const &room,
- gpg::MultiplayerParticipant const &participant) {}
- virtual void OnP2PDisconnected(
- gpg::RealTimeRoom const &room,
- gpg::MultiplayerParticipant const &participant) {}
-
- private:
- // Callbacks for GPG authentication.
- void OnAuthActionStarted(gpg::AuthOperation op);
- void OnAuthActionFinished(gpg::AuthOperation op, gpg::AuthStatus status);
-
- void UpdateScore();
- bool UpdateTime();
-
- void EnableUI(bool enable);
- void InitUI();
- void TransformPosition(ndk_helper::Vec2 &vec);
- void UpdateFPS(float fFPS);
- void SetParameters(jui_helper::JUIButton *button, jui_helper::JUIView *below);
-
- std::unique_ptr service_; // gpg service instance
- std::unordered_map players_score_; // hashmap to
- // keep
- // tracking of
- // player
- // scores
- gpg::RealTimeRoom room_; // room status. This variable is updated each time
- // the room status is updated
- // in OnRoomStatusChanged()
- int32_t score_counter_; // Score counter of local player
- bool playing_; // Am I playing a game?
- std::string self_id_; // Local player's ID
- double start_time_; // Game start time
-
- // synchronization primitive to synchronize
- // UIThread, Timer thread and gpg callback thread
- mutable std::mutex mutex_;
-
- // Renderer of a teapot
- TeapotRenderer renderer_;
-
- // GLContext instance
- ndk_helper::GLContext *gl_context_;
-
- bool initialized_resources_;
- bool has_focus_;
-
- // Helpers for touch control
- ndk_helper::DoubletapDetector doubletap_detector_;
- ndk_helper::PinchDetector pinch_detector_;
- ndk_helper::DragDetector drag_detector_;
- ndk_helper::PerfMonitor monitor_;
- ndk_helper::TapCamera tap_camera_;
-
- // JUI text view to show FPS
- jui_helper::JUITextView *textViewFPS_;
-
- // Native acitivity app instance
- android_app *app_;
-
- // JUI dialog-related UI stuff here
- jui_helper::JUIDialog *dialog_;
-
- jui_helper::JUIButton *button_sign_in_;
- jui_helper::JUIButton *button_quick_match_;
- jui_helper::JUIButton *button_invite_;
- jui_helper::JUIButton *button_matches_;
-
- jui_helper::JUITextView *status_text_;
-
- jui_helper::JUITextView *time_text_;
- jui_helper::JUITextView *my_score_text_;
- jui_helper::JUITextView *scores_text_;
- jui_helper::JUIButton *button_play_;
-};
-
-#endif // TBMPSLEKETONNATIVIACTIVITY_H_
diff --git a/samples-android/ButtonClicker/src/main/cpp/ButtonClickerNativeActivity_Engine.cpp b/samples-android/ButtonClicker/src/main/cpp/ButtonClickerNativeActivity_Engine.cpp
deleted file mode 100644
index 6b7df0d..0000000
--- a/samples-android/ButtonClicker/src/main/cpp/ButtonClickerNativeActivity_Engine.cpp
+++ /dev/null
@@ -1,343 +0,0 @@
-// Copyright (c) 2014 Google. All rights reserved.
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-/*
- * Include files
- */
-#include "ButtonClickerNativeActivity.h"
-
-/*
- * Ctor
- */
-Engine::Engine()
- : initialized_resources_(false),
- has_focus_(false),
- textViewFPS_(nullptr),
- app_(nullptr),
- dialog_(nullptr),
- button_sign_in_(nullptr),
- button_invite_(nullptr),
- status_text_(nullptr) {
- gl_context_ = ndk_helper::GLContext::GetInstance();
-}
-
-/*
- * Dtor
- */
-Engine::~Engine() {
- jui_helper::JUIWindow::GetInstance()->Close();
- delete dialog_;
-}
-
-/**
- * Called when GPU resources need to be claimed (e.g. Textures, Shaders etc)
- * Initialize all GPU resources here.
- */
-void Engine::LoadResources() {
- renderer_.Init();
- renderer_.Bind(&tap_camera_);
-}
-
-/**
- * Called when GPU resources need to be cleaned up when GL Context has been lost
- * Cleanup all GPU resources here
- */
-void Engine::UnloadResources() { renderer_.Unload(); }
-
-/**
- * Initialize an EGL context for the current display.
- */
-int Engine::InitDisplay(const int32_t cmd) {
- if (!initialized_resources_) {
- gl_context_->Init(app_->window);
- InitUI();
- LoadResources();
- initialized_resources_ = true;
- } else {
- // initialize OpenGL ES and EGL
- if (EGL_SUCCESS != gl_context_->Resume(app_->window)) {
- UnloadResources();
- LoadResources();
- }
-
- jui_helper::JUIWindow::GetInstance()->Resume(app_->activity, cmd);
- }
-
- // Enable culling OpenGL state
- glEnable(GL_CULL_FACE);
-
- // Enabled depth test OpenGL state
- glEnable(GL_DEPTH_TEST);
- glDepthFunc(GL_LEQUAL);
-
- // Note that screen size might have been changed
- glViewport(0, 0, gl_context_->GetScreenWidth(),
- gl_context_->GetScreenHeight());
- renderer_.UpdateViewport();
-
- tap_camera_.SetFlip(1.f, -1.f, -1.f);
- tap_camera_.SetPinchTransformFactor(2.f, 2.f, 8.f);
-
- return 0;
-}
-
-/**
- * Just the current frame in the display.
- */
-void Engine::DrawFrame() {
- float fFPS;
- if (monitor_.Update(fFPS)) {
- UpdateFPS(fFPS);
- }
- renderer_.Update(monitor_.GetCurrentTime());
-
- // Just fill the screen with a color.
- glClearColor(0.5f, 0.5f, 0.5f, 1.f);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- renderer_.Render();
-
- // Swap
- if (EGL_SUCCESS != gl_context_->Swap()) {
- UnloadResources();
- LoadResources();
- }
-}
-
-/**
- * Tear down the EGL context currently associated with the display.
- */
-void Engine::TermDisplay(const int32_t cmd) {
- gl_context_->Suspend();
- jui_helper::JUIWindow::GetInstance()->Suspend(cmd);
-}
-
-void Engine::TrimMemory() {
- LOGI("Trimming memory");
- gl_context_->Invalidate();
-}
-
-/**
- * Process the next input event.
- * In the handler, it passes touch events to gesture detector helper class
- * Based on gesture detection, the app moves camera, model view accordingly
- */
-int32_t Engine::HandleInput(android_app *app, AInputEvent *event) {
- Engine *eng = (Engine *)app->userData;
- if (AInputEvent_getType(event) == AINPUT_EVENT_TYPE_MOTION) {
- ndk_helper::GESTURE_STATE doubleTapState =
- eng->doubletap_detector_.Detect(event);
- ndk_helper::GESTURE_STATE dragState = eng->drag_detector_.Detect(event);
- ndk_helper::GESTURE_STATE pinchState = eng->pinch_detector_.Detect(event);
-
- // Double tap detector has a priority over other detectors
- if (doubleTapState == ndk_helper::GESTURE_STATE_ACTION) {
- // Detect double tap
- eng->tap_camera_.Reset(true);
- } else {
- // Handle drag state
- if (dragState & ndk_helper::GESTURE_STATE_START) {
- // Otherwise, start dragging
- ndk_helper::Vec2 v;
- eng->drag_detector_.GetPointer(v);
- eng->TransformPosition(v);
- eng->tap_camera_.BeginDrag(v);
- } else if (dragState & ndk_helper::GESTURE_STATE_MOVE) {
- ndk_helper::Vec2 v;
- eng->drag_detector_.GetPointer(v);
- eng->TransformPosition(v);
- eng->tap_camera_.Drag(v);
- } else if (dragState & ndk_helper::GESTURE_STATE_END) {
- eng->tap_camera_.EndDrag();
- }
-
- // Handle pinch state
- if (pinchState & ndk_helper::GESTURE_STATE_START) {
- // Start new pinch
- ndk_helper::Vec2 v1;
- ndk_helper::Vec2 v2;
- eng->pinch_detector_.GetPointers(v1, v2);
- eng->TransformPosition(v1);
- eng->TransformPosition(v2);
- eng->tap_camera_.BeginPinch(v1, v2);
- } else if (pinchState & ndk_helper::GESTURE_STATE_MOVE) {
- // Multi touch
- // Start new pinch
- ndk_helper::Vec2 v1;
- ndk_helper::Vec2 v2;
- eng->pinch_detector_.GetPointers(v1, v2);
- eng->TransformPosition(v1);
- eng->TransformPosition(v2);
- eng->tap_camera_.Pinch(v1, v2);
- }
- }
- return 1;
- }
- return 0;
-}
-
-/**
- * Process the next main command.
- */
-void Engine::HandleCmd(struct android_app *app, int32_t cmd) {
- Engine *eng = (Engine *)app->userData;
- switch (cmd) {
- case APP_CMD_SAVE_STATE:
- break;
- case APP_CMD_INIT_WINDOW:
- if (app->window != NULL) {
- eng->InitDisplay(APP_CMD_INIT_WINDOW);
- eng->DrawFrame();
- }
-
- break;
- case APP_CMD_TERM_WINDOW:
- // Note that JUI helper needs to know if a window has been terminated
- eng->TermDisplay(APP_CMD_TERM_WINDOW);
-
- eng->has_focus_ = false;
- break;
- case APP_CMD_START:
- break;
- case APP_CMD_STOP:
- break;
- case APP_CMD_RESUME:
- jui_helper::JUIWindow::GetInstance()->Resume(app->activity,
- APP_CMD_RESUME);
- break;
- case APP_CMD_GAINED_FOCUS:
- // Start animation
- eng->has_focus_ = true;
- jui_helper::JUIWindow::GetInstance()->Resume(app->activity,
- APP_CMD_GAINED_FOCUS);
- break;
- case APP_CMD_LOST_FOCUS:
- // Also stop animating.
- eng->has_focus_ = false;
- eng->DrawFrame();
- break;
- case APP_CMD_LOW_MEMORY:
- // Free up GL resources
- eng->TrimMemory();
- break;
- case APP_CMD_CONFIG_CHANGED:
- // Configuration changes
- eng->TermDisplay(APP_CMD_CONFIG_CHANGED);
- eng->InitDisplay(APP_CMD_CONFIG_CHANGED);
- break;
- case APP_CMD_DESTROY:
- ndk_helper::JNIHelper::GetInstance()->DetachCurrentThread();
- break;
- }
-}
-
-/*
- * Misc
- */
-void Engine::SetState(android_app *state) {
- app_ = state;
- doubletap_detector_.SetConfiguration(app_->config);
- drag_detector_.SetConfiguration(app_->config);
- pinch_detector_.SetConfiguration(app_->config);
-}
-
-bool Engine::IsReady() {
- if (has_focus_) return true;
-
- return false;
-}
-
-void Engine::TransformPosition(ndk_helper::Vec2 &vec) {
- vec = ndk_helper::Vec2(2.0f, 2.0f) * vec /
- ndk_helper::Vec2(gl_context_->GetScreenWidth(),
- gl_context_->GetScreenHeight()) -
- ndk_helper::Vec2(1.f, 1.f);
-}
-
-void Engine::UpdateFPS(float fFPS) {
- ndk_helper::JNIHelper::GetInstance()->RunOnUiThread([fFPS, this]() {
- const int32_t count = 64;
- char str[count];
- snprintf(str, count, "%2.2f FPS", fFPS);
- textViewFPS_->SetAttribute("Text", (const char *)str);
- });
-
- return;
-}
-
-Engine g_engine;
-
-/**
- * This is the main entry point of a native application that is using
- * android_native_app_glue. It runs in its own thread, with its own
- * event loop for receiving input events and doing other things.
- */
-void android_main(android_app *state) {
-
- g_engine.SetState(state);
-
- // Init helper functions
- ndk_helper::JNIHelper::Init(state->activity, HELPER_CLASS_NAME,
- HELPER_CLASS_SONAME);
-
- // Init play game services
- g_engine.InitGooglePlayGameServices();
-
- state->userData = &g_engine;
- state->onAppCmd = Engine::HandleCmd;
- state->onInputEvent = Engine::HandleInput;
-
- // loop waiting for stuff to do.
- while (1) {
- // Read all pending events.
- int id;
- int events;
- android_poll_source *source;
-
- // If not animating, we will block forever waiting for events.
- // If animating, we loop until all events are read, then continue
- // to draw the next frame of animation.
- while ((id = ALooper_pollAll(g_engine.IsReady() ? 0 : -1, NULL, &events,
- (void **)&source)) >= 0) {
- // Process this event.
- if (source != NULL) source->process(state, source);
-
- // Check if we are exiting.
- if (state->destroyRequested != 0) {
- g_engine.TermDisplay(APP_CMD_TERM_WINDOW);
- return;
- }
- }
-
- if (g_engine.IsReady()) {
- // Drawing is throttled to the screen update rate, so there
- // is no need to do timing here.
- g_engine.DrawFrame();
- }
- }
-}
-
-extern "C" {
-JNIEXPORT void
-Java_com_google_example_games_ButtonClicker_ButtonClickerNativeActivity_OnPauseHandler(
- JNIEnv *env) {
- // 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.
- jui_helper::JUIWindow::GetInstance()->Suspend(APP_CMD_PAUSE);
-}
-}
diff --git a/samples-android/ButtonClicker/src/main/java/com/google/example/games/ButtonClicker/ButtonClickerApplication.java b/samples-android/ButtonClicker/src/main/java/com/google/example/games/ButtonClicker/ButtonClickerApplication.java
deleted file mode 100644
index d5830c1..0000000
--- a/samples-android/ButtonClicker/src/main/java/com/google/example/games/ButtonClicker/ButtonClickerApplication.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.example.games.ButtonClicker;
-
-import android.app.Application;
-
-public class ButtonClickerApplication extends Application {
- public void onCreate() {
- super.onCreate();
- }
-}
diff --git a/samples-android/ButtonClicker/src/main/java/com/google/example/games/ButtonClicker/ButtonClickerNativeActivity.java b/samples-android/ButtonClicker/src/main/java/com/google/example/games/ButtonClicker/ButtonClickerNativeActivity.java
deleted file mode 100644
index 898d104..0000000
--- a/samples-android/ButtonClicker/src/main/java/com/google/example/games/ButtonClicker/ButtonClickerNativeActivity.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Copyright 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.example.games.ButtonClicker;
-
-import android.annotation.SuppressLint;
-import android.app.Activity;
-import android.app.NativeActivity;
-import android.content.Intent;
-import android.os.Bundle;
-import android.view.View;
-
-public class ButtonClickerNativeActivity extends NativeActivity {
- // Load SO
- static {
- System.loadLibrary("ButtonClickerNativeActivity");
- }
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- // Hide toolbar
- int SDK_INT = android.os.Build.VERSION.SDK_INT;
- if (SDK_INT >= 19) {
- setImmersiveSticky();
-
- View decorView = getWindow().getDecorView();
- decorView
- .setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
- @Override
- public void onSystemUiVisibilityChange(int visibility) {
- setImmersiveSticky();
- }
- });
- }
- nativeOnActivityCreated(this, savedInstanceState);
- }
-
- @SuppressLint("InlinedApi")
- @SuppressWarnings("deprecation")
- protected void onResume() {
- super.onResume();
-
- // Hide toolbar
- int SDK_INT = android.os.Build.VERSION.SDK_INT;
- if (SDK_INT >= 11 && SDK_INT < 14) {
- getWindow().getDecorView().setSystemUiVisibility(
- View.STATUS_BAR_HIDDEN);
- } else if (SDK_INT >= 14 && SDK_INT < 19) {
- getWindow().getDecorView().setSystemUiVisibility(
- View.SYSTEM_UI_FLAG_FULLSCREEN
- | View.SYSTEM_UI_FLAG_LOW_PROFILE);
- } else if (SDK_INT >= 19) {
- setImmersiveSticky();
- }
-
- nativeOnActivityResumed(this);
- }
-
- @SuppressLint("InlinedApi")
- void setImmersiveSticky() {
- View decorView = getWindow().getDecorView();
- decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN
- | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
- | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
- | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
- | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
- | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
- }
-
- protected void onPause() {
- super.onPause();
- // 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();
-
- nativeOnActivityPaused(this);
- }
-
- protected void onDestroy() {
- super.onDestroy();
- nativeOnActivityDestroyed(this);
- }
-
- protected void onStart() {
- super.onStart();
- nativeOnActivityStarted(this);
- }
-
- protected void onStop() {
- super.onStop();
- nativeOnActivityStopped(this);
- }
-
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- nativeOnActivitySaveInstanceState(this, outState);
- }
-
- 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);
-
- public static native void nativeOnActivityCreated(Activity activity,
- Bundle savedInstanceState);
-
- private static native void nativeOnActivityDestroyed(Activity activity);
-
- private static native void nativeOnActivityPaused(Activity activity);
-
- private static native void nativeOnActivityResumed(Activity activity);
-
- private static native void nativeOnActivitySaveInstanceState(
- Activity activity, Bundle outState);
-
- private static native void nativeOnActivityStarted(Activity activity);
-
- private static native void nativeOnActivityStopped(Activity activity);
-
- native public void OnPauseHandler();
-}
diff --git a/samples-android/ButtonClicker/src/main/res/drawable-hdpi/ic_launcher.png b/samples-android/ButtonClicker/src/main/res/drawable-hdpi/ic_launcher.png
deleted file mode 100644
index ea01cbf..0000000
Binary files a/samples-android/ButtonClicker/src/main/res/drawable-hdpi/ic_launcher.png and /dev/null differ
diff --git a/samples-android/ButtonClicker/src/main/res/drawable-ldpi/ic_launcher.png b/samples-android/ButtonClicker/src/main/res/drawable-ldpi/ic_launcher.png
deleted file mode 100644
index a3d6a18..0000000
Binary files a/samples-android/ButtonClicker/src/main/res/drawable-ldpi/ic_launcher.png and /dev/null differ
diff --git a/samples-android/ButtonClicker/src/main/res/drawable-mdpi/ic_launcher.png b/samples-android/ButtonClicker/src/main/res/drawable-mdpi/ic_launcher.png
deleted file mode 100644
index 8f80897..0000000
Binary files a/samples-android/ButtonClicker/src/main/res/drawable-mdpi/ic_launcher.png and /dev/null differ
diff --git a/samples-android/ButtonClicker/src/main/res/drawable-xhdpi/ic_launcher.png b/samples-android/ButtonClicker/src/main/res/drawable-xhdpi/ic_launcher.png
deleted file mode 100644
index b779a2b..0000000
Binary files a/samples-android/ButtonClicker/src/main/res/drawable-xhdpi/ic_launcher.png and /dev/null differ
diff --git a/samples-android/ButtonClicker/src/main/res/values/ids.xml b/samples-android/ButtonClicker/src/main/res/values/ids.xml
deleted file mode 100644
index cd729a8..0000000
--- a/samples-android/ButtonClicker/src/main/res/values/ids.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
- REPLACE_ME
-
-
diff --git a/samples-android/ButtonClicker/src/main/res/values/strings.xml b/samples-android/ButtonClicker/src/main/res/values/strings.xml
deleted file mode 100644
index facc182..0000000
--- a/samples-android/ButtonClicker/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
- ButtonClicker
-
-
diff --git a/samples-android/ButtonClicker/src/main/res/values/styles.xml b/samples-android/ButtonClicker/src/main/res/values/styles.xml
deleted file mode 100644
index 4a10ca4..0000000
--- a/samples-android/ButtonClicker/src/main/res/values/styles.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/samples-android/TbmpSkeletonNative/CMakeLists.txt b/samples-android/TbmpSkeletonNative/CMakeLists.txt
deleted file mode 100644
index 8d2a0ca..0000000
--- a/samples-android/TbmpSkeletonNative/CMakeLists.txt
+++ /dev/null
@@ -1,84 +0,0 @@
-# Copyright (C) 2017 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-##
-
-cmake_minimum_required(VERSION 3.4.1)
-
-# Import the GPGS C++ SDK library
-add_library(gpg_sdk STATIC IMPORTED)
-set_target_properties(gpg_sdk PROPERTIES IMPORTED_LOCATION
- ${GPG_SDK_PATH}/lib/c++/${ANDROID_ABI}/libgpg.a)
-
-# build native_app_glue as a static lib
-add_library(native_app_glue STATIC
- ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c)
-
-# build cpufeatures as a static lib
-add_library(cpufeatures STATIC
- ${ANDROID_NDK}/sources/android/cpufeatures/cpu-features.c)
-
-#include the native part of JUI Helper
-add_subdirectory (${JUI_HELPER_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/libs/${ANDROID_ABI}/libjuihelper")
-
-#include the native part of NDKHelper
-add_subdirectory (${NDK_HELPER_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/libs/${ANDROID_ABI}/libndkhelper")
-
-#JSON library
-add_library(json STATIC
- ${JSON_PATH}/src/lib_json/json_writer.cpp
- ${JSON_PATH}/src/lib_json/json_reader.cpp
- ${JSON_PATH}/src/lib_json/json_value.cpp
- )
- target_include_directories(json PRIVATE
- ${JSON_PATH}/include
- )
-
-# Export ANativeActivity_onCreate(),
-# Refer to: https://github.com/android-ndk/ndk/issues/381.
-set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate")
-
-
-add_library(TBMPSkeletonNativeActivity
- SHARED
- src/main/cpp/TBMPSkeletonNativeActivity.cpp
- src/main/cpp/TBMPSkeletonNativeActivity_Engine.cpp
- ${TEAPOT_RENDERER_PATH}/TeapotRenderer.cpp
- )
-
-target_include_directories(TBMPSkeletonNativeActivity PRIVATE
- ${ANDROID_NDK}/sources/android/native_app_glue
- ${ANDROID_NDK}/sources/android/cpufeatures
- ${GPG_SDK_PATH}/include
- ${JSON_PATH}/include
- ${juihelper_SOURCE_DIR}/src/main/cpp
- ${ndkhelper_SOURCE_DIR}/src/main/cpp
- ${TEAPOT_RENDERER_PATH}
-)
-
-# Specifies libraries CMake should link to your target library. You
-# can link multiple libraries, such as libraries you define in this
-# build script, prebuilt third-party libraries, or system libraries.
-
-target_link_libraries(TBMPSkeletonNativeActivity
- gpg_sdk
- native_app_glue
- cpufeatures
- juihelper
- ndkhelper
- json
- log
- android
- EGL
- GLESv2
- z)
diff --git a/samples-android/TbmpSkeletonNative/build.gradle b/samples-android/TbmpSkeletonNative/build.gradle
deleted file mode 100644
index df1d311..0000000
--- a/samples-android/TbmpSkeletonNative/build.gradle
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright 2017 (C) Google LLC
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-apply plugin: 'com.android.application'
-
-android {
- compileSdkVersion 27
- defaultConfig {
- //
- // REPLACE THE APPLICATION ID with your bundle ID
- //
- applicationId "com.google.example.games.ReplaceMe"
- versionCode 1
- versionName "1.0"
-
- minSdkVersion 14
- targetSdkVersion 27
-
- ndk.abiFilters 'x86', 'armeabi-v7a', 'arm64-v8a'
-
- externalNativeBuild {
- cmake {
- cppFlags "-std=c++11 -frtti -Wall -Werror"
- arguments "-DJUI_HELPER_PATH=${project(':Common:JuiHelper').projectDir}" ,
- "-DNDK_HELPER_PATH=${project(':Common:NDKHelper').projectDir}" ,
- "-DGPG_SDK_PATH=${project(':Common:gpg-sdk').projectDir}/gpg-cpp-sdk/android",
- "-DJSON_PATH=${project(':Common:gpg-sdk').projectDir}/../external/jsoncpp/",
- "-DTEAPOT_RENDERER_PATH=${project(':Common').projectDir}/TeapotRenderer" ,
- "-DANDROID_STL=c++_static",
- "-DANDROID_TOOLCHAIN=clang"
- }
-
- }
- }
-
- externalNativeBuild {
- cmake.path "CMakeLists.txt"
- }
-}
-
-dependencies {
- implementation project(":Common:JuiHelper")
- implementation 'com.google.android.gms:play-services-games:11.8.0'
- implementation 'com.google.android.gms:play-services-nearby:11.8.0'
- implementation 'com.android.support:support-v4:27.0.2'
-}
diff --git a/samples-android/TbmpSkeletonNative/proguard-project.txt b/samples-android/TbmpSkeletonNative/proguard-project.txt
deleted file mode 100644
index f2fe155..0000000
--- a/samples-android/TbmpSkeletonNative/proguard-project.txt
+++ /dev/null
@@ -1,20 +0,0 @@
-# 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 *;
-#}
diff --git a/samples-android/TbmpSkeletonNative/src/main/AndroidManifest.xml b/samples-android/TbmpSkeletonNative/src/main/AndroidManifest.xml
deleted file mode 100644
index 59bd37d..0000000
--- a/samples-android/TbmpSkeletonNative/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,59 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/samples-android/TbmpSkeletonNative/src/main/assets/Shaders/ShaderPlain.fsh b/samples-android/TbmpSkeletonNative/src/main/assets/Shaders/ShaderPlain.fsh
deleted file mode 100644
index 75ae290..0000000
--- a/samples-android/TbmpSkeletonNative/src/main/assets/Shaders/ShaderPlain.fsh
+++ /dev/null
@@ -1,42 +0,0 @@
-
-//
-// ShaderPlain.fsh
-//
-
-#define USE_PHONG (1)
-
-uniform lowp vec3 vMaterialAmbient;
-uniform mediump vec4 vMaterialSpecular;
-
-varying lowp vec4 colorDiffuse;
-
-#if USE_PHONG
-uniform highp vec3 vLight0;
-varying mediump vec3 position;
-varying mediump vec3 normal;
-#else
-varying lowp vec4 colorSpecular;
-#endif
-
-/*
- Standard phong fragment shader implementation.
- Take object space light position and normal, derive a specular intensity.
-*/
-void main() {
-#if USE_PHONG
- mediump vec3
- halfVector = normalize(-vLight0 + position);
- mediump
- float NdotH = max(dot(normalize(normal), halfVector), 0.0);
- mediump
- float fPower = vMaterialSpecular.w;
- mediump
- float specular = pow(NdotH, fPower);
-
- lowp vec4
- colorSpecular = vec4(vMaterialSpecular.xyz * specular, 1);
- gl_FragColor = colorDiffuse + colorSpecular;
-#else
- gl_FragColor = colorDiffuse + colorSpecular;
-#endif
-}
\ No newline at end of file
diff --git a/samples-android/TbmpSkeletonNative/src/main/assets/Shaders/VS_ShaderPlain.vsh b/samples-android/TbmpSkeletonNative/src/main/assets/Shaders/VS_ShaderPlain.vsh
deleted file mode 100644
index a62e4a8..0000000
--- a/samples-android/TbmpSkeletonNative/src/main/assets/Shaders/VS_ShaderPlain.vsh
+++ /dev/null
@@ -1,64 +0,0 @@
-//
-// ShaderPlain.vsh
-//
-
-#define USE_PHONG (1)
-
-attribute highp vec3 myVertex;
-attribute highp vec3 myNormal;
-attribute mediump vec2 myUV;
-attribute mediump vec4 myBone;
-
-varying mediump vec2 texCoord;
-varying lowp vec4 colorDiffuse;
-
-#if USE_PHONG
-varying mediump vec3 position;
-varying mediump vec3 normal;
-#else
-varying lowp vec4 colorSpecular;
-#endif
-
-uniform highp mat4 uMVMatrix;
-uniform highp mat4 uPMatrix;
-
-uniform highp vec3 vLight0;
-
-uniform lowp vec4 vMaterialDiffuse;
-uniform lowp vec3 vMaterialAmbient;
-uniform lowp vec4 vMaterialSpecular;
-
-/*
- Standard vertex shader shader implementation.
- Transform vertices and normal,
- derive diffuse value and pass object space light source
- position to fragment shader for phong shading.
-*/
-void main(void) {
- highp vec4
- p = vec4(myVertex, 1);
- gl_Position = uPMatrix * p;
-
- texCoord = myUV;
-
- highp vec3
- worldNormal = vec3(
- mat3(uMVMatrix[0].xyz, uMVMatrix[1].xyz, uMVMatrix[2].xyz) * myNormal);
- highp vec3
- ecPosition = p.xyz;
-
- colorDiffuse = dot(worldNormal, normalize(-vLight0 + ecPosition))
- * vMaterialDiffuse + vec4(vMaterialAmbient, 1);
-
-#if USE_PHONG
- normal = worldNormal;
- position = ecPosition;
-#else
- highp vec3 halfVector = normalize(ecPosition - vLight0);
-
- highp float NdotH = max(-dot(worldNormal, halfVector), 0.0);
- float fPower = vMaterialSpecular.w;
- highp float specular = min( pow(NdotH, fPower), 1.0);
- colorSpecular = vec4(vMaterialSpecular.xyz * specular, 1);
-#endif
-}
diff --git a/samples-android/TbmpSkeletonNative/src/main/cpp/TBMPSkeletonNativeActivity.cpp b/samples-android/TbmpSkeletonNative/src/main/cpp/TBMPSkeletonNativeActivity.cpp
deleted file mode 100644
index 481ce82..0000000
--- a/samples-android/TbmpSkeletonNative/src/main/cpp/TBMPSkeletonNativeActivity.cpp
+++ /dev/null
@@ -1,746 +0,0 @@
-/*
- * Copyright 2013 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
- * Include files
- */
-#include "TBMPSkeletonNativeActivity.h"
-
-/*
- * Key for JSON object
- */
-const char *TurnCounterKey = "turnCounter";
-const char *StringToPassKey = "data";
-
-/*
- * Initialize GooglePlayGameServices
- */
-void Engine::InitGooglePlayGameServices() {
- gpg::AndroidInitialization::android_main(app_);
-
- if (service_ == nullptr) {
- // Game Services have not been initialized, create a new Game Services.
- gpg::AndroidPlatformConfiguration platform_configuration;
- platform_configuration.SetActivity(app_->activity->clazz);
-
- gpg::GameServices::Builder builder;
- service_ = builder.SetOnAuthActionStarted([this](gpg::AuthOperation op) {
- OnAuthActionStarted(op);
- })
- .SetOnAuthActionFinished(
- [this](gpg::AuthOperation op, gpg::AuthStatus status) {
- OnAuthActionFinished(op, status);
- })
- .SetOnTurnBasedMatchEvent(
- [this](gpg::MultiplayerEvent event, std::string match_id,
- gpg::TurnBasedMatch match) {
- LOGI("TurnBasedMultiplayerEvent callback");
- //Show default inbox
- ShowMatchInbox();
- })
- .SetOnMultiplayerInvitationEvent(
- [this](gpg::MultiplayerEvent event, std::string match_id,
- gpg::MultiplayerInvitation invitation) {
- LOGI("MultiplayerInvitationEvent callback");
- //Show default inbox
- ShowMatchInbox();
- }).Create(platform_configuration);
- }
-}
-
-/*
- * Callback: Authentication started
- */
-void Engine::OnAuthActionStarted(gpg::AuthOperation op) {
- ndk_helper::JNIHelper::GetInstance()->RunOnUiThread([this, op]() {
- EnableUI(false);
- authorizing_ = true;
- if (status_text_) {
- if (op == gpg::AuthOperation::SIGN_IN) {
- LOGI("Signing in to GPG");
- status_text_->SetAttribute("Text", "Signing In...");
- } else {
- LOGI("Signing out from GPG");
- status_text_->SetAttribute("Text", "Signing Out...");
- }
- }
- });
-}
-
-/*
- * Callback: Authentication finishes
- */
-void Engine::OnAuthActionFinished(gpg::AuthOperation op,
- gpg::AuthStatus status) {
- ndk_helper::JNIHelper::GetInstance()->RunOnUiThread([this, status]() {
- EnableUI(true);
- authorizing_ = false;
- if (button_sign_in_) {
- button_sign_in_->SetAttribute(
- "Text", gpg::IsSuccess(status) ? "Sign Out" : "Sign In");
- }
-
- if (status_text_) {
- status_text_->SetAttribute(
- "Text",
- gpg::IsSuccess(status) ? "Signed In" : "Signed Out");
- }
- });
-}
-
-/*
- * Show match inbox
- */
-void Engine::ShowMatchInbox() {
- service_->TurnBasedMultiplayer().ShowMatchInboxUI([this](
- gpg::TurnBasedMultiplayerManager::MatchInboxUIResponse const & response) {
- if (gpg::IsSuccess(response.status)) {
- //Show game based on the user's selection
- switch (response.match.Status()) {
- case gpg::MatchStatus::THEIR_TURN:
- //Manage match with dismiss, leave and cancel options
- ManageGame(response.match, true, true, false);
- break;
- case gpg::MatchStatus::MY_TURN:
- //Play selected game
- PlayGame(response.match);
- break;
- case gpg::MatchStatus::COMPLETED:
- //Manage match with dismiss, rematch options
- ManageGame(response.match, false, false, true);
- break;
- case gpg::MatchStatus::EXPIRED:
- default:
- //Manage match with dismiss option
- ManageGame(response.match, false, false, false);
- break;
- }
- } else {
- LOGI("Invalid response status");
- }
- });
-}
-
-/*
- * Quick match
- * - Create a match with minimal setting and play the game
- */
-void Engine::QuickMatch() {
- gpg::TurnBasedMultiplayerManager &manager = service_->TurnBasedMultiplayer();
- gpg::TurnBasedMatchConfig config =
- gpg::TurnBasedMatchConfig::Builder().SetMinimumAutomatchingPlayers(1)
- .SetMaximumAutomatchingPlayers(2).Create();
-
- EnableUI(false);
- manager.CreateTurnBasedMatch(
- config,
- [this](gpg::TurnBasedMultiplayerManager::TurnBasedMatchResponse const &
- matchResponse) {
- EnableUI(true);
- if (gpg::IsSuccess(matchResponse.status)) {
- PlayGame(matchResponse.match);
- }
- });
-}
-
-/*
- * Invite friends
- * - Show Player Select UI via ShowPlayerSelectUI,
- * - When the UI is finished, create match and show game UI
- */
-void Engine::InviteFriend() {
- service_->TurnBasedMultiplayer().ShowPlayerSelectUI(
- MIN_PLAYERS, MAX_PLAYERS, true,
- [this](gpg::TurnBasedMultiplayerManager::PlayerSelectUIResponse const &
- response) {
- LOGI("selected match %d", response.status);
- if (gpg::IsSuccess(response.status)) {
- // Create new match with the config
- gpg::TurnBasedMatchConfig config = gpg::TurnBasedMatchConfig::Builder()
- .SetMinimumAutomatchingPlayers(response.minimum_automatching_players)
- .SetMaximumAutomatchingPlayers(response.maximum_automatching_players)
- .AddAllPlayersToInvite(response.player_ids).Create();
- EnableUI(false);
- service_->TurnBasedMultiplayer().CreateTurnBasedMatch(
- config,
- [this](
- gpg::TurnBasedMultiplayerManager::TurnBasedMatchResponse const &
- matchResponse) {
- EnableUI(true);
- if (gpg::IsSuccess(matchResponse.status)) {
- PlayGame(matchResponse.match);
- }
- });
- }
- });
-}
-
-/*
- * Cancel current match
- */
-void Engine::CancelMatch() {
- EnableUI(false);
- gpg::TurnBasedMultiplayerManager &manager = service_->TurnBasedMultiplayer();
- manager.CancelMatch(current_match_, [this](gpg::MultiplayerStatus status) {
- EnableUI(true);
- LOGI("Canceled the game");
- });
-}
-
-/*
- * Dismiss current match
- */
-void Engine::DismissMatch() {
- gpg::TurnBasedMultiplayerManager &manager = service_->TurnBasedMultiplayer();
- manager.DismissMatch(current_match_);
-}
-
-/*
- * Rematch selected match
- */
-void Engine::Rematch() {
- EnableUI(false);
- gpg::TurnBasedMultiplayerManager &manager = service_->TurnBasedMultiplayer();
- manager.Rematch(
- current_match_,
- [this](gpg::TurnBasedMultiplayerManager::TurnBasedMatchResponse
- matchResponse) {
- LOGI("Remathing the game");
- EnableUI(true);
- if (gpg::IsSuccess(matchResponse.status)) {
- PlayGame(matchResponse.match);
- }
- });
-}
-
-/*
- * Leave current match
- * Invoking different APIs based on match state
- */
-void Engine::LeaveMatch() {
- gpg::TurnBasedMultiplayerManager &manager = service_->TurnBasedMultiplayer();
- if (current_match_.Status() == gpg::MatchStatus::MY_TURN) {
- //Leave a game
- manager.LeaveMatchDuringMyTurn(current_match_,
- current_match_.SuggestedNextParticipant(),
- [](gpg::MultiplayerStatus status) {
- LOGI("Left the game");
- });
- } else {
- manager.LeaveMatchDuringTheirTurn(current_match_,
- [](gpg::MultiplayerStatus status) {
- LOGI("Left the game");
- });
- }
- return;
-}
-
-/*
- * Take turn based on playGame UI parameters
- */
-void Engine::TakeTurn(const bool winning, const bool losing) {
- gpg::TurnBasedMultiplayerManager &manager = service_->TurnBasedMultiplayer();
-
- // When it is MY_TURN, localParticipant is always PendingParticipant().
- gpg::MultiplayerParticipant localParticipant =
- current_match_.PendingParticipant();
-
- LOGI("Taking my turn. local participant id:%s",
- localParticipant.Id().c_str());
-
- gpg::MultiplayerParticipant nextParticipant =
- current_match_.SuggestedNextParticipant();
-
- if (!nextParticipant.Valid()) {
- //Error case
- manager.DismissMatch(current_match_);
- return;
- }
-
- turn_counter_++;
- std::vector match_data = SetupMatchData();
-
- //By default, passing through existing ParticipantResults
- gpg::ParticipantResults results = current_match_.ParticipantResults();
-
- if (winning) {
- //Create winning participants result
- results = current_match_.ParticipantResults()
- .WithResult(localParticipant.Id(), // local player ID
- 0, // placing
- gpg::MatchResult::WIN // status
- );
- } else if (losing) {
- //Create losing participants result
- results = current_match_.ParticipantResults()
- .WithResult(localParticipant.Id(), // local player ID
- 0, // placing
- gpg::MatchResult::LOSS // status
- );
- }
-
- //Take normal turn
- manager.TakeMyTurn(
- current_match_, match_data, results, nextParticipant,
- [](gpg::TurnBasedMultiplayerManager::TurnBasedMatchResponse const &
- response) {
- LOGI("Took turn");
- });
-}
-
-/*
- * Play games UI that is in your turn
- */
-void Engine::PlayGame(gpg::TurnBasedMatch const &match) {
- current_match_ = match;
- ParseMatchData();
-
- ndk_helper::JNIHelper::GetInstance()->RunOnUiThread([this]() {
- LOGI("Playing match");
- if (dialog_)
- delete dialog_;
-
- dialog_ = new jui_helper::JUIDialog(app_->activity);
-
- // Setting up CheckBox
- checkBoxWinning_ = new jui_helper::JUICheckBox("Win the game");
- checkBoxLosing_ = new jui_helper::JUICheckBox("I have lost");
- checkBoxQuit_ = new jui_helper::JUICheckBox("Leave");
-
- // Setting up linear layout
- jui_helper::JUILinearLayout *layout = new jui_helper::JUILinearLayout();
- layout->SetLayoutParams(jui_helper::ATTRIBUTE_SIZE_MATCH_PARENT,
- jui_helper::ATTRIBUTE_SIZE_WRAP_CONTENT);
- layout->SetMargins(0, 50, 0, 50);
- layout->SetAttribute("Orientation",
- jui_helper::LAYOUT_ORIENTATION_VERTICAL);
- layout->AddView(checkBoxWinning_);
- layout->AddView(checkBoxLosing_);
- layout->AddView(checkBoxQuit_);
-
- // Take Turn Button
- jui_helper::JUIButton *button = new jui_helper::JUIButton("Take Turn");
- button->SetCallback(
- [this](jui_helper::JUIView * view, const int32_t message) {
- if (message == jui_helper::JUICALLBACK_BUTTON_UP) {
- if (checkBoxQuit_->IsChecked())
- LeaveMatch();
- else
- TakeTurn(checkBoxWinning_->IsChecked(), checkBoxLosing_->IsChecked());
- dialog_->Close();
- }
- });
- button->AddRule(jui_helper::LAYOUT_PARAMETER_CENTER_IN_PARENT,
- jui_helper::LAYOUT_PARAMETER_TRUE);
- button->AddRule(jui_helper::LAYOUT_PARAMETER_BELOW, layout);
-
- jui_helper::JUIButton *buttonCancel = new jui_helper::JUIButton("Cancel");
- buttonCancel->SetCallback(
- [this](jui_helper::JUIView * view, const int32_t message) {
- if (message == jui_helper::JUICALLBACK_BUTTON_UP) {
- CancelMatch();
- dialog_->Close();
- }
- });
- buttonCancel->AddRule(jui_helper::LAYOUT_PARAMETER_CENTER_IN_PARENT,
- jui_helper::LAYOUT_PARAMETER_TRUE);
- buttonCancel->AddRule(jui_helper::LAYOUT_PARAMETER_BELOW, button);
-
- dialog_->SetCallback(
- jui_helper::JUICALLBACK_DIALOG_CANCELLED,
- [this](jui_helper::JUIDialog * dialog, const int32_t message) {
- LOGI("Dialog cancelled");
- CancelMatch();
- dialog_->Close();
- });
- dialog_->SetCallback(
- jui_helper::JUICALLBACK_DIALOG_DISMISSED,
- [this](jui_helper::JUIDialog * dialog, const int32_t message) {
- LOGI("Dialog dismissed");
- dialog_->Close();
- });
-
- size_t size = 64;
- char str[size];
- snprintf(str, size, "Turn %d", turn_counter_);
- dialog_->SetAttribute("Title", (const char *)str);
- dialog_->AddView(layout);
- dialog_->AddView(button);
- dialog_->Show();
- LOGI("Showing dialog");
- });
-}
-
-/*
- * Manage games UI when finished/their turn game is selected in match inbox UI
- */
-void Engine::ManageGame(gpg::TurnBasedMatch const &match, const bool leave,
- const bool cancel, const bool rematch) {
- current_match_ = match;
- ParseMatchData();
-
- ndk_helper::JNIHelper::GetInstance()->RunOnUiThread(
- [this, leave, cancel, rematch]() {
- LOGI("Managing match");
- if (dialog_)
- delete dialog_;
- dialog_ = new jui_helper::JUIDialog(app_->activity);
-
- jui_helper::JUIButton *currentButton;
- // Take Turn Button
- jui_helper::JUIButton *button = new jui_helper::JUIButton("Dismiss");
- button->SetCallback(
- [this](jui_helper::JUIView * view, const int32_t message) {
- if (message == jui_helper::JUICALLBACK_BUTTON_UP) {
- DismissMatch();
- dialog_->Close();
- }
- });
- button->AddRule(jui_helper::LAYOUT_PARAMETER_ALIGN_PARENT_TOP,
- jui_helper::LAYOUT_PARAMETER_TRUE);
- button->AddRule(jui_helper::LAYOUT_PARAMETER_CENTER_IN_PARENT,
- jui_helper::LAYOUT_PARAMETER_TRUE);
- dialog_->AddView(button);
- currentButton = button;
-
- if (leave) {
- LOGI("Adding leave button");
- // Leave Button
- jui_helper::JUIButton *leaveButton = new jui_helper::JUIButton("Leave");
- leaveButton->SetCallback(
- [this](jui_helper::JUIView * view, const int32_t message) {
- if (message == jui_helper::JUICALLBACK_BUTTON_UP) {
- LeaveMatch();
- dialog_->Close();
- }
- });
- leaveButton->AddRule(jui_helper::LAYOUT_PARAMETER_CENTER_IN_PARENT,
- jui_helper::LAYOUT_PARAMETER_TRUE);
- leaveButton->AddRule(jui_helper::LAYOUT_PARAMETER_BELOW, currentButton);
- dialog_->AddView(leaveButton);
- currentButton = leaveButton;
- }
-
- if (cancel) {
- LOGI("Adding cancel button");
- // Cancel Button
- jui_helper::JUIButton *cancelButton = new jui_helper::JUIButton("Cancel");
- cancelButton->SetCallback(
- [this](jui_helper::JUIView * view, const int32_t message) {
- if (message == jui_helper::JUICALLBACK_BUTTON_UP) {
- CancelMatch();
- dialog_->Close();
- }
- });
- cancelButton->AddRule(jui_helper::LAYOUT_PARAMETER_CENTER_IN_PARENT,
- jui_helper::LAYOUT_PARAMETER_TRUE);
- cancelButton->AddRule(jui_helper::LAYOUT_PARAMETER_BELOW, currentButton);
- dialog_->AddView(cancelButton);
- currentButton = cancelButton;
- }
-
- if (rematch) {
- LOGI("Adding rematch button");
- // Leave Button
- jui_helper::JUIButton *rematchButton = new jui_helper::JUIButton("Rematch");
- rematchButton->SetCallback(
- [this](jui_helper::JUIView * view, const int32_t message) {
- if (message == jui_helper::JUICALLBACK_BUTTON_UP) {
- Rematch();
- dialog_->Close();
- }
- });
- rematchButton->AddRule(jui_helper::LAYOUT_PARAMETER_CENTER_IN_PARENT,
- jui_helper::LAYOUT_PARAMETER_TRUE);
- rematchButton->AddRule(jui_helper::LAYOUT_PARAMETER_BELOW, currentButton);
- dialog_->AddView(rematchButton);
- }
-
- dialog_->SetCallback(
- jui_helper::JUICALLBACK_DIALOG_CANCELLED,
- [this](jui_helper::JUIDialog * dialog, const int32_t message) {
- LOGI("Dialog cancelled");
- dialog_->Close();
- });
- dialog_->SetCallback(
- jui_helper::JUICALLBACK_DIALOG_DISMISSED,
- [this](jui_helper::JUIDialog * dialog, const int32_t message) {
- LOGI("Dialog dismissed");
- dialog_->Close();
- });
-
- size_t size = 64;
- char str[size];
- snprintf(str, size, "Turn %d", turn_counter_);
- dialog_->SetAttribute("Title", (const char *)str);
- dialog_->Show();
- LOGI("Showing dialog");
- });
-}
-
-/*
- * Parse JSON match data
- */
-void Engine::ParseMatchData() {
- LOGI("Parsing match data %d", static_cast(current_match_.Data().size()));
- turn_counter_ = 1;
- if (!current_match_.HasData() || current_match_.Data().size() == 0) {
- LOGI("Game data not found");
- return;
- }
-
- //UTF16 to UTF8 conversion
- //Removing BOM for first 2 bytes
- std::u16string source;
- auto it = current_match_.Data().begin();
- auto end = current_match_.Data().end();
- //Skip BOM
- it++;
- it++;
- while (it != end) {
- uint16_t i = *it++;
- i |= (*it++) << 8;
- source.push_back(i);
- }
-
- std::wstring_convert, char16_t> convert;
- std::string str = convert.to_bytes(source);
-
- Json::Value root;
- Json::Reader reader;
- bool parsingSuccessful = reader.parse(str, root);
- if (!parsingSuccessful) {
- LOGI("Data parse error");
- return;
- }
-
- turn_counter_ = root[TurnCounterKey].asInt();
- LOGI("Got turn counter %d", turn_counter_);
-}
-
-/*
- * Create JSON data to store
- */
-std::vector Engine::SetupMatchData() {
- Json::StyledWriter writer;
- Json::Value root;
- root[TurnCounterKey] = turn_counter_;
- root[StringToPassKey] = "test";
- std::string source = writer.write(root);
-
- //Converting back from UTF8 to UTF16
- std::wstring_convert, char16_t> convert;
- std::u16string dest = convert.from_bytes(source);
-
- std::vector v;
- v.push_back(0xff); //Adding BOM
- v.push_back(0xfe); //Adding BOM
- auto it = dest.begin();
- auto end = dest.end();
- while (it != end) {
- uint16_t i = *it++;
- v.push_back( (unsigned char)(i & 0x0ff));
- v.push_back((unsigned char) i >> 8);
- }
-
- LOGI("Created Game Data: size: %d", static_cast(v.size()));
- return v;
-}
-
-/*
- * Initialize main sample UI,
- * invoking jui_helper functions to create java UIs
- */
-void Engine::InitUI() {
- const int32_t buttonWidth = 600;
- // Show toast with app label
- ndk_helper::JNIHelper::GetInstance()->RunOnUiThread([]() {
- jui_helper::JUIToast toast(
- ndk_helper::JNIHelper::GetInstance()->GetAppLabel());
- toast.Show();
- });
-
- // The window initialization
- jui_helper::JUIWindow::Init(app_->activity, JUIHELPER_CLASS_NAME);
-
- //
- // Buttons
- //
- // Sign in button.
- button_sign_in_ = new jui_helper::JUIButton(
- service_->IsAuthorized() ? "Sign Out" : "Sign In");
- button_sign_in_->AddRule(jui_helper::LAYOUT_PARAMETER_CENTER_IN_PARENT,
- jui_helper::LAYOUT_PARAMETER_TRUE);
- button_sign_in_->AddRule(jui_helper::LAYOUT_PARAMETER_CENTER_IN_PARENT,
- jui_helper::LAYOUT_PARAMETER_TRUE);
- button_sign_in_->SetCallback(
- [this](jui_helper::JUIView * view, const int32_t message) {
- LOGI("button_sign_in_ click: %d", message);
- if (message == jui_helper::JUICALLBACK_BUTTON_UP) {
- if (service_->IsAuthorized()) {
- service_->SignOut();
- } else {
- service_->StartAuthorizationUI();
- }
- }
- });
- button_sign_in_->SetAttribute("MinimumWidth", buttonWidth);
- button_sign_in_->SetMargins(0, 0, 0, 50);
-
- jui_helper::JUIWindow::GetInstance()->AddView(button_sign_in_);
-
- button_quick_match_ = new jui_helper::JUIButton("Quick match");
- button_quick_match_->AddRule(jui_helper::LAYOUT_PARAMETER_BELOW,
- button_sign_in_);
- button_quick_match_->AddRule(jui_helper::LAYOUT_PARAMETER_CENTER_IN_PARENT,
- jui_helper::LAYOUT_PARAMETER_TRUE);
- button_quick_match_->SetAttribute("MinimumWidth", buttonWidth);
- button_quick_match_->SetCallback(
- [this](jui_helper::JUIView * view, const int32_t message) {
- if (message == jui_helper::JUICALLBACK_BUTTON_UP) {
- QuickMatch();
- }
- });
- jui_helper::JUIWindow::GetInstance()->AddView(button_quick_match_);
-
- button_invite_ = new jui_helper::JUIButton("Invite Friends!");
- button_invite_->AddRule(jui_helper::LAYOUT_PARAMETER_BELOW,
- button_quick_match_);
- button_invite_->AddRule(jui_helper::LAYOUT_PARAMETER_CENTER_IN_PARENT,
- jui_helper::LAYOUT_PARAMETER_TRUE);
- button_invite_->SetAttribute("MinimumWidth", buttonWidth);
- button_invite_->SetCallback(
- [this](jui_helper::JUIView * view, const int32_t message) {
- if (message == jui_helper::JUICALLBACK_BUTTON_UP) {
- InviteFriend();
- }
- });
- jui_helper::JUIWindow::GetInstance()->AddView(button_invite_);
-
- button_matches_ = new jui_helper::JUIButton("All my matches");
- button_matches_->AddRule(jui_helper::LAYOUT_PARAMETER_BELOW, button_invite_);
- button_matches_->AddRule(jui_helper::LAYOUT_PARAMETER_CENTER_IN_PARENT,
- jui_helper::LAYOUT_PARAMETER_TRUE);
- button_matches_->SetAttribute("MinimumWidth", buttonWidth);
- button_matches_->SetCallback(
- [this](jui_helper::JUIView * view, const int32_t message) {
- if (message == jui_helper::JUICALLBACK_BUTTON_UP) {
- ShowMatchInbox();
- }
- });
- jui_helper::JUIWindow::GetInstance()->AddView(button_matches_);
-
- status_text_ = new jui_helper::JUITextView(
- service_->IsAuthorized() ? "Signed In." : "Signed Out.");
-
- status_text_->AddRule(jui_helper::LAYOUT_PARAMETER_ALIGN_PARENT_BOTTOM,
- jui_helper::LAYOUT_PARAMETER_TRUE);
- status_text_->AddRule(jui_helper::LAYOUT_PARAMETER_CENTER_IN_PARENT,
- jui_helper::LAYOUT_PARAMETER_TRUE);
- jui_helper::JUIWindow::GetInstance()->AddView(status_text_);
-
- textViewFPS_ = new jui_helper::JUITextView("0.0FPS");
- textViewFPS_->SetAttribute("Gravity", jui_helper::ATTRIBUTE_GRAVITY_LEFT);
- textViewFPS_->SetAttribute("TextColor", 0xffffffff);
- textViewFPS_->SetAttribute("TextSize", jui_helper::ATTRIBUTE_UNIT_SP, 18.f);
- textViewFPS_->SetAttribute("Padding", 10, 10, 10, 10);
- jui_helper::JUIWindow::GetInstance()->AddView(textViewFPS_);
-
- if (authorizing_)
- EnableUI(false);
- return;
-}
-
-void Engine::EnableUI(bool enable) {
- LOGI("Updating UI:%d", enable);
- ndk_helper::JNIHelper::GetInstance()->RunOnUiThread([this, enable]() {
- button_sign_in_->SetAttribute("Enabled", enable);
-
- bool b = enable;
- if (service_->IsAuthorized() == false)
- b = false;
- button_quick_match_->SetAttribute("Enabled", b);
- button_invite_->SetAttribute("Enabled", b);
- button_matches_->SetAttribute("Enabled", b);
- });
-}
-
-/*
- * JNI functions those manage activity lifecycle
- */
-extern "C" {
-/*
- * These callbacks are necessary to work Google Play Game Services UIs properly
- *
- * For apps which target Android 2.3 or 3.x devices (API Version prior to 14),
- * Play Game Services has no way to automatically receive Activity lifecycle
- * callbacks. In these cases, Play Game Services relies on the owning Activity
- * to notify it of lifecycle events. Any Activity which owns a GameServices
- * object should call the AndroidSupport::* functions from within their own
- * lifecycle callback functions. The arguments in these functions match those
- * provided by Android, so no additional processing is necessary.
- */
-JNIEXPORT void
-Java_com_google_example_games_tbmpskel_TBMPSkeletonNativeActivity_nativeOnActivityResult(
- JNIEnv *env, jobject thiz, jobject activity, jint requestCode,
- jint resultCode, jobject data) {
- gpg::AndroidSupport::OnActivityResult(env, activity, requestCode, resultCode,
- data);
-}
-
-JNIEXPORT void
-Java_com_google_example_games_tbmpskel_TBMPSkeletonNativeActivity_nativeOnActivityCreated(
- JNIEnv *env, jobject thiz, jobject activity, jobject saved_instance_state) {
- gpg::AndroidSupport::OnActivityCreated(env, activity, saved_instance_state);
-}
-
-JNIEXPORT void
-Java_com_google_example_games_tbmpskel_TBMPSkeletonNativeActivity_nativeOnActivityDestroyed(
- JNIEnv *env, jobject thiz, jobject activity) {
- gpg::AndroidSupport::OnActivityDestroyed(env, activity);
-}
-
-JNIEXPORT void
-Java_com_google_example_games_tbmpskel_TBMPSkeletonNativeActivity_nativeOnActivityPaused(
- JNIEnv *env, jobject thiz, jobject activity) {
- gpg::AndroidSupport::OnActivityPaused(env, activity);
-}
-
-JNIEXPORT void
-Java_com_google_example_games_tbmpskel_TBMPSkeletonNativeActivity_nativeOnActivityResumed(
- JNIEnv *env, jobject thiz, jobject activity) {
- gpg::AndroidSupport::OnActivityResumed(env, activity);
-}
-
-JNIEXPORT void
-Java_com_google_example_games_tbmpskel_TBMPSkeletonNativeActivity_nativeOnActivitySaveInstanceState(
- JNIEnv *env, jobject thiz, jobject activity, jobject out_state) {
- gpg::AndroidSupport::OnActivitySaveInstanceState(env, activity, out_state);
-}
-
-JNIEXPORT void
-Java_com_google_example_games_tbmpskel_TBMPSkeletonNativeActivity_nativeOnActivityStarted(
- JNIEnv *env, jobject thiz, jobject activity) {
- gpg::AndroidSupport::OnActivityStarted(env, activity);
-}
-
-JNIEXPORT void
-Java_com_google_example_games_tbmpskel_TBMPSkeletonNativeActivity_nativeOnActivityStopped(
- JNIEnv *env, jobject thiz, jobject activity) {
- gpg::AndroidSupport::OnActivityStopped(env, activity);
-}
-
-}
diff --git a/samples-android/TbmpSkeletonNative/src/main/cpp/TBMPSkeletonNativeActivity.h b/samples-android/TbmpSkeletonNative/src/main/cpp/TBMPSkeletonNativeActivity.h
deleted file mode 100644
index 6c10779..0000000
--- a/samples-android/TbmpSkeletonNative/src/main/cpp/TBMPSkeletonNativeActivity.h
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Copyright 2013 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef TBMPSLEKETONNATIVIACTIVITY_H_
-#define TBMPSLEKETONNATIVIACTIVITY_H_
-
-/*
- * Include files
- */
-#include
-#include
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-// For GPGS
-#include "gpg/gpg.h"
-
-// For JSON parser
-#include "json/json.h"
-
-#include "TeapotRenderer.h"
-#include "NDKHelper.h"
-#include "JavaUI.h"
-
-/*
- * Preprocessors
- */
-
-// Class name of helper function
-#define HELPER_CLASS_NAME "com.sample.helper.NDKHelper"
-// Class name of JUIhelper function
-#define JUIHELPER_CLASS_NAME "com.sample.helper.JUIHelper"
-// Share object name of helper function library
-#define HELPER_CLASS_SONAME "TBMPSkeletonNativeActivity"
-
-//
-// Also set "com.google.android.gms.games.APP_ID" in AndrdoiManifest.xml
-//
-
-const int32_t MIN_PLAYERS = 1;
-const int32_t MAX_PLAYERS = 3;
-
-/*
- * Engine class of the sample
- */
-struct android_app;
-class Engine {
-public:
- // GPG related methods
- void InitGooglePlayGameServices();
- void InviteFriend();
- void ShowMatchInbox();
- void QuickMatch();
- void PlayGame(gpg::TurnBasedMatch const &match);
- void TakeTurn(const bool winning, const bool losing);
- void LeaveMatch();
- void CancelMatch();
- void DismissMatch();
- void Rematch();
-
- // Event handling
- static void HandleCmd(struct android_app *app, int32_t cmd);
- static int32_t HandleInput(android_app *app, AInputEvent *event);
-
- // Engine life cycles
- Engine();
- ~Engine();
- void SetState(android_app *state);
- int InitDisplay(const int32_t cmd);
- void LoadResources();
- void UnloadResources();
- void DrawFrame();
- void TermDisplay(const int32_t cmd);
- void TrimMemory();
- bool IsReady();
-
- // Sensor managers
- void ProcessSensors(const int32_t id) { sensroManager_.Process(id); }
- void ResumeSensors() { sensroManager_.Resume(); }
- void SuspendSensors() { sensroManager_.Suspend(); }
-
-private:
- // Callbacks from GPG.
- void OnAuthActionStarted(gpg::AuthOperation op);
- void OnAuthActionFinished(gpg::AuthOperation op, gpg::AuthStatus status);
-
- void ParseMatchData();
- std::vector SetupMatchData();
- void ManageGame(gpg::TurnBasedMatch const &match, const bool leave,
- const bool cancel, const bool rematch);
-
- std::unique_ptr service_;
- gpg::TurnBasedMatch current_match_;
- int32_t turn_counter_;
-
- bool authorizing_;
- //
- void EnableUI(bool enable);
- void InitUI();
- void TransformPosition(ndk_helper::Vec2 &vec);
- void UpdateFPS(float fFPS);
-
- // Renderer of a teapot
- TeapotRenderer renderer_;
-
- // GLContext instance
- ndk_helper::GLContext *gl_context_;
-
- // Sensor manager
- ndk_helper::SensorManager sensroManager_;
-
- bool initialized_resources_;
- bool has_focus_;
-
- // Helpers for touch control
- ndk_helper::DoubletapDetector doubletap_detector_;
- ndk_helper::PinchDetector pinch_detector_;
- ndk_helper::DragDetector drag_detector_;
- ndk_helper::PerfMonitor monitor_;
- ndk_helper::TapCamera tap_camera_;
-
- // JUI text view to show FPS
- jui_helper::JUITextView *textViewFPS_;
-
- // Native activity app instance
- android_app *app_;
-
- // JUI dialog
- jui_helper::JUIDialog *dialog_;
-
- jui_helper::JUIButton *button_sign_in_;
- jui_helper::JUIButton *button_quick_match_;
- jui_helper::JUIButton *button_invite_;
- jui_helper::JUIButton *button_matches_;
-
- jui_helper::JUITextView *status_text_;
-
- jui_helper::JUICheckBox *checkBoxWinning_;
- jui_helper::JUICheckBox *checkBoxLosing_;
- jui_helper::JUICheckBox *checkBoxQuit_;
-};
-
-#endif //TBMPSLEKETONNATIVIACTIVITY_H_
diff --git a/samples-android/TbmpSkeletonNative/src/main/cpp/TBMPSkeletonNativeActivity_Engine.cpp b/samples-android/TbmpSkeletonNative/src/main/cpp/TBMPSkeletonNativeActivity_Engine.cpp
deleted file mode 100644
index 0ca9a3a..0000000
--- a/samples-android/TbmpSkeletonNative/src/main/cpp/TBMPSkeletonNativeActivity_Engine.cpp
+++ /dev/null
@@ -1,341 +0,0 @@
-/*
- * Copyright 2013 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
- * Include files
- */
-#include "TBMPSkeletonNativeActivity.h"
-
-/*
- * Ctor
- */
-Engine::Engine()
- : authorizing_(false), initialized_resources_(false), has_focus_(false),
- textViewFPS_(nullptr), app_(nullptr), dialog_(nullptr),
- button_sign_in_(nullptr), button_invite_(nullptr), status_text_(nullptr) {
- gl_context_ = ndk_helper::GLContext::GetInstance();
-}
-
-/*
- * Dtor
- */
-Engine::~Engine() {
- jui_helper::JUIWindow::GetInstance()->Close();
- delete dialog_;
-}
-
-/**
- * Load resources
- */
-void Engine::LoadResources() {
- renderer_.Init();
- renderer_.Bind(&tap_camera_);
-}
-
-/**
- * Unload resources
- */
-void Engine::UnloadResources() { renderer_.Unload(); }
-
-/**
- * Initialize an EGL context for the current display.
- */
-int Engine::InitDisplay(const int32_t cmd) {
- if (!initialized_resources_) {
- gl_context_->Init(app_->window);
- InitUI();
- LoadResources();
- initialized_resources_ = true;
- } else {
- // initialize OpenGL ES and EGL
- if (EGL_SUCCESS != gl_context_->Resume(app_->window)) {
- UnloadResources();
- LoadResources();
- }
-
- jui_helper::JUIWindow::GetInstance()->Resume(app_->activity, cmd);
- }
-
- // Enable culling OpenGL state
- glEnable(GL_CULL_FACE);
-
- // Enabled depth test OpenGL state
- glEnable(GL_DEPTH_TEST);
- glDepthFunc(GL_LEQUAL);
-
- // Note that screen size might have been changed
- glViewport(0, 0, gl_context_->GetScreenWidth(),
- gl_context_->GetScreenHeight());
- renderer_.UpdateViewport();
-
- tap_camera_.SetFlip(1.f, -1.f, -1.f);
- tap_camera_.SetPinchTransformFactor(2.f, 2.f, 8.f);
-
- return 0;
-}
-
-/**
- * Just the current frame in the display.
- */
-void Engine::DrawFrame() {
- float fFPS;
- if (monitor_.Update(fFPS)) {
- UpdateFPS(fFPS);
- }
- renderer_.Update(monitor_.GetCurrentTime());
-
- // Just fill the screen with a color.
- glClearColor(0.5f, 0.5f, 0.5f, 1.f);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- renderer_.Render();
-
- // Swap
- if (EGL_SUCCESS != gl_context_->Swap()) {
- UnloadResources();
- LoadResources();
- }
-}
-
-/**
- * Tear down the EGL context currently associated with the display.
- */
-void Engine::TermDisplay(const int32_t cmd) {
- gl_context_->Suspend();
- jui_helper::JUIWindow::GetInstance()->Suspend(cmd);
-}
-
-void Engine::TrimMemory() {
- LOGI("Trimming memory");
- gl_context_->Invalidate();
-}
-
-/**
- * Process the next input event.
- * In the handler, it passes touch events to gesture detector helper class
- * Based on gesture detection, the app moves camera, model view accordingly
- */
-int32_t Engine::HandleInput(android_app *app, AInputEvent *event) {
- Engine *eng = (Engine *)app->userData;
- if (AInputEvent_getType(event) == AINPUT_EVENT_TYPE_MOTION) {
- ndk_helper::GESTURE_STATE doubleTapState =
- eng->doubletap_detector_.Detect(event);
- ndk_helper::GESTURE_STATE dragState = eng->drag_detector_.Detect(event);
- ndk_helper::GESTURE_STATE pinchState = eng->pinch_detector_.Detect(event);
-
- // Double tap detector has a priority over other detectors
- if (doubleTapState == ndk_helper::GESTURE_STATE_ACTION) {
- // Detect double tap
- eng->tap_camera_.Reset(true);
- } else {
- // Handle drag state
- if (dragState & ndk_helper::GESTURE_STATE_START) {
- // Otherwise, start dragging
- ndk_helper::Vec2 v;
- eng->drag_detector_.GetPointer(v);
- eng->TransformPosition(v);
- eng->tap_camera_.BeginDrag(v);
- } else if (dragState & ndk_helper::GESTURE_STATE_MOVE) {
- ndk_helper::Vec2 v;
- eng->drag_detector_.GetPointer(v);
- eng->TransformPosition(v);
- eng->tap_camera_.Drag(v);
- } else if (dragState & ndk_helper::GESTURE_STATE_END) {
- eng->tap_camera_.EndDrag();
- }
-
- // Handle pinch state
- if (pinchState & ndk_helper::GESTURE_STATE_START) {
- // Start new pinch
- ndk_helper::Vec2 v1;
- ndk_helper::Vec2 v2;
- eng->pinch_detector_.GetPointers(v1, v2);
- eng->TransformPosition(v1);
- eng->TransformPosition(v2);
- eng->tap_camera_.BeginPinch(v1, v2);
- } else if (pinchState & ndk_helper::GESTURE_STATE_MOVE) {
- // Multi touch
- // Start new pinch
- ndk_helper::Vec2 v1;
- ndk_helper::Vec2 v2;
- eng->pinch_detector_.GetPointers(v1, v2);
- eng->TransformPosition(v1);
- eng->TransformPosition(v2);
- eng->tap_camera_.Pinch(v1, v2);
- }
- }
- return 1;
- }
- return 0;
-}
-
-/**
- * Process the next main command.
- */
-void Engine::HandleCmd(struct android_app *app, int32_t cmd) {
- Engine *eng = (Engine *)app->userData;
- switch (cmd) {
- case APP_CMD_SAVE_STATE:
- break;
- case APP_CMD_INIT_WINDOW:
- if (app->window != NULL) {
- eng->InitDisplay(APP_CMD_INIT_WINDOW);
- eng->DrawFrame();
- }
-
- break;
- case APP_CMD_TERM_WINDOW:
- // Note that JUI helper needs to know if a window has been terminated
- eng->TermDisplay(APP_CMD_TERM_WINDOW);
-
- eng->has_focus_ = false;
- break;
- case APP_CMD_START:
- break;
- case APP_CMD_STOP:
- break;
- case APP_CMD_RESUME:
- jui_helper::JUIWindow::GetInstance()->Resume(app->activity, APP_CMD_RESUME);
- break;
- case APP_CMD_GAINED_FOCUS:
- // Start animation
- eng->ResumeSensors();
- eng->has_focus_ = true;
- jui_helper::JUIWindow::GetInstance()->Resume(app->activity,
- APP_CMD_GAINED_FOCUS);
- break;
- case APP_CMD_LOST_FOCUS:
- // Also stop animating.
- eng->SuspendSensors();
- eng->has_focus_ = false;
- eng->DrawFrame();
- break;
- case APP_CMD_LOW_MEMORY:
- // Free up GL resources
- eng->TrimMemory();
- break;
- case APP_CMD_CONFIG_CHANGED:
- // Configuration changes
- eng->TermDisplay(APP_CMD_CONFIG_CHANGED);
- eng->InitDisplay(APP_CMD_CONFIG_CHANGED);
- break;
- case APP_CMD_DESTROY:
- ndk_helper::JNIHelper::GetInstance()->DetachCurrentThread();
- break;
- }
-}
-
-/*
- * Misc
- */
-void Engine::SetState(android_app *state) {
- app_ = state;
- doubletap_detector_.SetConfiguration(app_->config);
- drag_detector_.SetConfiguration(app_->config);
- pinch_detector_.SetConfiguration(app_->config);
- sensroManager_.Init(state);
-}
-
-bool Engine::IsReady() {
- return has_focus_;
-
-}
-
-void Engine::TransformPosition(ndk_helper::Vec2 &vec) {
- vec = ndk_helper::Vec2(2.0f, 2.0f) * vec /
- ndk_helper::Vec2(gl_context_->GetScreenWidth(),
- gl_context_->GetScreenHeight()) -
- ndk_helper::Vec2(1.f, 1.f);
-}
-
-void Engine::UpdateFPS(float fFPS) {
- ndk_helper::JNIHelper::GetInstance()->RunOnUiThread([fFPS, this]() {
- const int32_t count = 64;
- char str[count];
- snprintf(str, count, "%2.2f FPS", fFPS);
- textViewFPS_->SetAttribute("Text", (const char *)str);
- });
-
- return;
-}
-
-Engine g_engine;
-
-/**
- * This is the main entry point of a native application that is using
- * android_native_app_glue. It runs in its own thread, with its own
- * event loop for receiving input events and doing other things.
- */
-void android_main(android_app *state) {
- g_engine.SetState(state);
-
- // Init helper functions
- ndk_helper::JNIHelper::Init(state->activity, HELPER_CLASS_NAME,
- HELPER_CLASS_SONAME);
-
- // Init play game services
- g_engine.InitGooglePlayGameServices();
-
- state->userData = &g_engine;
- state->onAppCmd = Engine::HandleCmd;
- state->onInputEvent = Engine::HandleInput;
-
- // loop waiting for stuff to do.
- while (1) {
- // Read all pending events.
- int id;
- int events;
- android_poll_source *source;
-
- // If not animating, we will block forever waiting for events.
- // If animating, we loop until all events are read, then continue
- // to draw the next frame of animation.
- while ((id = ALooper_pollAll(g_engine.IsReady() ? 0 : -1, NULL, &events,
- (void **)&source)) >= 0) {
- // Process this event.
- if (source != NULL)
- source->process(state, source);
-
- g_engine.ProcessSensors(id);
-
- // Check if we are exiting.
- if (state->destroyRequested != 0) {
- g_engine.TermDisplay(APP_CMD_TERM_WINDOW);
- return;
- }
- }
-
- if (g_engine.IsReady()) {
- // Drawing is throttled to the screen update rate, so there
- // is no need to do timing here.
- g_engine.DrawFrame();
- }
- }
-}
-
-extern "C" {
-JNIEXPORT void
-Java_com_google_example_games_tbmpskel_TBMPSkeletonNativeActivity_OnPauseHandler(
- JNIEnv *env) {
- // 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.
- jui_helper::JUIWindow::GetInstance()->Suspend(APP_CMD_PAUSE);
-}
-}
diff --git a/samples-android/TbmpSkeletonNative/src/main/java/com/google/example/games/tbmpskel/TBMPSkeletonApplication.java b/samples-android/TbmpSkeletonNative/src/main/java/com/google/example/games/tbmpskel/TBMPSkeletonApplication.java
deleted file mode 100644
index a64881b..0000000
--- a/samples-android/TbmpSkeletonNative/src/main/java/com/google/example/games/tbmpskel/TBMPSkeletonApplication.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright 2013 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.example.games.tbmpskel;
-
-import android.app.Application;
-
-public class TBMPSkeletonApplication extends Application {
- public void onCreate() {
- super.onCreate();
- }
-}
diff --git a/samples-android/TbmpSkeletonNative/src/main/java/com/google/example/games/tbmpskel/TBMPSkeletonNativeActivity.java b/samples-android/TbmpSkeletonNative/src/main/java/com/google/example/games/tbmpskel/TBMPSkeletonNativeActivity.java
deleted file mode 100644
index e4a9eca..0000000
--- a/samples-android/TbmpSkeletonNative/src/main/java/com/google/example/games/tbmpskel/TBMPSkeletonNativeActivity.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Copyright 2013 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.example.games.tbmpskel;
-
-import android.annotation.SuppressLint;
-import android.app.Activity;
-import android.app.NativeActivity;
-import android.content.Intent;
-import android.os.Bundle;
-import android.view.View;
-
-public class TBMPSkeletonNativeActivity extends NativeActivity {
- // Load SO
- static {
- System.loadLibrary("TBMPSkeletonNativeActivity");
- }
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- // Hide toolbar
- int SDK_INT = android.os.Build.VERSION.SDK_INT;
- if (SDK_INT >= 19) {
- setImmersiveSticky();
-
- View decorView = getWindow().getDecorView();
- decorView
- .setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
- @Override
- public void onSystemUiVisibilityChange(int visibility) {
- setImmersiveSticky();
- }
- });
- }
-
- nativeOnActivityCreated(this, savedInstanceState);
- }
-
- @SuppressLint("InlinedApi")
- @SuppressWarnings("deprecation")
- protected void onResume() {
- super.onResume();
-
- // Hide toolbar
- int SDK_INT = android.os.Build.VERSION.SDK_INT;
- if (SDK_INT >= 11 && SDK_INT < 14) {
- getWindow().getDecorView().setSystemUiVisibility(
- View.STATUS_BAR_HIDDEN);
- } else if (SDK_INT >= 14 && SDK_INT < 19) {
- getWindow().getDecorView().setSystemUiVisibility(
- View.SYSTEM_UI_FLAG_FULLSCREEN
- | View.SYSTEM_UI_FLAG_LOW_PROFILE);
- } else if (SDK_INT >= 19) {
- setImmersiveSticky();
- }
-
- nativeOnActivityResumed(this);
- }
-
- @SuppressLint("InlinedApi")
- void setImmersiveSticky() {
- View decorView = getWindow().getDecorView();
- decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN
- | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
- | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
- | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
- | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
- | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
- }
-
- protected void onPause() {
- super.onPause();
- // 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();
-
- nativeOnActivityPaused(this);
- }
-
- protected void onDestroy() {
- super.onDestroy();
- nativeOnActivityDestroyed(this);
- }
-
- protected void onStart() {
- super.onStart();
- nativeOnActivityStarted(this);
- }
-
- protected void onStop() {
- super.onStop();
- nativeOnActivityStopped(this);
- }
-
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- nativeOnActivitySaveInstanceState(this, outState);
- }
-
- 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);
-
- public static native void nativeOnActivityCreated(Activity activity,
- Bundle savedInstanceState);
-
- private static native void nativeOnActivityDestroyed(Activity activity);
-
- private static native void nativeOnActivityPaused(Activity activity);
-
- private static native void nativeOnActivityResumed(Activity activity);
-
- private static native void nativeOnActivitySaveInstanceState(
- Activity activity, Bundle outState);
-
- private static native void nativeOnActivityStarted(Activity activity);
-
- private static native void nativeOnActivityStopped(Activity activity);
-
- native public void OnPauseHandler();
-}
diff --git a/samples-android/TbmpSkeletonNative/src/main/res/drawable-hdpi/ic_launcher.png b/samples-android/TbmpSkeletonNative/src/main/res/drawable-hdpi/ic_launcher.png
deleted file mode 100644
index ea01cbf..0000000
Binary files a/samples-android/TbmpSkeletonNative/src/main/res/drawable-hdpi/ic_launcher.png and /dev/null differ
diff --git a/samples-android/TbmpSkeletonNative/src/main/res/drawable-ldpi/ic_launcher.png b/samples-android/TbmpSkeletonNative/src/main/res/drawable-ldpi/ic_launcher.png
deleted file mode 100644
index a3d6a18..0000000
Binary files a/samples-android/TbmpSkeletonNative/src/main/res/drawable-ldpi/ic_launcher.png and /dev/null differ
diff --git a/samples-android/TbmpSkeletonNative/src/main/res/drawable-mdpi/ic_launcher.png b/samples-android/TbmpSkeletonNative/src/main/res/drawable-mdpi/ic_launcher.png
deleted file mode 100644
index 8f80897..0000000
Binary files a/samples-android/TbmpSkeletonNative/src/main/res/drawable-mdpi/ic_launcher.png and /dev/null differ
diff --git a/samples-android/TbmpSkeletonNative/src/main/res/drawable-xhdpi/ic_launcher.png b/samples-android/TbmpSkeletonNative/src/main/res/drawable-xhdpi/ic_launcher.png
deleted file mode 100644
index b779a2b..0000000
Binary files a/samples-android/TbmpSkeletonNative/src/main/res/drawable-xhdpi/ic_launcher.png and /dev/null differ
diff --git a/samples-android/TbmpSkeletonNative/src/main/res/layout/widgets.xml b/samples-android/TbmpSkeletonNative/src/main/res/layout/widgets.xml
deleted file mode 100644
index c689a52..0000000
--- a/samples-android/TbmpSkeletonNative/src/main/res/layout/widgets.xml
+++ /dev/null
@@ -1,8 +0,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
deleted file mode 100644
index b2fc703..0000000
--- a/samples-android/TbmpSkeletonNative/src/main/res/values/ids.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
- REPLACE_ME
-
-
diff --git a/samples-android/TbmpSkeletonNative/src/main/res/values/strings.xml b/samples-android/TbmpSkeletonNative/src/main/res/values/strings.xml
deleted file mode 100644
index 6a7c191..0000000
--- a/samples-android/TbmpSkeletonNative/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
- TBMPSkeleton
-
-
diff --git a/samples-android/TbmpSkeletonNative/src/main/res/values/styles.xml b/samples-android/TbmpSkeletonNative/src/main/res/values/styles.xml
deleted file mode 100644
index 4a10ca4..0000000
--- a/samples-android/TbmpSkeletonNative/src/main/res/values/styles.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/samples-android/build.gradle b/samples-android/build.gradle
index f788858..9a7e39d 100644
--- a/samples-android/build.gradle
+++ b/samples-android/build.gradle
@@ -21,7 +21,7 @@ buildscript {
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.0.1'
+ classpath 'com.android.tools.build:gradle:3.5.1'
}
}
diff --git a/samples-android/gradle/wrapper/gradle-wrapper.properties b/samples-android/gradle/wrapper/gradle-wrapper.properties
index 1e53d6d..6e515af 100644
--- a/samples-android/gradle/wrapper/gradle-wrapper.properties
+++ b/samples-android/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Tue Nov 14 14:20:53 PST 2017
+#Mon Aug 03 01:36:35 BST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.3-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
diff --git a/samples-android/settings.gradle b/samples-android/settings.gradle
index 361c872..36c7dd2 100644
--- a/samples-android/settings.gradle
+++ b/samples-android/settings.gradle
@@ -1,9 +1,7 @@
include ':Common:gpg-sdk',
':Common:JuiHelper',
':Common:NDKHelper',
- ':ButtonClicker',
':CollectAllTheStarsNative',
':Minimalist',
- ':TbmpSkeletonNative',
':Teapot'