mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-28 02:30:35 +00:00
(Android) PendingIntent code created bad dependencies on Java frontend and
made it impossible for external clients like Dinothawr to use RetroArch as a library
This commit is contained in:
parent
b5ea9b4eb9
commit
b20b6525d3
@ -265,12 +265,14 @@ static void *android_input_init(void)
|
||||
if (!class)
|
||||
goto retobj;
|
||||
|
||||
#if 0
|
||||
GET_METHOD_ID(env, android->onBackPressed, class, "onBackPressed", "()V");
|
||||
if (!android->onBackPressed)
|
||||
{
|
||||
RARCH_ERR("Could not set onBackPressed JNI function pointer.\n");
|
||||
goto retobj;
|
||||
}
|
||||
#endif
|
||||
|
||||
retobj:
|
||||
return android;
|
||||
@ -1773,6 +1775,7 @@ static void android_input_poll(void *data)
|
||||
AInputQueue_finishEvent(android_app->inputQueue, event, handled);
|
||||
break;
|
||||
}
|
||||
#if 0
|
||||
else if (android->onBackPressed && g_settings.input.back_behavior == BACK_BUTTON_MENU_TOGGLE)
|
||||
{
|
||||
RARCH_LOG("Invoke onBackPressed through JNI.\n");
|
||||
@ -1782,6 +1785,7 @@ static void android_input_poll(void *data)
|
||||
CALL_VOID_METHOD(env, android_app->activity->clazz, android->onBackPressed);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (type_event == AINPUT_EVENT_TYPE_MOTION)
|
||||
|
@ -1,94 +1,12 @@
|
||||
package com.retroarch.browser.retroactivity;
|
||||
|
||||
import com.retroarch.browser.mainmenu.MainMenuActivity;
|
||||
import com.retroarch.browser.preferences.util.UserPreferences;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
* Class which provides common methods for RetroActivity related classes.
|
||||
*/
|
||||
public class RetroActivityCommon extends RetroActivityLocation
|
||||
{
|
||||
private Intent pendingIntent = null;
|
||||
|
||||
@Override
|
||||
public void onNewIntent(Intent intent)
|
||||
{
|
||||
Log.i("RetroActivity", "onNewIntent invoked.");
|
||||
super.onNewIntent(intent);
|
||||
setIntent(intent);
|
||||
pendingIntent = intent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the ROM file specified in the pending intent.
|
||||
*
|
||||
* @return the ROM file specified in the pending intent.
|
||||
*/
|
||||
public String getPendingIntentFullPath()
|
||||
{
|
||||
return pendingIntent.getStringExtra("ROM");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the specified path to the libretro core in the pending intent.
|
||||
*
|
||||
* @return the specified path to the libretro core in the pending intent.
|
||||
*/
|
||||
public String getPendingIntentLibretroPath()
|
||||
{
|
||||
return pendingIntent.getStringExtra("LIBRETRO");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the path specified in the pending intent to the retroarch cfg file.
|
||||
*
|
||||
* @return the path specified in the pending intent to the retroarch cfg file.
|
||||
*/
|
||||
public String getPendingIntentConfigPath()
|
||||
{
|
||||
return pendingIntent.getStringExtra("CONFIGFILE");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the specified IME in the pending intent.
|
||||
*
|
||||
* @return the specified IME in the pending intent.
|
||||
*/
|
||||
public String getPendingIntentIME()
|
||||
{
|
||||
return pendingIntent.getStringExtra("IME");
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether or not a pending intent exists.
|
||||
*
|
||||
* @return true if a pending intent exists, false otherwise.
|
||||
*/
|
||||
public boolean hasPendingIntent()
|
||||
{
|
||||
if (pendingIntent == null)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the current pending intent.
|
||||
*/
|
||||
public void clearPendingIntent()
|
||||
{
|
||||
pendingIntent = null;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* MISC
|
||||
* Other RetroArch functions
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void onDestroy()
|
||||
{
|
||||
@ -104,23 +22,4 @@ public class RetroActivityCommon extends RetroActivityLocation
|
||||
public void onTrimMemory(int level)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed()
|
||||
{
|
||||
Log.i("RetroActivity", "onBackKeyPressed");
|
||||
Intent retro = new Intent(this, MainMenuActivity.class);
|
||||
retro.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
startActivity(retro);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current Android version being used on a device.
|
||||
*
|
||||
* @return the current Android version.
|
||||
*/
|
||||
public int getAndroidOSVersion()
|
||||
{
|
||||
return android.os.Build.VERSION.SDK_INT;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,89 @@
|
||||
package com.retroarch.browser.retroactivity;
|
||||
|
||||
import com.retroarch.browser.mainmenu.MainMenuActivity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
|
||||
public class RetroActivityIntent extends RetroActivityCommon {
|
||||
private Intent pendingIntent = null;
|
||||
|
||||
@Override
|
||||
public void onBackPressed()
|
||||
{
|
||||
Log.i("RetroActivity", "onBackKeyPressed");
|
||||
Intent retro = new Intent(this, MainMenuActivity.class);
|
||||
retro.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
startActivity(retro);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNewIntent(Intent intent)
|
||||
{
|
||||
Log.i("RetroActivity", "onNewIntent invoked.");
|
||||
super.onNewIntent(intent);
|
||||
setIntent(intent);
|
||||
pendingIntent = intent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the ROM file specified in the pending intent.
|
||||
*
|
||||
* @return the ROM file specified in the pending intent.
|
||||
*/
|
||||
public String getPendingIntentFullPath()
|
||||
{
|
||||
return pendingIntent.getStringExtra("ROM");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the specified path to the libretro core in the pending intent.
|
||||
*
|
||||
* @return the specified path to the libretro core in the pending intent.
|
||||
*/
|
||||
public String getPendingIntentLibretroPath()
|
||||
{
|
||||
return pendingIntent.getStringExtra("LIBRETRO");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the path specified in the pending intent to the retroarch cfg file.
|
||||
*
|
||||
* @return the path specified in the pending intent to the retroarch cfg file.
|
||||
*/
|
||||
public String getPendingIntentConfigPath()
|
||||
{
|
||||
return pendingIntent.getStringExtra("CONFIGFILE");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the specified IME in the pending intent.
|
||||
*
|
||||
* @return the specified IME in the pending intent.
|
||||
*/
|
||||
public String getPendingIntentIME()
|
||||
{
|
||||
return pendingIntent.getStringExtra("IME");
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether or not a pending intent exists.
|
||||
*
|
||||
* @return true if a pending intent exists, false otherwise.
|
||||
*/
|
||||
public boolean hasPendingIntent()
|
||||
{
|
||||
if (pendingIntent == null)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the current pending intent.
|
||||
*/
|
||||
public void clearPendingIntent()
|
||||
{
|
||||
pendingIntent = null;
|
||||
}
|
||||
}
|
@ -463,6 +463,7 @@ static void get_environment_settings(int argc, char *argv[], void *data)
|
||||
|
||||
static void process_pending_intent(void *data)
|
||||
{
|
||||
#if 0
|
||||
RARCH_LOG("process_pending_intent.\n");
|
||||
JNIEnv *env;
|
||||
struct android_app* android_app = (struct android_app*)data;
|
||||
@ -546,17 +547,19 @@ static void process_pending_intent(void *data)
|
||||
}
|
||||
|
||||
CALL_VOID_METHOD(env, android_app->activity->clazz, android_app->clearPendingIntent);
|
||||
#endif
|
||||
}
|
||||
|
||||
static int process_events(void *data)
|
||||
{
|
||||
jboolean hasPendingIntent;
|
||||
JNIEnv *env;
|
||||
//jboolean hasPendingIntent;
|
||||
//JNIEnv *env;
|
||||
struct android_app* android_app = (struct android_app*)data;
|
||||
|
||||
if (input_key_pressed_func(RARCH_PAUSE_TOGGLE))
|
||||
android_run_events(android_app);
|
||||
|
||||
#if 0
|
||||
env = jni_thread_getenv();
|
||||
if (!env)
|
||||
return -1;
|
||||
@ -564,6 +567,7 @@ static int process_events(void *data)
|
||||
CALL_BOOLEAN_METHOD(env, hasPendingIntent, android_app->activity->clazz, android_app->hasPendingIntent);
|
||||
if (hasPendingIntent)
|
||||
process_pending_intent(android_app);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -607,6 +611,7 @@ static void system_init(void *data)
|
||||
GET_OBJECT_CLASS(env, class, android_app->activity->clazz);
|
||||
GET_METHOD_ID(env, android_app->getIntent, class, "getIntent", "()Landroid/content/Intent;");
|
||||
CALL_OBJ_METHOD(env, obj, android_app->activity->clazz, android_app->getIntent);
|
||||
#if 0
|
||||
GET_METHOD_ID(env, android_app->hasPendingIntent, class, "hasPendingIntent", "()Z");
|
||||
GET_METHOD_ID(env, android_app->clearPendingIntent, class, "clearPendingIntent", "()V");
|
||||
GET_METHOD_ID(env, android_app->getPendingIntentConfigPath, class, "getPendingIntentConfigPath",
|
||||
@ -617,6 +622,7 @@ static void system_init(void *data)
|
||||
"()Ljava/lang/String;");
|
||||
GET_METHOD_ID(env, android_app->getPendingIntentIME, class, "getPendingIntentIME",
|
||||
"()Ljava/lang/String;");
|
||||
#endif
|
||||
|
||||
GET_OBJECT_CLASS(env, class, obj);
|
||||
GET_METHOD_ID(env, android_app->getStringExtra, class, "getStringExtra", "(Ljava/lang/String;)Ljava/lang/String;");
|
||||
|
Loading…
Reference in New Issue
Block a user