From d73418261b5aed44861ea66faaa4ef3d2589fc6a Mon Sep 17 00:00:00 2001 From: Jonathan De Wachter Date: Tue, 24 Jun 2014 07:40:16 +0200 Subject: [PATCH] [Android] Do not hardcode java const values (JNI) --- src/SFML/Main/MainAndroid.cpp | 9 ++++++++- src/SFML/Main/SFMLActivity.cpp | 10 ++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/SFML/Main/MainAndroid.cpp b/src/SFML/Main/MainAndroid.cpp index b3c681fe3..08e232ab6 100644 --- a/src/SFML/Main/MainAndroid.cpp +++ b/src/SFML/Main/MainAndroid.cpp @@ -440,8 +440,15 @@ void ANativeActivity_onCreate(ANativeActivity* activity, void* savedState, size_ jobject objectDecorView = lJNIEnv->CallObjectMethod(objectWindow, methodGetDecorView); jclass classView = lJNIEnv->FindClass("android/view/View"); + + jfieldID FieldSYSTEM_UI_FLAG_HIDE_NAVIGATION = lJNIEnv->GetStaticFieldID(classView, "SYSTEM_UI_FLAG_HIDE_NAVIGATION", "I"); + jint SYSTEM_UI_FLAG_HIDE_NAVIGATION = lJNIEnv->GetStaticIntField(classView, FieldSYSTEM_UI_FLAG_HIDE_NAVIGATION); + + jfieldID FieldSYSTEM_UI_FLAG_FULLSCREEN = lJNIEnv->GetStaticFieldID(classView, "SYSTEM_UI_FLAG_FULLSCREEN", "I"); + jint SYSTEM_UI_FLAG_FULLSCREEN = lJNIEnv->GetStaticIntField(classView, FieldSYSTEM_UI_FLAG_FULLSCREEN); + jmethodID methodsetSystemUiVisibility = lJNIEnv->GetMethodID(classView, "setSystemUiVisibility", "(I)V"); - lJNIEnv->CallVoidMethod(objectDecorView, methodsetSystemUiVisibility, (jint)(2 | 4)); + lJNIEnv->CallVoidMethod(objectDecorView, methodsetSystemUiVisibility, SYSTEM_UI_FLAG_HIDE_NAVIGATION | SYSTEM_UI_FLAG_FULLSCREEN); // Initialize the display eglInitialize(states->display, NULL, NULL); diff --git a/src/SFML/Main/SFMLActivity.cpp b/src/SFML/Main/SFMLActivity.cpp index d0c19ec3c..c94646694 100644 --- a/src/SFML/Main/SFMLActivity.cpp +++ b/src/SFML/Main/SFMLActivity.cpp @@ -152,13 +152,11 @@ void ANativeActivity_onCreate(ANativeActivity* activity, void* savedState, size_ jclass ClassPackageManager = lJNIEnv->FindClass("android/content/pm/PackageManager"); - //jfieldID FieldGET_META_DATA = lJNIEnv->GetStaticFieldID(ClassPackageManager, "GET_META_DATA", "L"); - //jobject GET_META_DATA = lJNIEnv->GetStaticObjectField(ClassPackageManager, FieldGET_META_DATA); - // getActivityInfo(getIntent().getComponent(), PackageManager.GET_META_DATA) -> ActivityInfo object - jmethodID MethodGetActivityInfo = lJNIEnv->GetMethodID(ClassPackageManager, "getActivityInfo", "(Landroid/content/ComponentName;I)Landroid/content/pm/ActivityInfo;"); + jfieldID FieldGET_META_DATA = lJNIEnv->GetStaticFieldID(ClassPackageManager, "GET_META_DATA", "I"); + jint GET_META_DATA = lJNIEnv->GetStaticIntField(ClassPackageManager, FieldGET_META_DATA); - // todo: do not hardcode the GET_META_DATA integer value but retrieve it instead - jobject ObjectActivityInfo = lJNIEnv->CallObjectMethod(ObjectPackageManager, MethodGetActivityInfo, ObjectComponentName, (jint)128); + jmethodID MethodGetActivityInfo = lJNIEnv->GetMethodID(ClassPackageManager, "getActivityInfo", "(Landroid/content/ComponentName;I)Landroid/content/pm/ActivityInfo;"); + jobject ObjectActivityInfo = lJNIEnv->CallObjectMethod(ObjectPackageManager, MethodGetActivityInfo, ObjectComponentName, GET_META_DATA); // Load our libraries in reverse order loadLibrary("c++_shared", lJNIEnv, ObjectActivityInfo);