diff --git a/android/phoenix/.project b/android/phoenix/.project index 1a51a6a5da..4af1961cac 100644 --- a/android/phoenix/.project +++ b/android/phoenix/.project @@ -1,6 +1,6 @@ - Retroarch + RetroArch diff --git a/android/phoenix/AndroidManifest.xml b/android/phoenix/AndroidManifest.xml index 7cafe349de..e52cc668db 100644 --- a/android/phoenix/AndroidManifest.xml +++ b/android/phoenix/AndroidManifest.xml @@ -13,7 +13,7 @@ android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" > - + @@ -22,12 +22,18 @@ + + + + + + + + - + - - \ No newline at end of file diff --git a/android/phoenix/res/xml/prefs.xml b/android/phoenix/res/xml/prefs.xml index fef1179bd3..f63c7088a8 100644 --- a/android/phoenix/res/xml/prefs.xml +++ b/android/phoenix/res/xml/prefs.xml @@ -21,6 +21,16 @@ android:key="video_smooth" android:summary="Applies bilinear filter, smooths out edges" android:title="Bilinear filter" /> + + + + + backStack; + + protected String startDirectory; + protected String pathSettingKey; + + protected void setStartDirectory(String path) { + startDirectory = path; + } + + protected void setPathSettingKey(String key) { + pathSettingKey = key; + } @Override public void onCreate(Bundle savedInstanceState) { @@ -126,8 +138,9 @@ public class DirectoryActivity extends Activity implements if (backStack == null || backStack.size() == 0) { backStack = new ArrayList(); - backStack.add(new BackStackItem(Environment - .getExternalStorageDirectory().getPath(), false)); + String startPath = (startDirectory == null || startDirectory.isEmpty()) ? Environment + .getExternalStorageDirectory().getPath() : startDirectory; + backStack.add(new BackStackItem(startPath, false)); } wrapFiles(); @@ -159,7 +172,16 @@ public class DirectoryActivity extends Activity implements wrapFiles(); } else { Intent intent = new Intent(); - intent.putExtra("PATH", selected.getAbsolutePath()); + String filePath = selected.getAbsolutePath(); + + if (pathSettingKey != null && !pathSettingKey.isEmpty()) { + SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); + SharedPreferences.Editor editor = settings.edit(); + editor.putString(pathSettingKey, filePath); + editor.commit(); + } + + intent.putExtra("PATH", filePath); setResult(RESULT_OK, intent); finish(); } @@ -181,6 +203,41 @@ public class DirectoryActivity extends Activity implements return super.onKeyDown(keyCode, event); } + + private ArrayList allowedExt; + private ArrayList disallowedExt; + + private boolean filterPath(String path) { + if (disallowedExt != null) { + for (String ext : disallowedExt) + if (path.endsWith(ext)) + return false; + } + + if (allowedExt != null) { + for (String ext : allowedExt) + if (path.endsWith(ext)) + return true; + + return false; + } + + return true; + } + + protected void addAllowedExt(String ext) { + if (allowedExt == null) + allowedExt = new ArrayList(); + + allowedExt.add(ext); + } + + protected void addDisallowedExt(String ext) { + if (disallowedExt == null) + disallowedExt = new ArrayList(); + + disallowedExt.add(ext); + } private void wrapFiles() { listedDirectory = new File(backStack.get(backStack.size() - 1).path); @@ -202,16 +259,12 @@ public class DirectoryActivity extends Activity implements for (File file : files) { String path = file.getName(); - boolean isRomFile = !path.endsWith(".srm") - && !path.endsWith(".state") - && !path.contains(".state.auto") - && !path.endsWith(".rtc"); + boolean allowFile = filterPath(path); // Don't list save files in ROM list. - if (isRomFile) { + if (allowFile) adapter.add(new FileWrapper(file, false, file.isDirectory() || true)); - } } } diff --git a/android/phoenix/src/org/retroarch/browser/ROMActivity.java b/android/phoenix/src/org/retroarch/browser/ROMActivity.java new file mode 100644 index 0000000000..c46a2c7b73 --- /dev/null +++ b/android/phoenix/src/org/retroarch/browser/ROMActivity.java @@ -0,0 +1,14 @@ +package org.retroarch.browser; + +import android.os.Bundle; + +public class ROMActivity extends DirectoryActivity { + @Override + public void onCreate(Bundle savedInstanceState) { + super.addDisallowedExt(".state"); + super.addDisallowedExt(".srm"); + super.addDisallowedExt(".state.auto"); + super.addDisallowedExt(".rtc"); + super.onCreate(savedInstanceState); + } +} diff --git a/android/phoenix/src/org/retroarch/browser/ModuleActivity.java b/android/phoenix/src/org/retroarch/browser/RetroArch.java similarity index 94% rename from android/phoenix/src/org/retroarch/browser/ModuleActivity.java rename to android/phoenix/src/org/retroarch/browser/RetroArch.java index c9d12d5bdc..b768ec2c6b 100644 --- a/android/phoenix/src/org/retroarch/browser/ModuleActivity.java +++ b/android/phoenix/src/org/retroarch/browser/RetroArch.java @@ -43,7 +43,7 @@ class ModuleWrapper implements IconAdapterItem { } } -public class ModuleActivity extends Activity implements +public class RetroArch extends Activity implements AdapterView.OnItemClickListener, PopupMenu.OnMenuItemClickListener { private IconAdapter adapter; static private final int ACTIVITY_LOAD_ROM = 0; @@ -101,7 +101,7 @@ public class ModuleActivity extends Activity implements libretro_path = item.file.getAbsolutePath(); Intent myIntent; - myIntent = new Intent(this, DirectoryActivity.class); + myIntent = new Intent(this, ROMActivity.class); startActivityForResult(myIntent, ACTIVITY_LOAD_ROM); } @@ -157,6 +157,15 @@ public class ModuleActivity extends Activity implements config.setBoolean("video_force_aspect", true); config.setDouble("video_aspect_ratio", aspect_ratio); } + + String shaderPath = prefs.getString("video_bsnes_shader", ""); + if (new File(shaderPath).exists()) { + config.setString("video_shader_type", "bsnes"); + config.setString("video_bsnes_shader", shaderPath); + } else { + config.setString("video_shader_type", "none"); + config.setString("video_bsnes_shader", ""); + } String confPath = getDefaultConfigPath(); try { diff --git a/android/phoenix/src/org/retroarch/browser/ShaderActivity.java b/android/phoenix/src/org/retroarch/browser/ShaderActivity.java new file mode 100644 index 0000000000..02062f4830 --- /dev/null +++ b/android/phoenix/src/org/retroarch/browser/ShaderActivity.java @@ -0,0 +1,12 @@ +package org.retroarch.browser; + +import android.os.Bundle; + +public class ShaderActivity extends DirectoryActivity { + @Override + public void onCreate(Bundle savedInstanceState) { + super.addAllowedExt(".shader"); + super.setPathSettingKey("video_bsnes_shader"); + super.onCreate(savedInstanceState); + } +}