Module to run jME3 tests on Android platform. Test cases are copied in from the jme3-android project and the jme3-examples.define_list_fix
@ -0,0 +1 @@ |
||||
/build |
@ -0,0 +1,17 @@ |
||||
# Add project specific ProGuard rules here. |
||||
# By default, the flags in this file are appended to flags specified |
||||
# in C:\Users\potterec\AppData\Local\Android\sdk/tools/proguard/proguard-android.txt |
||||
# You can edit the include path and order by changing the proguardFiles |
||||
# directive in build.gradle. |
||||
# |
||||
# For more details, see |
||||
# http://developer.android.com/guide/developing/tools/proguard.html |
||||
|
||||
# Add any project specific keep options here: |
||||
|
||||
# If your project uses WebView with JS, uncomment the following |
||||
# and specify the fully qualified class name to the JavaScript interface |
||||
# class: |
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { |
||||
# public *; |
||||
#} |
@ -0,0 +1,13 @@ |
||||
package org.jmonkeyengine.jme3androidexamples; |
||||
|
||||
import android.app.Application; |
||||
import android.test.ApplicationTestCase; |
||||
|
||||
/** |
||||
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a> |
||||
*/ |
||||
public class ApplicationTest extends ApplicationTestCase<Application> { |
||||
public ApplicationTest() { |
||||
super(Application.class); |
||||
} |
||||
} |
@ -1,20 +1,49 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" |
||||
package="com.jme3.android"> |
||||
package="org.jmonkeyengine.jme3androidexamples"> |
||||
|
||||
<application |
||||
android:allowBackup="true" |
||||
android:icon="@mipmap/smartmonkey" |
||||
android:label="@string/app_name" |
||||
android:supportsRtl="true" |
||||
android:theme="@style/AppTheme"> |
||||
<activity |
||||
android:name=".MainActivity" |
||||
android:label="@string/app_name" |
||||
android:launchMode="singleTask"> |
||||
<intent-filter> |
||||
<action android:name="android.intent.action.MAIN"/> |
||||
|
||||
<category android:name="android.intent.category.LAUNCHER"/> |
||||
</intent-filter> |
||||
</activity> |
||||
<activity |
||||
android:name=".TestActivity" |
||||
android:label="@string/app_name" |
||||
android:launchMode="singleTask" |
||||
android:screenOrientation="landscape"> |
||||
</activity> |
||||
</application> |
||||
|
||||
<!-- Tell the system that you need ES 2.0. --> |
||||
<uses-feature android:glEsVersion="0x00020000" android:required="true" /> |
||||
<uses-feature |
||||
android:glEsVersion="0x00020000" |
||||
android:required="true"/> |
||||
|
||||
<!-- Tell the system that you need distinct touches (for the zoom gesture). --> |
||||
<uses-feature android:name="android.hardware.touchscreen.multitouch.distinct" android:required="true" /> |
||||
<uses-feature |
||||
android:name="android.hardware.touchscreen.multitouch.distinct" |
||||
android:required="true"/> |
||||
|
||||
<application android:label="@string/app_name" android:allowBackup="true"> |
||||
<activity android:name="jme3test.android.TestChooserAndroid" |
||||
android:label="@string/app_name"> |
||||
<intent-filter> |
||||
<action android:name="android.intent.action.MAIN" /> |
||||
<category android:name="android.intent.category.LAUNCHER" /> |
||||
</intent-filter> |
||||
</activity> |
||||
</application> |
||||
<supports-screens |
||||
android:anyDensity="true" |
||||
android:largeScreens="true" |
||||
android:normalScreens="true" |
||||
android:smallScreens="true"/> |
||||
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> |
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE"/> |
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> |
||||
|
||||
</manifest> |
||||
</manifest> |
||||
|
@ -1,12 +0,0 @@ |
||||
package jme3test.android; |
||||
|
||||
import android.content.pm.ActivityInfo; |
||||
import android.app.*; |
||||
import android.os.Bundle; |
||||
|
||||
public class TestChooserAndroid extends Activity { |
||||
@Override |
||||
public void onCreate(Bundle savedInstanceState) { |
||||
super.onCreate(savedInstanceState); |
||||
} |
||||
} |
@ -0,0 +1,165 @@ |
||||
package org.jmonkeyengine.jme3androidexamples; |
||||
|
||||
import android.content.Context; |
||||
import android.util.Log; |
||||
import android.view.LayoutInflater; |
||||
import android.view.View; |
||||
import android.view.ViewGroup; |
||||
import android.widget.ArrayAdapter; |
||||
import android.widget.Filter; |
||||
import android.widget.LinearLayout; |
||||
import android.widget.TextView; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
public class CustomArrayAdapter extends ArrayAdapter<String> { |
||||
private static final String TAG = "CustomArrayAdapter"; |
||||
|
||||
/* List of items */ |
||||
private List<String> entries; |
||||
private Context activity; |
||||
|
||||
/* Position of selected answer */ |
||||
private int selectedPosition = -1; |
||||
/* Background Color of selected item */ |
||||
private int selectedBackgroundColor = 0xffff00; |
||||
/* Background Color of non selected item */ |
||||
private int nonselectedBackgroundColor = 0x000000; |
||||
/* Background Drawable Resource ID of selected item */ |
||||
private int selectedBackgroundResource = 0; |
||||
/* Background Drawable Resource ID of non selected items */ |
||||
private int nonselectedBackgroundResource = 0; |
||||
|
||||
/* Variables to support list filtering */ |
||||
private ArrayList<String> filteredEntries; |
||||
private Filter filter; |
||||
|
||||
public CustomArrayAdapter(Context context, int textViewResourceId, List<String> objects) { |
||||
super(context, textViewResourceId, objects); |
||||
activity = context; |
||||
entries = new ArrayList<String>(objects); |
||||
filteredEntries = new ArrayList<String>(objects); |
||||
filter = new ClassNameFilter(); |
||||
} |
||||
|
||||
/** Setter for selected item position */ |
||||
public void setSelectedPosition(int selectedPosition) { |
||||
this.selectedPosition = selectedPosition; |
||||
Log.i(TAG, "Setting position to: " + this.selectedPosition); |
||||
} |
||||
|
||||
/** Setter for selected item background color */ |
||||
public void setSelectedBackgroundColor(int selectedBackgroundColor) { |
||||
this.selectedBackgroundColor = selectedBackgroundColor; |
||||
} |
||||
|
||||
/** Setter for non selected background color */ |
||||
public void setNonSelectedBackgroundColor(int nonselectedBackgroundColor) { |
||||
this.nonselectedBackgroundColor = nonselectedBackgroundColor; |
||||
} |
||||
|
||||
/** Setter for selected item background resource id*/ |
||||
public void setSelectedBackgroundResource(int selectedBackgroundResource) { |
||||
this.selectedBackgroundResource = selectedBackgroundResource; |
||||
} |
||||
|
||||
/** Setter for non selected background resource id*/ |
||||
public void setNonSelectedBackgroundResource(int nonselectedBackgroundResource) { |
||||
this.nonselectedBackgroundResource = nonselectedBackgroundResource; |
||||
} |
||||
|
||||
@Override |
||||
public View getView(int position, View convertView, ViewGroup parent) { |
||||
Log.i(TAG, "getView for position: " + position + " with selectedItem: " + selectedPosition); |
||||
|
||||
View v = convertView; |
||||
ViewHolder holder; |
||||
if (v == null) { |
||||
LayoutInflater vi = |
||||
(LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); |
||||
v = vi.inflate(R.layout.test_chooser_row, null); |
||||
holder = new ViewHolder(); |
||||
holder.textView = (TextView) v.findViewById(R.id.txtClassName); |
||||
holder.layoutRow = (LinearLayout) v.findViewById(R.id.layoutTestChooserRow); |
||||
v.setTag(holder); |
||||
} else { |
||||
holder=(ViewHolder)v.getTag(); |
||||
} |
||||
|
||||
final String itemText = filteredEntries.get(position); |
||||
if (itemText != null) { |
||||
holder.textView.setText(itemText); |
||||
if (position == selectedPosition) { |
||||
Log.i(TAG, "setting Background Color to: " + selectedBackgroundColor); |
||||
// holder.textView.setBackgroundColor(selectedBackgroundColor);
|
||||
// holder.textView.setBackgroundResource(selectedBackgroundResource);
|
||||
holder.layoutRow.setBackgroundResource(selectedBackgroundResource); |
||||
} else { |
||||
Log.i(TAG, "setting Background Color to: " + nonselectedBackgroundColor); |
||||
// holder.textView.setBackgroundColor(nonselectedBackgroundColor);
|
||||
// holder.textView.setBackgroundResource(nonselectedBackgroundResource);
|
||||
holder.layoutRow.setBackgroundResource(nonselectedBackgroundResource); |
||||
} |
||||
} |
||||
return v; |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public Filter getFilter(){ |
||||
if(filter == null){ |
||||
filter = new ClassNameFilter(); |
||||
} |
||||
return filter; |
||||
} |
||||
|
||||
public static class ViewHolder{ |
||||
public TextView textView; |
||||
public LinearLayout layoutRow; |
||||
} |
||||
|
||||
private class ClassNameFilter extends Filter{ |
||||
@Override |
||||
protected FilterResults performFiltering(CharSequence constraint){ |
||||
FilterResults results = new FilterResults(); |
||||
String prefix = constraint.toString().toLowerCase(); |
||||
Log.i(TAG, "performFiltering: entries size: " + entries.size()); |
||||
if (prefix == null || prefix.length() == 0){ |
||||
ArrayList<String> list = new ArrayList<String>(entries); |
||||
results.values = list; |
||||
results.count = list.size(); |
||||
Log.i(TAG, "clearing filter with size: " + list.size()); |
||||
}else{ |
||||
final ArrayList<String> list = new ArrayList<String>(entries); |
||||
final ArrayList<String> nlist = new ArrayList<String>(); |
||||
int count = list.size(); |
||||
|
||||
for (int i = 0; i<count; i++){ |
||||
if(list.get(i).toLowerCase().contains(prefix)){ |
||||
nlist.add(list.get(i)); |
||||
} |
||||
results.values = nlist; |
||||
results.count = nlist.size(); |
||||
} |
||||
Log.i(TAG, "filtered list size: " + nlist.size() + ", entries size: " + entries.size()); |
||||
} |
||||
Log.i(TAG, "Returning filter count: " + results.count); |
||||
return results; |
||||
} |
||||
|
||||
@SuppressWarnings("unchecked") |
||||
@Override |
||||
protected void publishResults(CharSequence constraint, FilterResults results) { |
||||
filteredEntries = (ArrayList<String>)results.values; |
||||
notifyDataSetChanged(); |
||||
clear(); |
||||
int count = filteredEntries.size(); |
||||
for(int i = 0; i<count; i++){ |
||||
add(filteredEntries.get(i)); |
||||
notifyDataSetInvalidated(); |
||||
} |
||||
Log.i(TAG, "publishing results with size: " + count); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,75 @@ |
||||
package org.jmonkeyengine.jme3androidexamples; |
||||
|
||||
import android.os.Bundle; |
||||
import com.jme3.app.AndroidHarnessFragment; |
||||
|
||||
import java.util.logging.Level; |
||||
import java.util.logging.LogManager; |
||||
|
||||
import static org.jmonkeyengine.jme3androidexamples.MainActivity.*; |
||||
|
||||
/** |
||||
* A placeholder fragment containing a the jME GLSurfaceView. |
||||
*/ |
||||
public class JmeFragment extends AndroidHarnessFragment { |
||||
|
||||
public JmeFragment() { |
||||
// Set the desired EGL configuration
|
||||
eglBitsPerPixel = 24; |
||||
eglAlphaBits = 0; |
||||
eglDepthBits = 16; |
||||
eglSamples = 0; |
||||
eglStencilBits = 0; |
||||
|
||||
// Set the maximum framerate
|
||||
// (default = -1 for unlimited)
|
||||
frameRate = -1; |
||||
|
||||
// Set the maximum resolution dimension
|
||||
// (the smaller side, height or width, is set automatically
|
||||
// to maintain the original device screen aspect ratio)
|
||||
// (default = -1 to match device screen resolution)
|
||||
maxResolutionDimension = -1; |
||||
|
||||
/* |
||||
Skip these settings and use the settings stored in the Bundle retrieved during onCreate. |
||||
|
||||
// Set main project class (fully qualified path)
|
||||
appClass = ""; |
||||
|
||||
// Set input configuration settings
|
||||
joystickEventsEnabled = false; |
||||
keyEventsEnabled = true; |
||||
mouseEventsEnabled = true; |
||||
*/ |
||||
|
||||
// Set application exit settings
|
||||
finishOnAppStop = true; |
||||
handleExitHook = true; |
||||
exitDialogTitle = "Do you want to exit?"; |
||||
exitDialogMessage = "Use your home key to bring this app into the background or exit to terminate it."; |
||||
|
||||
// Set splash screen resource id, if used
|
||||
// (default = 0, no splash screen)
|
||||
// For example, if the image file name is "splash"...
|
||||
// splashPicID = R.drawable.splash;
|
||||
splashPicID = 0; |
||||
// splashPicID = R.drawable.android_splash;
|
||||
|
||||
// Set the default logging level (default=Level.INFO, Level.ALL=All Debug Info)
|
||||
LogManager.getLogManager().getLogger("").setLevel(Level.INFO); |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void onCreate(Bundle savedInstanceState) { |
||||
Bundle bundle=getArguments(); |
||||
|
||||
appClass = bundle.getString(SELECTED_APP_CLASS); |
||||
joystickEventsEnabled = bundle.getBoolean(ENABLE_JOYSTICK_EVENTS); |
||||
keyEventsEnabled = bundle.getBoolean(ENABLE_KEY_EVENTS); |
||||
mouseEventsEnabled = bundle.getBoolean(ENABLE_MOUSE_EVENTS); |
||||
|
||||
super.onCreate(savedInstanceState); |
||||
} |
||||
} |
@ -0,0 +1,408 @@ |
||||
package org.jmonkeyengine.jme3androidexamples; |
||||
|
||||
import android.app.Activity; |
||||
import android.content.Intent; |
||||
import android.content.pm.ApplicationInfo; |
||||
import android.os.Bundle; |
||||
import android.text.Editable; |
||||
import android.text.TextWatcher; |
||||
import android.util.Log; |
||||
import android.view.Menu; |
||||
import android.view.MenuInflater; |
||||
import android.view.MenuItem; |
||||
import android.view.View; |
||||
import android.widget.AdapterView; |
||||
import android.widget.AdapterView.OnItemClickListener; |
||||
import android.widget.Button; |
||||
import android.widget.EditText; |
||||
import android.widget.ListView; |
||||
import com.jme3.app.Application; |
||||
import dalvik.system.DexFile; |
||||
import java.io.IOException; |
||||
import java.util.ArrayList; |
||||
import java.util.Enumeration; |
||||
import java.util.List; |
||||
|
||||
//TODO: Create onscreen virtual keypad for triggering normal mapped keys used by test apps or modify test apps for touch with onscreen keypad
|
||||
|
||||
/** |
||||
* Main Activity started by the application. Users select different jME3 test |
||||
* applications that are started via TestsHarness Activity. |
||||
* @author iwgeric |
||||
*/ |
||||
public class MainActivity extends Activity implements OnItemClickListener, View.OnClickListener, TextWatcher { |
||||
private static final String TAG = "MainActivity"; |
||||
|
||||
/** |
||||
* Static String to pass the key for the selected test app to the |
||||
* TestsHarness class to start the application. Also used to store the |
||||
* current selection to the savedInstanceState Bundle. |
||||
*/ |
||||
public static final String SELECTED_APP_CLASS = "Selected_App_Class"; |
||||
|
||||
/** |
||||
* Static String to pass the key for the selected list position to the |
||||
* savedInstanceState Bundle so the list position can be restored after |
||||
* exiting the test application. |
||||
*/ |
||||
public static final String SELECTED_LIST_POSITION = "Selected_List_Position"; |
||||
|
||||
/** |
||||
* Static String to pass the key for the setting for enabling mouse events to the |
||||
* savedInstanceState Bundle. |
||||
*/ |
||||
public static final String ENABLE_MOUSE_EVENTS = "Enable_Mouse_Events"; |
||||
|
||||
/** |
||||
* Static String to pass the key for the setting for enabling joystick events to the |
||||
* savedInstanceState Bundle. |
||||
*/ |
||||
public static final String ENABLE_JOYSTICK_EVENTS = "Enable_Joystick_Events"; |
||||
|
||||
/** |
||||
* Static String to pass the key for the setting for enabling key events to the |
||||
* savedInstanceState Bundle. |
||||
*/ |
||||
public static final String ENABLE_KEY_EVENTS = "Enable_Key_Events"; |
||||
|
||||
/* Fields to contain the current position and display contents of the spinner */ |
||||
private int currentPosition = 0; |
||||
private String currentSelection = ""; |
||||
private List<String> classNames = new ArrayList<String>(); |
||||
private List<String> exclusions = new ArrayList<String>(); |
||||
private String rootPackage; |
||||
|
||||
/* ListView that displays the test application class names. */ |
||||
private ListView listClasses; |
||||
|
||||
/* ArrayAdapter connects the spinner widget to array-based data. */ |
||||
private CustomArrayAdapter arrayAdapter; |
||||
|
||||
/* Buttons to start application or stop the activity. */ |
||||
private Button btnOK; |
||||
private Button btnCancel; |
||||
|
||||
/* Filter Edit Box */ |
||||
EditText editFilterText; |
||||
|
||||
/* Custom settings for the test app */ |
||||
private boolean enableMouseEvents = true; |
||||
private boolean enableJoystickEvents = false; |
||||
private boolean enableKeyEvents = true; |
||||
|
||||
|
||||
/** |
||||
* Called when the activity is first created. |
||||
*/ |
||||
@Override |
||||
public void onCreate(Bundle savedInstanceState) { |
||||
super.onCreate(savedInstanceState); |
||||
|
||||
if (savedInstanceState != null) { |
||||
Log.i(TAG, "Restoring selections in onCreate: " |
||||
+ "position: " + savedInstanceState.getInt(SELECTED_LIST_POSITION, 0) |
||||
+ "class: " + savedInstanceState.getString(SELECTED_APP_CLASS) |
||||
); |
||||
currentPosition = savedInstanceState.getInt(SELECTED_LIST_POSITION, 0); |
||||
currentSelection = savedInstanceState.getString(SELECTED_APP_CLASS); |
||||
enableMouseEvents = savedInstanceState.getBoolean(ENABLE_MOUSE_EVENTS, true); |
||||
enableJoystickEvents = savedInstanceState.getBoolean(ENABLE_JOYSTICK_EVENTS, false); |
||||
enableKeyEvents = savedInstanceState.getBoolean(ENABLE_KEY_EVENTS, true); |
||||
} |
||||
|
||||
|
||||
/* Set content view and register views */ |
||||
setContentView(R.layout.test_chooser_layout); |
||||
btnOK = (Button) findViewById(R.id.btnOK); |
||||
btnCancel = (Button) findViewById(R.id.btnCancel); |
||||
listClasses = (ListView) findViewById(R.id.listClasses); |
||||
editFilterText = (EditText) findViewById(R.id.txtFilter); |
||||
|
||||
|
||||
/* Define the root package to start with */ |
||||
rootPackage = "jme3test"; |
||||
|
||||
/* Create an array of Strings to define which classes to exclude */ |
||||
exclusions.add("$"); // inner classes
|
||||
exclusions.add("TestChooser"); // Desktop test chooser class
|
||||
exclusions.add("awt"); // Desktop test chooser class
|
||||
|
||||
// mExclusions.add("");
|
||||
|
||||
/* |
||||
* Read the class names from the dex file and filter based on |
||||
* name and super class. |
||||
*/ |
||||
|
||||
Log.i(TAG, "Composing Test list..."); |
||||
|
||||
ApplicationInfo ai = this.getApplicationInfo(); |
||||
String classPath = ai.sourceDir; |
||||
DexFile dex = null; |
||||
Enumeration<String> apkClassNames = null; |
||||
try { |
||||
dex = new DexFile(classPath); |
||||
apkClassNames = dex.entries(); |
||||
while (apkClassNames.hasMoreElements()) { |
||||
String className = apkClassNames.nextElement(); |
||||
if (checkClassName(className) && checkClassType(className)) { |
||||
classNames.add(className); |
||||
} |
||||
// classNames.add(className);
|
||||
} |
||||
} catch (IOException e) { |
||||
e.printStackTrace(); |
||||
} finally { |
||||
try { |
||||
dex.close(); |
||||
} catch (IOException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
|
||||
/* |
||||
* Create a backing Adapter for the List View from a list of the |
||||
* classes. The list is defined by array of class names. |
||||
*/ |
||||
arrayAdapter = new CustomArrayAdapter( |
||||
this, |
||||
R.layout.test_chooser_row, // text view to display selection
|
||||
classNames // array of strings to display
|
||||
); |
||||
|
||||
/* Set the resource id for selected and non selected backgrounds */ |
||||
Log.i(TAG, "Setting Adapter Background Resource IDs"); |
||||
arrayAdapter.setSelectedBackgroundResource(R.drawable.selected); |
||||
arrayAdapter.setNonSelectedBackgroundResource(R.drawable.nonselected); |
||||
|
||||
/* Attach the Adapter to the spinner */ |
||||
Log.i(TAG, "Setting ListView Adapter"); |
||||
listClasses.setAdapter(arrayAdapter); |
||||
|
||||
/* Set initial selection for the list */ |
||||
setSelection(currentPosition); |
||||
|
||||
/* Set Click and Text Changed listeners */ |
||||
listClasses.setOnItemClickListener(this); |
||||
btnOK.setOnClickListener(this); |
||||
btnCancel.setOnClickListener(this); |
||||
editFilterText.addTextChangedListener(this); |
||||
|
||||
} |
||||
|
||||
/** |
||||
* User selected an application. Sets the current selection and redraws |
||||
* the list view to highlight the selected item. |
||||
* @param parent AdapterView tied to the list |
||||
* @param view The ListView |
||||
* @param position Selection position in the list of class names |
||||
* @param id |
||||
*/ |
||||
@Override |
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { |
||||
setSelection(position); |
||||
} |
||||
|
||||
/** |
||||
* User clicked a view on the screen. Check for the OK and Cancel buttons |
||||
* and either start the applicaiton or exit. |
||||
* @param view |
||||
*/ |
||||
public void onClick(View view) { |
||||
if (view.equals(btnOK)) { |
||||
/* Get selected class, pack it in the intent and start the test app */ |
||||
Log.i(TAG, "User selected OK for class: " + currentSelection); |
||||
Intent intent = new Intent(this, TestActivity.class); |
||||
intent.putExtra(SELECTED_APP_CLASS, currentSelection); |
||||
intent.putExtra(ENABLE_MOUSE_EVENTS, enableMouseEvents); |
||||
intent.putExtra(ENABLE_JOYSTICK_EVENTS, enableJoystickEvents); |
||||
startActivity(intent); |
||||
} else if (view.equals(btnCancel)) { |
||||
/* Exit */ |
||||
Log.i(TAG, "User selected Cancel"); |
||||
finish(); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Check class name to see if the class is in the root package and if it |
||||
* contains any of the exclusion strings |
||||
* @param className Class name to check |
||||
* @return true if the check passes, false otherwise |
||||
*/ |
||||
private boolean checkClassName(String className) { |
||||
boolean include = true; |
||||
/* check to see if the class in inside the rootPackage package */ |
||||
if (className.startsWith(rootPackage)) { |
||||
/* check to see if the class contains any of the exlusion strings */ |
||||
for (int i = 0; i < exclusions.size(); i++) { |
||||
if (className.contains(exclusions.get(i))) { |
||||
Log.i(TAG, "Skipping Class " + className + ". Includes exclusion string: " + exclusions.get(i) + "."); |
||||
include = false; |
||||
break; |
||||
} |
||||
} |
||||
} else { |
||||
include = false; |
||||
Log.i(TAG, "Skipping Class " + className + ". Not in the root package: " + rootPackage + "."); |
||||
} |
||||
return include; |
||||
} |
||||
|
||||
/** |
||||
* Check to see if the class extends Application or SimpleApplication |
||||
* @param className Class name to check |
||||
* @return true if the check passes, false otherwise |
||||
*/ |
||||
private boolean checkClassType(String className) { |
||||
boolean include = true; |
||||
try { |
||||
Class<?> clazz = (Class<?>)Class.forName(className); |
||||
if (Application.class.isAssignableFrom(clazz)) { |
||||
Log.i(TAG, "Class " + className + " is a jME Application"); |
||||
} else { |
||||
include = false; |
||||
Log.i(TAG, "Skipping Class " + className + ". Not a jME Application"); |
||||
} |
||||
|
||||
} catch (ClassNotFoundException cnfe) { |
||||
include = false; |
||||
Log.i(TAG, "Skipping Class " + className + ". Class not found."); |
||||
} |
||||
return include; |
||||
} |
||||
|
||||
private void setSelection(int position) { |
||||
if (position == -1) { |
||||
arrayAdapter.setSelectedPosition(-1); |
||||
currentPosition = -1; |
||||
currentSelection = ""; |
||||
btnOK.setEnabled(false); |
||||
listClasses.invalidateViews(); |
||||
} else { |
||||
arrayAdapter.setSelectedPosition(position); |
||||
currentPosition = position; |
||||
currentSelection = arrayAdapter.getItem(position); |
||||
btnOK.setEnabled(true); |
||||
listClasses.invalidateViews(); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void onSaveInstanceState(Bundle savedInstanceState) { |
||||
super.onSaveInstanceState(savedInstanceState); |
||||
Log.i(TAG, "Saving selections in onSaveInstanceState: " |
||||
+ "position: " + currentPosition + ", " |
||||
+ "class: " + currentSelection + ", " |
||||
+ "mouseEvents: " + enableMouseEvents + ", " |
||||
+ "joystickEvents: " + enableJoystickEvents + ", " |
||||
); |
||||
// Save current selections to the savedInstanceState.
|
||||
// This bundle will be passed to onCreate if the process is
|
||||
// killed and restarted.
|
||||
savedInstanceState.putString(SELECTED_APP_CLASS, currentSelection); |
||||
savedInstanceState.putInt(SELECTED_LIST_POSITION, currentPosition); |
||||
savedInstanceState.putBoolean(ENABLE_MOUSE_EVENTS, enableMouseEvents); |
||||
savedInstanceState.putBoolean(ENABLE_JOYSTICK_EVENTS, enableJoystickEvents); |
||||
} |
||||
|
||||
@Override |
||||
public void onRestoreInstanceState(Bundle savedInstanceState) { |
||||
super.onRestoreInstanceState(savedInstanceState); |
||||
// Log.i(TAG, "Restoring selections in onRestoreInstanceState: "
|
||||
// + "position: " + savedInstanceState.getInt(SELECTED_LIST_POSITION, 0)
|
||||
// + "class: " + savedInstanceState.getString(SELECTED_APP_CLASS)
|
||||
// );
|
||||
// //Restore selections from the savedInstanceState.
|
||||
// // This bundle has also been passed to onCreate.
|
||||
// currentPosition = savedInstanceState.getInt(SELECTED_LIST_POSITION, 0);
|
||||
// currentSelection = savedInstanceState.getString(SELECTED_APP_CLASS);
|
||||
} |
||||
|
||||
public void beforeTextChanged(CharSequence cs, int i, int i1, int i2) { |
||||
} |
||||
|
||||
public void onTextChanged(CharSequence cs, int startPos, int beforePos, int count) { |
||||
Log.i(TAG, "onTextChanged with cs: " + cs + ", startPos: " + startPos + ", beforePos: " + beforePos + ", count: " + count); |
||||
arrayAdapter.getFilter().filter(cs.toString()); |
||||
setSelection(-1); |
||||
} |
||||
|
||||
public void afterTextChanged(Editable edtbl) { |
||||
} |
||||
|
||||
@Override |
||||
protected void onDestroy() { |
||||
super.onDestroy(); |
||||
editFilterText.removeTextChangedListener(this); |
||||
} |
||||
|
||||
@Override |
||||
public boolean onCreateOptionsMenu(Menu menu) { |
||||
MenuInflater inflater = getMenuInflater(); |
||||
inflater.inflate(R.menu.menu_items, menu); |
||||
|
||||
return true; |
||||
} |
||||
|
||||
@Override |
||||
public boolean onPrepareOptionsMenu (Menu menu) { |
||||
MenuItem item; |
||||
|
||||
item = menu.findItem(R.id.optionMouseEvents); |
||||
if (item != null) { |
||||
Log.i(TAG, "Found EnableMouseEvents menu item"); |
||||
if (enableMouseEvents) { |
||||
item.setTitle(R.string.strOptionDisableMouseEventsTitle); |
||||
} else { |
||||
item.setTitle(R.string.strOptionEnableMouseEventsTitle); |
||||
} |
||||
} |
||||
|
||||
item = menu.findItem(R.id.optionJoystickEvents); |
||||
if (item != null) { |
||||
Log.i(TAG, "Found EnableJoystickEvents menu item"); |
||||
if (enableJoystickEvents) { |
||||
item.setTitle(R.string.strOptionDisableJoystickEventsTitle); |
||||
} else { |
||||
item.setTitle(R.string.strOptionEnableJoystickEventsTitle); |
||||
} |
||||
} |
||||
|
||||
item = menu.findItem(R.id.optionKeyEvents); |
||||
if (item != null) { |
||||
Log.i(TAG, "Found EnableKeyEvents menu item"); |
||||
if (enableKeyEvents) { |
||||
item.setTitle(R.string.strOptionDisableKeyEventsTitle); |
||||
} else { |
||||
item.setTitle(R.string.strOptionEnableKeyEventsTitle); |
||||
} |
||||
} |
||||
|
||||
return true; |
||||
} |
||||
|
||||
@Override |
||||
public boolean onOptionsItemSelected(MenuItem item) { |
||||
switch (item.getItemId()) { |
||||
case R.id.optionMouseEvents: |
||||
enableMouseEvents = !enableMouseEvents; |
||||
Log.i(TAG, "enableMouseEvents set to: " + enableMouseEvents); |
||||
break; |
||||
case R.id.optionJoystickEvents: |
||||
enableJoystickEvents = !enableJoystickEvents; |
||||
Log.i(TAG, "enableJoystickEvents set to: " + enableJoystickEvents); |
||||
break; |
||||
case R.id.optionKeyEvents: |
||||
enableKeyEvents = !enableKeyEvents; |
||||
Log.i(TAG, "enableKeyEvents set to: " + enableKeyEvents); |
||||
break; |
||||
default: |
||||
return super.onOptionsItemSelected(item); |
||||
} |
||||
|
||||
return true; |
||||
|
||||
} |
||||
|
||||
} |
@ -0,0 +1,49 @@ |
||||
package org.jmonkeyengine.jme3androidexamples; |
||||
|
||||
import android.app.FragmentTransaction; |
||||
import android.support.v7.app.AppCompatActivity; |
||||
import android.os.Bundle; |
||||
import android.util.Log; |
||||
|
||||
public class TestActivity extends AppCompatActivity { |
||||
|
||||
@Override |
||||
protected void onCreate(Bundle savedInstanceState) { |
||||
super.onCreate(savedInstanceState); |
||||
setContentView(R.layout.activity_test); |
||||
|
||||
JmeFragment fragment = new JmeFragment(); |
||||
// Supply index input as an argument.
|
||||
Bundle args = new Bundle(); |
||||
|
||||
String appClass = savedInstanceState.getString(MainActivity.SELECTED_APP_CLASS); |
||||
args.putString(MainActivity.SELECTED_APP_CLASS, appClass); |
||||
Log.d(TestActivity.class.getSimpleName(), "AppClass="+appClass); |
||||
|
||||
boolean mouseEnabled = savedInstanceState.getBoolean(MainActivity.ENABLE_MOUSE_EVENTS, true); |
||||
args.putBoolean(MainActivity.ENABLE_MOUSE_EVENTS, mouseEnabled); |
||||
Log.d(TestActivity.class.getSimpleName(), "MouseEnabled="+mouseEnabled); |
||||
|
||||
boolean joystickEnabled = savedInstanceState.getBoolean(MainActivity.ENABLE_JOYSTICK_EVENTS, true); |
||||
args.putBoolean(MainActivity.ENABLE_JOYSTICK_EVENTS, joystickEnabled); |
||||
Log.d(TestActivity.class.getSimpleName(), "JoystickEnabled="+joystickEnabled); |
||||
|
||||
boolean keyEnabled = savedInstanceState.getBoolean(MainActivity.ENABLE_KEY_EVENTS, true); |
||||
args.putBoolean(MainActivity.ENABLE_KEY_EVENTS, keyEnabled); |
||||
Log.d(TestActivity.class.getSimpleName(), "KeyEnabled="+keyEnabled); |
||||
|
||||
fragment.setArguments(args); |
||||
|
||||
|
||||
FragmentTransaction transaction = getFragmentManager().beginTransaction(); |
||||
|
||||
// Replace whatever is in the fragment_container view with this fragment,
|
||||
// and add the transaction to the back stack so the user can navigate back
|
||||
transaction.replace(R.id.jMEFragment, fragment); |
||||
transaction.addToBackStack(null); |
||||
|
||||
// Commit the transaction
|
||||
transaction.commit(); |
||||
|
||||
} |
||||
} |
After Width: | Height: | Size: 33 KiB |
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 100 KiB |
After Width: | Height: | Size: 108 KiB |
After Width: | Height: | Size: 134 B |
After Width: | Height: | Size: 124 B |
@ -0,0 +1,21 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||
xmlns:tools="http://schemas.android.com/tools" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" |
||||
android:paddingBottom="@dimen/activity_vertical_margin" |
||||
android:paddingLeft="@dimen/activity_horizontal_margin" |
||||
android:paddingRight="@dimen/activity_horizontal_margin" |
||||
android:paddingTop="@dimen/activity_vertical_margin" |
||||
tools:context="org.jmonkeyengine.jme3androidexamples.TestActivity"> |
||||
|
||||
<fragment |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" |
||||
android:name="org.jmonkeyengine.jme3androidexamples.JmeFragment" |
||||
android:id="@+id/jMEFragment" |
||||
android:layout_alignParentTop="true" |
||||
android:layout_alignParentStart="true" |
||||
android:layout_alignParentLeft="true"/> |
||||
|
||||
</RelativeLayout> |
@ -0,0 +1,119 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||
android:id="@+id/layoutTestChooser" |
||||
android:layout_width="fill_parent" |
||||
android:layout_height="fill_parent" |
||||
android:background="#FFFFFF" |
||||
> |
||||
|
||||
<TextView |
||||
android:id="@+id/lblTitle" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_alignParentLeft="true" |
||||
android:layout_alignParentTop="true" |
||||
android:layout_marginTop="10dp" |
||||
android:layout_marginLeft="10dp" |
||||
android:layout_marginRight="10dp" |
||||
android:text="@string/strLblTitle" |
||||
android:textSize="20sp" |
||||
android:textColor="#000000" |
||||
/> |
||||
|
||||
<LinearLayout |
||||
android:id="@+id/layoutFilter" |
||||
android:layout_width="fill_parent" |
||||
android:layout_height="wrap_content" |
||||
android:layout_below="@id/lblTitle" |
||||
android:layout_marginBottom="10dp" |
||||
android:layout_marginTop="10dp" |
||||
android:layout_marginLeft="10dp" |
||||
android:layout_marginRight="10dp" |
||||
android:orientation="horizontal" |
||||
> |
||||
|
||||
<TextView |
||||
android:id="@+id/lblFindTitle" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginRight="10dp" |
||||
android:text="@string/strLblFindTitle" |
||||
android:textSize="20sp" |
||||
android:textColor="#000000" |
||||
/> |
||||
|
||||
<EditText |
||||
android:id="@+id/txtFilter" |
||||
android:layout_width="fill_parent" |
||||
android:layout_height="wrap_content" |
||||
android:layout_weight="1" |
||||
android:ems="10" |
||||
android:hint="@string/strTxtFilterHint" |
||||
android:inputType="text" |
||||
android:textSize="20sp" |
||||
android:textColor="#000000" |
||||
/> |
||||
|
||||
</LinearLayout> |
||||
|
||||
<LinearLayout |
||||
android:id="@+id/layoutButtons" |
||||
android:layout_width="fill_parent" |
||||
android:layout_height="wrap_content" |
||||
android:layout_alignParentBottom="true" |
||||
android:gravity="center" |
||||
android:layout_marginTop="20dp" |
||||
android:focusable="true" |
||||
android:focusableInTouchMode="true" |
||||
> |
||||
|
||||
<Button |
||||
android:id="@+id/btnOK" |
||||
android:layout_width="100dp" |
||||
android:layout_height="wrap_content" |
||||
android:text="@string/strBtnOK" |
||||
android:layout_marginRight="20dp" |
||||
android:textSize="20sp" |
||||
android:textColor="#000000" |
||||
/> |
||||
|
||||
<Button |
||||
android:id="@+id/btnCancel" |
||||
android:layout_width="100dp" |
||||
android:layout_height="wrap_content" |
||||
android:text="@string/strBtnCancel" |
||||
android:layout_marginLeft="20dp" |
||||
android:textSize="20sp" |
||||
android:textColor="#000000" |
||||
/> |
||||
<requestFocus/> |
||||
|
||||
</LinearLayout> |
||||
|
||||
<LinearLayout |
||||
android:layout_width="fill_parent" |
||||
android:layout_height="wrap_content" |
||||
android:layout_above="@id/layoutButtons" |
||||
android:layout_below="@id/layoutFilter" |
||||
android:gravity="center" |
||||
android:background="@drawable/selected" |
||||
> |
||||
|
||||
<ListView |
||||
android:id="@+id/listClasses" |
||||
android:layout_width="fill_parent" |
||||
android:layout_height="fill_parent" |
||||
android:choiceMode="singleChoice" |
||||
android:listSelector="@drawable/selected" |
||||
android:layout_marginTop="5dp" |
||||
android:layout_marginBottom="5dp" |
||||
android:scrollbars="vertical" |
||||
android:fadeScrollbars="false" |
||||
android:textFilterEnabled="true" |
||||
> |
||||
|
||||
</ListView> |
||||
|
||||
</LinearLayout> |
||||
|
||||
</RelativeLayout> |
@ -0,0 +1,30 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<LinearLayout |
||||
xmlns:android="http://schemas.android.com/apk/res/android" |
||||
android:id="@+id/layoutTestChooserRow" |
||||
android:orientation="horizontal" |
||||
android:layout_width="fill_parent" |
||||
android:layout_height="fill_parent" |
||||
android:padding="10dp"> |
||||
|
||||
<!-- |
||||
<ImageView android:id="@+id/imgIcon" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="fill_parent" |
||||
android:gravity="center_vertical" |
||||
android:layout_marginRight="15dp" |
||||
android:layout_marginTop="5dp" |
||||
android:layout_marginBottom="5dp" /> |
||||
--> |
||||
|
||||
<TextView android:id="@+id/txtClassName" |
||||
android:layout_width="fill_parent" |
||||
android:layout_height="fill_parent" |
||||
android:gravity="center_vertical" |
||||
android:textStyle="bold" |
||||
android:textSize="22sp" |
||||
android:textColor="#000000" |
||||
android:layout_marginTop="5dp" |
||||
android:layout_marginBottom="5dp" /> |
||||
|
||||
</LinearLayout> |
@ -0,0 +1,29 @@ |
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android" |
||||
xmlns:app="http://schemas.android.com/apk/res-auto" |
||||
xmlns:tools="http://schemas.android.com/tools" |
||||
tools:context="org.jmonkeyengine.jme3androidexamples.MainActivity"> |
||||
|
||||
This menu should show up as 3 icons in the app toolbar. |
||||
|
||||
<item |
||||
android:id="@+id/optionMouseEvents" |
||||
android:orderInCategory="100" |
||||
android:title="@string/strOptionEnableMouseEventsTitle" |
||||
app:showAsAction="ifRoom" /> |
||||
<item |
||||
android:id="@+id/optionJoystickEvents" |
||||
android:orderInCategory="200" |
||||
android:title="@string/strOptionEnableJoystickEventsTitle" |
||||
app:showAsAction="ifRoom" /> |
||||
<item |
||||
android:id="@+id/optionKeyEvents" |
||||
android:orderInCategory="300" |
||||
android:title="@string/strOptionEnableKeyEventsTitle" |
||||
app:showAsAction="ifRoom" /> |
||||
|
||||
<!-- |
||||
android:icon="@mipmap/redmonkey" |
||||
android:icon="@mipmap/greenmonkey" |
||||
android:icon="@mipmap/bluemonkey" |
||||
--> |
||||
</menu> |
After Width: | Height: | Size: 5.2 KiB |
After Width: | Height: | Size: 3.5 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 67 KiB |
After Width: | Height: | Size: 67 KiB |
@ -0,0 +1,6 @@ |
||||
<resources> |
||||
<!-- Example customization of dimensions originally defined in res/values/dimens.xml |
||||
(such as screen margins) for screens with more than 820dp of available width. This |
||||
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). --> |
||||
<dimen name="activity_horizontal_margin">64dp</dimen> |
||||
</resources> |
@ -0,0 +1,6 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<resources> |
||||
<color name="colorPrimary">#3F51B5</color> |
||||
<color name="colorPrimaryDark">#303F9F</color> |
||||
<color name="colorAccent">#FF4081</color> |
||||
</resources> |
@ -0,0 +1,5 @@ |
||||
<resources> |
||||
<!-- Default screen margins, per the Android Design guidelines. --> |
||||
<dimen name="activity_horizontal_margin">16dp</dimen> |
||||
<dimen name="activity_vertical_margin">16dp</dimen> |
||||
</resources> |
@ -1,6 +1,19 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<resources> |
||||
<string name="app_name">JMEAndroidTest</string> |
||||
<string name="about">About</string> |
||||
<string name="quit">Quit</string> |
||||
</resources> |
||||
<!-- Main Application Title --> |
||||
<string name="app_name">jME3 Tests Android</string> |
||||
|
||||
<!-- MainActivity UIF Labels --> |
||||
<string name="strLblTitle">Choose a demo to start:</string> |
||||
<string name="strLblFindTitle">Find:</string> |
||||
<string name="strTxtFilterHint">Enter a Filter</string> |
||||
<string name="strBtnOK">OK</string> |
||||
<string name="strBtnCancel">Cancel</string> |
||||
|
||||
<!-- MainActivity Menu Labels --> |
||||
<string name="strOptionEnableMouseEventsTitle">Enable Mouse Events</string> |
||||
<string name="strOptionDisableMouseEventsTitle">Disable Mouse Events</string> |
||||
<string name="strOptionEnableJoystickEventsTitle">Enable Joystick Events</string> |
||||
<string name="strOptionDisableJoystickEventsTitle">Disable Joystick Events</string> |
||||
<string name="strOptionEnableKeyEventsTitle">Enable Key Events</string> |
||||
<string name="strOptionDisableKeyEventsTitle">Disable Key Events</string> |
||||
</resources> |
||||
|
@ -0,0 +1,11 @@ |
||||
<resources> |
||||
|
||||
<!-- Base application theme. --> |
||||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> |
||||
<!-- Customize your theme here. --> |
||||
<item name="colorPrimary">@color/colorPrimary</item> |
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> |
||||
<item name="colorAccent">@color/colorAccent</item> |
||||
</style> |
||||
|
||||
</resources> |
@ -0,0 +1,15 @@ |
||||
package org.jmonkeyengine.jme3androidexamples; |
||||
|
||||
import org.junit.Test; |
||||
|
||||
import static org.junit.Assert.*; |
||||
|
||||
/** |
||||
* To work on unit tests, switch the Test Artifact in the Build Variants view. |
||||
*/ |
||||
public class ExampleUnitTest { |
||||
@Test |
||||
public void addition_isCorrect() throws Exception { |
||||
assertEquals(4, 2 + 2); |
||||
} |
||||
} |