(Android frontend) Refactor RetroActivity launching

This commit is contained in:
twinaphex 2014-06-13 05:48:13 +02:00
parent d255dea771
commit d6486df835
3 changed files with 43 additions and 25 deletions

View File

@ -8,6 +8,7 @@ import java.io.InputStreamReader;
import com.retroarch.R;
import com.retroarch.browser.mainmenu.MainMenuActivity;
import com.retroarch.browser.mainmenu.MainMenuFragment;
import com.retroarch.browser.preferences.util.UserPreferences;
import com.retroarch.browser.retroactivity.RetroActivityFuture;
import com.retroarch.browser.retroactivity.RetroActivityPast;
@ -104,6 +105,7 @@ public final class HistorySelection extends DialogFragment
return rootView;
}
private final OnItemClickListener onItemClickListener = new OnItemClickListener()
{
@Override
@ -124,11 +126,12 @@ public final class HistorySelection extends DialogFragment
Settings.Secure.DEFAULT_INPUT_METHOD);
Toast.makeText(ctx, String.format(getString(R.string.loading_gamepath), gamePath), Toast.LENGTH_SHORT).show();
Intent retro = getRetroActivity();
retro.putExtra("ROM", gamePath);
retro.putExtra("LIBRETRO", corePath);
retro.putExtra("CONFIGFILE", UserPreferences.getDefaultConfigPath(ctx));
retro.putExtra("IME", current_ime);
retro.putExtra("DATADIR", getActivity().getApplicationInfo().dataDir);
MainMenuFragment.startRetroActivity(retro,
gamePath,
corePath,
UserPreferences.getDefaultConfigPath(ctx),
current_ime,
getActivity().getApplicationInfo().dataDir);
startActivity(retro);
dismiss();
}

View File

@ -29,6 +29,7 @@ import com.retroarch.R;
import com.retroarch.browser.FileWrapper;
import com.retroarch.browser.IconAdapter;
import com.retroarch.browser.ModuleWrapper;
import com.retroarch.browser.mainmenu.MainMenuFragment;
import com.retroarch.browser.preferences.util.UserPreferences;
import com.retroarch.browser.retroactivity.RetroActivityFuture;
import com.retroarch.browser.retroactivity.RetroActivityPast;
@ -275,12 +276,13 @@ public final class DetectCoreDirectoryFragment extends DirectoryFragment
retro = new Intent(getActivity(), RetroActivityPast.class);
UserPreferences.updateConfigFile(getActivity());
String current_ime = Settings.Secure.getString(getActivity().getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD);
retro.putExtra("ROM", contentPath);
retro.putExtra("LIBRETRO", corePath);
retro.putExtra("CONFIGFILE", UserPreferences.getDefaultConfigPath(getActivity()));
retro.putExtra("IME", current_ime);
retro.putExtra("DATADIR", getActivity().getApplicationInfo().dataDir);
MainMenuFragment.startRetroActivity(
retro,
contentPath,
corePath,
UserPreferences.getDefaultConfigPath(getActivity()),
Settings.Secure.getString(getActivity().getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD),
getActivity().getApplicationInfo().dataDir);
startActivity(retro);
dismiss();
}

View File

@ -209,15 +209,16 @@ public final class MainMenuFragment extends PreferenceListFragment implements On
if (prefKey.equals("resumeContentPref"))
{
UserPreferences.updateConfigFile(ctx);
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx);
final String libretro_path = prefs.getString("libretro_path", ctx.getApplicationInfo().dataDir + "/cores");
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);
retro.putExtra("DATADIR", ctx.getApplicationInfo().dataDir);
MainMenuFragment.startRetroActivity(
retro,
null,
prefs.getString("libretro_path", ctx.getApplicationInfo().dataDir + "/cores"),
UserPreferences.getDefaultConfigPath(ctx),
Settings.Secure.getString(ctx.getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD),
ctx.getApplicationInfo().dataDir);
startActivity(retro);
}
// Load Core Preference
@ -281,17 +282,29 @@ public final class MainMenuFragment extends PreferenceListFragment implements On
public void onDirectoryFragmentClosed(String path)
{
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx);
final String libretro_path = prefs.getString("libretro_path", "");
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 = getRetroActivity();
retro.putExtra("ROM", path);
retro.putExtra("LIBRETRO", libretro_path);
retro.putExtra("CONFIGFILE", UserPreferences.getDefaultConfigPath(ctx));
retro.putExtra("IME", current_ime);
retro.putExtra("DATADIR", ctx.getApplicationInfo().dataDir);
MainMenuFragment.startRetroActivity(
retro,
path,
prefs.getString("libretro_path", ""),
UserPreferences.getDefaultConfigPath(ctx),
Settings.Secure.getString(ctx.getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD),
ctx.getApplicationInfo().dataDir);
startActivity(retro);
}
public static void startRetroActivity(Intent retro, String contentPath, String corePath,
String configFilePath, String imePath, String dataDirPath)
{
if (contentPath != null) {
retro.putExtra("ROM", contentPath);
}
retro.putExtra("LIBRETRO", corePath);
retro.putExtra("CONFIGFILE", configFilePath);
retro.putExtra("IME", imePath);
retro.putExtra("DATADIR", dataDirPath);
}
}