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