Begin implementing a BIOS selection dialog

This is a dedicated dialog for selecting the BIOS on first run
This commit is contained in:
TwistedUmbrella 2015-04-16 17:01:01 -04:00
parent d7d0f23a29
commit 604a3a0f8a
2 changed files with 48 additions and 59 deletions

View File

@ -6,6 +6,7 @@
<string name="browser_path">Default System Path</string>
<string name="games_path">Storage Path (location of *.gdi, *.chd or *.cdi images)</string>
<string name="button_theme">Onscreen Button Theme</string>
<string name="bios_selection">Select a BIOS source</string>
<string name="game_path">Default Game Storage</string>
<string name="config_home">Please configure a home directory.</string>
@ -14,6 +15,7 @@
<string name="unsupported">Unsupported kernel version!</string>
<string name="locate">Locate</string>
<string name="browse">Browse</string>
<string name="gdrive">Google Drive</string>
<string name="boot_bios">Boot Dreamcast BIOS</string>
<string name="missing_bios_title">Missing Dreamcast BIOS</string>

View File

@ -385,65 +385,7 @@ public class MainActivity extends SlidingFragmentActivity implements
msg = getString(R.string.missing_flash, home_directory);
if (msg != null) {
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
this);
// set title
if (!isBiosExisting(MainActivity.this))
alertDialogBuilder.setTitle(R.string.missing_bios_title);
else if (!isFlashExisting(MainActivity.this))
alertDialogBuilder.setTitle(R.string.missing_flash_title);
// set dialog message
alertDialogBuilder
.setMessage(msg)
.setCancelable(false)
.setPositiveButton(R.string.dismiss,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// if this button is clicked, close
// current activity
// MainActivity.this.finish();
}
})
.setNegativeButton(R.string.options,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
FileBrowser firstFragment = new FileBrowser();
Bundle args = new Bundle();
// args.putBoolean("ImgBrowse", false);
// specify ImgBrowse option. true = images,
// false = folders only
args.putString("browse_entry", sdcard.toString());
// specify a path for selecting folder
// options
args.putBoolean("games_entry", false);
// selecting a BIOS folder, so this is not
// games
firstFragment.setArguments(args);
// In case this activity was started with
// special instructions from
// an Intent, pass the Intent's extras to
// the fragment as arguments
// firstFragment.setArguments(getIntent().getExtras());
// Add the fragment to the
// 'fragment_container' FrameLayout
getSupportFragmentManager()
.beginTransaction()
.replace(R.id.fragment_container,
firstFragment,
"MAIN_BROWSER")
.addToBackStack(null).commit();
}
});
// create alert dialog
AlertDialog alertDialog = alertDialogBuilder.create();
// show it
alertDialog.show();
launchBIOSdetection();
} else {
Config.nativeact = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getBoolean(Config.pref_nativeact, Config.nativeact);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD && Config.nativeact) {
@ -456,6 +398,51 @@ public class MainActivity extends SlidingFragmentActivity implements
}
}
private void launchBIOSdetection() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.bios_selection);
builder.setPositiveButton(R.string.browse,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
FileBrowser firstFragment = new FileBrowser();
Bundle args = new Bundle();
// args.putBoolean("ImgBrowse", false);
// specify ImgBrowse option. true = images,
// false = folders only
args.putString("browse_entry", sdcard.toString());
// specify a path for selecting folder
// options
args.putBoolean("games_entry", false);
// selecting a BIOS folder, so this is not
// games
firstFragment.setArguments(args);
// In case this activity was started with
// special instructions from
// an Intent, pass the Intent's extras to
// the fragment as arguments
// firstFragment.setArguments(getIntent().getExtras());
// Add the fragment to the
// 'fragment_container' FrameLayout
getSupportFragmentManager()
.beginTransaction()
.replace(R.id.fragment_container,
firstFragment,
"MAIN_BROWSER")
.addToBackStack(null).commit();
}
});
builder.setNegativeButton(R.string.gdrive,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(MainActivity.this, R.string.require_bios, Toast.LENGTH_SHORT).show();
}
});
builder.create();
builder.show();
}
public void onFolderSelected(Uri uri) {
FileBrowser browserFrag = (FileBrowser) getSupportFragmentManager()
.findFragmentByTag("MAIN_BROWSER");