Merge pull request #393 from lioncash/master

[Android] Get rid of the RetroTVMode class.
This commit is contained in:
Squarepusher 2013-11-19 18:09:53 -08:00
commit 7464ae6824
3 changed files with 25 additions and 54 deletions

View File

@ -3,11 +3,9 @@
android:title="@string/mainmenu_title" >
<!-- TV Mode -->
<Preference android:title="@string/tv_mode">
<intent
android:targetClass="com.retroarch.browser.RetroTVMode"
android:targetPackage="com.retroarch" />
</Preference>
<Preference
android:key="retroTVMode"
android:title="@string/tv_mode"/>
<!-- Load Core -->
<Preference

View File

@ -1,42 +0,0 @@
package com.retroarch.browser;
import com.retroarch.browser.preferences.util.UserPreferences;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.provider.Settings;
/**
* The {@link Activity} derivative responsible for displaying the TV Mode feature.
*/
public final class RetroTVMode extends Activity
{
// Need to do this wonky logic as we have to keep this activity alive until
// RetroArch is done running.
// Have to readback config right after RetroArch has run to avoid potential
// broken config state.
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
if (savedInstanceState == null || !savedInstanceState.getBoolean("started", false))
{
UserPreferences.updateConfigFile(this);
Intent myIntent = new Intent(this, RetroActivity.class);
String current_ime = Settings.Secure.getString(getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD);
myIntent.putExtra("CONFIGFILE", UserPreferences.getDefaultConfigPath(this));
myIntent.putExtra("IME", current_ime);
startActivity(myIntent);
finish();
}
}
@Override
protected void onSaveInstanceState(Bundle savedInstanceState)
{
savedInstanceState.putBoolean("started", true);
}
}

View File

@ -55,6 +55,7 @@ public final class MainMenuFragment extends PreferenceListFragment implements On
addPreferencesFromResource(R.xml.main_menu);
// Set the listeners for the menu items
findPreference("retroTVMode").setOnPreferenceClickListener(this);
findPreference("loadCorePref").setOnPreferenceClickListener(this);
findPreference("loadRomPref").setOnPreferenceClickListener(this);
findPreference("loadRomHistoryPref").setOnPreferenceClickListener(this);
@ -328,8 +329,22 @@ public final class MainMenuFragment extends PreferenceListFragment implements On
{
final String prefKey = preference.getKey();
// TV Mode
if (prefKey.equals("retroTVMode"))
{
UserPreferences.updateConfigFile(ctx);
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx);
final String libretro_path = prefs.getString("libretro_path", "");
final Intent rgui = new Intent(ctx, RetroActivity.class);
final String current_ime = Settings.Secure.getString(ctx.getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD);
rgui.putExtra("LIBRETRO", libretro_path);
rgui.putExtra("CONFIGFILE", UserPreferences.getDefaultConfigPath(ctx));
rgui.putExtra("IME", current_ime);
startActivity(rgui);
}
// Load Core Preference
if (prefKey.equals("loadCorePref"))
else if (prefKey.equals("loadCorePref"))
{
final CoreSelection coreSelection = new CoreSelection();
coreSelection.show(getFragmentManager(), "core_selection");
@ -376,11 +391,11 @@ 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 myIntent = new Intent(ctx, RetroActivity.class);
myIntent.putExtra("ROM", path);
myIntent.putExtra("LIBRETRO", libretro_path);
myIntent.putExtra("CONFIGFILE", UserPreferences.getDefaultConfigPath(ctx));
myIntent.putExtra("IME", current_ime);
startActivity(myIntent);
Intent retro = new Intent(ctx, RetroActivity.class);
retro.putExtra("ROM", path);
retro.putExtra("LIBRETRO", libretro_path);
retro.putExtra("CONFIGFILE", UserPreferences.getDefaultConfigPath(ctx));
retro.putExtra("IME", current_ime);
startActivity(retro);
}
}