MCPcopy Create free account
hub / github.com/SFML/SFML / goToFullscreenMode

Function goToFullscreenMode

src/SFML/Main/MainAndroid.cpp:124–180  ·  view source on GitHub ↗

///////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

122
123////////////////////////////////////////////////////////////
124void goToFullscreenMode(ANativeActivity& activity)
125{
126 // Get the current Android API level.
127 const int apiLevel = getAndroidApiLevel(activity);
128
129 // Hide the status bar
130 ANativeActivity_setWindowFlags(&activity, AWINDOW_FLAG_FULLSCREEN, AWINDOW_FLAG_FULLSCREEN);
131
132 // Hide the navigation bar
133 JNIEnv& lJNIEnv = *activity.env;
134
135 jobject objectActivity = activity.clazz;
136 jclass classActivity = lJNIEnv.GetObjectClass(objectActivity);
137
138 jmethodID methodGetWindow = lJNIEnv.GetMethodID(classActivity, "getWindow", "()Landroid/view/Window;");
139 jobject objectWindow = lJNIEnv.CallObjectMethod(objectActivity, methodGetWindow);
140
141 jclass classWindow = lJNIEnv.FindClass("android/view/Window");
142 jmethodID methodGetDecorView = lJNIEnv.GetMethodID(classWindow, "getDecorView", "()Landroid/view/View;");
143 jobject objectDecorView = lJNIEnv.CallObjectMethod(objectWindow, methodGetDecorView);
144
145 jclass classView = lJNIEnv.FindClass("android/view/View");
146
147 // Default flags
148 jint flags = 0;
149
150 // API Level 14
151 if (apiLevel >= 14)
152 {
153 jfieldID fieldSystemUiFlagLowProfile = lJNIEnv.GetStaticFieldID(classView,
154 "SYSTEM_UI_FLAG_HIDE_NAVIGATION",
155 "I");
156 const jint systemUiFlagLowProfile = lJNIEnv.GetStaticIntField(classView, fieldSystemUiFlagLowProfile);
157 flags |= systemUiFlagLowProfile;
158 }
159
160 // API Level 16
161 if (apiLevel >= 16)
162 {
163 jfieldID fieldSystemUiFlagFullscreen = lJNIEnv.GetStaticFieldID(classView, "SYSTEM_UI_FLAG_FULLSCREEN", "I");
164 const jint systemUiFlagFullscreen = lJNIEnv.GetStaticIntField(classView, fieldSystemUiFlagFullscreen);
165 flags |= systemUiFlagFullscreen;
166 }
167
168 // API Level 19
169 if (apiLevel >= 19)
170 {
171 jfieldID fieldSystemUiFlagImmersiveSticky = lJNIEnv.GetStaticFieldID(classView,
172 "SYSTEM_UI_FLAG_IMMERSIVE_STICKY",
173 "I");
174 const jint systemUiFlagImmersiveSticky = lJNIEnv.GetStaticIntField(classView, fieldSystemUiFlagImmersiveSticky);
175 flags |= systemUiFlagImmersiveSticky;
176 }
177
178 jmethodID methodsetSystemUiVisibility = lJNIEnv.GetMethodID(classView, "setSystemUiVisibility", "(I)V");
179 lJNIEnv.CallVoidMethod(objectDecorView, methodsetSystemUiVisibility, flags);
180}
181

Callers 1

onResumeFunction · 0.85

Calls 1

getAndroidApiLevelFunction · 0.85

Tested by

no test coverage detected