diff options
author | Alexander Tkachev | 2016-07-15 19:18:19 +0600 |
---|---|---|
committer | Alexander Tkachev | 2016-08-24 16:07:55 +0600 |
commit | ded8cdf0a092894781bb4d93f2d1e9d061878ea1 (patch) | |
tree | 138590d9e47b22e28236f833b7bbf0e840c9dfde /backends/platform/android | |
parent | 40dfb0b4f17590100b4dcfe212ee3f34369d788e (diff) | |
download | scummvm-rg350-ded8cdf0a092894781bb4d93f2d1e9d061878ea1.tar.gz scummvm-rg350-ded8cdf0a092894781bb4d93f2d1e9d061878ea1.tar.bz2 scummvm-rg350-ded8cdf0a092894781bb4d93f2d1e9d061878ea1.zip |
CLOUD: Add openurl-android.cpp
Diffstat (limited to 'backends/platform/android')
-rw-r--r-- | backends/platform/android/jni.cpp | 21 | ||||
-rw-r--r-- | backends/platform/android/jni.h | 2 | ||||
-rw-r--r-- | backends/platform/android/org/scummvm/scummvm/ScummVM.java | 1 | ||||
-rw-r--r-- | backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java | 7 |
4 files changed, 31 insertions, 0 deletions
diff --git a/backends/platform/android/jni.cpp b/backends/platform/android/jni.cpp index 22e6a749c2..6360bb1416 100644 --- a/backends/platform/android/jni.cpp +++ b/backends/platform/android/jni.cpp @@ -76,6 +76,7 @@ bool JNI::_ready_for_events = 0; jmethodID JNI::_MID_getDPI = 0; jmethodID JNI::_MID_displayMessageOnOSD = 0; +jmethodID JNI::_MID_openUrl = 0; jmethodID JNI::_MID_setWindowCaption = 0; jmethodID JNI::_MID_showVirtualKeyboard = 0; jmethodID JNI::_MID_getSysArchives = 0; @@ -232,6 +233,25 @@ void JNI::displayMessageOnOSD(const char *msg) { env->DeleteLocalRef(java_msg); } +bool JNI::openUrl(const char *url) { + bool success = true; + JNIEnv *env = JNI::getEnv(); + jstring javaUrl = env->NewStringUTF(url); + + env->CallVoidMethod(_jobj, _MID_openUrl, javaUrl); + + if (env->ExceptionCheck()) { + LOGE("Failed to open URL"); + + env->ExceptionDescribe(); + env->ExceptionClear(); + success = false; + } + + env->DeleteLocalRef(javaUrl); + return success; +} + void JNI::setWindowCaption(const char *caption) { JNIEnv *env = JNI::getEnv(); jstring java_caption = env->NewStringUTF(caption); @@ -411,6 +431,7 @@ void JNI::create(JNIEnv *env, jobject self, jobject asset_manager, FIND_METHOD(, setWindowCaption, "(Ljava/lang/String;)V"); FIND_METHOD(, getDPI, "([F)V"); FIND_METHOD(, displayMessageOnOSD, "(Ljava/lang/String;)V"); + FIND_METHOD(, openUrl, "(Ljava/lang/String;)V"); FIND_METHOD(, showVirtualKeyboard, "(Z)V"); FIND_METHOD(, getSysArchives, "()[Ljava/lang/String;"); FIND_METHOD(, initSurface, "()Ljavax/microedition/khronos/egl/EGLSurface;"); diff --git a/backends/platform/android/jni.h b/backends/platform/android/jni.h index 70feaaf72a..de4c95bd76 100644 --- a/backends/platform/android/jni.h +++ b/backends/platform/android/jni.h @@ -58,6 +58,7 @@ public: static void setWindowCaption(const char *caption); static void getDPI(float *values); static void displayMessageOnOSD(const char *msg); + static bool openUrl(const char *url); static void showVirtualKeyboard(bool enable); static void addSysArchivesToSearchSet(Common::SearchSet &s, int priority); @@ -89,6 +90,7 @@ private: static jmethodID _MID_getDPI; static jmethodID _MID_displayMessageOnOSD; + static jmethodID _MID_openUrl; static jmethodID _MID_setWindowCaption; static jmethodID _MID_showVirtualKeyboard; static jmethodID _MID_getSysArchives; diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVM.java b/backends/platform/android/org/scummvm/scummvm/ScummVM.java index 3b370a583d..50642805a4 100644 --- a/backends/platform/android/org/scummvm/scummvm/ScummVM.java +++ b/backends/platform/android/org/scummvm/scummvm/ScummVM.java @@ -53,6 +53,7 @@ public abstract class ScummVM implements SurfaceHolder.Callback, Runnable { // Callbacks from C++ peer instance abstract protected void getDPI(float[] values); abstract protected void displayMessageOnOSD(String msg); + abstract protected void openUrl(String url); abstract protected void setWindowCaption(String caption); abstract protected void showVirtualKeyboard(boolean enable); abstract protected String[] getSysArchives(); diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java index 5b2dcae175..2f3701a557 100644 --- a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java +++ b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java @@ -5,6 +5,7 @@ import android.app.AlertDialog; import android.content.DialogInterface; import android.content.Intent; import android.media.AudioManager; +import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.os.Environment; @@ -75,6 +76,12 @@ public class ScummVMActivity extends Activity { } @Override + protected void openUrl(String url) { + startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); + } + + + @Override protected void setWindowCaption(final String caption) { runOnUiThread(new Runnable() { public void run() { |