mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-26 01:30:51 +00:00
Merge branch 'android-2.3'
Conflicts: android/phoenix/src/org/retroarch/browser/RetroArch.java android/phoenix/src/org/retroarch/browser/SettingsActivity.java
This commit is contained in:
commit
f4f284665c
@ -4,7 +4,7 @@
|
||||
android:versionName="0.9.8" >
|
||||
<uses-feature android:glEsVersion="0x00020000" />
|
||||
<uses-sdk
|
||||
android:minSdkVersion="11"
|
||||
android:minSdkVersion="9"
|
||||
android:targetSdkVersion="16" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
||||
|
@ -6,6 +6,7 @@ import java.io.*;
|
||||
|
||||
import android.content.*;
|
||||
import android.content.res.AssetManager;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.*;
|
||||
import android.media.AudioManager;
|
||||
import android.net.Uri;
|
||||
@ -15,6 +16,7 @@ import android.provider.Settings;
|
||||
import android.widget.*;
|
||||
import android.util.Log;
|
||||
import android.view.*;
|
||||
import android.view.ContextMenu.ContextMenuInfo;
|
||||
import android.view.inputmethod.*;
|
||||
import android.graphics.drawable.*;
|
||||
|
||||
@ -53,7 +55,7 @@ class ModuleWrapper implements IconAdapterItem {
|
||||
}
|
||||
|
||||
public class RetroArch extends Activity implements
|
||||
AdapterView.OnItemClickListener, PopupMenu.OnMenuItemClickListener {
|
||||
AdapterView.OnItemClickListener {
|
||||
private IconAdapter<ModuleWrapper> adapter;
|
||||
static private final int ACTIVITY_LOAD_ROM = 0;
|
||||
static private String libretro_path;
|
||||
@ -233,6 +235,11 @@ public class RetroArch extends Activity implements
|
||||
}
|
||||
|
||||
this.setVolumeControlStream(AudioManager.STREAM_MUSIC);
|
||||
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB)
|
||||
{
|
||||
this.registerForContextMenu(findViewById(android.R.id.content));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -393,15 +400,37 @@ public class RetroArch extends Activity implements
|
||||
getMenuInflater().inflate(R.menu.directory_list, aMenu);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void showPopup(View v) {
|
||||
PopupMenu menu = new PopupMenu(this, v);
|
||||
MenuInflater inflater = menu.getMenuInflater();
|
||||
inflater.inflate(R.menu.context_menu, menu.getMenu());
|
||||
menu.setOnMenuItemClickListener(this);
|
||||
menu.show();
|
||||
}
|
||||
|
||||
public void showPopup(View v) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
|
||||
{
|
||||
PopupMenuAbstract menu = new PopupMenuAbstract(this, v);
|
||||
MenuInflater inflater = menu.getMenuInflater();
|
||||
inflater.inflate(R.menu.context_menu, menu.getMenu());
|
||||
menu.setOnMenuItemClickListener(new PopupMenuAbstract.OnMenuItemClickListener()
|
||||
{
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
return onContextItemSelected(item);
|
||||
}
|
||||
|
||||
});
|
||||
menu.show();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.openContextMenu(findViewById(android.R.id.content));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateContextMenu(ContextMenu menu, View v,
|
||||
ContextMenuInfo menuInfo) {
|
||||
super.onCreateContextMenu(menu, v, menuInfo);
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate(R.menu.context_menu, menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem aItem) {
|
||||
switch (aItem.getItemId()) {
|
||||
@ -414,9 +443,9 @@ public class RetroArch extends Activity implements
|
||||
return super.onOptionsItemSelected(aItem);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
public boolean onContextItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.input_method_select:
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
@ -459,3 +488,105 @@ public class RetroArch extends Activity implements
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
abstract class LazyPopupMenu {
|
||||
public abstract Menu getMenu();
|
||||
public abstract MenuInflater getMenuInflater();
|
||||
public abstract void setOnMenuItemClickListener(LazyPopupMenu.OnMenuItemClickListener listener);
|
||||
public abstract void show();
|
||||
public interface OnMenuItemClickListener {
|
||||
public abstract boolean onMenuItemClick(MenuItem item);
|
||||
}
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
|
||||
class HoneycombPopupMenu extends LazyPopupMenu {
|
||||
private PopupMenu instance;
|
||||
HoneycombPopupMenu.OnMenuItemClickListener listen;
|
||||
|
||||
public HoneycombPopupMenu(Context context, View anchor)
|
||||
{
|
||||
instance = new PopupMenu(context, anchor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnMenuItemClickListener(HoneycombPopupMenu.OnMenuItemClickListener listener)
|
||||
{
|
||||
listen = listener;
|
||||
instance.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
return listen.onMenuItemClick(item);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Menu getMenu() {
|
||||
return instance.getMenu();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MenuInflater getMenuInflater() {
|
||||
return instance.getMenuInflater();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show() {
|
||||
instance.show();
|
||||
}
|
||||
}
|
||||
|
||||
class PopupMenuAbstract extends LazyPopupMenu
|
||||
{
|
||||
private LazyPopupMenu lazy;
|
||||
|
||||
public PopupMenuAbstract(Context context, View anchor)
|
||||
{
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
|
||||
{
|
||||
lazy = new HoneycombPopupMenu(context, anchor);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Menu getMenu() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
|
||||
{
|
||||
return lazy.getMenu();
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MenuInflater getMenuInflater() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
|
||||
{
|
||||
return lazy.getMenuInflater();
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnMenuItemClickListener(PopupMenuAbstract.OnMenuItemClickListener listener) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
|
||||
{
|
||||
lazy.setOnMenuItemClickListener(listener);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
|
||||
{
|
||||
lazy.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,30 +2,18 @@ package org.retroarch.browser;
|
||||
|
||||
import org.retroarch.R;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.media.AudioManager;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceFragment;
|
||||
import android.preference.PreferenceActivity;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
public class SettingsActivity extends Activity {
|
||||
public class SettingsActivity extends PreferenceActivity {
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getFragmentManager().beginTransaction().
|
||||
replace(android.R.id.content, new SettingsFragment()).commit();
|
||||
addPreferencesFromResource(R.xml.prefs);
|
||||
PreferenceManager.setDefaultValues(this, R.xml.prefs, false);
|
||||
this.setVolumeControlStream(AudioManager.STREAM_MUSIC);
|
||||
}
|
||||
|
||||
public static class SettingsFragment extends PreferenceFragment {
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
// Load the preferences from an XML resource
|
||||
addPreferencesFromResource(R.xml.prefs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user