From 7f9f4dc182d82fa64288af3397f002719b9e17a2 Mon Sep 17 00:00:00 2001 From: Benau Date: Sat, 5 Dec 2020 14:22:59 +0800 Subject: [PATCH] Fix compilation with latest sdl2 --- .../src/main/java/SuperTuxKartActivity.java | 16 ------- src/online/link_helper.cpp | 43 +------------------ 2 files changed, 2 insertions(+), 57 deletions(-) diff --git a/android/src/main/java/SuperTuxKartActivity.java b/android/src/main/java/SuperTuxKartActivity.java index 0132de4e3..85485e72b 100644 --- a/android/src/main/java/SuperTuxKartActivity.java +++ b/android/src/main/java/SuperTuxKartActivity.java @@ -309,22 +309,6 @@ public class SuperTuxKartActivity extends SDLActivity } // ------------------------------------------------------------------------ /* Called by STK in JNI. */ - public void openURL(final String url) - { - try - { - Uri uri = Uri.parse(url); - Intent i = new Intent(Intent.ACTION_VIEW, uri); - if (i.resolveActivity(getPackageManager()) != null) - startActivity(i); - } - catch (ActivityNotFoundException e) - { - e.printStackTrace(); - } - } - // ------------------------------------------------------------------------ - /* Called by STK in JNI. */ public void fromSTKEditBox(final int widget_id, final String text, final int selection_start, final int selection_end, final int type) diff --git a/src/online/link_helper.cpp b/src/online/link_helper.cpp index 92d9e98e7..d642f9f5b 100644 --- a/src/online/link_helper.cpp +++ b/src/online/link_helper.cpp @@ -24,8 +24,7 @@ #endif #ifdef ANDROID -#include -#include "SDL_system.h" +#include "SDL_misc.h" #endif #ifdef IOS_STK @@ -48,45 +47,7 @@ namespace Online void LinkHelper::openURL (std::string url) { #if defined(ANDROID) - JNIEnv* env = (JNIEnv*)SDL_AndroidGetJNIEnv(); - if (env == NULL) - { - Log::error("LinkHelper", - "openURL unable to SDL_AndroidGetJNIEnv."); - return; - } - - jobject native_activity = (jobject)SDL_AndroidGetActivity(); - if (native_activity == NULL) - { - Log::error("LinkHelper", - "openURL unable to SDL_AndroidGetActivity."); - return; - } - - jclass class_native_activity = env->GetObjectClass(native_activity); - - if (class_native_activity == NULL) - { - Log::error("LinkHelper", "openURL unable to find object class."); - env->DeleteLocalRef(native_activity); - return; - } - - jmethodID method_id = env->GetMethodID(class_native_activity, "openURL", "(Ljava/lang/String;)V"); - - if (method_id == NULL) - { - Log::error("LinkHelper", "openURL unable to find method id."); - env->DeleteLocalRef(class_native_activity); - env->DeleteLocalRef(native_activity); - return; - } - jstring url_jstring = env->NewStringUTF(url.c_str()); - env->CallVoidMethod(native_activity, method_id, url_jstring); - env->DeleteLocalRef(url_jstring); - env->DeleteLocalRef(class_native_activity); - env->DeleteLocalRef(native_activity); + SDL_OpenURL(url.c_str()); #elif defined(_WIN32) ShellExecuteA(NULL, "open", url.c_str(), NULL, NULL, SW_SHOWNORMAL); #elif defined(IOS_STK)