Merge pull request #113 from NoblesseOblige/master

Updates to address issue items (past and future)
This commit is contained in:
Stefanos Kornilios Mitsis Poiitidis 2014-01-20 16:30:24 -08:00
commit e59372f0d2
10 changed files with 334 additions and 160 deletions

View File

@ -223,4 +223,12 @@
</TableLayout>
<Button
android:id="@+id/debug_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="8"
android:text="@string/menu_debug" />
</LinearLayout>

View File

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
android:layout_height="match_parent"
android:orientation="vertical" >
<TableLayout
android:layout_width="match_parent"
@ -59,6 +60,13 @@
android:layout_height="wrap_content" />
</LinearLayout>
</TableRow>
</TableLayout>
<TableLayout
android:id="@+id/input_devices"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:stretchColumns="*" >
<TableRow
android:layout_marginTop="25dp"
@ -241,4 +249,4 @@
</TableRow>
</TableLayout>
</ScrollView>
</LinearLayout>

View File

@ -28,6 +28,17 @@
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="32dp" />
<ImageView
android:id="@+id/config"
android:layout_width="48dp"
android:layout_height="fill_parent"
android:layout_marginBottom="2dp"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:layout_marginTop="2dp"
android:scaleType="fitCenter"
android:src="@drawable/config" />
<ImageView
android:id="@+id/options"
android:layout_width="48dp"
@ -40,7 +51,7 @@
android:src="@drawable/open_folder" />
<ImageView
android:id="@+id/config"
android:id="@+id/input"
android:layout_width="48dp"
android:layout_height="fill_parent"
android:layout_marginBottom="2dp"
@ -48,7 +59,7 @@
android:layout_marginRight="2dp"
android:layout_marginTop="2dp"
android:scaleType="fitCenter"
android:src="@drawable/config" />
android:src="@drawable/input" />
<ImageView
android:id="@+id/about"

View File

@ -87,4 +87,6 @@
<string name="textOn">ON</string>
<string name="textOff">OFF</string>
<string name="menu_debug">Save Error Logs</string>
</resources>

View File

@ -1,7 +1,13 @@
package com.reicast.emulator;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Scanner;
import org.apache.commons.lang3.StringUtils;
@ -20,13 +26,13 @@ import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public class ConfigureFragment extends Fragment {
Activity parentActivity;
@ -46,6 +52,21 @@ public class ConfigureFragment extends Fragment {
private File sdcard = Environment.getExternalStorageDirectory();
private String home_directory = sdcard + "/dc";
public static final String build_model = android.os.Build.MODEL;
public static final String build_device = android.os.Build.DEVICE;
public static final String build_board = android.os.Build.BOARD;
public static final int build_sdk = android.os.Build.VERSION.SDK_INT;
public static final String DN = "Donut";
public static final String EC = "Eclair";
public static final String FR = "Froyo";
public static final String GB = "Gingerbread";
public static final String HC = "Honeycomb";
public static final String IC = "Ice Cream Sandwich";
public static final String JB = "JellyBean";
public static final String KK = "KitKat";
public static final String NF = "Not Found";
// Container Activity must implement this interface
public interface OnClickListener {
public void onMainBrowseSelected(String path_entry, boolean games);
@ -321,6 +342,124 @@ public class ConfigureFragment extends Fragment {
pvr_render.setChecked(false);
}
pvr_render.setOnCheckedChangeListener(pvr_rendering);*/
Button debug_button = (Button) getView()
.findViewById(R.id.debug_button);
debug_button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
generateErrorLog();
}
});
}
public void generateErrorLog() {
String currentTime = String.valueOf(System.currentTimeMillis());
String logOuput = home_directory + "/" + currentTime + ".txt";
Process mLogcatProc = null;
BufferedReader reader = null;
try {
mLogcatProc = Runtime.getRuntime().exec(
new String[] { "logcat", "-d", "AndroidRuntime:E *:S" });
reader = new BufferedReader(new InputStreamReader(
mLogcatProc.getInputStream()));
String line;
final StringBuilder log = new StringBuilder();
String separator = System.getProperty("line.separator");
log.append(discoverCPUData());
log.append(separator);
log.append(separator);
log.append("AndroidRuntime Output");
log.append(separator);
log.append(separator);
while ((line = reader.readLine()) != null) {
log.append(line);
log.append(separator);
}
reader.close();
mLogcatProc = null;
reader = null;
int PID = android.os.Process
.getUidForName("com.reicast.emulator");
mLogcatProc = Runtime.getRuntime().exec(
new String[] { "logcat", "-d", "|", "grep " + PID });
reader = new BufferedReader(new InputStreamReader(
mLogcatProc.getInputStream()));
log.append(separator);
log.append(separator);
log.append("Application ID Output");
log.append(separator);
log.append(separator);
while ((line = reader.readLine()) != null) {
log.append(line);
log.append(separator);
}
reader.close();
File file = new File(logOuput);
BufferedWriter writer = new BufferedWriter(new FileWriter(file));
writer.write(log.toString());
writer.flush();
writer.close();
} catch (IOException e) {
}
}
private String discoverCPUData() {
String s = "MODEL: " + Build.MODEL;
s += "\r\n";
s += "DEVICE: " + build_device;
s += "\r\n";
s += "BOARD: " + build_board;
s += "\r\n";
if (String.valueOf(build_sdk) != null) {
String build_version = NF;
if (build_sdk >= 4 && build_sdk < 7) {
build_version = DN;
} else if (build_sdk == 7) {
build_version = EC;
} else if (build_sdk == 8) {
build_version = FR;
} else if (build_sdk >= 9 && build_sdk < 11) {
build_version = GB;
} else if (build_sdk >= 11 && build_sdk < 14) {
build_version = HC;
} else if (build_sdk >= 14 && build_sdk < 16) {
build_version = IC;
} else if (build_sdk >= 16 && build_sdk < 17) {
build_version = JB;
} else if (build_sdk >= 17) {
build_version = KK;
}
s += build_version + " (" + build_sdk + ")";
} else {
String prop_build_version = "ro.build.version.release";
String prop_sdk_version = "ro.build.version.sdk";
String build_version = readOutput("/system/bin/getprop "
+ prop_build_version);
String sdk_version = readOutput("/system/bin/getprop "
+ prop_sdk_version);
s += build_version + " (" + sdk_version + ")";
}
return s;
}
public static String readOutput(String command) {
try {
Process p = Runtime.getRuntime().exec(command);
InputStream is = null;
if (p.waitFor() == 0) {
is = p.getInputStream();
} else {
is = p.getErrorStream();
}
BufferedReader br = new BufferedReader(new InputStreamReader(is),
2048);
String line = br.readLine();
br.close();
return line;
} catch (Exception ex) {
return "ERROR: " + ex.getMessage();
}
}
private boolean executeAppendConfig(String identifier, String value) {

View File

@ -218,40 +218,6 @@ public class FileBrowser extends Fragment {
}
private void createListHeader(String header_text, View view, boolean hasBios) {
LinearLayout list_header = new LinearLayout(parentActivity);
LinearLayout.LayoutParams listParams = new LinearLayout.LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
int margin_top = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10, getResources().getDisplayMetrics());
listParams.setMargins(0, margin_top, 0, 0);
list_header.setLayoutParams(listParams);
ImageView list_icon = new ImageView(parentActivity);
LinearLayout.LayoutParams imageParams = new LinearLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
int size = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 32, getResources().getDisplayMetrics());
imageParams.width = size;
imageParams.height = size;
int margin_left_right = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 6, getResources().getDisplayMetrics());
int margin_top_bottom = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2, getResources().getDisplayMetrics());
imageParams.setMargins(margin_left_right, margin_top_bottom, margin_left_right, margin_top_bottom);
imageParams.gravity=Gravity.CENTER_VERTICAL;
list_icon.setLayoutParams(imageParams);
list_icon.setScaleType(ScaleType.FIT_CENTER);
list_icon.setImageResource(R.drawable.open_folder);
list_header.addView(list_icon);
TextView list_text = new TextView(parentActivity);
LinearLayout.LayoutParams textParams = new LinearLayout.LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
textParams.gravity=Gravity.CENTER_VERTICAL;
textParams.weight=1;
list_text.setLayoutParams(textParams);
list_text.setTextAppearance(parentActivity,
android.R.style.TextAppearance_Large);
list_text.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
list_text.setText(header_text);
list_header.addView(list_text);
if (hasBios) {
final View childview = parentActivity.getLayoutInflater().inflate(
R.layout.bios_list_item, null, false);
@ -292,7 +258,13 @@ public class FileBrowser extends Fragment {
((ViewGroup) view).addView(childview);
}
((ViewGroup) view).addView(list_header);
final View headerView = parentActivity.getLayoutInflater().inflate(
R.layout.app_list_item, null, false);
((ImageView) headerView.findViewById(R.id.item_icon))
.setImageResource(R.drawable.open_folder);
((TextView) headerView.findViewById(R.id.item_name))
.setText(header_text);
((ViewGroup) view).addView(headerView);
}

View File

@ -181,11 +181,18 @@ public class GL2JNIActivity extends Activity {
}
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
JNIdc.initControllers(new boolean[] {controllerTwoConnected, controllerThreeConnected, controllerFourConnected});
int joys[] = InputDevice.getDeviceIds();
for (int i = 0; i < joys.length; i++) {
String descriptor = InputDevice.getDevice(joys[i]).getDescriptor();
String descriptor = null;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
descriptor = InputDevice.getDevice(joys[i]).getDescriptor();
} else {
descriptor = InputDevice.getDevice(joys[i]).getName();
}
Log.d("reidc", "InputDevice ID: " + joys[i]);
Log.d("reidc", "InputDevice Name: "
+ InputDevice.getDevice(joys[i]).getName());
@ -279,6 +286,9 @@ public class GL2JNIActivity extends Activity {
OuyaController.BUTTON_R1, key_CONT_START };
}
}
}
}
// When viewing a resource, pass its URI to the native code for opening
@ -299,6 +309,8 @@ public class GL2JNIActivity extends Activity {
// Log.w("INPUT", event.toString() + " " + event.getSource());
// Get all the axis for the KeyEvent
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
Integer playerNum = deviceDescriptor_PlayerNum.get(deviceId_deviceDescriptor.get(event.getDeviceId()));
if (playerNum == null)
@ -340,6 +352,11 @@ public class GL2JNIActivity extends Activity {
return false;
else
return true;
} else {
return false;
}
}
private static final int key_CONT_B = 0x0002;

View File

@ -20,11 +20,11 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.TableLayout;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.CompoundButton.OnCheckedChangeListener;
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public class InputFragment extends Fragment {
private Activity parentActivity;
@ -77,6 +77,8 @@ public class InputFragment extends Fragment {
}
switchTouchVibrationEnabled.setOnCheckedChangeListener(touch_vibration);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
Button buttonSelectControllerPlayer1 = (Button) getView()
.findViewById(R.id.buttonSelectControllerPlayer1);
buttonSelectControllerPlayer1.setOnClickListener(new View.OnClickListener() {
@ -138,8 +140,16 @@ public class InputFragment extends Fragment {
}
});
updateVibration();
updateControllers();
} else {
TableLayout input_devices = (TableLayout) parentActivity.findViewById(R.id.input_devices);
input_devices.setVisibility(View.GONE);
}
updateVibration();
}
private void updateVibration() {
@ -157,7 +167,12 @@ public class InputFragment extends Fragment {
for (int devideId : InputDevice.getDeviceIds()) {
InputDevice dev = InputDevice.getDevice(devideId);
String descriptor = dev.getDescriptor();
String descriptor = null;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
descriptor = dev.getDescriptor();
} else {
descriptor = dev.getName();
}
if (descriptor != null) {
if (descriptor.equals(deviceDescriptorPlayer1))
@ -266,7 +281,14 @@ public class InputFragment extends Fragment {
keyCode == KeyEvent.KEYCODE_VOLUME_UP || keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)
return false;
String descriptor = InputDevice.getDevice(event.getDeviceId()).getDescriptor();
String descriptor = null;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
descriptor = InputDevice.getDevice(event.getDeviceId())
.getDescriptor();
} else {
descriptor = InputDevice.getDevice(event.getDeviceId())
.getName();
}
if (descriptor == null)
return false;

View File

@ -30,6 +30,7 @@ import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.ListView;
public class MainActivity extends FragmentActivity implements
@ -154,6 +155,7 @@ public class MainActivity extends FragmentActivity implements
// icons
invalidateOptionsMenu();
}
@SuppressLint("NewApi")
public void onDrawerOpened(View drawerView) {
getActionBar().setTitle(mDrawerTitle);
@ -169,6 +171,25 @@ public class MainActivity extends FragmentActivity implements
}
} else {
findViewById(R.id.config).setOnClickListener(new OnClickListener() {
public void onClick(View view) {
ConfigureFragment configFrag = (ConfigureFragment) getSupportFragmentManager()
.findFragmentByTag("CONFIG_FRAG");
if (configFrag != null) {
if (configFrag.isVisible()) {
return;
}
}
configFrag = new ConfigureFragment();
getSupportFragmentManager()
.beginTransaction()
.replace(R.id.fragment_container, configFrag,
"CONFIG_FRAG").addToBackStack(null)
.commit();
}
});
findViewById(R.id.options).setOnClickListener(
new OnClickListener() {
public void onClick(View view) {
@ -185,45 +206,24 @@ public class MainActivity extends FragmentActivity implements
.replace(R.id.fragment_container,
optionsFrag, "OPTIONS_FRAG")
.addToBackStack(null).commit();
/*
* AlertDialog.Builder alertDialogBuilder = new
* AlertDialog.Builder( MainActivity.this);
*
* // set title
* alertDialogBuilder.setTitle("Configure");
*
* // set dialog message alertDialogBuilder
* .setMessage("No configuration for now :D")
* .setCancelable(false)
* .setPositiveButton("Oh well",new
* DialogInterface.OnClickListener() { public void
* onClick(DialogInterface dialog,int id) {
* //FileBrowser.this.finish(); } });
*
* // create alert dialog AlertDialog alertDialog =
* alertDialogBuilder.create();
*
* // show it alertDialog.show();
*/
}
});
findViewById(R.id.config).setOnClickListener(new OnClickListener() {
findViewById(R.id.input).setOnClickListener(new OnClickListener() {
public void onClick(View view) {
ConfigureFragment configFrag = (ConfigureFragment) getSupportFragmentManager()
.findFragmentByTag("CONFIG_FRAG");
if (configFrag != null) {
if (configFrag.isVisible()) {
InputFragment inputFrag = (InputFragment) getSupportFragmentManager()
.findFragmentByTag("INPUT_FRAG");
if (inputFrag != null) {
if (inputFrag.isVisible()) {
return;
}
}
configFrag = new ConfigureFragment();
inputFrag = new InputFragment();
getSupportFragmentManager()
.beginTransaction()
.replace(R.id.fragment_container, configFrag,
"CONFIG_FRAG").addToBackStack(null)
.commit();
.replace(R.id.fragment_container, inputFrag,
"INPUT_FRAG").addToBackStack(null).commit();
}
});
@ -295,7 +295,7 @@ public class MainActivity extends FragmentActivity implements
int id) {
// if this button is clicked, close
// current activity
//MainActivity.this.finish();
// MainActivity.this.finish();
}
})
.setNegativeButton("Options",
@ -304,22 +304,31 @@ public class MainActivity extends FragmentActivity implements
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("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
// 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
// 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
// Add the fragment to the
// 'fragment_container' FrameLayout
getSupportFragmentManager()
.beginTransaction()
.replace(R.id.fragment_container, firstFragment, "MAIN_BROWSER")
.replace(R.id.fragment_container,
firstFragment,
"MAIN_BROWSER")
.addToBackStack(null).commit();
}
});
@ -329,8 +338,7 @@ public class MainActivity extends FragmentActivity implements
// show it
alertDialog.show();
}
else {
} else {
Intent inte = new Intent(Intent.ACTION_VIEW, uri, getBaseContext(),
GL2JNIActivity.class);
startActivity(inte);

View File

@ -12,15 +12,12 @@ import android.preference.PreferenceManager;
import android.support.v4.app.Fragment;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.InputDevice;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public class OptionsFragment extends Fragment {
Activity parentActivity;
@ -51,16 +48,6 @@ public class OptionsFragment extends Fragment {
throw new ClassCastException(activity.toString()
+ " must implement OnClickListener");
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
int joys[] = InputDevice.getDeviceIds();
for (int i = 0; i < joys.length; i++) {
Log.d("reidc", "InputDevice ID: " + joys[i]);
Log.d("reidc",
"InputDevice Name: "
+ InputDevice.getDevice(joys[i]).getName());
}
}
}
@Override