diff --git a/samples-android/ButtonClicker/build.gradle b/samples-android/ButtonClicker/build.gradle index e237ac4..6ed5ef6 100644 --- a/samples-android/ButtonClicker/build.gradle +++ b/samples-android/ButtonClicker/build.gradle @@ -16,15 +16,17 @@ apply plugin : 'com.android.application' android { - compileSdkVersion 26 + compileSdkVersion 27 defaultConfig { // // REPLACE THE APPLICATION ID with your bundle ID // applicationId "com.google.example.games.ReplaceMe" - minSdkVersion 14 - targetSdkVersion 26 + versionCode 1 + versionName "1.0" + minSdkVersion 14 + targetSdkVersion 27 ndk.abiFilters 'x86', 'armeabi-v7a', 'arm64-v8a' @@ -47,7 +49,7 @@ android { dependencies { implementation project(":Common:JuiHelper") - implementation 'com.google.android.gms:play-services-games:11.6.2' - implementation 'com.google.android.gms:play-services-nearby:11.6.2' - implementation 'com.android.support:support-v4:26.1.0' + 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/src/main/AndroidManifest.xml b/samples-android/ButtonClicker/src/main/AndroidManifest.xml index ef93975..63831da 100644 --- a/samples-android/ButtonClicker/src/main/AndroidManifest.xml +++ b/samples-android/ButtonClicker/src/main/AndroidManifest.xml @@ -1,25 +1,32 @@ - + + - - + + android:theme="@style/AppTheme" + tools:ignore="GoogleAppIndexingWarning"> diff --git a/samples-android/ButtonClicker/src/main/jni/ButtonClickerNativeActivity.cpp b/samples-android/ButtonClicker/src/main/jni/ButtonClickerNativeActivity.cpp index bdb4729..49ce929 100644 --- a/samples-android/ButtonClicker/src/main/jni/ButtonClickerNativeActivity.cpp +++ b/samples-android/ButtonClicker/src/main/jni/ButtonClickerNativeActivity.cpp @@ -68,7 +68,7 @@ void Engine::InitGooglePlayGameServices() { LOGI("MultiplayerInvitationEvent callback"); if (event == - gpg::TurnBasedMultiplayerEvent::UPDATED_FROM_APP_LAUNCH) { + gpg::MultiplayerEvent::UPDATED_FROM_APP_LAUNCH) { // In this case, an invitation has been accepted already // in notification or in Play game app @@ -282,7 +282,7 @@ void Engine::BroadcastScore(bool bFinal) { * 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 recieved. + * 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: @@ -296,13 +296,13 @@ void Engine::OnDataReceived(gpg::RealTimeRoom const &room, // Got final score players_score_[from_participant.Id()].score = data[1]; players_score_[from_participant.Id()].finished = true; - LOGI("Got final data from Dispname:%s ID:%s", + 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 Dispname:%s ID:%s", + LOGI("Got data from name:%s ID:%s", from_participant.DisplayName().c_str(), from_participant.Id().c_str()); } UpdateScore(); @@ -449,7 +449,7 @@ void Engine::UpdateScore() { // gpg callback tread and UI callback thread std::lock_guard lock(mutex_); - int32_t SIZE = 64; + size_t SIZE = 64; char str[SIZE]; snprintf(str, SIZE, "%03d", score_counter_); std::string str_myscore(str); @@ -461,7 +461,7 @@ void Engine::UpdateScore() { // Append other player std::vector participants = room_.Participants(); for (gpg::MultiplayerParticipant participant : participants) { - LOGI("Participant Dispname:%s ID:%s", participant.DisplayName().c_str(), + 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(), @@ -487,10 +487,8 @@ void Engine::UpdateScore() { // 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", const_cast(str_myscore.c_str())); - scores_text_->SetAttribute("Text", - const_cast(allstr.c_str())); + my_score_text_->SetAttribute("Text", str_myscore.c_str()); + scores_text_->SetAttribute("Text", allstr.c_str()); }); } @@ -498,7 +496,7 @@ void Engine::UpdateScore() { * Update game timer and game UI */ bool Engine::UpdateTime() { - // UpdateTime() is invoked from other thread asynchrnously + // UpdateTime() is invoked from other thread asynchronously // So need to Lock mutex std::lock_guard lock(mutex_); @@ -511,15 +509,14 @@ bool Engine::UpdateTime() { // finish game playing_ = false; current_time = GAME_DURATION; - ndk_helper::JNIHelper::GetInstance()->RunOnUiThread([this, current_time]() { + 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]() { - // LOGI("Updating time %f", current_time); - int32_t SIZE = 64; + size_t SIZE = 64; char str[SIZE]; snprintf(str, SIZE, "0:%02.0f", GAME_DURATION - current_time); time_text_->SetAttribute("Text", const_cast(str)); diff --git a/samples-android/ButtonClicker/src/main/jni/ButtonClickerNativeActivity.h b/samples-android/ButtonClicker/src/main/jni/ButtonClickerNativeActivity.h index e7055df..f0f1777 100644 --- a/samples-android/ButtonClicker/src/main/jni/ButtonClickerNativeActivity.h +++ b/samples-android/ButtonClicker/src/main/jni/ButtonClickerNativeActivity.h @@ -55,13 +55,8 @@ const int32_t MIN_PLAYERS = 1; const int32_t MAX_PLAYERS = 3; const double GAME_DURATION = 20.0; -enum NEXT_PARTICIPANT { - NEXT_PARTICIPANT_AUTOMATCH = -1, - NEXT_PARTICIPANT_NONE = -2, -}; - struct PLAYER_STATUS { - int32_t score; + uint8_t score; bool finished; }; /* @@ -85,7 +80,6 @@ class Engine : public gpg::IRealTimeEventListener { // Event handling static void HandleCmd(struct android_app *app, int32_t cmd); static int32_t HandleInput(android_app *app, AInputEvent *event); - void UpdatePosition(AInputEvent *event, int32_t iIndex, float &fX, float &fY); // Engine life cycles Engine(); diff --git a/samples-android/ButtonClicker/src/main/jni/ButtonClickerNativeActivity_Engine.cpp b/samples-android/ButtonClicker/src/main/jni/ButtonClickerNativeActivity_Engine.cpp index 7431ae9..6b7df0d 100644 --- a/samples-android/ButtonClicker/src/main/jni/ButtonClickerNativeActivity_Engine.cpp +++ b/samples-android/ButtonClicker/src/main/jni/ButtonClickerNativeActivity_Engine.cpp @@ -23,12 +23,12 @@ Engine::Engine() : initialized_resources_(false), has_focus_(false), + textViewFPS_(nullptr), app_(nullptr), dialog_(nullptr), - textViewFPS_(nullptr), button_sign_in_(nullptr), - status_text_(nullptr), - button_invite_(nullptr) { + button_invite_(nullptr), + status_text_(nullptr) { gl_context_ = ndk_helper::GLContext::GetInstance(); } @@ -283,7 +283,6 @@ Engine g_engine; * event loop for receiving input events and doing other things. */ void android_main(android_app *state) { - app_dummy(); g_engine.SetState(state); diff --git a/samples-android/ButtonClicker/src/main/res/layout/widgets.xml b/samples-android/ButtonClicker/src/main/res/layout/widgets.xml deleted file mode 100644 index c689a52..0000000 --- a/samples-android/ButtonClicker/src/main/res/layout/widgets.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - \ No newline at end of file diff --git a/samples-android/ButtonClicker/src/main/res/values-v11/styles.xml b/samples-android/ButtonClicker/src/main/res/values-v11/styles.xml deleted file mode 100644 index 541752f..0000000 --- a/samples-android/ButtonClicker/src/main/res/values-v11/styles.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/samples-android/ButtonClicker/src/main/res/values-v14/styles.xml b/samples-android/ButtonClicker/src/main/res/values-v14/styles.xml deleted file mode 100644 index f20e015..0000000 --- a/samples-android/ButtonClicker/src/main/res/values-v14/styles.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/samples-android/CollectAllTheStarsNative/build.gradle b/samples-android/CollectAllTheStarsNative/build.gradle index 3fa871a..6f830d7 100644 --- a/samples-android/CollectAllTheStarsNative/build.gradle +++ b/samples-android/CollectAllTheStarsNative/build.gradle @@ -1,14 +1,32 @@ +/* + * 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 26 + 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 26 + targetSdkVersion 27 ndk.abiFilters 'x86', 'armeabi-v7a', 'arm64-v8a' @@ -33,7 +51,7 @@ android { dependencies { implementation project(":Common:JuiHelper") - implementation 'com.google.android.gms:play-services-games:11.6.2' - implementation 'com.google.android.gms:play-services-nearby:11.6.2' - implementation 'com.android.support:support-v4:26.1.0' + 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/CollectAllTheStarsNative/src/main/AndroidManifest.xml b/samples-android/CollectAllTheStarsNative/src/main/AndroidManifest.xml index 448f51a..9a9cd60 100644 --- a/samples-android/CollectAllTheStarsNative/src/main/AndroidManifest.xml +++ b/samples-android/CollectAllTheStarsNative/src/main/AndroidManifest.xml @@ -1,25 +1,32 @@ - + + - - + + android:theme="@style/AppTheme" + tools:ignore="GoogleAppIndexingWarning"> diff --git a/samples-android/CollectAllTheStarsNative/src/main/ant.properties b/samples-android/CollectAllTheStarsNative/src/main/ant.properties deleted file mode 100644 index e542d7f..0000000 --- a/samples-android/CollectAllTheStarsNative/src/main/ant.properties +++ /dev/null @@ -1 +0,0 @@ -source.dir=java diff --git a/samples-android/CollectAllTheStarsNative/src/main/build.sh b/samples-android/CollectAllTheStarsNative/src/main/build.sh deleted file mode 100755 index 9f1fe54..0000000 --- a/samples-android/CollectAllTheStarsNative/src/main/build.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash -set -eua - -declare -r script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -pushd "${script_dir}" -source ../../../build_sample.sh "$@" - diff --git a/samples-android/CollectAllTheStarsNative/src/main/jni/Android.mk b/samples-android/CollectAllTheStarsNative/src/main/jni/Android.mk deleted file mode 100644 index c4e3817..0000000 --- a/samples-android/CollectAllTheStarsNative/src/main/jni/Android.mk +++ /dev/null @@ -1,40 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := CollectAllTheStarsNativeActivity -LOCAL_SRC_FILES := CollectAllTheStarsNativeActivity.cpp \ - CollectAllTheStarsNativeActivity_Engine.cpp \ - TeapotRenderer.cpp \ - ../../../../Common/external/jsoncpp/src/lib_json/json_writer.cpp \ - ../../../../Common/external/jsoncpp/src/lib_json/json_reader.cpp \ - ../../../../Common/external/jsoncpp/src/lib_json/json_value.cpp - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../../Common/external/jsoncpp/include/ -LOCAL_CFLAGS := -LOCAL_CPPFLAGS := -std=c++11 -Wall - -LOCAL_LDLIBS := -llog -landroid -lEGL -lGLESv2 -latomic -lz -LOCAL_STATIC_LIBRARIES := cpufeatures android_native_app_glue ndk_helper jui_helper gpg-1 - -#hard-fp setting -ifneq ($(filter %armeabi-v7a,$(TARGET_ARCH_ABI)),) -#For now, only armeabi-v7a is supported for hard-fp -#adding compiler/liker flags specifying hard float ABI for user code and math library -LOCAL_CFLAGS += -mhard-float -D_NDK_MATH_NO_SOFTFP=1 -LOCAL_LDLIBS += -lm_hard -ifeq (,$(filter -fuse-ld=mcld,$(APP_LDFLAGS) $(LOCAL_LDFLAGS))) -#Supressing warn-mismatch warnings -LOCAL_LDFLAGS += -Wl,--no-warn-mismatch -endif -endif - -include $(BUILD_SHARED_LIBRARY) - -include $(LOCAL_PATH)/../../../../Common/gpg-sdk/gpg-cpp-sdk/android/Android.mk - -$(call import-add-path,$(LOCAL_PATH)/../../../../Common) -$(call import-module,ndk_helper) -$(call import-module,jui_helper) -$(call import-module,android/native_app_glue) -$(call import-module,android/cpufeatures) diff --git a/samples-android/CollectAllTheStarsNative/src/main/jni/Application.mk b/samples-android/CollectAllTheStarsNative/src/main/jni/Application.mk deleted file mode 100644 index 4eea3a5..0000000 --- a/samples-android/CollectAllTheStarsNative/src/main/jni/Application.mk +++ /dev/null @@ -1,7 +0,0 @@ -APP_PLATFORM := android-11 -APP_ABI := armeabi armeabi-v7a x86 - -APP_STL := c++_static - -APP_CPPFLAGS := -std=c++11 -frtti -NDK_TOOLCHAIN_VERSION := clang diff --git a/samples-android/CollectAllTheStarsNative/src/main/jni/CollectAllTheStarsNativeActivity.cpp b/samples-android/CollectAllTheStarsNative/src/main/jni/CollectAllTheStarsNativeActivity.cpp index ba2aecb..5ce85f8 100644 --- a/samples-android/CollectAllTheStarsNative/src/main/jni/CollectAllTheStarsNativeActivity.cpp +++ b/samples-android/CollectAllTheStarsNative/src/main/jni/CollectAllTheStarsNativeActivity.cpp @@ -127,7 +127,7 @@ void Engine::ShowSnapshotSelectUI() { void Engine::SaveSnapshot() { EnableUI(false); std::string fileName; - if (current_snapshot_.Valid() == false) { + if (!current_snapshot_.Valid()) { fileName = GenerateSaveFileName(); LOGI("Creating new snapshot %s", fileName.c_str()); } else { @@ -382,11 +382,11 @@ std::vector Engine::SetupSnapshotData() { auto it = source.begin(); auto end = source.end(); while (it != end) { - uint8_t i = *it++; + uint8_t i = static_cast(*it++); v.push_back(i); } - LOGI("Created Game Data: size: %ld", v.size()); + LOGI("Created Game Data: size: %d", static_cast(v.size())); return v; } diff --git a/samples-android/CollectAllTheStarsNative/src/main/project.properties b/samples-android/CollectAllTheStarsNative/src/main/project.properties deleted file mode 100644 index 69c13e5..0000000 --- a/samples-android/CollectAllTheStarsNative/src/main/project.properties +++ /dev/null @@ -1,15 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system edit -# "ant.properties", and override values to adapt the script to your -# project structure. -# -# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): -#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt - -# Project target. -target=android-19 -android.library.reference.1=${gpg.lib} diff --git a/samples-android/Common/external/jsoncpp/include/json/features.h b/samples-android/Common/external/jsoncpp/include/json/features.h index 5a9adec..5d3ff5a 100644 --- a/samples-android/Common/external/jsoncpp/include/json/features.h +++ b/samples-android/Common/external/jsoncpp/include/json/features.h @@ -1,3 +1,18 @@ +/* + * Copyright 2018 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. + */ #ifndef CPPTL_JSON_FEATURES_H_INCLUDED # define CPPTL_JSON_FEATURES_H_INCLUDED diff --git a/samples-android/Common/external/jsoncpp/src/lib_json/json_batchallocator.h b/samples-android/Common/external/jsoncpp/src/lib_json/json_batchallocator.h index 87ea5ed..362d6cc 100644 --- a/samples-android/Common/external/jsoncpp/src/lib_json/json_batchallocator.h +++ b/samples-android/Common/external/jsoncpp/src/lib_json/json_batchallocator.h @@ -1,3 +1,18 @@ +/* + * Copyright 2018 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. + */ #ifndef JSONCPP_BATCHALLOCATOR_H_INCLUDED # define JSONCPP_BATCHALLOCATOR_H_INCLUDED diff --git a/samples-android/Common/external/jsoncpp/src/lib_json/json_internalarray.inl b/samples-android/Common/external/jsoncpp/src/lib_json/json_internalarray.inl index 9b985d2..345e362 100644 --- a/samples-android/Common/external/jsoncpp/src/lib_json/json_internalarray.inl +++ b/samples-android/Common/external/jsoncpp/src/lib_json/json_internalarray.inl @@ -1,3 +1,18 @@ +/* + * Copyright 2018 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. + */ // included by json_value.cpp // everything is within Json namespace diff --git a/samples-android/Common/external/jsoncpp/src/lib_json/json_internalmap.inl b/samples-android/Common/external/jsoncpp/src/lib_json/json_internalmap.inl index 1977148..3610176 100644 --- a/samples-android/Common/external/jsoncpp/src/lib_json/json_internalmap.inl +++ b/samples-android/Common/external/jsoncpp/src/lib_json/json_internalmap.inl @@ -1,3 +1,18 @@ +/* + * Copyright 2018 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. + */ // included by json_value.cpp // everything is within Json namespace diff --git a/samples-android/Common/external/jsoncpp/src/lib_json/json_reader.cpp b/samples-android/Common/external/jsoncpp/src/lib_json/json_reader.cpp index 94a9816..29e8761 100644 --- a/samples-android/Common/external/jsoncpp/src/lib_json/json_reader.cpp +++ b/samples-android/Common/external/jsoncpp/src/lib_json/json_reader.cpp @@ -1,3 +1,19 @@ +/* + * Copyright 2018 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. + */ + #include #include #include @@ -7,10 +23,6 @@ #include #include -#if _MSC_VER >= 1400 // VC++ 8.0 -#pragma warning( disable : 4996 ) // disable warning about strdup being deprecated. -#endif - namespace Json { // Implementation of class Features @@ -87,8 +99,8 @@ static std::string codePointToUTF8(unsigned int cp) { result.resize(3); result[2] = static_cast(0x80 | (0x3f & cp)); - result[1] = 0x80 | static_cast((0x3f & (cp >> 6))); - result[0] = 0xE0 | static_cast((0xf & (cp >> 12))); + result[1] = static_cast(0x80 | static_cast((0x3f & (cp >> 6)))); + result[0] = static_cast(0xE0 | static_cast((0xf & (cp >> 12)))); } else if (cp <= 0x10FFFF) { @@ -622,7 +634,7 @@ Reader::decodeDouble( Token &token ) double value = 0; const int bufferSize = 32; int count; - int length = int(token.end_ - token.start_); + size_t length = token.end_ - token.start_; if ( length <= bufferSize ) { Char buffer[bufferSize]; @@ -773,7 +785,7 @@ Reader::addError( const std::string &message, bool Reader::recoverFromError( TokenType skipUntilToken ) { - int errorCount = int(errors_.size()); + unsigned long errorCount = errors_.size(); Token skip; while ( true ) { @@ -875,9 +887,7 @@ Reader::getFormatedErrorMessages() const std::istream& operator>>( std::istream &sin, Value &root ) { Json::Reader reader; - bool ok = reader.parse(sin, root, true); - //JSON_ASSERT( ok ); - //if (!ok) throw std::runtime_error(reader.getFormatedErrorMessages()); + reader.parse(sin, root, true); return sin; } diff --git a/samples-android/Common/external/jsoncpp/src/lib_json/json_value.cpp b/samples-android/Common/external/jsoncpp/src/lib_json/json_value.cpp index 84cc78e..a79fea5 100644 --- a/samples-android/Common/external/jsoncpp/src/lib_json/json_value.cpp +++ b/samples-android/Common/external/jsoncpp/src/lib_json/json_value.cpp @@ -1,3 +1,18 @@ +/* + * Copyright 2018 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. + */ #include #include #include diff --git a/samples-android/Common/external/jsoncpp/src/lib_json/json_valueiterator.inl b/samples-android/Common/external/jsoncpp/src/lib_json/json_valueiterator.inl index 736e260..3a1039a 100644 --- a/samples-android/Common/external/jsoncpp/src/lib_json/json_valueiterator.inl +++ b/samples-android/Common/external/jsoncpp/src/lib_json/json_valueiterator.inl @@ -1,3 +1,18 @@ +/* + * Copyright 2018 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. + */ // included by json_value.cpp // everything is within Json namespace diff --git a/samples-android/Common/external/jsoncpp/src/lib_json/json_writer.cpp b/samples-android/Common/external/jsoncpp/src/lib_json/json_writer.cpp index cdf4188..12f85e8 100644 --- a/samples-android/Common/external/jsoncpp/src/lib_json/json_writer.cpp +++ b/samples-android/Common/external/jsoncpp/src/lib_json/json_writer.cpp @@ -1,3 +1,18 @@ +/* + * Copyright 2018 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. + */ #include #include #include diff --git a/samples-android/Common/external/jsoncpp/src/lib_json/sconscript b/samples-android/Common/external/jsoncpp/src/lib_json/sconscript deleted file mode 100644 index f6520d1..0000000 --- a/samples-android/Common/external/jsoncpp/src/lib_json/sconscript +++ /dev/null @@ -1,8 +0,0 @@ -Import( 'env buildLibrary' ) - -buildLibrary( env, Split( """ - json_reader.cpp - json_value.cpp - json_writer.cpp - """ ), - 'json' ) diff --git a/samples-android/Common/gpg-sdk/build.gradle b/samples-android/Common/gpg-sdk/build.gradle index a74fd2e..3010323 100644 --- a/samples-android/Common/gpg-sdk/build.gradle +++ b/samples-android/Common/gpg-sdk/build.gradle @@ -2,7 +2,9 @@ sub module to download the Google Play games */ project.ext { - gpg_sdk_link = 'https://developers.google.com/games/services/downloads/gpg-cpp-sdk.v2.1.zip' + if (!project.hasProperty('gpg_sdk_link')) { + gpg_sdk_link = 'https://developers.google.com/games/services/downloads/gpg-cpp-sdk.v3.0.zip' + } } task download_and_stage_gpg_sdk(dependsOn:'unzip_gpg_sdk') { diff --git a/samples-android/Minimalist/build.gradle b/samples-android/Minimalist/build.gradle index 02029bc..6a0b29d 100644 --- a/samples-android/Minimalist/build.gradle +++ b/samples-android/Minimalist/build.gradle @@ -15,14 +15,17 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 26 + 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 26 + targetSdkVersion 27 ndk.abiFilters 'x86', 'armeabi-v7a', 'arm64-v8a' @@ -41,7 +44,7 @@ android { } dependencies { - implementation 'com.google.android.gms:play-services-games:11.6.2' - implementation 'com.google.android.gms:play-services-nearby:11.6.2' - implementation 'com.android.support:support-v4:26.1.0' + 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/Minimalist/src/main/AndroidManifest.xml b/samples-android/Minimalist/src/main/AndroidManifest.xml index d6f433a..9b05544 100644 --- a/samples-android/Minimalist/src/main/AndroidManifest.xml +++ b/samples-android/Minimalist/src/main/AndroidManifest.xml @@ -1,14 +1,29 @@ + - - + xmlns:tools="http://schemas.android.com/tools" + package="com.google.example.games.Minimalist"> - + diff --git a/samples-android/Minimalist/src/main/ant.properties b/samples-android/Minimalist/src/main/ant.properties deleted file mode 100644 index e542d7f..0000000 --- a/samples-android/Minimalist/src/main/ant.properties +++ /dev/null @@ -1 +0,0 @@ -source.dir=java diff --git a/samples-android/Minimalist/src/main/build.sh b/samples-android/Minimalist/src/main/build.sh deleted file mode 100755 index 9f1fe54..0000000 --- a/samples-android/Minimalist/src/main/build.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash -set -eua - -declare -r script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -pushd "${script_dir}" -source ../../../build_sample.sh "$@" - diff --git a/samples-android/Minimalist/src/main/jni/Android.mk b/samples-android/Minimalist/src/main/jni/Android.mk deleted file mode 100644 index 93090cb..0000000 --- a/samples-android/Minimalist/src/main/jni/Android.mk +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright (C) 2010 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# 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. -# -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := native-activity -LOCAL_SRC_FILES := main.cpp StateManager.cpp -LOCAL_LDLIBS := -llog -landroid -lEGL -lGLESv1_CM -lz -LOCAL_STATIC_LIBRARIES := android_native_app_glue gpg-1 gnustl-static - -include $(BUILD_SHARED_LIBRARY) - -include $(LOCAL_PATH)/../../../../Common/gpg-sdk/gpg-cpp-sdk/android/Android.mk - -$(call import-module,android/native_app_glue) diff --git a/samples-android/Minimalist/src/main/jni/Application.mk b/samples-android/Minimalist/src/main/jni/Application.mk deleted file mode 100644 index 8cb73be..0000000 --- a/samples-android/Minimalist/src/main/jni/Application.mk +++ /dev/null @@ -1,4 +0,0 @@ -APP_STL := gnustl_static -APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=c++11 -Wno-deprecated-declarations -Wno-multichar -Wno-literal-suffix -APP_ABI := armeabi armeabi-v7a x86 -NDK_TOOLCHAIN_VERSION := 4.8 diff --git a/samples-android/Minimalist/src/main/jni/StateManager.cpp b/samples-android/Minimalist/src/main/jni/StateManager.cpp index 6eda8c4..ccd22a2 100644 --- a/samples-android/Minimalist/src/main/jni/StateManager.cpp +++ b/samples-android/Minimalist/src/main/jni/StateManager.cpp @@ -40,7 +40,7 @@ void OnAuthActionStarted(gpg::AuthOperation op) { } } -gpg::GameServices *StateManager::GetGameServices() { +gpg::GameServices* StateManager::GetGameServices() { return game_services_.get(); } @@ -75,14 +75,14 @@ void StateManager::SubmitHighScore(char const *leaderboard_id, uint64_t score) { void StateManager::ShowAchievements() { if (game_services_->IsAuthorized()) { LOGI("Show achievement"); - game_services_->Achievements().ShowAllUI(); + game_services_->Achievements().ShowAllUI([](const gpg::UIStatus status) {}); } } void StateManager::ShowLeaderboard(char const *leaderboard_id) { if (game_services_->IsAuthorized()) { LOGI("Show achievement"); - game_services_->Leaderboards().ShowUI(leaderboard_id); + game_services_->Leaderboards().ShowUI(leaderboard_id, [](const gpg::UIStatus status) {}); } } @@ -113,7 +113,8 @@ void StateManager::InitServices( return; } LOGI("Fetching all blocking"); - gpg::AchievementManager::FetchAllResponse fetchResponse = game_services_->Achievements().FetchAllBlocking(std::chrono::milliseconds(1000)); + gpg::AchievementManager::FetchAllResponse fetchResponse = + game_services_->Achievements().FetchAllBlocking(std::chrono::milliseconds(1000)); LOGI("--------------------------------------------------------------"); LOGI("Fetching all nonblocking"); diff --git a/samples-android/Minimalist/src/main/jni/StateManager.h b/samples-android/Minimalist/src/main/jni/StateManager.h index d9586c6..0456e5f 100644 --- a/samples-android/Minimalist/src/main/jni/StateManager.h +++ b/samples-android/Minimalist/src/main/jni/StateManager.h @@ -1,3 +1,17 @@ +// Copyright (c) 2014 Google Inc. +// +// 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 TEAPOT_JNI_STATE_MANAGER_H #define TEAPOT_JNI_STATE_MANAGER_H @@ -21,7 +35,7 @@ class StateManager { gpg::GameServices::Builder::OnAuthActionStartedCallback started_callback, gpg::GameServices::Builder::OnAuthActionFinishedCallback finished_callback); - static gpg::GameServices *GetGameServices(); + static gpg::GameServices* GetGameServices(); static void BeginUserInitiatedSignIn(); static void SignOut(); static void UnlockAchievement(const char *achievementId); diff --git a/samples-android/Minimalist/src/main/jni/main.cpp b/samples-android/Minimalist/src/main/jni/main.cpp index 198f82a..047d2da 100644 --- a/samples-android/Minimalist/src/main/jni/main.cpp +++ b/samples-android/Minimalist/src/main/jni/main.cpp @@ -93,7 +93,7 @@ static int engine_init_display(struct engine* engine) { const EGLint attribs[] = {EGL_SURFACE_TYPE, EGL_WINDOW_BIT, EGL_BLUE_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_RED_SIZE, 8, EGL_NONE}; - EGLint w, h, dummy; + EGLint w, h; EGLint numConfigs; EGLConfig config; EGLSurface surface; @@ -180,7 +180,7 @@ static int32_t engine_handle_input(struct android_app* app, AInputEvent* event) { struct engine* engine = (struct engine*)app->userData; if (AInputEvent_getType(event) == AINPUT_EVENT_TYPE_MOTION) { - unsigned int flags = + int32_t flags = AMotionEvent_getAction(event) & AMOTION_EVENT_ACTION_MASK; // gpg-cpp: Sign in or out on tap @@ -199,8 +199,8 @@ static int32_t engine_handle_input(struct android_app* app, // Make things pretty engine->animating = 1; - engine->state.x = AMotionEvent_getX(event, 0); - engine->state.y = AMotionEvent_getY(event, 0); + engine->state.x = static_cast(AMotionEvent_getX(event, 0)); + engine->state.y = static_cast(AMotionEvent_getY(event, 0)); return 1; } @@ -253,6 +253,8 @@ static void engine_handle_cmd(struct android_app* app, int32_t cmd) { engine->animating = 0; engine_draw_frame(engine); break; + default: + LOGI("Ignoring %d", cmd); } } @@ -277,7 +279,7 @@ void android_main(struct android_app* state) { engine.sensorEventQueue = ASensorManager_createEventQueue( engine.sensorManager, state->looper, LOOPER_ID_USER, NULL, NULL); - // gpg-cpp: Set platform intiialization + // gpg-cpp: Set platform initialization gpg::AndroidInitialization::android_main(state); // gpg-cpp: Here we create the callback on auth operations diff --git a/samples-android/Minimalist/src/main/project.properties b/samples-android/Minimalist/src/main/project.properties deleted file mode 100644 index 69c13e5..0000000 --- a/samples-android/Minimalist/src/main/project.properties +++ /dev/null @@ -1,15 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system edit -# "ant.properties", and override values to adapt the script to your -# project structure. -# -# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): -#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt - -# Project target. -target=android-19 -android.library.reference.1=${gpg.lib} diff --git a/samples-android/Minimalist/src/main/res/drawable-hdpi/ic_launcher.png b/samples-android/Minimalist/src/main/res/drawable-hdpi/ic_launcher.png new file mode 100644 index 0000000..ea01cbf Binary files /dev/null and b/samples-android/Minimalist/src/main/res/drawable-hdpi/ic_launcher.png differ diff --git a/samples-android/Minimalist/src/main/res/drawable-ldpi/ic_launcher.png b/samples-android/Minimalist/src/main/res/drawable-ldpi/ic_launcher.png new file mode 100644 index 0000000..a3d6a18 Binary files /dev/null and b/samples-android/Minimalist/src/main/res/drawable-ldpi/ic_launcher.png differ diff --git a/samples-android/Minimalist/src/main/res/drawable-mdpi/ic_launcher.png b/samples-android/Minimalist/src/main/res/drawable-mdpi/ic_launcher.png new file mode 100644 index 0000000..8f80897 Binary files /dev/null and b/samples-android/Minimalist/src/main/res/drawable-mdpi/ic_launcher.png differ diff --git a/samples-android/Minimalist/src/main/res/drawable-xhdpi/ic_launcher.png b/samples-android/Minimalist/src/main/res/drawable-xhdpi/ic_launcher.png new file mode 100644 index 0000000..b779a2b Binary files /dev/null and b/samples-android/Minimalist/src/main/res/drawable-xhdpi/ic_launcher.png differ diff --git a/samples-android/TbmpSkeletonNative/build.gradle b/samples-android/TbmpSkeletonNative/build.gradle index c8823a8..0d46d7a 100644 --- a/samples-android/TbmpSkeletonNative/build.gradle +++ b/samples-android/TbmpSkeletonNative/build.gradle @@ -15,14 +15,17 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 26 + 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 26 + targetSdkVersion 27 ndk.abiFilters 'x86', 'armeabi-v7a', 'arm64-v8a' @@ -47,7 +50,7 @@ android { dependencies { implementation project(":Common:JuiHelper") - implementation 'com.google.android.gms:play-services-games:11.6.2' - implementation 'com.google.android.gms:play-services-nearby:11.6.2' - implementation 'com.android.support:support-v4:26.1.0' + 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/src/main/AndroidManifest.xml b/samples-android/TbmpSkeletonNative/src/main/AndroidManifest.xml index 54630a6..59bd37d 100644 --- a/samples-android/TbmpSkeletonNative/src/main/AndroidManifest.xml +++ b/samples-android/TbmpSkeletonNative/src/main/AndroidManifest.xml @@ -1,25 +1,34 @@ + + + xmlns:tools="http://schemas.android.com/tools" + package="com.google.example.games.tbmpskel"> - - - - - - - + + android:theme="@style/AppTheme" + tools:ignore="GoogleAppIndexingWarning"> + diff --git a/samples-android/TbmpSkeletonNative/src/main/ant.properties b/samples-android/TbmpSkeletonNative/src/main/ant.properties deleted file mode 100644 index e542d7f..0000000 --- a/samples-android/TbmpSkeletonNative/src/main/ant.properties +++ /dev/null @@ -1 +0,0 @@ -source.dir=java diff --git a/samples-android/TbmpSkeletonNative/src/main/build.sh b/samples-android/TbmpSkeletonNative/src/main/build.sh deleted file mode 100755 index 9f1fe54..0000000 --- a/samples-android/TbmpSkeletonNative/src/main/build.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash -set -eua - -declare -r script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -pushd "${script_dir}" -source ../../../build_sample.sh "$@" - diff --git a/samples-android/TbmpSkeletonNative/src/main/jni/Android.mk b/samples-android/TbmpSkeletonNative/src/main/jni/Android.mk deleted file mode 100644 index 42abd83..0000000 --- a/samples-android/TbmpSkeletonNative/src/main/jni/Android.mk +++ /dev/null @@ -1,40 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := TBMPSkeletonNativeActivity -LOCAL_SRC_FILES := TBMPSkeletonNativeActivity.cpp \ - TBMPSkeletonNativeActivity_Engine.cpp \ - TeapotRenderer.cpp \ - ../../../../Common/external/jsoncpp/src/lib_json/json_writer.cpp \ - ../../../../Common/external/jsoncpp/src/lib_json/json_reader.cpp \ - ../../../../Common/external/jsoncpp/src/lib_json/json_value.cpp - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../../Common/external/jsoncpp/include/ -LOCAL_CFLAGS := -LOCAL_CPPFLAGS := -std=c++11 - -LOCAL_LDLIBS := -llog -landroid -lEGL -lGLESv2 -latomic -lz -LOCAL_STATIC_LIBRARIES := cpufeatures android_native_app_glue ndk_helper jui_helper gpg-1 - -#hard-fp setting -ifneq ($(filter %armeabi-v7a,$(TARGET_ARCH_ABI)),) -#For now, only armeabi-v7a is supported for hard-fp -#adding compiler/liker flags specifying hard float ABI for user code and math library -LOCAL_CFLAGS += -mhard-float -D_NDK_MATH_NO_SOFTFP=1 -LOCAL_LDLIBS += -lm_hard -ifeq (,$(filter -fuse-ld=mcld,$(APP_LDFLAGS) $(LOCAL_LDFLAGS))) -#Supressing warn-mismatch warnings -LOCAL_LDFLAGS += -Wl,--no-warn-mismatch -endif -endif - -include $(BUILD_SHARED_LIBRARY) - -include $(LOCAL_PATH)/../../../../Common/gpg-sdk/gpg-cpp-sdk/android/Android.mk - -$(call import-add-path,$(LOCAL_PATH)/../../../../Common) -$(call import-module,ndk_helper) -$(call import-module,jui_helper) -$(call import-module,android/native_app_glue) -$(call import-module,android/cpufeatures) diff --git a/samples-android/TbmpSkeletonNative/src/main/jni/Application.mk b/samples-android/TbmpSkeletonNative/src/main/jni/Application.mk deleted file mode 100644 index 4eea3a5..0000000 --- a/samples-android/TbmpSkeletonNative/src/main/jni/Application.mk +++ /dev/null @@ -1,7 +0,0 @@ -APP_PLATFORM := android-11 -APP_ABI := armeabi armeabi-v7a x86 - -APP_STL := c++_static - -APP_CPPFLAGS := -std=c++11 -frtti -NDK_TOOLCHAIN_VERSION := clang diff --git a/samples-android/TbmpSkeletonNative/src/main/jni/TBMPSkeletonNativeActivity.cpp b/samples-android/TbmpSkeletonNative/src/main/jni/TBMPSkeletonNativeActivity.cpp index 9568d61..481ce82 100644 --- a/samples-android/TbmpSkeletonNative/src/main/jni/TBMPSkeletonNativeActivity.cpp +++ b/samples-android/TbmpSkeletonNative/src/main/jni/TBMPSkeletonNativeActivity.cpp @@ -236,12 +236,12 @@ void Engine::LeaveMatch() { //Leave a game manager.LeaveMatchDuringMyTurn(current_match_, current_match_.SuggestedNextParticipant(), - [this](gpg::MultiplayerStatus status) { + [](gpg::MultiplayerStatus status) { LOGI("Left the game"); }); } else { manager.LeaveMatchDuringTheirTurn(current_match_, - [this](gpg::MultiplayerStatus status) { + [](gpg::MultiplayerStatus status) { LOGI("Left the game"); }); } @@ -273,7 +273,7 @@ void Engine::TakeTurn(const bool winning, const bool losing) { turn_counter_++; std::vector match_data = SetupMatchData(); - //By default, passing through existing participatntResults + //By default, passing through existing ParticipantResults gpg::ParticipantResults results = current_match_.ParticipantResults(); if (winning) { @@ -295,7 +295,7 @@ void Engine::TakeTurn(const bool winning, const bool losing) { //Take normal turn manager.TakeMyTurn( current_match_, match_data, results, nextParticipant, - [this](gpg::TurnBasedMultiplayerManager::TurnBasedMatchResponse const & + [](gpg::TurnBasedMultiplayerManager::TurnBasedMatchResponse const & response) { LOGI("Took turn"); }); @@ -335,15 +335,13 @@ void Engine::PlayGame(gpg::TurnBasedMatch const &match) { jui_helper::JUIButton *button = new jui_helper::JUIButton("Take Turn"); button->SetCallback( [this](jui_helper::JUIView * view, const int32_t message) { - switch (message) { - case jui_helper::JUICALLBACK_BUTTON_UP: { + 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); @@ -352,12 +350,10 @@ void Engine::PlayGame(gpg::TurnBasedMatch const &match) { jui_helper::JUIButton *buttonCancel = new jui_helper::JUIButton("Cancel"); buttonCancel->SetCallback( [this](jui_helper::JUIView * view, const int32_t message) { - switch (message) { - case jui_helper::JUICALLBACK_BUTTON_UP: { - CancelMatch(); - dialog_->Close(); - } - } + if (message == jui_helper::JUICALLBACK_BUTTON_UP) { + CancelMatch(); + dialog_->Close(); + } }); buttonCancel->AddRule(jui_helper::LAYOUT_PARAMETER_CENTER_IN_PARENT, jui_helper::LAYOUT_PARAMETER_TRUE); @@ -377,7 +373,7 @@ void Engine::PlayGame(gpg::TurnBasedMatch const &match) { dialog_->Close(); }); - int32_t size = 64; + size_t size = 64; char str[size]; snprintf(str, size, "Turn %d", turn_counter_); dialog_->SetAttribute("Title", (const char *)str); @@ -408,12 +404,10 @@ void Engine::ManageGame(gpg::TurnBasedMatch const &match, const bool leave, jui_helper::JUIButton *button = new jui_helper::JUIButton("Dismiss"); button->SetCallback( [this](jui_helper::JUIView * view, const int32_t message) { - switch (message) { - case jui_helper::JUICALLBACK_BUTTON_UP: { - DismissMatch(); + if (message == jui_helper::JUICALLBACK_BUTTON_UP) { + DismissMatch(); dialog_->Close(); } - } }); button->AddRule(jui_helper::LAYOUT_PARAMETER_ALIGN_PARENT_TOP, jui_helper::LAYOUT_PARAMETER_TRUE); @@ -428,12 +422,10 @@ void Engine::ManageGame(gpg::TurnBasedMatch const &match, const bool leave, jui_helper::JUIButton *leaveButton = new jui_helper::JUIButton("Leave"); leaveButton->SetCallback( [this](jui_helper::JUIView * view, const int32_t message) { - switch (message) { - case jui_helper::JUICALLBACK_BUTTON_UP: { - LeaveMatch(); + if (message == jui_helper::JUICALLBACK_BUTTON_UP) { + LeaveMatch(); dialog_->Close(); } - } }); leaveButton->AddRule(jui_helper::LAYOUT_PARAMETER_CENTER_IN_PARENT, jui_helper::LAYOUT_PARAMETER_TRUE); @@ -448,12 +440,10 @@ void Engine::ManageGame(gpg::TurnBasedMatch const &match, const bool leave, jui_helper::JUIButton *cancelButton = new jui_helper::JUIButton("Cancel"); cancelButton->SetCallback( [this](jui_helper::JUIView * view, const int32_t message) { - switch (message) { - case jui_helper::JUICALLBACK_BUTTON_UP: { - CancelMatch(); + if (message == jui_helper::JUICALLBACK_BUTTON_UP) { + CancelMatch(); dialog_->Close(); } - } }); cancelButton->AddRule(jui_helper::LAYOUT_PARAMETER_CENTER_IN_PARENT, jui_helper::LAYOUT_PARAMETER_TRUE); @@ -468,18 +458,15 @@ void Engine::ManageGame(gpg::TurnBasedMatch const &match, const bool leave, jui_helper::JUIButton *rematchButton = new jui_helper::JUIButton("Rematch"); rematchButton->SetCallback( [this](jui_helper::JUIView * view, const int32_t message) { - switch (message) { - case jui_helper::JUICALLBACK_BUTTON_UP: { + 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); - currentButton = rematchButton; } dialog_->SetCallback( @@ -495,7 +482,7 @@ void Engine::ManageGame(gpg::TurnBasedMatch const &match, const bool leave, dialog_->Close(); }); - int32_t size = 64; + size_t size = 64; char str[size]; snprintf(str, size, "Turn %d", turn_counter_); dialog_->SetAttribute("Title", (const char *)str); @@ -508,7 +495,7 @@ void Engine::ManageGame(gpg::TurnBasedMatch const &match, const bool leave, * Parse JSON match data */ void Engine::ParseMatchData() { - LOGI("Parsing match data %ld", current_match_.Data().size()); + 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"); @@ -569,7 +556,7 @@ std::vector Engine::SetupMatchData() { v.push_back((unsigned char) i >> 8); } - LOGI("Created Game Data: size: %ld", v.size()); + LOGI("Created Game Data: size: %d", static_cast(v.size())); return v; } diff --git a/samples-android/TbmpSkeletonNative/src/main/jni/TBMPSkeletonNativeActivity.h b/samples-android/TbmpSkeletonNative/src/main/jni/TBMPSkeletonNativeActivity.h index 614bdde..6c10779 100644 --- a/samples-android/TbmpSkeletonNative/src/main/jni/TBMPSkeletonNativeActivity.h +++ b/samples-android/TbmpSkeletonNative/src/main/jni/TBMPSkeletonNativeActivity.h @@ -142,7 +142,7 @@ class Engine { // JUI text view to show FPS jui_helper::JUITextView *textViewFPS_; - // Native acitivity app instance + // Native activity app instance android_app *app_; // JUI dialog diff --git a/samples-android/TbmpSkeletonNative/src/main/jni/TBMPSkeletonNativeActivity_Engine.cpp b/samples-android/TbmpSkeletonNative/src/main/jni/TBMPSkeletonNativeActivity_Engine.cpp index f199a53..0ca9a3a 100644 --- a/samples-android/TbmpSkeletonNative/src/main/jni/TBMPSkeletonNativeActivity_Engine.cpp +++ b/samples-android/TbmpSkeletonNative/src/main/jni/TBMPSkeletonNativeActivity_Engine.cpp @@ -23,9 +23,9 @@ * Ctor */ Engine::Engine() - : initialized_resources_(false), has_focus_(false), authorizing_(false), - app_(nullptr), dialog_(nullptr), textViewFPS_(nullptr), - button_sign_in_(nullptr), status_text_(nullptr), button_invite_(nullptr) { + : 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(); } diff --git a/samples-android/TbmpSkeletonNative/src/main/project.properties b/samples-android/TbmpSkeletonNative/src/main/project.properties deleted file mode 100644 index 69c13e5..0000000 --- a/samples-android/TbmpSkeletonNative/src/main/project.properties +++ /dev/null @@ -1,15 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system edit -# "ant.properties", and override values to adapt the script to your -# project structure. -# -# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): -#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt - -# Project target. -target=android-19 -android.library.reference.1=${gpg.lib} diff --git a/samples-android/TbmpSkeletonNative/src/main/res/values-v11/styles.xml b/samples-android/TbmpSkeletonNative/src/main/res/values-v11/styles.xml deleted file mode 100644 index 541752f..0000000 --- a/samples-android/TbmpSkeletonNative/src/main/res/values-v11/styles.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/samples-android/TbmpSkeletonNative/src/main/res/values-v14/styles.xml b/samples-android/TbmpSkeletonNative/src/main/res/values-v14/styles.xml deleted file mode 100644 index f20e015..0000000 --- a/samples-android/TbmpSkeletonNative/src/main/res/values-v14/styles.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/samples-android/Teapot/build.gradle b/samples-android/Teapot/build.gradle index 00f85b3..94a930b 100644 --- a/samples-android/Teapot/build.gradle +++ b/samples-android/Teapot/build.gradle @@ -1,14 +1,31 @@ +/* + * Copyright 2018 (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 26 + 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 26 + targetSdkVersion 27 ndk.abiFilters 'x86', 'armeabi-v7a', 'arm64-v8a' @@ -32,7 +49,7 @@ apply plugin: 'com.android.application' } dependencies { implementation project(":Common:JuiHelper") - implementation 'com.google.android.gms:play-services-games:11.6.2' - implementation 'com.google.android.gms:play-services-nearby:11.6.2' - implementation 'com.android.support:support-v4:26.1.0' + 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/Teapot/src/main/AndroidManifest.xml b/samples-android/Teapot/src/main/AndroidManifest.xml index 09ee62b..820cebc 100644 --- a/samples-android/Teapot/src/main/AndroidManifest.xml +++ b/samples-android/Teapot/src/main/AndroidManifest.xml @@ -16,19 +16,20 @@ // --> + xmlns:tools="http://schemas.android.com/tools" + package="com.google.example.nativegame"> + tools:ignore="GoogleAppIndexingWarning"> + = 14 && SDK_INT < 19) + else if(SDK_INT >= 16 && SDK_INT < 19) { getWindow().getDecorView().setSystemUiVisibility( View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_LOW_PROFILE); @@ -92,58 +92,6 @@ void setImmersiveSticky() { PopupWindow _popupWindow; TextView _label; - public void showUI() - { - if( _popupWindow != null ) - return; - - _activity = this; - - this.runOnUiThread(new Runnable() { - @Override - public void run() { - LayoutInflater layoutInflater - = (LayoutInflater)getBaseContext() - .getSystemService(LAYOUT_INFLATER_SERVICE); - if (layoutInflater != null) { - View popupView = layoutInflater.inflate(R.layout.widgets, null); - _popupWindow = new PopupWindow( - popupView, - LayoutParams.WRAP_CONTENT, - LayoutParams.WRAP_CONTENT); - - LinearLayout mainLayout = new LinearLayout(_activity); - MarginLayoutParams params = new MarginLayoutParams(LayoutParams.WRAP_CONTENT, - LayoutParams.WRAP_CONTENT); - params.setMargins(0, 0, 0, 0); - _activity.setContentView(mainLayout, params); - - // Show our UI over NativeActivity window - _popupWindow.showAtLocation(mainLayout, Gravity.TOP | Gravity.START, 10, 10); - _popupWindow.update(); - - _label = popupView.findViewById(R.id.textViewFPS); - } else { - throw new IllegalStateException("Cannot get layout service!"); - } - - }}); - } - - public void updateFPS(final float fFPS) - { - if( _label == null ) - return; - - _activity = this; - this.runOnUiThread(new Runnable() { - @Override - public void run() { - _label.setText(String.format(Locale.getDefault(),"%2.2f FPS", fFPS)); - - }}); - } - protected void onPause() { super.onPause(); if (_popupWindow != null) { @@ -165,7 +113,7 @@ protected void onPause() { /* - * This is needed to foward the onActivityResult call to the games SDK. + * This is needed to forward the onActivityResult call to the games SDK. * The SDK uses this to manage the display of the standard UI calls. */ protected void onActivityResult(int requestCode, int resultCode, Intent data) { diff --git a/samples-android/Teapot/src/main/jni/NativeGameActivity.cpp b/samples-android/Teapot/src/main/jni/NativeGameActivity.cpp index e831401..e340d65 100644 --- a/samples-android/Teapot/src/main/jni/NativeGameActivity.cpp +++ b/samples-android/Teapot/src/main/jni/NativeGameActivity.cpp @@ -99,8 +99,8 @@ class Engine { Engine g_engine; Engine::Engine() - : initialized_resources_(false), has_focus_(false), app_(nullptr), - button_sign_in_(nullptr), status_text_(nullptr) { + : initialized_resources_(false), has_focus_(false), + button_sign_in_(nullptr), status_text_(nullptr), app_(nullptr) { gl_context_ = ndk_helper::GLContext::GetInstance(); } @@ -132,7 +132,7 @@ void Engine::InitUI() { 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) { + [](jui_helper::JUIView *view, const int32_t message) { LOGI("button_sign_in_ click: %d", message); if (message == jui_helper::JUICALLBACK_BUTTON_UP) { if (StateManager::GetGameServices()->IsAuthorized()) { @@ -152,7 +152,7 @@ void Engine::InitUI() { button_achievement->AddRule(jui_helper::LAYOUT_PARAMETER_CENTER_IN_PARENT, jui_helper::LAYOUT_PARAMETER_TRUE); button_achievement->SetCallback( - [this](jui_helper::JUIView *view, const int32_t message) { + [](jui_helper::JUIView *view, const int32_t message) { LOGI("Button click: %d", message); if (message == jui_helper::JUICALLBACK_BUTTON_UP) { std::string id = ndk_helper::JNIHelper::GetInstance()->GetStringResource("achievement_prime"); @@ -174,7 +174,7 @@ void Engine::InitUI() { jui_helper::LAYOUT_PARAMETER_CENTER_IN_PARENT, jui_helper::LAYOUT_PARAMETER_TRUE); button_show_achievements_ui->SetCallback( - [this](jui_helper::JUIView *view, const int32_t message) { + [](jui_helper::JUIView *view, const int32_t message) { LOGI("Button click: %d", message); if (message == jui_helper::JUICALLBACK_BUTTON_UP) { StateManager::ShowAchievements(); @@ -235,7 +235,7 @@ void Engine::InitUI() { jui_helper::LAYOUT_PARAMETER_CENTER_IN_PARENT, jui_helper::LAYOUT_PARAMETER_TRUE); button_show_leaderboard_ui->SetCallback( - [this](jui_helper::JUIView *view, const int32_t message) { + [](jui_helper::JUIView *view, const int32_t message) { LOGI("Button click: %d", message); if (message == jui_helper::JUICALLBACK_BUTTON_UP) { std::string id = ndk_helper::JNIHelper::GetInstance()->GetStringResource("leaderboard_easy"); diff --git a/samples-android/Teapot/src/main/jni/StateManager.cpp b/samples-android/Teapot/src/main/jni/StateManager.cpp index 298dea9..53de4de 100644 --- a/samples-android/Teapot/src/main/jni/StateManager.cpp +++ b/samples-android/Teapot/src/main/jni/StateManager.cpp @@ -39,7 +39,7 @@ void OnAuthActionStarted(gpg::AuthOperation op) { } } -gpg::GameServices *StateManager::GetGameServices() { +gpg::GameServices* StateManager::GetGameServices() { return game_services_.get(); } @@ -74,14 +74,14 @@ void StateManager::SubmitHighScore(char const *leaderboard_id, uint64_t score) { void StateManager::ShowAchievements() { if (game_services_->IsAuthorized()) { LOGI("Show achievement"); - game_services_->Achievements().ShowAllUI(); + game_services_->Achievements().ShowAllUI([](gpg::UIStatus status){}); } } void StateManager::ShowLeaderboard(char const *leaderboard_id) { if (game_services_->IsAuthorized()) { LOGI("Show achievement"); - game_services_->Leaderboards().ShowUI(leaderboard_id); + game_services_->Leaderboards().ShowUI(leaderboard_id,[](gpg::UIStatus status){}); } } diff --git a/samples-android/Teapot/src/main/res/layout/widgets.xml b/samples-android/Teapot/src/main/res/layout/widgets.xml index 73fb171..154ff41 100644 --- a/samples-android/Teapot/src/main/res/layout/widgets.xml +++ b/samples-android/Teapot/src/main/res/layout/widgets.xml @@ -25,8 +25,8 @@ android:id="@+id/textViewFPS" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:gravity="right" - android:text="0.0 FPS" + android:gravity="end" + android:text="@string/fps" android:textAppearance="?android:attr/textAppearanceMedium" android:textColor="@android:color/white" /> diff --git a/samples-android/Teapot/src/main/res/values-v11/styles.xml b/samples-android/Teapot/src/main/res/values-v11/styles.xml deleted file mode 100644 index 7fdff7e..0000000 --- a/samples-android/Teapot/src/main/res/values-v11/styles.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/samples-android/Teapot/src/main/res/values-v14/styles.xml b/samples-android/Teapot/src/main/res/values-v14/styles.xml deleted file mode 100644 index c9ca3a0..0000000 --- a/samples-android/Teapot/src/main/res/values-v14/styles.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/samples-android/Teapot/src/main/res/values/strings.xml b/samples-android/Teapot/src/main/res/values/strings.xml index 363fff3..3cfd6d0 100644 --- a/samples-android/Teapot/src/main/res/values/strings.xml +++ b/samples-android/Teapot/src/main/res/values/strings.xml @@ -17,4 +17,5 @@ --> TeapotNativeGame + 0.0 FPS \ No newline at end of file