[Android] Update Android bridge for notification

This commit is contained in:
zilmar 2016-08-11 20:43:51 +10:00
parent c39937f63c
commit a277fc0a60
4 changed files with 98 additions and 49 deletions

View File

@ -134,6 +134,18 @@ void JavaBridge::DisplayMessage(const char * Message)
}
}
void JavaBridge::DisplayMessage2(const char * Message)
{
JNIEnv *env = Android_JNI_GetEnv();
if (env)
{
jstring j_Message = env->NewStringUTF(Message);
jmethodID midShowToast = env->GetStaticMethodID(m_NotifierClass, "showToast", "(Landroid/app/Activity;Ljava/lang/String;)V");
env->CallStaticVoidMethod(m_NotifierClass, midShowToast,g_Activity,j_Message);
env->DeleteLocalRef(j_Message);
}
}
void JavaBridge::EmulationStopped(void)
{
JNIEnv *env = Android_JNI_GetEnv();

View File

@ -24,6 +24,7 @@ public:
//Notification
void DisplayError(const char * Message);
void DisplayMessage(const char * Message);
void DisplayMessage2(const char * Message);
void EmulationStopped(void);
private:

View File

@ -80,8 +80,6 @@ void CNotificationImp::DisplayMessage(int DisplayTime, LanguageStringID StringID
void CNotificationImp::DisplayMessage(int DisplayTime, const char * Message) const
{
#ifdef ANDROID
__android_log_print(ANDROID_LOG_VERBOSE, "PJ64-Bridge", "%s", Message);
if (g_JavaBridge == NULL) { return; }
/*if (m_NextMsg > 0 || DisplayTime > 0)
@ -109,8 +107,16 @@ void CNotificationImp::DisplayMessage(int DisplayTime, const char * Message) con
#endif
}
void CNotificationImp::DisplayMessage2(const char * /*Message*/) const
void CNotificationImp::DisplayMessage2(const char * Message) const
{
#ifdef ANDROID
if (g_JavaBridge == NULL) { return; }
g_JavaBridge->DisplayMessage2(Message);
#else
// ignore warning usage
Message = Message;
#endif
}
// Ask a Yes/No Question to the user, yes = true, no = false

View File

@ -21,6 +21,7 @@
#include "jniBridge.h"
#include "jniBridgeSettings.h"
#include "JavaBridge.h"
#include "SyncBridge.h"
#include "UISettings.h"
#include "JavaRomList.h"
@ -58,6 +59,7 @@ AndroidLogger * g_Logger = NULL;
static pthread_key_t g_ThreadKey;
static JavaVM* g_JavaVM = NULL;
JavaBridge * g_JavaBridge = NULL;
SyncBridge * g_SyncBridge = NULL;
jobject g_Activity = NULL;
jobject g_GLThread = NULL;
@ -160,7 +162,8 @@ EXPORT jboolean CALL Java_emu_project64_jni_NativeExports_appInit(JNIEnv* env, j
if (res)
{
g_JavaBridge = new JavaBridge(g_JavaVM);
g_Plugins->SetRenderWindows(g_JavaBridge, NULL);
g_SyncBridge = new SyncBridge(g_JavaBridge);
g_Plugins->SetRenderWindows(g_JavaBridge, g_SyncBridge);
JniBridegSettings = new CJniBridegSettings();
@ -183,6 +186,7 @@ EXPORT void CALL Java_emu_project64_jni_NativeExports_SettingsSaveBool(JNIEnv* e
{
WriteTrace(TraceUserInterface, TraceDebug, "Saving %d value: %s",Type,Value ? "true" : "false");
g_Settings->SaveBool((SettingID)Type, Value);
CSettings::FlushSettings(g_Settings);
WriteTrace(TraceUserInterface, TraceDebug, "Saved");
}
@ -190,6 +194,7 @@ EXPORT void CALL Java_emu_project64_jni_NativeExports_SettingsSaveDword(JNIEnv*
{
WriteTrace(TraceUserInterface, TraceDebug, "Saving %d value: 0x%X",Type,Value);
g_Settings->SaveDword((SettingID)Type, Value);
CSettings::FlushSettings(g_Settings);
WriteTrace(TraceUserInterface, TraceDebug, "Saved");
}
@ -198,6 +203,7 @@ EXPORT void CALL Java_emu_project64_jni_NativeExports_SettingsSaveString(JNIEnv*
const char *value = env->GetStringUTFChars(Buffer, 0);
WriteTrace(TraceUserInterface, TraceDebug, "Saving %d value: %s",Type,value);
g_Settings->SaveString((SettingID)Type, value);
CSettings::FlushSettings(g_Settings);
WriteTrace(TraceUserInterface, TraceDebug, "Saved");
env->ReleaseStringUTFChars(Buffer, value);
}
@ -281,9 +287,21 @@ EXPORT void CALL Java_emu_project64_jni_NativeExports_ExternalEvent(JNIEnv* env,
EXPORT void CALL Java_emu_project64_jni_NativeExports_onSurfaceCreated(JNIEnv * env, jclass cls)
{
WriteTrace(TraceUserInterface, TraceDebug, "Start");
if (g_Plugins != NULL && g_Plugins->Gfx() != NULL && g_Plugins->Gfx()->SurfaceCreated)
if (g_BaseSystem != NULL && g_BaseSystem->GetPlugins() != NULL && g_BaseSystem->GetPlugins()->Gfx() != NULL)
{
g_Plugins->Gfx()->SurfaceCreated();
CGfxPlugin * GfxPlugin = g_BaseSystem->GetPlugins()->Gfx();
if (GfxPlugin->SurfaceCreated != NULL)
{
GfxPlugin->SurfaceCreated();
}
}
if (g_SyncSystem != NULL && g_SyncSystem->GetPlugins() != NULL && g_SyncSystem->GetPlugins()->Gfx() != NULL)
{
CGfxPlugin * GfxPlugin = g_SyncSystem->GetPlugins()->Gfx();
if (GfxPlugin->SurfaceCreated != NULL)
{
GfxPlugin->SurfaceCreated();
}
}
WriteTrace(TraceUserInterface, TraceDebug, "Done");
}
@ -291,9 +309,21 @@ EXPORT void CALL Java_emu_project64_jni_NativeExports_onSurfaceCreated(JNIEnv *
EXPORT void CALL Java_emu_project64_jni_NativeExports_onSurfaceChanged(JNIEnv * env, jclass cls, jint width, jint height)
{
WriteTrace(TraceUserInterface, TraceDebug, "Start");
if (g_Plugins != NULL && g_Plugins->Gfx() != NULL && g_Plugins->Gfx()->SurfaceChanged)
if (g_BaseSystem != NULL && g_BaseSystem->GetPlugins() != NULL && g_BaseSystem->GetPlugins()->Gfx() != NULL)
{
g_Plugins->Gfx()->SurfaceChanged(width,height);
CGfxPlugin * GfxPlugin = g_BaseSystem->GetPlugins()->Gfx();
if (GfxPlugin->SurfaceChanged != NULL)
{
GfxPlugin->SurfaceChanged(width,height);
}
}
if (g_SyncSystem != NULL && g_SyncSystem->GetPlugins() != NULL && g_SyncSystem->GetPlugins()->Gfx() != NULL)
{
CGfxPlugin * GfxPlugin = g_SyncSystem->GetPlugins()->Gfx();
if (GfxPlugin->SurfaceChanged != NULL)
{
GfxPlugin->SurfaceChanged(width,height);
}
}
WriteTrace(TraceUserInterface, TraceDebug, "Done");
}
@ -341,7 +371,7 @@ EXPORT void CALL Java_emu_project64_jni_NativeExports_StartEmulation(JNIEnv* env
EXPORT void CALL Java_emu_project64_jni_NativeExports_CloseSystem(JNIEnv* env, jclass cls)
{
WriteTrace(TraceUserInterface, TraceDebug, "Start");
CN64System::CloseSystem();
g_BaseSystem->EndEmulation();
WriteTrace(TraceUserInterface, TraceDebug, "Done");
}