From 2d82cf78e1b88ffe61836d8134bca2a20359503f Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Mon, 5 Oct 2020 13:59:03 -0400 Subject: [PATCH] url: put the Android bits in core/android --- src/core/android/SDL_android.c | 10 ++++++++++ src/core/android/SDL_android.h | 2 ++ src/misc/android/SDL_sysurl.c | 6 +----- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/core/android/SDL_android.c b/src/core/android/SDL_android.c index f8c02ea1d..520ad1ede 100644 --- a/src/core/android/SDL_android.c +++ b/src/core/android/SDL_android.c @@ -2606,6 +2606,16 @@ int Android_JNI_GetLocale(char *buf, size_t buflen) return 0; } +int +Android_JNI_OpenURL(const char *url) +{ + JNIEnv *env = Android_JNI_GetEnv(); + jstring jurl = (*env)->NewStringUTF(env, url); + const int ret = (*env)->CallStaticIntMethod(env, mActivityClass, midOpenURL, jurl); + (*env)->DeleteLocalRef(env, jurl); + return ret; +} + #endif /* __ANDROID__ */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/core/android/SDL_android.h b/src/core/android/SDL_android.h index 153105199..1726e4a3e 100644 --- a/src/core/android/SDL_android.h +++ b/src/core/android/SDL_android.h @@ -129,6 +129,8 @@ SDL_bool Android_JNI_SetRelativeMouseEnabled(SDL_bool enabled); /* Request permission */ SDL_bool Android_JNI_RequestPermission(const char *permission); +int Android_JNI_OpenURL(const char *url); + int SDL_GetAndroidSDKVersion(void); SDL_bool SDL_IsAndroidTablet(void); diff --git a/src/misc/android/SDL_sysurl.c b/src/misc/android/SDL_sysurl.c index 6ee5f8b23..c7f1d2aab 100644 --- a/src/misc/android/SDL_sysurl.c +++ b/src/misc/android/SDL_sysurl.c @@ -25,11 +25,7 @@ int SDL_SYS_OpenURL(const char *url) { - JNIEnv *env = Android_JNI_GetEnv(); - jstring jurl = (*env)->NewStringUTF(env, url); - const int ret = (*env)->CallStaticIntMethod(env, mActivityClass, midOpenURL, jurl); - (*env)->DeleteLocalRef(env, jurl); - return ret; + return Android_JNI_OpenURL(url); } /* vi: set ts=4 sw=4 expandtab: */