Skip to content

Commit a271740

Browse files
author
Google Automerger
committed
Merge commit '379bb817a7ff24311f904ab7c5fc34425faee2c0' into HEAD
2 parents b82f0d7 + 379bb81 commit a271740

File tree

2 files changed

+168
-0
lines changed

2 files changed

+168
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright 2014 The Android Open Source Project
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
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
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+
17+
package com.google.example.games.bc3;
18+
19+
import android.app.Application;
20+
21+
public class ButtonClickerApplication extends Application {
22+
public void onCreate() {
23+
}
24+
}
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
/*
2+
* Copyright 2014 The Android Open Source Project
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
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
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+
17+
package com.google.example.games.bc3;
18+
19+
import android.annotation.SuppressLint;
20+
import android.app.Activity;
21+
import android.app.NativeActivity;
22+
import android.content.Intent;
23+
import android.os.Bundle;
24+
import android.view.View;
25+
26+
public class ButtonClickerNativeActivity extends NativeActivity {
27+
// Load SO
28+
static {
29+
System.load("libButtonClickerNativeActivity.so");
30+
}
31+
32+
@Override
33+
protected void onCreate(Bundle savedInstanceState) {
34+
super.onCreate(savedInstanceState);
35+
// Hide toolbar
36+
int SDK_INT = android.os.Build.VERSION.SDK_INT;
37+
if (SDK_INT >= 19) {
38+
setImmersiveSticky();
39+
40+
View decorView = getWindow().getDecorView();
41+
decorView
42+
.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
43+
@Override
44+
public void onSystemUiVisibilityChange(int visibility) {
45+
setImmersiveSticky();
46+
}
47+
});
48+
}
49+
50+
nativeOnActivityCreated(this, savedInstanceState);
51+
}
52+
53+
@SuppressLint("InlinedApi")
54+
@SuppressWarnings("deprecation")
55+
protected void onResume() {
56+
super.onResume();
57+
58+
// Hide toolbar
59+
int SDK_INT = android.os.Build.VERSION.SDK_INT;
60+
if (SDK_INT >= 11 && SDK_INT < 14) {
61+
getWindow().getDecorView().setSystemUiVisibility(
62+
View.STATUS_BAR_HIDDEN);
63+
} else if (SDK_INT >= 14 && SDK_INT < 19) {
64+
getWindow().getDecorView().setSystemUiVisibility(
65+
View.SYSTEM_UI_FLAG_FULLSCREEN
66+
| View.SYSTEM_UI_FLAG_LOW_PROFILE);
67+
} else if (SDK_INT >= 19) {
68+
setImmersiveSticky();
69+
}
70+
71+
nativeOnActivityResumed(this);
72+
}
73+
74+
@SuppressLint("InlinedApi")
75+
void setImmersiveSticky() {
76+
View decorView = getWindow().getDecorView();
77+
decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN
78+
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
79+
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
80+
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
81+
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
82+
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
83+
}
84+
85+
protected void onPause() {
86+
super.onPause();
87+
// This call is to suppress 'E/WindowManager():
88+
// android.view.WindowLeaked...' errors.
89+
// Since orientation change events in NativeActivity comes later than
90+
// expected, we can not dismiss
91+
// popupWindow gracefully from NativeActivity.
92+
// So we are releasing popupWindows explicitly triggered from Java
93+
// callback through JNI call.
94+
OnPauseHandler();
95+
96+
nativeOnActivityPaused(this);
97+
}
98+
99+
protected void onDestroy() {
100+
super.onDestroy();
101+
nativeOnActivityDestroyed(this);
102+
}
103+
104+
protected void onStart() {
105+
super.onStart();
106+
nativeOnActivityStarted(this);
107+
}
108+
109+
protected void onStop() {
110+
super.onStop();
111+
nativeOnActivityStopped(this);
112+
}
113+
114+
protected void onSaveInstanceState(Bundle outState) {
115+
super.onSaveInstanceState(outState);
116+
nativeOnActivitySaveInstanceState(this, outState);
117+
}
118+
119+
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
120+
nativeOnActivityResult(this, requestCode,resultCode, data);
121+
}
122+
123+
// Implemented in C++.
124+
public static native void nativeOnActivityResult(Activity activity,
125+
int requestCode, int resultCode, Intent data);
126+
127+
public static native void nativeOnActivityCreated(Activity activity,
128+
Bundle savedInstanceState);
129+
130+
private static native void nativeOnActivityDestroyed(Activity activity);
131+
132+
private static native void nativeOnActivityPaused(Activity activity);
133+
134+
private static native void nativeOnActivityResumed(Activity activity);
135+
136+
private static native void nativeOnActivitySaveInstanceState(
137+
Activity activity, Bundle outState);
138+
139+
private static native void nativeOnActivityStarted(Activity activity);
140+
141+
private static native void nativeOnActivityStopped(Activity activity);
142+
143+
native public void OnPauseHandler();
144+
}

0 commit comments

Comments
 (0)