From 0bbd9699b44cf07050bac837b98dd144581d4f75 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 14 Aug 2013 04:27:44 +0200 Subject: [PATCH] (Android Phoenix) TV Mode now loads the config file --- .../org/retroarch/browser/RetroTVMode.java | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/android/phoenix/src/org/retroarch/browser/RetroTVMode.java b/android/phoenix/src/org/retroarch/browser/RetroTVMode.java index a2ee4372e3..e69445b5e9 100644 --- a/android/phoenix/src/org/retroarch/browser/RetroTVMode.java +++ b/android/phoenix/src/org/retroarch/browser/RetroTVMode.java @@ -1,16 +1,48 @@ package org.retroarch.browser; +import java.io.File; + import android.app.Activity; -import android.app.AlertDialog; import android.content.Intent; import android.os.Bundle; import android.provider.Settings; public class RetroTVMode extends Activity { + private String getDefaultConfigPath() { + String internal = System.getenv("INTERNAL_STORAGE"); + String external = System.getenv("EXTERNAL_STORAGE"); + + if (external != null) { + String confPath = external + File.separator + "retroarch.cfg"; + if (new File(confPath).exists()) + return confPath; + } else if (internal != null) { + String confPath = internal + File.separator + "retroarch.cfg"; + if (new File(confPath).exists()) + return confPath; + } else { + String confPath = "/mnt/extsd/retroarch.cfg"; + if (new File(confPath).exists()) + return confPath; + } + + if (internal != null && new File(internal + File.separator + "retroarch.cfg").canWrite()) + return internal + File.separator + "retroarch.cfg"; + else if (external != null && new File(internal + File.separator + "retroarch.cfg").canWrite()) + return external + File.separator + "retroarch.cfg"; + else if ((getApplicationInfo().dataDir) != null) + return (getApplicationInfo().dataDir) + File.separator + "retroarch.cfg"; + else // emergency fallback, all else failed + return "/mnt/sd/retroarch.cfg"; + } + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent myIntent = new Intent(this, RetroActivity.class); + String current_ime = Settings.Secure.getString(getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD); + myIntent.putExtra("CONFIGFILE", getDefaultConfigPath()); + myIntent.putExtra("IME", current_ime); startActivity(myIntent); finish(); }