diff options
Diffstat (limited to 'backends')
| -rw-r--r-- | backends/module.mk | 9 | ||||
| -rw-r--r-- | backends/networking/browser/openurl-android.cpp | 35 | ||||
| -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 | 
6 files changed, 74 insertions, 1 deletions
diff --git a/backends/module.mk b/backends/module.mk index 26fdca4a36..b8feffb61d 100644 --- a/backends/module.mk +++ b/backends/module.mk @@ -155,9 +155,16 @@ MODULE_OBJS += \  	fs/chroot/chroot-fs.o \  	plugins/posix/posix-provider.o \  	saves/posix/posix-saves.o \ -	taskbar/unity/unity-taskbar.o \ +	taskbar/unity/unity-taskbar.o + +ifeq ($(BACKEND),android) +MODULE_OBJS += \ +	networking/browser/openurl-android.o +else +MODULE_OBJS += \  	networking/browser/openurl-posix.o  endif +endif  ifdef MACOSX  MODULE_OBJS += \ diff --git a/backends/networking/browser/openurl-android.cpp b/backends/networking/browser/openurl-android.cpp new file mode 100644 index 0000000000..98fc803c0d --- /dev/null +++ b/backends/networking/browser/openurl-android.cpp @@ -0,0 +1,35 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "backends/networking/browser/openurl.h" +#include "backends/platform/android/jni.h" + +namespace Networking { +namespace Browser { + +bool openUrl(const Common::String &url) {	 +	return JNI::openUrl(url.c_str()); +} + +} // End of namespace Browser +} // End of namespace Networking + 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() {  | 
