Skip to content

Commit ad4599d

Browse files
committed
De-linting native samples.
Change-Id: Ic63db565bb4b5f42a0038d331c4bb52d8888ec69
1 parent 2299766 commit ad4599d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+371
-543
lines changed

samples-android/ButtonClicker/build.gradle

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,17 @@
1616
apply plugin : 'com.android.application'
1717

1818
android {
19-
compileSdkVersion 26
19+
compileSdkVersion 27
2020
defaultConfig {
2121
//
2222
// REPLACE THE APPLICATION ID with your bundle ID
2323
//
2424
applicationId "com.google.example.games.ReplaceMe"
25-
minSdkVersion 14
26-
targetSdkVersion 26
25+
versionCode 1
26+
versionName "1.0"
2727

28+
minSdkVersion 14
29+
targetSdkVersion 27
2830

2931
ndk.abiFilters 'x86', 'armeabi-v7a', 'arm64-v8a'
3032

@@ -47,7 +49,7 @@ android {
4749

4850
dependencies {
4951
implementation project(":Common:JuiHelper")
50-
implementation 'com.google.android.gms:play-services-games:11.6.2'
51-
implementation 'com.google.android.gms:play-services-nearby:11.6.2'
52-
implementation 'com.android.support:support-v4:26.1.0'
52+
implementation 'com.google.android.gms:play-services-games:11.8.0'
53+
implementation 'com.google.android.gms:play-services-nearby:11.8.0'
54+
implementation 'com.android.support:support-v4:27.0.2'
5355
}

samples-android/ButtonClicker/src/main/AndroidManifest.xml

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,32 @@
1-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2-
package="com.google.example.games.ButtonClicker"
3-
android:versionCode="1"
4-
android:versionName="1.0" >
1+
<!--
2+
Copyright 2018 Google LLC
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
57
6-
<uses-sdk
7-
android:minSdkVersion="11"
8-
android:targetSdkVersion="22" />
8+
http://www.apache.org/licenses/LICENSE-2.0
99
10-
<uses-feature android:glEsVersion="0x00020000" >
11-
</uses-feature>
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
17+
xmlns:tools="http://schemas.android.com/tools"
18+
package="com.google.example.games.ButtonClicker">
1219

13-
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" >
14-
</uses-permission>
20+
<uses-feature android:glEsVersion="0x00020000"/>
1521

1622
<application
1723
android:name="com.google.example.games.ButtonClicker.ButtonClickerApplication"
18-
android:allowBackup="true"
24+
android:allowBackup="false"
1925
android:hasCode="true"
2026
android:icon="@drawable/ic_launcher"
2127
android:label="@string/app_name"
22-
android:theme="@style/AppTheme" >
28+
android:theme="@style/AppTheme"
29+
tools:ignore="GoogleAppIndexingWarning">
2330
<meta-data
2431
android:name="com.google.android.gms.version"
2532
android:value="@integer/google_play_services_version" />

samples-android/ButtonClicker/src/main/jni/ButtonClickerNativeActivity.cpp

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ void Engine::InitGooglePlayGameServices() {
6868
LOGI("MultiplayerInvitationEvent callback");
6969

7070
if (event ==
71-
gpg::TurnBasedMultiplayerEvent::UPDATED_FROM_APP_LAUNCH) {
71+
gpg::MultiplayerEvent::UPDATED_FROM_APP_LAUNCH) {
7272

7373
// In this case, an invitation has been accepted already
7474
// in notification or in Play game app
@@ -282,7 +282,7 @@ void Engine::BroadcastScore(bool bFinal) {
282282
* Got message from peers
283283
* room : The room which from_participant is in.
284284
* from_participant : The participant who sent the data.
285-
* data : The data which was recieved.
285+
* data : The data which was received.
286286
* is_reliable : Whether the data was sent using the unreliable or
287287
* reliable mechanism.
288288
* In this app, packet format is defined as:
@@ -296,13 +296,13 @@ void Engine::OnDataReceived(gpg::RealTimeRoom const &room,
296296
// Got final score
297297
players_score_[from_participant.Id()].score = data[1];
298298
players_score_[from_participant.Id()].finished = true;
299-
LOGI("Got final data from Dispname:%s ID:%s",
299+
LOGI("Got final data from name:%s ID:%s",
300300
from_participant.DisplayName().c_str(), from_participant.Id().c_str());
301301
} else if (data[0] == 'U' && !is_reliable) {
302302
// Got current score
303303
uint8_t score = players_score_[from_participant.Id()].score;
304304
players_score_[from_participant.Id()].score = std::max(score, data[1]);
305-
LOGI("Got data from Dispname:%s ID:%s",
305+
LOGI("Got data from name:%s ID:%s",
306306
from_participant.DisplayName().c_str(), from_participant.Id().c_str());
307307
}
308308
UpdateScore();
@@ -449,7 +449,7 @@ void Engine::UpdateScore() {
449449
// gpg callback tread and UI callback thread
450450
std::lock_guard<std::mutex> lock(mutex_);
451451

452-
int32_t SIZE = 64;
452+
size_t SIZE = 64;
453453
char str[SIZE];
454454
snprintf(str, SIZE, "%03d", score_counter_);
455455
std::string str_myscore(str);
@@ -461,7 +461,7 @@ void Engine::UpdateScore() {
461461
// Append other player
462462
std::vector<gpg::MultiplayerParticipant> participants = room_.Participants();
463463
for (gpg::MultiplayerParticipant participant : participants) {
464-
LOGI("Participant Dispname:%s ID:%s", participant.DisplayName().c_str(),
464+
LOGI("Participant name:%s ID:%s", participant.DisplayName().c_str(),
465465
participant.Id().c_str());
466466
if (participant.HasPlayer())
467467
LOGI("self:%s PlayerID:%s", self_id_.c_str(),
@@ -487,18 +487,16 @@ void Engine::UpdateScore() {
487487
// Update game UI, UI update needs to be performed in UI thread
488488
ndk_helper::JNIHelper::GetInstance()
489489
->RunOnUiThread([this, str_myscore, allstr]() {
490-
my_score_text_->SetAttribute(
491-
"Text", const_cast<const char *>(str_myscore.c_str()));
492-
scores_text_->SetAttribute("Text",
493-
const_cast<const char *>(allstr.c_str()));
490+
my_score_text_->SetAttribute("Text", str_myscore.c_str());
491+
scores_text_->SetAttribute("Text", allstr.c_str());
494492
});
495493
}
496494

497495
/*
498496
* Update game timer and game UI
499497
*/
500498
bool Engine::UpdateTime() {
501-
// UpdateTime() is invoked from other thread asynchrnously
499+
// UpdateTime() is invoked from other thread asynchronously
502500
// So need to Lock mutex
503501
std::lock_guard<std::mutex> lock(mutex_);
504502

@@ -511,15 +509,14 @@ bool Engine::UpdateTime() {
511509
// finish game
512510
playing_ = false;
513511
current_time = GAME_DURATION;
514-
ndk_helper::JNIHelper::GetInstance()->RunOnUiThread([this, current_time]() {
512+
ndk_helper::JNIHelper::GetInstance()->RunOnUiThread([this]() {
515513
button_play_->SetAttribute("Enabled", false);
516514
});
517515
}
518516

519517
// Update game UI, UI update needs to be performed in UI thread
520518
ndk_helper::JNIHelper::GetInstance()->RunOnUiThread([this, current_time]() {
521-
// LOGI("Updating time %f", current_time);
522-
int32_t SIZE = 64;
519+
size_t SIZE = 64;
523520
char str[SIZE];
524521
snprintf(str, SIZE, "0:%02.0f", GAME_DURATION - current_time);
525522
time_text_->SetAttribute("Text", const_cast<const char *>(str));

samples-android/ButtonClicker/src/main/jni/ButtonClickerNativeActivity.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,8 @@ const int32_t MIN_PLAYERS = 1;
5555
const int32_t MAX_PLAYERS = 3;
5656
const double GAME_DURATION = 20.0;
5757

58-
enum NEXT_PARTICIPANT {
59-
NEXT_PARTICIPANT_AUTOMATCH = -1,
60-
NEXT_PARTICIPANT_NONE = -2,
61-
};
62-
6358
struct PLAYER_STATUS {
64-
int32_t score;
59+
uint8_t score;
6560
bool finished;
6661
};
6762
/*
@@ -85,7 +80,6 @@ class Engine : public gpg::IRealTimeEventListener {
8580
// Event handling
8681
static void HandleCmd(struct android_app *app, int32_t cmd);
8782
static int32_t HandleInput(android_app *app, AInputEvent *event);
88-
void UpdatePosition(AInputEvent *event, int32_t iIndex, float &fX, float &fY);
8983

9084
// Engine life cycles
9185
Engine();

samples-android/ButtonClicker/src/main/jni/ButtonClickerNativeActivity_Engine.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323
Engine::Engine()
2424
: initialized_resources_(false),
2525
has_focus_(false),
26+
textViewFPS_(nullptr),
2627
app_(nullptr),
2728
dialog_(nullptr),
28-
textViewFPS_(nullptr),
2929
button_sign_in_(nullptr),
30-
status_text_(nullptr),
31-
button_invite_(nullptr) {
30+
button_invite_(nullptr),
31+
status_text_(nullptr) {
3232
gl_context_ = ndk_helper::GLContext::GetInstance();
3333
}
3434

@@ -283,7 +283,6 @@ Engine g_engine;
283283
* event loop for receiving input events and doing other things.
284284
*/
285285
void android_main(android_app *state) {
286-
app_dummy();
287286

288287
g_engine.SetState(state);
289288

samples-android/ButtonClicker/src/main/res/layout/widgets.xml

Lines changed: 0 additions & 8 deletions
This file was deleted.

samples-android/ButtonClicker/src/main/res/values-v11/styles.xml

Lines changed: 0 additions & 11 deletions
This file was deleted.

samples-android/ButtonClicker/src/main/res/values-v14/styles.xml

Lines changed: 0 additions & 12 deletions
This file was deleted.

samples-android/CollectAllTheStarsNative/build.gradle

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,32 @@
1+
/*
2+
* Copyright 2017 (C) Google LLC
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
116
apply plugin: 'com.android.application'
217

318
android {
4-
compileSdkVersion 26
19+
compileSdkVersion 27
520
defaultConfig {
621
//
722
// REPLACE THE APPLICATION ID with your bundle ID
823
//
924
applicationId "com.google.example.games.ReplaceMe"
25+
versionCode 1
26+
versionName "1.0"
27+
1028
minSdkVersion 14
11-
targetSdkVersion 26
29+
targetSdkVersion 27
1230

1331
ndk.abiFilters 'x86', 'armeabi-v7a', 'arm64-v8a'
1432

@@ -33,7 +51,7 @@ android {
3351

3452
dependencies {
3553
implementation project(":Common:JuiHelper")
36-
implementation 'com.google.android.gms:play-services-games:11.6.2'
37-
implementation 'com.google.android.gms:play-services-nearby:11.6.2'
38-
implementation 'com.android.support:support-v4:26.1.0'
54+
implementation 'com.google.android.gms:play-services-games:11.8.0'
55+
implementation 'com.google.android.gms:play-services-nearby:11.8.0'
56+
implementation 'com.android.support:support-v4:27.0.2'
3957
}

samples-android/CollectAllTheStarsNative/src/main/AndroidManifest.xml

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,32 @@
1-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2-
package="com.google.example.games.cats"
3-
android:versionCode="1"
4-
android:versionName="1.0" >
1+
<!--
2+
Copyright 2018 Google LLC
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
57
6-
<uses-sdk
7-
android:minSdkVersion="11"
8-
android:targetSdkVersion="19" />
8+
http://www.apache.org/licenses/LICENSE-2.0
99
10-
<uses-feature android:glEsVersion="0x00020000" >
11-
</uses-feature>
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
17+
xmlns:tools="http://schemas.android.com/tools"
18+
package="com.google.example.games.cats">
1219

13-
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" >
14-
</uses-permission>
20+
<uses-feature android:glEsVersion="0x00020000"/>
1521

1622
<application
1723
android:name="com.google.example.games.cats.CollectAllTheStarsApplication"
18-
android:allowBackup="true"
24+
android:allowBackup="false"
1925
android:hasCode="true"
2026
android:icon="@drawable/ic_launcher"
2127
android:label="@string/app_name"
22-
android:theme="@style/AppTheme" >
28+
android:theme="@style/AppTheme"
29+
tools:ignore="GoogleAppIndexingWarning">
2330
<meta-data
2431
android:name="com.google.android.gms.version"
2532
android:value="@integer/google_play_services_version" />

0 commit comments

Comments
 (0)