Android: Fix OSD editor and standardize launch
This commit is contained in:
parent
36d094949d
commit
ddffa3b8de
|
@ -311,8 +311,7 @@ public class FileBrowser extends Fragment {
|
||||||
final View childview = getActivity().getLayoutInflater().inflate(
|
final View childview = getActivity().getLayoutInflater().inflate(
|
||||||
R.layout.bios_list_item, null, false);
|
R.layout.bios_list_item, null, false);
|
||||||
|
|
||||||
((TextView) childview.findViewById(R.id.item_name))
|
((TextView) childview.findViewById(R.id.item_name)).setText(R.string.boot_bios);
|
||||||
.setText(R.string.boot_bios);
|
|
||||||
|
|
||||||
childview.setTag(null);
|
childview.setTag(null);
|
||||||
|
|
||||||
|
@ -323,8 +322,7 @@ public class FileBrowser extends Fragment {
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
File f = (File) view.getTag();
|
File f = (File) view.getTag();
|
||||||
vib.vibrate(50);
|
vib.vibrate(50);
|
||||||
mCallback.onGameSelected(f != null ? Uri
|
mCallback.onGameSelected(f != null ? Uri.fromFile(f) : Uri.EMPTY);
|
||||||
.fromFile(f) : Uri.EMPTY);
|
|
||||||
vib.vibrate(250);
|
vib.vibrate(250);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -372,16 +370,16 @@ public class FileBrowser extends Fragment {
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
if (isGame) {
|
if (isGame) {
|
||||||
vib.vibrate(50);
|
vib.vibrate(50);
|
||||||
mCallback.onGameSelected(game != null ? Uri
|
mCallback.onGameSelected(game != null ? Uri.fromFile(game) : Uri.EMPTY);
|
||||||
.fromFile(game) : Uri.EMPTY);
|
|
||||||
vib.vibrate(250);
|
vib.vibrate(250);
|
||||||
} else {
|
} else {
|
||||||
vib.vibrate(50);
|
vib.vibrate(50);
|
||||||
home_directory = game.getAbsolutePath().substring(0,
|
home_directory = game.getAbsolutePath().substring(0,
|
||||||
game.getAbsolutePath().lastIndexOf(File.separator)).replace("/data", "");
|
game.getAbsolutePath().lastIndexOf(File.separator))
|
||||||
|
.replace("/data", "");
|
||||||
if (!DataDirectoryBIOS()) {
|
if (!DataDirectoryBIOS()) {
|
||||||
showToastMessage(getActivity().getString(R.string.config_data, home_directory),
|
showToastMessage(getActivity().getString(R.string.config_data,
|
||||||
Snackbar.LENGTH_LONG);
|
home_directory), Snackbar.LENGTH_LONG);
|
||||||
}
|
}
|
||||||
mPrefs.edit().putString(Config.pref_home, home_directory).apply();
|
mPrefs.edit().putString(Config.pref_home, home_directory).apply();
|
||||||
mCallback.onFolderSelected(Uri.fromFile(new File(home_directory)));
|
mCallback.onFolderSelected(Uri.fromFile(new File(home_directory)));
|
||||||
|
@ -507,13 +505,13 @@ public class FileBrowser extends Fragment {
|
||||||
browser.get().mCallback.onFolderSelected(
|
browser.get().mCallback.onFolderSelected(
|
||||||
Uri.fromFile(new File(browser.get().game_directory)));
|
Uri.fromFile(new File(browser.get().game_directory)));
|
||||||
} else {
|
} else {
|
||||||
browser.get().home_directory = heading.replace("/data", "");
|
browser.get().home_directory = heading
|
||||||
|
.replace("/data", "");
|
||||||
browser.get().mPrefs.edit().putString(
|
browser.get().mPrefs.edit().putString(
|
||||||
Config.pref_home, browser.get().home_directory).apply();
|
Config.pref_home, browser.get().home_directory).apply();
|
||||||
if (!browser.get().DataDirectoryBIOS()) {
|
if (!browser.get().DataDirectoryBIOS()) {
|
||||||
browser.get().showToastMessage(
|
browser.get().showToastMessage(browser.get()
|
||||||
browser.get().getActivity().getString(
|
.getActivity().getString(R.string.config_data,
|
||||||
R.string.config_data,
|
|
||||||
browser.get().home_directory),
|
browser.get().home_directory),
|
||||||
Snackbar.LENGTH_LONG);
|
Snackbar.LENGTH_LONG);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,19 +34,19 @@ import android.view.WindowManager;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.reicast.emulator.config.Config;
|
import com.reicast.emulator.config.Config;
|
||||||
|
import com.reicast.emulator.config.EditVJoyActivity;
|
||||||
import com.reicast.emulator.config.InputFragment;
|
import com.reicast.emulator.config.InputFragment;
|
||||||
import com.reicast.emulator.config.OptionsFragment;
|
import com.reicast.emulator.config.OptionsFragment;
|
||||||
import com.reicast.emulator.config.PGConfigFragment;
|
import com.reicast.emulator.config.PGConfigFragment;
|
||||||
import com.reicast.emulator.debug.GenerateLogs;
|
import com.reicast.emulator.debug.GenerateLogs;
|
||||||
import com.reicast.emulator.emu.JNIdc;
|
import com.reicast.emulator.emu.JNIdc;
|
||||||
import com.reicast.emulator.periph.Gamepad;
|
|
||||||
|
|
||||||
import java.lang.Thread.UncaughtExceptionHandler;
|
import java.lang.Thread.UncaughtExceptionHandler;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity implements
|
public class MainActivity extends AppCompatActivity implements
|
||||||
FileBrowser.OnItemSelectedListener, OptionsFragment.OnClickListener,
|
NavigationView.OnNavigationItemSelectedListener, FileBrowser.OnItemSelectedListener,
|
||||||
NavigationView.OnNavigationItemSelectedListener {
|
OptionsFragment.OnClickListener, InputFragment.OnClickListener {
|
||||||
private static final int PERMISSION_REQUEST = 1001;
|
private static final int PERMISSION_REQUEST = 1001;
|
||||||
|
|
||||||
private SharedPreferences mPrefs;
|
private SharedPreferences mPrefs;
|
||||||
|
@ -54,8 +54,6 @@ public class MainActivity extends AppCompatActivity implements
|
||||||
|
|
||||||
private UncaughtExceptionHandler mUEHandler;
|
private UncaughtExceptionHandler mUEHandler;
|
||||||
|
|
||||||
Gamepad pad = new Gamepad();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
@ -223,6 +221,16 @@ public class MainActivity extends AppCompatActivity implements
|
||||||
builder.show();
|
builder.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onEditorSelected(Uri uri) {
|
||||||
|
String home_directory = mPrefs.getString(Config.pref_home,
|
||||||
|
Environment.getExternalStorageDirectory().getAbsolutePath());
|
||||||
|
|
||||||
|
JNIdc.config(home_directory);
|
||||||
|
|
||||||
|
startActivity(new Intent("com.reicast.EMULATOR", uri,
|
||||||
|
getApplicationContext(), EditVJoyActivity.class));
|
||||||
|
}
|
||||||
|
|
||||||
public void onGameSelected(Uri uri) {
|
public void onGameSelected(Uri uri) {
|
||||||
String home_directory = mPrefs.getString(Config.pref_home,
|
String home_directory = mPrefs.getString(Config.pref_home,
|
||||||
Environment.getExternalStorageDirectory().getAbsolutePath());
|
Environment.getExternalStorageDirectory().getAbsolutePath());
|
||||||
|
|
|
@ -4,6 +4,7 @@ import android.app.Activity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
@ -18,7 +19,6 @@ import android.widget.ImageView.ScaleType;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.PopupWindow;
|
import android.widget.PopupWindow;
|
||||||
|
|
||||||
import com.reicast.emulator.Emulator;
|
|
||||||
import com.reicast.emulator.MainActivity;
|
import com.reicast.emulator.MainActivity;
|
||||||
import com.reicast.emulator.R;
|
import com.reicast.emulator.R;
|
||||||
import com.reicast.emulator.emu.GL2JNIView;
|
import com.reicast.emulator.emu.GL2JNIView;
|
||||||
|
@ -49,16 +49,21 @@ public class EditVJoyActivity extends Activity {
|
||||||
|
|
||||||
popUp = createVJoyPopup();
|
popUp = createVJoyPopup();
|
||||||
|
|
||||||
|
String fileName = null;
|
||||||
|
|
||||||
// Call parent onCreate()
|
// Call parent onCreate()
|
||||||
super.onCreate(icicle);
|
super.onCreate(icicle);
|
||||||
|
|
||||||
SharedPreferences prefs = PreferenceManager
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
.getDefaultSharedPreferences(this);
|
|
||||||
Emulator app = (Emulator)getApplicationContext();
|
JNIdc.initControllers(new boolean[] { false, false, false },
|
||||||
app.getConfigurationPrefs(prefs);
|
new int[][] { {1, 1}, {0, 0}, {0, 0}, {0, 0} });
|
||||||
|
|
||||||
|
if (getIntent().getAction().equals("com.reicast.EMULATOR"))
|
||||||
|
fileName = Uri.decode(getIntent().getData().toString());
|
||||||
|
|
||||||
// Create the actual GLES view
|
// Create the actual GLES view
|
||||||
mView = new GL2JNIView(EditVJoyActivity.this, null, false,
|
mView = new GL2JNIView(EditVJoyActivity.this, fileName, false,
|
||||||
prefs.getInt(Config.pref_renderdepth, 24), 0, true);
|
prefs.getInt(Config.pref_renderdepth, 24), 0, true);
|
||||||
mView.setFpsDisplay(null);
|
mView.setFpsDisplay(null);
|
||||||
setContentView(mView);
|
setContentView(mView);
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
package com.reicast.emulator.config;
|
package com.reicast.emulator.config;
|
||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
|
@ -42,18 +43,47 @@ import java.io.File;
|
||||||
public class InputFragment extends Fragment {
|
public class InputFragment extends Fragment {
|
||||||
private static final int PERMISSION_REQUEST = 1001;
|
private static final int PERMISSION_REQUEST = 1001;
|
||||||
|
|
||||||
|
private OnClickListener mCallback;
|
||||||
|
|
||||||
private int listenForButton = 0;
|
private int listenForButton = 0;
|
||||||
private AlertDialog alertDialogSelectController;
|
private AlertDialog alertDialogSelectController;
|
||||||
private SharedPreferences mPrefs;
|
private SharedPreferences mPrefs;
|
||||||
private CompoundButton switchTouchVibrationEnabled;
|
private CompoundButton switchTouchVibrationEnabled;
|
||||||
private CompoundButton micPluggedIntoController;
|
private CompoundButton micPluggedIntoController;
|
||||||
|
|
||||||
private Gamepad pad = new Gamepad();
|
|
||||||
Vibrator vib;
|
Vibrator vib;
|
||||||
|
|
||||||
// Container Activity must implement this interface
|
// Container Activity must implement this interface
|
||||||
public interface OnClickListener {
|
public interface OnClickListener {
|
||||||
void onMainBrowseSelected(String path_entry, boolean games);
|
void onEditorSelected(Uri uri);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAttach(Activity activity) {
|
||||||
|
super.onAttach(activity);
|
||||||
|
|
||||||
|
// This makes sure that the container activity has implemented
|
||||||
|
// the callback interface. If not, it throws an exception
|
||||||
|
try {
|
||||||
|
mCallback = (OnClickListener) activity;
|
||||||
|
} catch (ClassCastException e) {
|
||||||
|
throw new ClassCastException(activity.toString()
|
||||||
|
+ " must implement OnClickListener");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAttach(Context context) {
|
||||||
|
super.onAttach(context);
|
||||||
|
|
||||||
|
// This makes sure that the container activity has implemented
|
||||||
|
// the callback interface. If not, it throws an exception
|
||||||
|
try {
|
||||||
|
mCallback = (OnClickListener) context;
|
||||||
|
} catch (ClassCastException e) {
|
||||||
|
throw new ClassCastException(context.getClass().toString()
|
||||||
|
+ " must implement OnClickListener");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -87,8 +117,7 @@ public class InputFragment extends Fragment {
|
||||||
R.id.buttonLaunchEditor);
|
R.id.buttonLaunchEditor);
|
||||||
buttonLaunchEditor.setOnClickListener(new View.OnClickListener() {
|
buttonLaunchEditor.setOnClickListener(new View.OnClickListener() {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
Intent inte = new Intent(getActivity(), EditVJoyActivity.class);
|
mCallback.onEditorSelected(Uri.EMPTY);
|
||||||
startActivity(inte);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -69,11 +69,6 @@ public class InputModFragment extends Fragment {
|
||||||
private int playerNum = -1;
|
private int playerNum = -1;
|
||||||
private mapKeyCode mKey;
|
private mapKeyCode mKey;
|
||||||
|
|
||||||
// Container Activity must implement this interface
|
|
||||||
public interface OnClickListener {
|
|
||||||
void onMainBrowseSelected(String path_entry, boolean games);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
|
|
|
@ -13,8 +13,6 @@ import android.support.constraint.ConstraintLayout;
|
||||||
import android.support.design.widget.Snackbar;
|
import android.support.design.widget.Snackbar;
|
||||||
import android.support.graphics.drawable.VectorDrawableCompat;
|
import android.support.graphics.drawable.VectorDrawableCompat;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.text.Editable;
|
|
||||||
import android.text.TextWatcher;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
|
|
|
@ -106,8 +106,8 @@ public class GL2JNIView extends GLSurfaceView
|
||||||
}
|
}
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
|
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
|
||||||
public GL2JNIView(Context context, String newFileName,
|
public GL2JNIView(Context context, String newFileName, boolean translucent,
|
||||||
boolean translucent, int depth, int stencil, boolean editVjoyMode) {
|
int depth, int stencil, boolean editVjoyMode) {
|
||||||
super(context);
|
super(context);
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.editVjoyMode = editVjoyMode;
|
this.editVjoyMode = editVjoyMode;
|
||||||
|
@ -174,10 +174,8 @@ public class GL2JNIView extends GLSurfaceView
|
||||||
// our surface exactly. This is going to be done in our
|
// our surface exactly. This is going to be done in our
|
||||||
// custom config chooser. See ConfigChooser class definition
|
// custom config chooser. See ConfigChooser class definition
|
||||||
// below.
|
// below.
|
||||||
setEGLConfigChooser(translucent?
|
setEGLConfigChooser(new GLCFactory.ConfigChooser(
|
||||||
new GLCFactory.ConfigChooser(8, 8, 8, 8, depth, stencil)
|
8, 8, 8, translucent ? 8 : 0, depth, stencil));
|
||||||
: new GLCFactory.ConfigChooser(5, 6, 5, 0, depth, stencil)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Set the renderer responsible for frame rendering
|
// Set the renderer responsible for frame rendering
|
||||||
setRenderer(rend = new Renderer(this));
|
setRenderer(rend = new Renderer(this));
|
||||||
|
|
Loading…
Reference in New Issue