mirror of
https://github.com/libretro/RetroArch
synced 2025-03-23 19:21:03 +00:00
(Android) Add new frontend for easier install and use.
This commit is contained in:
parent
fa2b716d5e
commit
fca88c4bd0
9
android/andretro/.classpath
Normal file
9
android/andretro/.classpath
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="gen"/>
|
||||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
|
||||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
|
||||
<classpathentry kind="lib" path="libs/android-support-v4.jar"/>
|
||||
<classpathentry kind="output" path="bin/classes"/>
|
||||
</classpath>
|
5
android/andretro/.gitignore
vendored
Normal file
5
android/andretro/.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
/gen
|
||||
/bin
|
||||
/libs/*/*
|
||||
/obj
|
||||
/jni/modules/*.so
|
33
android/andretro/.project
Normal file
33
android/andretro/.project
Normal file
@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Retroarch</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
11
android/andretro/.settings/org.eclipse.jdt.core.prefs
Normal file
11
android/andretro/.settings/org.eclipse.jdt.core.prefs
Normal file
@ -0,0 +1,11 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
31
android/andretro/AndroidManifest.xml
Normal file
31
android/andretro/AndroidManifest.xml
Normal file
@ -0,0 +1,31 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.retroarch"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0" >
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="9"
|
||||
android:targetSdkVersion="16" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
||||
|
||||
<application
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_name" >
|
||||
<activity android:name=".browser.ModuleActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
|
||||
</activity>
|
||||
|
||||
<activity android:name=".browser.DirectoryActivity"></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" />
|
||||
</activity>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
17
android/andretro/ant.properties
Normal file
17
android/andretro/ant.properties
Normal file
@ -0,0 +1,17 @@
|
||||
# This file is used to override default values used by the Ant build system.
|
||||
#
|
||||
# This file must be checked into Version Control Systems, as it is
|
||||
# integral to the build system of your project.
|
||||
|
||||
# This file is only used by the Ant script.
|
||||
|
||||
# You can use this to override default values such as
|
||||
# 'source.dir' for the location of your java source folder and
|
||||
# 'out.dir' for the location of your output folder.
|
||||
|
||||
# You can also use it define how the release builds are signed by declaring
|
||||
# the following properties:
|
||||
# 'key.store' for the location of your keystore and
|
||||
# 'key.alias' for the name of the key to use.
|
||||
# The password will be asked during the build when you use the 'release' target.
|
||||
|
92
android/andretro/build.xml
Normal file
92
android/andretro/build.xml
Normal file
@ -0,0 +1,92 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="retroarch" default="help">
|
||||
|
||||
<!-- The local.properties file is created and updated by the 'android' tool.
|
||||
It contains the path to the SDK. It should *NOT* be checked into
|
||||
Version Control Systems. -->
|
||||
<property file="local.properties" />
|
||||
|
||||
<!-- The ant.properties file can be created by you. It is only edited by the
|
||||
'android' tool to add properties to it.
|
||||
This is the place to change some Ant specific build properties.
|
||||
Here are some properties you may want to change/update:
|
||||
|
||||
source.dir
|
||||
The name of the source directory. Default is 'src'.
|
||||
out.dir
|
||||
The name of the output directory. Default is 'bin'.
|
||||
|
||||
For other overridable properties, look at the beginning of the rules
|
||||
files in the SDK, at tools/ant/build.xml
|
||||
|
||||
Properties related to the SDK location or the project target should
|
||||
be updated using the 'android' tool with the 'update' action.
|
||||
|
||||
This file is an integral part of the build system for your
|
||||
application and should be checked into Version Control Systems.
|
||||
|
||||
-->
|
||||
<property file="ant.properties" />
|
||||
|
||||
<!-- if sdk.dir was not set from one of the property file, then
|
||||
get it from the ANDROID_HOME env var.
|
||||
This must be done before we load project.properties since
|
||||
the proguard config can use sdk.dir -->
|
||||
<property environment="env" />
|
||||
<condition property="sdk.dir" value="${env.ANDROID_HOME}">
|
||||
<isset property="env.ANDROID_HOME" />
|
||||
</condition>
|
||||
|
||||
<!-- The project.properties file is created and updated by the 'android'
|
||||
tool, as well as ADT.
|
||||
|
||||
This contains project specific properties such as project target, and library
|
||||
dependencies. Lower level build properties are stored in ant.properties
|
||||
(or in .classpath for Eclipse projects).
|
||||
|
||||
This file is an integral part of the build system for your
|
||||
application and should be checked into Version Control Systems. -->
|
||||
<loadproperties srcFile="project.properties" />
|
||||
|
||||
<!-- quick check on sdk.dir -->
|
||||
<fail
|
||||
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable."
|
||||
unless="sdk.dir"
|
||||
/>
|
||||
|
||||
<!--
|
||||
Import per project custom build rules if present at the root of the project.
|
||||
This is the place to put custom intermediary targets such as:
|
||||
-pre-build
|
||||
-pre-compile
|
||||
-post-compile (This is typically used for code obfuscation.
|
||||
Compiled code location: ${out.classes.absolute.dir}
|
||||
If this is not done in place, override ${out.dex.input.absolute.dir})
|
||||
-post-package
|
||||
-post-build
|
||||
-pre-clean
|
||||
-->
|
||||
<import file="custom_rules.xml" optional="true" />
|
||||
|
||||
<!-- Import the actual build file.
|
||||
|
||||
To customize existing targets, there are two options:
|
||||
- Customize only one target:
|
||||
- copy/paste the target into this file, *before* the
|
||||
<import> task.
|
||||
- customize it to your needs.
|
||||
- Customize the whole content of build.xml
|
||||
- copy/paste the content of the rules files (minus the top node)
|
||||
into this file, replacing the <import> task.
|
||||
- customize to your needs.
|
||||
|
||||
***********************
|
||||
****** IMPORTANT ******
|
||||
***********************
|
||||
In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
|
||||
in order to avoid having your file be overridden by tools such as "android update project"
|
||||
-->
|
||||
<!-- version-tag: 1 -->
|
||||
<import file="${sdk.dir}/tools/ant/build.xml" />
|
||||
|
||||
</project>
|
71
android/andretro/jni/Android.mk
Normal file
71
android/andretro/jni/Android.mk
Normal file
@ -0,0 +1,71 @@
|
||||
RARCH_VERSION = "0.9.8-beta3"
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
PERF_TEST := 1
|
||||
HAVE_OPENSL := 1
|
||||
HAVE_NEON := 1
|
||||
HAVE_SINC := 1
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
ifeq ($(TARGET_ARCH),arm)
|
||||
LOCAL_CFLAGS += -DANDROID_ARM -marm
|
||||
LOCAL_ARM_MODE := arm
|
||||
endif
|
||||
|
||||
ifeq ($(TARGET_ARCH),x86)
|
||||
LOCAL_CFLAGS += -DANDROID_X86 -DHAVE_SSSE3
|
||||
endif
|
||||
|
||||
ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
|
||||
|
||||
ifeq ($(HAVE_NEON),1)
|
||||
LOCAL_CFLAGS += -DHAVE_NEON
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_SINC),1)
|
||||
ifeq ($(HAVE_NEON),1)
|
||||
LOCAL_SRC_FILES += ../../../audio/sinc_neon.S.neon
|
||||
endif
|
||||
LOCAL_CFLAGS += -DHAVE_SINC
|
||||
endif
|
||||
|
||||
LOCAL_CFLAGS += -DANDROID_ARM_V7
|
||||
endif
|
||||
|
||||
|
||||
ifeq ($(TARGET_ARCH),mips)
|
||||
LOCAL_CFLAGS += -DANDROID_MIPS -D__mips__ -D__MIPSEL__
|
||||
endif
|
||||
|
||||
LOCAL_MODULE := retroarch-activity
|
||||
|
||||
RARCH_PATH := ../../..
|
||||
LIBXML_PATH := ../../../deps/libxml2
|
||||
LOCAL_SRC_FILES += $(RARCH_PATH)/console/griffin/griffin.c
|
||||
|
||||
|
||||
ifeq ($(PERF_TEST), 1)
|
||||
LOCAL_CFLAGS += -DPERF_TEST
|
||||
endif
|
||||
|
||||
LOCAL_CFLAGS += -O3 -fno-stack-protector -funroll-loops -DNDEBUG -DHAVE_GRIFFIN -DANDROID -DHAVE_DYNAMIC -DHAVE_OPENGL -DHAVE_OPENGLES -DHAVE_VID_CONTEXT -DHAVE_OPENGLES2 -DGLSL_DEBUG -DHAVE_GLSL -DHAVE_ZLIB -DWANT_RZLIB -DINLINE=inline -DLSB_FIRST -DHAVE_THREAD -D__LIBRETRO__ -DHAVE_CONFIGFILE=1 -DRARCH_PERFORMANCE_MODE -DRARCH_GPU_PERFORMANCE_MODE -DPACKAGE_VERSION=\"$(RARCH_VERSION)\" -std=gnu99
|
||||
|
||||
LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -landroid -lEGL -lGLESv2 -llog -ldl
|
||||
LOCAL_C_INCLUDES += $(LIBXML_PATH)
|
||||
|
||||
ifeq ($(HAVE_OPENSL), 1)
|
||||
LOCAL_CFLAGS += -DHAVE_SL
|
||||
LOCAL_LDLIBS += -lOpenSLES
|
||||
endif
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
||||
# Include all present sub-modules
|
||||
FOCAL_PATH := $(LOCAL_PATH)
|
||||
|
||||
define function
|
||||
$(eval RETRO_MODULE_OBJECT := $(1))
|
||||
$(eval include $(FOCAL_PATH)/modules/Android.mk)
|
||||
endef
|
||||
|
||||
$(foreach m,$(wildcard $(FOCAL_PATH)/modules/*.so),$(eval $(call function,$(m))))
|
2
android/andretro/jni/Application.mk
Normal file
2
android/andretro/jni/Application.mk
Normal file
@ -0,0 +1,2 @@
|
||||
APP_PLATFORM := android-9
|
||||
APP_ABI := all
|
6
android/andretro/jni/modules/Android.mk
Normal file
6
android/andretro/jni/modules/Android.mk
Normal file
@ -0,0 +1,6 @@
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := $(notdir $(RETRO_MODULE_OBJECT))
|
||||
LOCAL_SRC_FILES := $(notdir $(RETRO_MODULE_OBJECT))
|
||||
include $(PREBUILT_SHARED_LIBRARY)
|
BIN
android/andretro/libs/android-support-v4.jar
Normal file
BIN
android/andretro/libs/android-support-v4.jar
Normal file
Binary file not shown.
20
android/andretro/proguard-project.txt
Normal file
20
android/andretro/proguard-project.txt
Normal file
@ -0,0 +1,20 @@
|
||||
# To enable ProGuard in your project, edit project.properties
|
||||
# to define the proguard.config property as described in that file.
|
||||
#
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in ${sdk.dir}/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the ProGuard
|
||||
# include property in project.properties.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
14
android/andretro/project.properties
Normal file
14
android/andretro/project.properties
Normal file
@ -0,0 +1,14 @@
|
||||
# This file is automatically generated by Android Tools.
|
||||
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
|
||||
#
|
||||
# This file must be checked in Version Control Systems.
|
||||
#
|
||||
# To customize properties used by the Ant build system edit
|
||||
# "ant.properties", and override values to adapt the script to your
|
||||
# project structure.
|
||||
#
|
||||
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
|
||||
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
|
||||
|
||||
# Project target.
|
||||
target=android-16
|
BIN
android/andretro/res/drawable-hdpi/ic_launcher.png
Normal file
BIN
android/andretro/res/drawable-hdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.5 KiB |
BIN
android/andretro/res/drawable-ldpi/ic_launcher.png
Normal file
BIN
android/andretro/res/drawable-ldpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 925 B |
BIN
android/andretro/res/drawable-mdpi/ic_launcher.png
Normal file
BIN
android/andretro/res/drawable-mdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
BIN
android/andretro/res/drawable-nodpi/file.png
Executable file
BIN
android/andretro/res/drawable-nodpi/file.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
BIN
android/andretro/res/drawable-nodpi/folder.png
Executable file
BIN
android/andretro/res/drawable-nodpi/folder.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 2.3 KiB |
BIN
android/andretro/res/drawable-xhdpi/ic_launcher.png
Normal file
BIN
android/andretro/res/drawable-xhdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.9 KiB |
23
android/andretro/res/layout/icon_grid_item.xml
Normal file
23
android/andretro/res/layout/icon_grid_item.xml
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/icon"
|
||||
android:layout_width="192dp"
|
||||
android:layout_height="192dp"
|
||||
android:layout_gravity="center"
|
||||
android:contentDescription="@string/file_type_icon"
|
||||
android:padding="8dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_weight="0.5"
|
||||
android:textSize="18sp" />
|
||||
|
||||
</LinearLayout>
|
8
android/andretro/res/layout/icon_grid_list.xml
Normal file
8
android/andretro/res/layout/icon_grid_list.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:numColumns="2" >
|
||||
|
||||
</GridView>
|
7
android/andretro/res/layout/line_list.xml
Normal file
7
android/andretro/res/layout/line_list.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" >
|
||||
</ListView>
|
||||
|
23
android/andretro/res/layout/line_list_item.xml
Normal file
23
android/andretro/res/layout/line_list_item.xml
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="48dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/icon"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:contentDescription="@string/file_type_icon"
|
||||
android:padding="8dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/name"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_weight="0.5"
|
||||
android:textSize="18sp" />
|
||||
|
||||
</LinearLayout>
|
4
android/andretro/res/menu/directory_list.xml
Normal file
4
android/andretro/res/menu/directory_list.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
<item android:id="@+id/input_method_select" android:title="@string/input_method" android:showAsAction="ifRoom"></item>
|
||||
</menu>
|
7
android/andretro/res/values/strings.xml
Normal file
7
android/andretro/res/values/strings.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<resources>
|
||||
|
||||
<string name="app_name">RetroArch</string>
|
||||
<string name="input_method">Input Method</string>
|
||||
<string name="file_type_icon">File type icon</string>
|
||||
|
||||
</resources>
|
@ -0,0 +1,153 @@
|
||||
package org.retroarch.browser;
|
||||
import org.retroarch.R;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.*;
|
||||
|
||||
import android.content.*;
|
||||
import android.app.*;
|
||||
import android.os.*;
|
||||
import android.widget.*;
|
||||
import android.view.*;
|
||||
import android.view.inputmethod.*;
|
||||
import android.graphics.drawable.*;
|
||||
|
||||
class FileWrapper implements IconAdapterItem
|
||||
{
|
||||
public final File file;
|
||||
protected final int typeIndex;
|
||||
protected final boolean enabled;
|
||||
|
||||
public FileWrapper(File aFile, boolean aIsEnabled)
|
||||
{
|
||||
file = aFile;
|
||||
typeIndex = (file.isDirectory() ? 1 : 0) + (file.isFile() ? 2 : 0);
|
||||
enabled = aIsEnabled;
|
||||
}
|
||||
|
||||
@Override public boolean isEnabled()
|
||||
{
|
||||
return enabled;
|
||||
}
|
||||
|
||||
@Override public String getText()
|
||||
{
|
||||
return file.getName();
|
||||
}
|
||||
|
||||
@Override public int getIconResourceId()
|
||||
{
|
||||
return file.isFile() ? R.drawable.file : R.drawable.folder;
|
||||
}
|
||||
|
||||
@Override public Drawable getIconDrawable()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public int compareTo(FileWrapper aOther)
|
||||
{
|
||||
if(null != aOther)
|
||||
{
|
||||
// Who says ternary is hard to follow
|
||||
if(isEnabled() == aOther.isEnabled())
|
||||
{
|
||||
return (typeIndex == aOther.typeIndex) ? file.compareTo(aOther.file) : ((typeIndex < aOther.typeIndex) ? -1 : 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
return isEnabled() ? -1 : 1;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
public class DirectoryActivity extends Activity implements AdapterView.OnItemClickListener
|
||||
{
|
||||
private IconAdapter<FileWrapper> adapter;
|
||||
private String modulePath;
|
||||
|
||||
@Override public void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setContentView(R.layout.line_list);
|
||||
|
||||
modulePath = getIntent().getStringExtra("LIBRETRO");
|
||||
|
||||
// Setup the list
|
||||
adapter = new IconAdapter<FileWrapper>(this, R.layout.line_list_item);
|
||||
ListView list = (ListView)findViewById(R.id.list);
|
||||
list.setAdapter(adapter);
|
||||
list.setOnItemClickListener(this);
|
||||
|
||||
// Load Directory
|
||||
String path = getIntent().getStringExtra("ROM");
|
||||
if(path == null)
|
||||
{
|
||||
path = Environment.getExternalStorageDirectory().getPath();
|
||||
}
|
||||
|
||||
wrapFiles(new File(path));
|
||||
setTitle(path);
|
||||
}
|
||||
|
||||
@Override public void onItemClick(AdapterView<?> aListView, View aView, int aPosition, long aID)
|
||||
{
|
||||
final File selected = adapter.getItem(aPosition).file;
|
||||
|
||||
final Intent intent = new Intent(this, selected.isFile() ? NativeActivity.class : DirectoryActivity.class)
|
||||
.putExtra("ROM", selected.getAbsolutePath())
|
||||
.putExtra("LIBRETRO", modulePath);
|
||||
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override public boolean onCreateOptionsMenu(Menu aMenu)
|
||||
{
|
||||
super.onCreateOptionsMenu(aMenu);
|
||||
getMenuInflater().inflate(R.menu.directory_list, aMenu);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override public boolean onOptionsItemSelected(MenuItem aItem)
|
||||
{
|
||||
if(R.id.input_method_select == aItem.getItemId())
|
||||
{
|
||||
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
imm.showInputMethodPicker();
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(aItem);
|
||||
}
|
||||
|
||||
private void wrapFiles(File aDirectory)
|
||||
{
|
||||
if(null == aDirectory || !aDirectory.isDirectory())
|
||||
{
|
||||
throw new IllegalArgumentException("Directory is not valid.");
|
||||
}
|
||||
|
||||
// Copy new items
|
||||
for(File file: aDirectory.listFiles())
|
||||
{
|
||||
adapter.add(new FileWrapper(file, file.isDirectory() || true));
|
||||
}
|
||||
|
||||
// Sort items
|
||||
adapter.sort(new Comparator<FileWrapper>()
|
||||
{
|
||||
@Override public int compare(FileWrapper aLeft, FileWrapper aRight)
|
||||
{
|
||||
return aLeft.compareTo(aRight);
|
||||
};
|
||||
});
|
||||
|
||||
// Update
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
78
android/andretro/src/org/retroarch/browser/IconAdapter.java
Normal file
78
android/andretro/src/org/retroarch/browser/IconAdapter.java
Normal file
@ -0,0 +1,78 @@
|
||||
package org.retroarch.browser;
|
||||
import org.retroarch.R;
|
||||
|
||||
import android.app.*;
|
||||
import android.content.*;
|
||||
import android.graphics.drawable.*;
|
||||
import android.view.*;
|
||||
import android.widget.*;
|
||||
|
||||
interface IconAdapterItem
|
||||
{
|
||||
public abstract boolean isEnabled();
|
||||
public abstract String getText();
|
||||
public abstract int getIconResourceId();
|
||||
public abstract Drawable getIconDrawable();
|
||||
}
|
||||
|
||||
class IconAdapter<T extends IconAdapterItem> extends ArrayAdapter<T>
|
||||
{
|
||||
private final int layout;
|
||||
|
||||
public IconAdapter(Activity aContext, int aLayout)
|
||||
{
|
||||
super(aContext, aLayout);
|
||||
|
||||
layout = aLayout;
|
||||
}
|
||||
|
||||
@Override public View getView(int aPosition, View aConvertView, ViewGroup aParent)
|
||||
{
|
||||
// Build the view
|
||||
if(aConvertView == null)
|
||||
{
|
||||
LayoutInflater inflater = (LayoutInflater)aParent.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
aConvertView = inflater.inflate(layout, aParent, false);
|
||||
}
|
||||
|
||||
// Fill the view
|
||||
IconAdapterItem item = getItem(aPosition);
|
||||
final boolean enabled = item.isEnabled();
|
||||
|
||||
TextView textView = (TextView)aConvertView.findViewById(R.id.name);
|
||||
if(null != textView)
|
||||
{
|
||||
textView.setText(item.getText());
|
||||
textView.setEnabled(enabled);
|
||||
}
|
||||
|
||||
ImageView imageView = (ImageView)aConvertView.findViewById(R.id.icon);
|
||||
if(null != imageView)
|
||||
{
|
||||
if(enabled)
|
||||
{
|
||||
final int id = item.getIconResourceId();
|
||||
if(0 != id)
|
||||
{
|
||||
imageView.setImageResource(id);
|
||||
}
|
||||
else
|
||||
{
|
||||
imageView.setImageDrawable(item.getIconDrawable());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
imageView.setImageDrawable(null);
|
||||
}
|
||||
}
|
||||
|
||||
return aConvertView;
|
||||
}
|
||||
|
||||
@Override public boolean isEnabled(int aPosition)
|
||||
{
|
||||
return getItem(aPosition).isEnabled();
|
||||
}
|
||||
|
||||
}
|
106
android/andretro/src/org/retroarch/browser/ModuleActivity.java
Normal file
106
android/andretro/src/org/retroarch/browser/ModuleActivity.java
Normal file
@ -0,0 +1,106 @@
|
||||
package org.retroarch.browser;
|
||||
import org.retroarch.R;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
import android.content.*;
|
||||
import android.app.*;
|
||||
import android.os.*;
|
||||
import android.widget.*;
|
||||
import android.view.*;
|
||||
import android.view.inputmethod.*;
|
||||
import android.graphics.drawable.*;
|
||||
|
||||
class ModuleWrapper implements IconAdapterItem
|
||||
{
|
||||
public final File file;
|
||||
|
||||
public ModuleWrapper(Context aContext, File aFile) throws IOException
|
||||
{
|
||||
file = aFile;
|
||||
}
|
||||
|
||||
@Override public boolean isEnabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override public String getText()
|
||||
{
|
||||
return file.getName();
|
||||
}
|
||||
|
||||
@Override public int getIconResourceId()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override public Drawable getIconDrawable()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public class ModuleActivity extends Activity implements AdapterView.OnItemClickListener
|
||||
{
|
||||
// HACK: Hard path
|
||||
private static final String modulePath = "/data/data/org.retroarch/lib/";
|
||||
private IconAdapter<ModuleWrapper> adapter;
|
||||
|
||||
@Override public void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setContentView(R.layout.line_list);
|
||||
|
||||
// Setup the list
|
||||
adapter = new IconAdapter<ModuleWrapper>(this, R.layout.line_list_item);
|
||||
ListView list = (ListView)findViewById(R.id.list);
|
||||
list.setAdapter(adapter);
|
||||
list.setOnItemClickListener(this);
|
||||
|
||||
setTitle("Select Emulator");
|
||||
|
||||
for(final File lib: new File(modulePath).listFiles())
|
||||
{
|
||||
if(lib.getName().startsWith("libretro_"))
|
||||
{
|
||||
try
|
||||
{
|
||||
adapter.add(new ModuleWrapper(this, lib));;
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
//Logger.d("Couldn't add module: " + lib.getPath());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void onItemClick(AdapterView<?> aListView, View aView, int aPosition, long aID)
|
||||
{
|
||||
final ModuleWrapper item = adapter.getItem(aPosition);
|
||||
|
||||
startActivity(new Intent(ModuleActivity.this, DirectoryActivity.class)
|
||||
.putExtra("LIBRETRO", item.file.getAbsolutePath()));
|
||||
}
|
||||
|
||||
@Override public boolean onCreateOptionsMenu(Menu aMenu)
|
||||
{
|
||||
super.onCreateOptionsMenu(aMenu);
|
||||
getMenuInflater().inflate(R.menu.directory_list, aMenu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override public boolean onOptionsItemSelected(MenuItem aItem)
|
||||
{
|
||||
if(R.id.input_method_select == aItem.getItemId())
|
||||
{
|
||||
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
imm.showInputMethodPicker();
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(aItem);
|
||||
}
|
||||
}
|
@ -339,9 +339,6 @@ static void* android_app_entry(void* param)
|
||||
RARCH_LOG("ROM Filename: [%s].\n", rom_path);
|
||||
RARCH_LOG("Libretro path: [%s].\n", libretro_path);
|
||||
|
||||
/* ugly hack for now - hardcode libretro path to 'allowed' dir */
|
||||
snprintf(libretro_path, sizeof(libretro_path), "/data/data/com.retroarch/lib/libretro.so");
|
||||
|
||||
int argc = 0;
|
||||
char *argv[MAX_ARGS] = {NULL};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user