(Android) Should be backwards compatible with Android 2.3.x again -

2.3.x now uses RetroActivityPast
This commit is contained in:
twinaphex 2013-11-29 01:35:56 +01:00
parent 03ca0d89b2
commit 98ca741ca0
5 changed files with 147 additions and 6 deletions

View File

@ -30,7 +30,11 @@
<activity android:name="com.retroarch.browser.preferences.PreferenceActivity" android:theme="@style/Theme.AppCompat" />
<activity android:name="com.retroarch.browser.coremanager.CoreManagerActivity" android:theme="@style/Theme.AppCompat"/>
<activity android:name="com.retroarch.browser.RetroActivity" android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:launchMode="singleInstance">
<activity android:name="com.retroarch.browser.RetroActivityFuture" android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:launchMode="singleInstance">
<meta-data android:name="android.app.lib_name" android:value="retroarch-activity" />
<meta-data android:name="android.app.func_name" android:value="ANativeActivity_onCreate" />
</activity>
<activity android:name="com.retroarch.browser.RetroActivityPast" android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:launchMode="singleInstance">
<meta-data android:name="android.app.lib_name" android:value="retroarch-activity" />
<meta-data android:name="android.app.func_name" android:value="ANativeActivity_onCreate" />
</activity>

View File

@ -11,6 +11,7 @@ import com.retroarch.browser.mainmenu.MainMenuActivity;
import com.retroarch.browser.preferences.util.UserPreferences;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.provider.Settings;
import android.support.v4.app.DialogFragment;
@ -32,6 +33,15 @@ public final class HistorySelection extends DialogFragment
{
private FragmentActivity ctx;
private IconAdapter<HistoryWrapper> adapter;
public Intent getRetroActivity()
{
if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB))
{
return new Intent(ctx, RetroActivityFuture.class);
}
return new Intent(ctx, RetroActivityPast.class);
}
/**
* Creates a statically instantiated instance of HistorySelection.
@ -111,7 +121,7 @@ public final class HistorySelection extends DialogFragment
String current_ime = Settings.Secure.getString(ctx.getContentResolver(),
Settings.Secure.DEFAULT_INPUT_METHOD);
Toast.makeText(ctx, String.format(getString(R.string.loading_gamepath), gamePath), Toast.LENGTH_SHORT).show();
Intent retro = new Intent(ctx, RetroActivity.class);
Intent retro = getRetroActivity();
retro.putExtra("ROM", gamePath);
retro.putExtra("LIBRETRO", corePath);
retro.putExtra("CONFIGFILE", UserPreferences.getDefaultConfigPath(ctx));

View File

@ -13,7 +13,9 @@ import android.hardware.Camera;
import android.os.Build;
import android.util.Log;
public final class RetroActivity extends NativeActivity
//For Android 3.0 and up
public final class RetroActivityFuture extends NativeActivity
{
private Camera mCamera;
private long lastTimestamp = 0;

View File

@ -0,0 +1,115 @@
package com.retroarch.browser;
import java.io.IOException;
import com.retroarch.browser.mainmenu.MainMenuActivity;
import com.retroarch.browser.preferences.util.UserPreferences;
import android.annotation.SuppressLint;
import android.app.NativeActivity;
import android.content.Intent;
import android.util.Log;
// For Android 2.3.x
public final class RetroActivityPast extends NativeActivity
{
private Intent pendingIntent = null;
public void onCameraStart()
{
}
public void onCameraStop()
{
}
public void onCameraInit()
{
}
public boolean onCameraPoll()
{
return false;
}
public void onCameraFree()
{
}
@SuppressLint("NewApi")
public void onCameraTextureInit(int gl_texid)
{
}
@SuppressLint("NewApi")
public void onCameraSetTexture(int gl_texid) throws IOException
{
}
@Override
public void onDestroy()
{
UserPreferences.readbackConfigFile(this);
}
@Override
public void onLowMemory()
{
}
@Override
public void onTrimMemory(int level)
{
}
@Override
public void onNewIntent(Intent intent)
{
Log.i("RetroActivity", "onNewIntent invoked.");
super.onNewIntent(intent);
setIntent(intent);
pendingIntent = intent;
}
public String getPendingIntentFullPath()
{
return pendingIntent.getStringExtra("ROM");
}
public String getPendingIntentLibretroPath()
{
return pendingIntent.getStringExtra("LIBRETRO");
}
public String getPendingIntentConfigPath()
{
return pendingIntent.getStringExtra("CONFIGFILE");
}
public String getPendingIntentIME()
{
return pendingIntent.getStringExtra("IME");
}
public boolean hasPendingIntent()
{
if (pendingIntent == null)
return false;
return true;
}
public void clearPendingIntent()
{
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);
}
}

View File

@ -28,7 +28,8 @@ import com.retroarch.R;
import com.retroarch.browser.CoreSelection;
import com.retroarch.browser.HistorySelection;
import com.retroarch.browser.NativeInterface;
import com.retroarch.browser.RetroActivity;
import com.retroarch.browser.RetroActivityFuture;
import com.retroarch.browser.RetroActivityPast;
import com.retroarch.browser.dirfragment.DirectoryFragment;
import com.retroarch.browser.dirfragment.DirectoryFragment.OnDirectoryFragmentClosedListener;
import com.retroarch.browser.mainmenu.gplwaiver.GPLWaiverDialogFragment;
@ -42,6 +43,15 @@ public final class MainMenuFragment extends PreferenceListFragment implements On
{
private static final String TAG = "MainMenuFragment";
private Context ctx;
public Intent getRetroActivity()
{
if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB))
{
return new Intent(ctx, RetroActivityFuture.class);
}
return new Intent(ctx, RetroActivityPast.class);
}
@Override
public void onCreate(Bundle savedInstanceState)
@ -337,8 +347,8 @@ public final class MainMenuFragment extends PreferenceListFragment implements On
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx);
final String libretro_path = prefs.getString("libretro_path", ctx.getApplicationInfo().dataDir + "/cores");
final Intent retro = new Intent(ctx, RetroActivity.class);
final String current_ime = Settings.Secure.getString(ctx.getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD);
final Intent retro = getRetroActivity();
retro.putExtra("LIBRETRO", libretro_path);
retro.putExtra("CONFIGFILE", UserPreferences.getDefaultConfigPath(ctx));
retro.putExtra("IME", current_ime);
@ -397,7 +407,7 @@ public final class MainMenuFragment extends PreferenceListFragment implements On
UserPreferences.updateConfigFile(ctx);
String current_ime = Settings.Secure.getString(ctx.getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD);
Toast.makeText(ctx, String.format(getString(R.string.loading_data), path), Toast.LENGTH_SHORT).show();
Intent retro = new Intent(ctx, RetroActivity.class);
Intent retro = getRetroActivity();
retro.putExtra("ROM", path);
retro.putExtra("LIBRETRO", libretro_path);
retro.putExtra("CONFIGFILE", UserPreferences.getDefaultConfigPath(ctx));