Start adding path settings.

This commit is contained in:
Themaister 2013-01-04 15:57:37 +01:00
parent d4020330d5
commit 100f5ac947
7 changed files with 120 additions and 16 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Retroarch</name>
<name>RetroArch</name>
<comment></comment>
<projects>
</projects>

View File

@ -13,7 +13,7 @@
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity android:name="org.retroarch.browser.ModuleActivity">
<activity android:name="org.retroarch.browser.RetroArch">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
@ -22,12 +22,18 @@
<activity android:name="org.retroarch.browser.SettingsActivity"></activity>
<activity android:name="org.retroarch.browser.DirectoryActivity"></activity>
<activity android:name="org.retroarch.browser.ROMActivity"></activity>
<activity android:name="org.retroarch.browser.ShaderActivity">
<intent-filter>
<action android:name="org.retroarch.action.ShaderSelect" />
<category android:name="android.intent.category.PREFERENCE" />
</intent-filter>
</activity>
<activity android:name="android.app.NativeActivity" android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale">
<meta-data android:name="android.app.lib_name" android:value="retroarch-activity" />
<meta-data android:name="android.app.func_name" android:value="ANativeActivity_onCreate" />
<meta-data android:name="android.app.func_name" android:value="ANativeActivity_onCreate" />
</activity>
</application>
</manifest>

View File

@ -21,6 +21,16 @@
android:key="video_smooth"
android:summary="Applies bilinear filter, smooths out edges"
android:title="Bilinear filter" />
<Preference
android:title="XML shader"
android:summary="Sets GLES2 style XML shader">
<intent
android:action="org.retroarch.action.ShaderSelect"
android:targetPackage="org.retroarch"
android:targetClass="org.retroarch.ShaderActivity" />
</Preference>
<CheckBoxPreference
android:defaultValue="true"
android:key="video_vsync"

View File

@ -8,6 +8,7 @@ import java.io.*;
import android.content.*;
import android.app.*;
import android.os.*;
import android.preference.PreferenceManager;
import android.widget.*;
import android.view.*;
import android.graphics.drawable.*;
@ -107,6 +108,17 @@ public class DirectoryActivity extends Activity implements
}
private ArrayList<BackStackItem> 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<BackStackItem>();
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<String> allowedExt;
private ArrayList<String> 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<String>();
allowedExt.add(ext);
}
protected void addDisallowedExt(String ext) {
if (disallowedExt == null)
disallowedExt = new ArrayList<String>();
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));
}
}
}

View File

@ -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);
}
}

View File

@ -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<ModuleWrapper> 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 {

View File

@ -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);
}
}