Skip to content

Commit

Permalink
De-linting native samples.
Browse files Browse the repository at this point in the history
Change-Id: Ic63db565bb4b5f42a0038d331c4bb52d8888ec69
  • Loading branch information
claywilkinson committed Jan 5, 2018
1 parent 2299766 commit ad4599d
Show file tree
Hide file tree
Showing 61 changed files with 371 additions and 543 deletions.
14 changes: 8 additions & 6 deletions samples-android/ButtonClicker/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -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'
}
33 changes: 20 additions & 13 deletions samples-android/ButtonClicker/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,25 +1,32 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.google.example.games.ButtonClicker"
android:versionCode="1"
android:versionName="1.0" >
<!--
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
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="22" />
http://www.apache.org/licenses/LICENSE-2.0
<uses-feature android:glEsVersion="0x00020000" >
</uses-feature>
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.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.google.example.games.ButtonClicker">

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" >
</uses-permission>
<uses-feature android:glEsVersion="0x00020000"/>

<application
android:name="com.google.example.games.ButtonClicker.ButtonClickerApplication"
android:allowBackup="true"
android:allowBackup="false"
android:hasCode="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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();
Expand Down Expand Up @@ -449,7 +449,7 @@ void Engine::UpdateScore() {
// gpg callback tread and UI callback thread
std::lock_guard<std::mutex> lock(mutex_);

int32_t SIZE = 64;
size_t SIZE = 64;
char str[SIZE];
snprintf(str, SIZE, "%03d", score_counter_);
std::string str_myscore(str);
Expand All @@ -461,7 +461,7 @@ void Engine::UpdateScore() {
// Append other player
std::vector<gpg::MultiplayerParticipant> 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(),
Expand All @@ -487,18 +487,16 @@ 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<const char *>(str_myscore.c_str()));
scores_text_->SetAttribute("Text",
const_cast<const char *>(allstr.c_str()));
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 asynchrnously
// UpdateTime() is invoked from other thread asynchronously
// So need to Lock mutex
std::lock_guard<std::mutex> lock(mutex_);

Expand All @@ -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<const char *>(str));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
/*
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down Expand Up @@ -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);

Expand Down
8 changes: 0 additions & 8 deletions samples-android/ButtonClicker/src/main/res/layout/widgets.xml

This file was deleted.

11 changes: 0 additions & 11 deletions samples-android/ButtonClicker/src/main/res/values-v11/styles.xml

This file was deleted.

12 changes: 0 additions & 12 deletions samples-android/ButtonClicker/src/main/res/values-v14/styles.xml

This file was deleted.

28 changes: 23 additions & 5 deletions samples-android/CollectAllTheStarsNative/build.gradle
Original file line number Diff line number Diff line change
@@ -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'

Expand All @@ -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'
}
Original file line number Diff line number Diff line change
@@ -1,25 +1,32 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.google.example.games.cats"
android:versionCode="1"
android:versionName="1.0" >
<!--
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
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="19" />
http://www.apache.org/licenses/LICENSE-2.0
<uses-feature android:glEsVersion="0x00020000" >
</uses-feature>
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.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.google.example.games.cats">

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" >
</uses-permission>
<uses-feature android:glEsVersion="0x00020000"/>

<application
android:name="com.google.example.games.cats.CollectAllTheStarsApplication"
android:allowBackup="true"
android:allowBackup="false"
android:hasCode="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
Expand Down

This file was deleted.

7 changes: 0 additions & 7 deletions samples-android/CollectAllTheStarsNative/src/main/build.sh

This file was deleted.

40 changes: 0 additions & 40 deletions samples-android/CollectAllTheStarsNative/src/main/jni/Android.mk

This file was deleted.

Loading

0 comments on commit ad4599d

Please sign in to comment.