mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
Cleanup Android C++ code
This commit is contained in:
parent
a837accc5d
commit
2afef001e7
33 changed files with 181 additions and 238 deletions
|
@ -80,7 +80,7 @@ jobject GodotIOJavaWrapper::get_instance() {
|
|||
Error GodotIOJavaWrapper::open_uri(const String &p_uri) {
|
||||
if (_open_URI) {
|
||||
JNIEnv *env = get_jni_env();
|
||||
ERR_FAIL_COND_V(env == nullptr, ERR_UNAVAILABLE);
|
||||
ERR_FAIL_NULL_V(env, ERR_UNAVAILABLE);
|
||||
jstring jStr = env->NewStringUTF(p_uri.utf8().get_data());
|
||||
return env->CallIntMethod(godot_io_instance, _open_URI, jStr) ? ERR_CANT_OPEN : OK;
|
||||
} else {
|
||||
|
@ -91,7 +91,7 @@ Error GodotIOJavaWrapper::open_uri(const String &p_uri) {
|
|||
String GodotIOJavaWrapper::get_cache_dir() {
|
||||
if (_get_cache_dir) {
|
||||
JNIEnv *env = get_jni_env();
|
||||
ERR_FAIL_COND_V(env == nullptr, String());
|
||||
ERR_FAIL_NULL_V(env, String());
|
||||
jstring s = (jstring)env->CallObjectMethod(godot_io_instance, _get_cache_dir);
|
||||
return jstring_to_string(s, env);
|
||||
} else {
|
||||
|
@ -102,7 +102,7 @@ String GodotIOJavaWrapper::get_cache_dir() {
|
|||
String GodotIOJavaWrapper::get_user_data_dir() {
|
||||
if (_get_data_dir) {
|
||||
JNIEnv *env = get_jni_env();
|
||||
ERR_FAIL_COND_V(env == nullptr, String());
|
||||
ERR_FAIL_NULL_V(env, String());
|
||||
jstring s = (jstring)env->CallObjectMethod(godot_io_instance, _get_data_dir);
|
||||
return jstring_to_string(s, env);
|
||||
} else {
|
||||
|
@ -113,7 +113,7 @@ String GodotIOJavaWrapper::get_user_data_dir() {
|
|||
String GodotIOJavaWrapper::get_locale() {
|
||||
if (_get_locale) {
|
||||
JNIEnv *env = get_jni_env();
|
||||
ERR_FAIL_COND_V(env == nullptr, String());
|
||||
ERR_FAIL_NULL_V(env, String());
|
||||
jstring s = (jstring)env->CallObjectMethod(godot_io_instance, _get_locale);
|
||||
return jstring_to_string(s, env);
|
||||
} else {
|
||||
|
@ -124,7 +124,7 @@ String GodotIOJavaWrapper::get_locale() {
|
|||
String GodotIOJavaWrapper::get_model() {
|
||||
if (_get_model) {
|
||||
JNIEnv *env = get_jni_env();
|
||||
ERR_FAIL_COND_V(env == nullptr, String());
|
||||
ERR_FAIL_NULL_V(env, String());
|
||||
jstring s = (jstring)env->CallObjectMethod(godot_io_instance, _get_model);
|
||||
return jstring_to_string(s, env);
|
||||
} else {
|
||||
|
@ -135,7 +135,7 @@ String GodotIOJavaWrapper::get_model() {
|
|||
int GodotIOJavaWrapper::get_screen_dpi() {
|
||||
if (_get_screen_DPI) {
|
||||
JNIEnv *env = get_jni_env();
|
||||
ERR_FAIL_COND_V(env == nullptr, 160);
|
||||
ERR_FAIL_NULL_V(env, 160);
|
||||
return env->CallIntMethod(godot_io_instance, _get_screen_DPI);
|
||||
} else {
|
||||
return 160;
|
||||
|
@ -145,7 +145,7 @@ int GodotIOJavaWrapper::get_screen_dpi() {
|
|||
float GodotIOJavaWrapper::get_scaled_density() {
|
||||
if (_get_scaled_density) {
|
||||
JNIEnv *env = get_jni_env();
|
||||
ERR_FAIL_COND_V(env == nullptr, 1.0f);
|
||||
ERR_FAIL_NULL_V(env, 1.0f);
|
||||
return env->CallFloatMethod(godot_io_instance, _get_scaled_density);
|
||||
} else {
|
||||
return 1.0f;
|
||||
|
@ -202,7 +202,7 @@ Rect2i GodotIOJavaWrapper::get_display_safe_area() {
|
|||
String GodotIOJavaWrapper::get_unique_id() {
|
||||
if (_get_unique_id) {
|
||||
JNIEnv *env = get_jni_env();
|
||||
ERR_FAIL_COND_V(env == nullptr, String());
|
||||
ERR_FAIL_NULL_V(env, String());
|
||||
jstring s = (jstring)env->CallObjectMethod(godot_io_instance, _get_unique_id);
|
||||
return jstring_to_string(s, env);
|
||||
} else {
|
||||
|
@ -211,13 +211,13 @@ String GodotIOJavaWrapper::get_unique_id() {
|
|||
}
|
||||
|
||||
bool GodotIOJavaWrapper::has_vk() {
|
||||
return (_show_keyboard != 0) && (_hide_keyboard != 0);
|
||||
return (_show_keyboard != nullptr) && (_hide_keyboard != nullptr);
|
||||
}
|
||||
|
||||
void GodotIOJavaWrapper::show_vk(const String &p_existing, bool p_multiline, int p_max_input_length, int p_cursor_start, int p_cursor_end) {
|
||||
if (_show_keyboard) {
|
||||
JNIEnv *env = get_jni_env();
|
||||
ERR_FAIL_COND(env == nullptr);
|
||||
ERR_FAIL_NULL(env);
|
||||
jstring jStr = env->NewStringUTF(p_existing.utf8().get_data());
|
||||
env->CallVoidMethod(godot_io_instance, _show_keyboard, jStr, p_multiline, p_max_input_length, p_cursor_start, p_cursor_end);
|
||||
}
|
||||
|
@ -226,7 +226,7 @@ void GodotIOJavaWrapper::show_vk(const String &p_existing, bool p_multiline, int
|
|||
void GodotIOJavaWrapper::hide_vk() {
|
||||
if (_hide_keyboard) {
|
||||
JNIEnv *env = get_jni_env();
|
||||
ERR_FAIL_COND(env == nullptr);
|
||||
ERR_FAIL_NULL(env);
|
||||
env->CallVoidMethod(godot_io_instance, _hide_keyboard);
|
||||
}
|
||||
}
|
||||
|
@ -234,7 +234,7 @@ void GodotIOJavaWrapper::hide_vk() {
|
|||
void GodotIOJavaWrapper::set_screen_orientation(int p_orient) {
|
||||
if (_set_screen_orientation) {
|
||||
JNIEnv *env = get_jni_env();
|
||||
ERR_FAIL_COND(env == nullptr);
|
||||
ERR_FAIL_NULL(env);
|
||||
env->CallVoidMethod(godot_io_instance, _set_screen_orientation, p_orient);
|
||||
}
|
||||
}
|
||||
|
@ -242,7 +242,7 @@ void GodotIOJavaWrapper::set_screen_orientation(int p_orient) {
|
|||
int GodotIOJavaWrapper::get_screen_orientation() {
|
||||
if (_get_screen_orientation) {
|
||||
JNIEnv *env = get_jni_env();
|
||||
ERR_FAIL_COND_V(env == nullptr, 0);
|
||||
ERR_FAIL_NULL_V(env, 0);
|
||||
return env->CallIntMethod(godot_io_instance, _get_screen_orientation);
|
||||
} else {
|
||||
return 0;
|
||||
|
@ -252,7 +252,7 @@ int GodotIOJavaWrapper::get_screen_orientation() {
|
|||
String GodotIOJavaWrapper::get_system_dir(int p_dir, bool p_shared_storage) {
|
||||
if (_get_system_dir) {
|
||||
JNIEnv *env = get_jni_env();
|
||||
ERR_FAIL_COND_V(env == nullptr, String("."));
|
||||
ERR_FAIL_NULL_V(env, String("."));
|
||||
jstring s = (jstring)env->CallObjectMethod(godot_io_instance, _get_system_dir, p_dir, p_shared_storage);
|
||||
return jstring_to_string(s, env);
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue