SDK: Updates to JME3 Tests for Android Template
- Add Android menu for enabling/disabling mouse events and joystick events - Exclude some of the mobile directories in the template zip file - Extract the uif labels as resource strings - Disable OK button on main activity until a test case is selected git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10392 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
b475a8e9c9
commit
305e3f25e0
@ -15,7 +15,7 @@
|
|||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="10dp"
|
||||||
android:layout_marginLeft="10dp"
|
android:layout_marginLeft="10dp"
|
||||||
android:layout_marginRight="10dp"
|
android:layout_marginRight="10dp"
|
||||||
android:text="Choose a demo to start:"
|
android:text="@string/strLblTitle"
|
||||||
android:textSize="20sp"
|
android:textSize="20sp"
|
||||||
android:textColor="#000000"
|
android:textColor="#000000"
|
||||||
/>
|
/>
|
||||||
@ -37,7 +37,7 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginRight="10dp"
|
android:layout_marginRight="10dp"
|
||||||
android:text="Find:"
|
android:text="@string/strLblFindTitle"
|
||||||
android:textSize="20sp"
|
android:textSize="20sp"
|
||||||
android:textColor="#000000"
|
android:textColor="#000000"
|
||||||
/>
|
/>
|
||||||
@ -48,7 +48,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:ems="10"
|
android:ems="10"
|
||||||
android:hint="Enter a Filter"
|
android:hint="@string/strTxtFilterHint"
|
||||||
android:inputType="text"
|
android:inputType="text"
|
||||||
android:textSize="20sp"
|
android:textSize="20sp"
|
||||||
android:textColor="#000000"
|
android:textColor="#000000"
|
||||||
@ -71,7 +71,7 @@
|
|||||||
android:id="@+id/btnOK"
|
android:id="@+id/btnOK"
|
||||||
android:layout_width="100dp"
|
android:layout_width="100dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="OK"
|
android:text="@string/strBtnOK"
|
||||||
android:layout_marginRight="20dp"
|
android:layout_marginRight="20dp"
|
||||||
android:textSize="20sp"
|
android:textSize="20sp"
|
||||||
android:textColor="#000000"
|
android:textColor="#000000"
|
||||||
@ -81,7 +81,7 @@
|
|||||||
android:id="@+id/btnCancel"
|
android:id="@+id/btnCancel"
|
||||||
android:layout_width="100dp"
|
android:layout_width="100dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Cancel"
|
android:text="@string/strBtnCancel"
|
||||||
android:layout_marginLeft="20dp"
|
android:layout_marginLeft="20dp"
|
||||||
android:textSize="20sp"
|
android:textSize="20sp"
|
||||||
android:textColor="#000000"
|
android:textColor="#000000"
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item
|
||||||
|
android:id="@+id/optionEnableMouseEvents"
|
||||||
|
android:title="@string/strOptionEnableMouseEventsTitle"
|
||||||
|
/>
|
||||||
|
<item android:id="@+id/optionEnableJoystickEvents"
|
||||||
|
android:title="@string/strOptionEnableJoystickEventsTitle" />
|
||||||
|
</menu>
|
@ -1,4 +1,18 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
<!-- Main Application Title -->
|
||||||
<string name="app_name">jMonkeyEngine Test Applications</string>
|
<string name="app_name">jMonkeyEngine Test Applications</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>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -49,6 +49,7 @@ public class CustomArrayAdapter extends ArrayAdapter<String> {
|
|||||||
/** Setter for selected item position */
|
/** Setter for selected item position */
|
||||||
public void setSelectedPosition(int selectedPosition) {
|
public void setSelectedPosition(int selectedPosition) {
|
||||||
this.selectedPosition = selectedPosition;
|
this.selectedPosition = selectedPosition;
|
||||||
|
Log.i(TAG, "Setting position to: " + this.selectedPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Setter for selected item background color */
|
/** Setter for selected item background color */
|
||||||
|
@ -11,13 +11,15 @@ import android.os.Bundle;
|
|||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuInflater;
|
||||||
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.AdapterView.OnItemClickListener;
|
import android.widget.AdapterView.OnItemClickListener;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.Toast;
|
|
||||||
import com.jme3.app.Application;
|
import com.jme3.app.Application;
|
||||||
import dalvik.system.DexFile;
|
import dalvik.system.DexFile;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -25,9 +27,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
//TODO: Add settings menu items for MouseEvents, JoystickEvents, and device orientation
|
|
||||||
//TODO: Create onscreen virtual keypad for triggering normal mapped keys used by test apps or modify test apps for touch with onscreen keypad
|
//TODO: Create onscreen virtual keypad for triggering normal mapped keys used by test apps or modify test apps for touch with onscreen keypad
|
||||||
//TODO: Go through each test and see if any classes need to be added to the exclusions list
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main Activity started by the application. Users select different jME3 test
|
* Main Activity started by the application. Users select different jME3 test
|
||||||
@ -51,6 +51,18 @@ public class MainActivity extends Activity implements OnItemClickListener, View.
|
|||||||
*/
|
*/
|
||||||
public static final String SELECTED_LIST_POSITION = "Selected_List_Position";
|
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";
|
||||||
|
|
||||||
/* Fields to contain the current position and display contents of the spinner */
|
/* Fields to contain the current position and display contents of the spinner */
|
||||||
private int currentPosition = 0;
|
private int currentPosition = 0;
|
||||||
private String currentSelection = "";
|
private String currentSelection = "";
|
||||||
@ -71,6 +83,10 @@ public class MainActivity extends Activity implements OnItemClickListener, View.
|
|||||||
/* Filter Edit Box */
|
/* Filter Edit Box */
|
||||||
EditText editFilterText;
|
EditText editFilterText;
|
||||||
|
|
||||||
|
/* Custom settings for the test app */
|
||||||
|
private boolean enableMouseEvents = true;
|
||||||
|
private boolean enableJoystickEvents = false;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the activity is first created.
|
* Called when the activity is first created.
|
||||||
@ -86,6 +102,8 @@ public class MainActivity extends Activity implements OnItemClickListener, View.
|
|||||||
);
|
);
|
||||||
currentPosition = savedInstanceState.getInt(SELECTED_LIST_POSITION, 0);
|
currentPosition = savedInstanceState.getInt(SELECTED_LIST_POSITION, 0);
|
||||||
currentSelection = savedInstanceState.getString(SELECTED_APP_CLASS);
|
currentSelection = savedInstanceState.getString(SELECTED_APP_CLASS);
|
||||||
|
enableMouseEvents = savedInstanceState.getBoolean(ENABLE_MOUSE_EVENTS, true);
|
||||||
|
enableJoystickEvents = savedInstanceState.getBoolean(ENABLE_JOYSTICK_EVENTS, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -192,6 +210,8 @@ public class MainActivity extends Activity implements OnItemClickListener, View.
|
|||||||
Log.i(TAG, "User selected OK for class: " + currentSelection);
|
Log.i(TAG, "User selected OK for class: " + currentSelection);
|
||||||
Intent intent = new Intent(this, TestsHarness.class);
|
Intent intent = new Intent(this, TestsHarness.class);
|
||||||
intent.putExtra(SELECTED_APP_CLASS, currentSelection);
|
intent.putExtra(SELECTED_APP_CLASS, currentSelection);
|
||||||
|
intent.putExtra(ENABLE_MOUSE_EVENTS, enableMouseEvents);
|
||||||
|
intent.putExtra(ENABLE_JOYSTICK_EVENTS, enableJoystickEvents);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
} else if (view.equals(btnCancel)) {
|
} else if (view.equals(btnCancel)) {
|
||||||
/* Exit */
|
/* Exit */
|
||||||
@ -250,14 +270,16 @@ public class MainActivity extends Activity implements OnItemClickListener, View.
|
|||||||
|
|
||||||
private void setSelection(int position) {
|
private void setSelection(int position) {
|
||||||
if (position == -1) {
|
if (position == -1) {
|
||||||
arrayAdapter.setSelectedPosition(0);
|
arrayAdapter.setSelectedPosition(-1);
|
||||||
currentPosition = -1;
|
currentPosition = -1;
|
||||||
currentSelection = "";
|
currentSelection = "";
|
||||||
|
btnOK.setEnabled(false);
|
||||||
listClasses.invalidateViews();
|
listClasses.invalidateViews();
|
||||||
} else {
|
} else {
|
||||||
arrayAdapter.setSelectedPosition(position);
|
arrayAdapter.setSelectedPosition(position);
|
||||||
currentPosition = position;
|
currentPosition = position;
|
||||||
currentSelection = arrayAdapter.getItem(position);
|
currentSelection = arrayAdapter.getItem(position);
|
||||||
|
btnOK.setEnabled(true);
|
||||||
listClasses.invalidateViews();
|
listClasses.invalidateViews();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -267,13 +289,17 @@ public class MainActivity extends Activity implements OnItemClickListener, View.
|
|||||||
super.onSaveInstanceState(savedInstanceState);
|
super.onSaveInstanceState(savedInstanceState);
|
||||||
Log.i(TAG, "Saving selections in onSaveInstanceState: "
|
Log.i(TAG, "Saving selections in onSaveInstanceState: "
|
||||||
+ "position: " + currentPosition + ", "
|
+ "position: " + currentPosition + ", "
|
||||||
+ "class: " + currentSelection
|
+ "class: " + currentSelection + ", "
|
||||||
|
+ "mouseEvents: " + enableMouseEvents + ", "
|
||||||
|
+ "joystickEvents: " + enableJoystickEvents + ", "
|
||||||
);
|
);
|
||||||
// Save current selections to the savedInstanceState.
|
// Save current selections to the savedInstanceState.
|
||||||
// This bundle will be passed to onCreate if the process is
|
// This bundle will be passed to onCreate if the process is
|
||||||
// killed and restarted.
|
// killed and restarted.
|
||||||
savedInstanceState.putString(SELECTED_APP_CLASS, currentSelection);
|
savedInstanceState.putString(SELECTED_APP_CLASS, currentSelection);
|
||||||
savedInstanceState.putInt(SELECTED_LIST_POSITION, currentPosition);
|
savedInstanceState.putInt(SELECTED_LIST_POSITION, currentPosition);
|
||||||
|
savedInstanceState.putBoolean(ENABLE_MOUSE_EVENTS, enableMouseEvents);
|
||||||
|
savedInstanceState.putBoolean(ENABLE_JOYSTICK_EVENTS, enableJoystickEvents);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -294,8 +320,8 @@ public class MainActivity extends Activity implements OnItemClickListener, View.
|
|||||||
|
|
||||||
public void onTextChanged(CharSequence cs, int startPos, int beforePos, int count) {
|
public void onTextChanged(CharSequence cs, int startPos, int beforePos, int count) {
|
||||||
Log.i(TAG, "onTextChanged with cs: " + cs + ", startPos: " + startPos + ", beforePos: " + beforePos + ", count: " + count);
|
Log.i(TAG, "onTextChanged with cs: " + cs + ", startPos: " + startPos + ", beforePos: " + beforePos + ", count: " + count);
|
||||||
// setSelection(-1);
|
|
||||||
arrayAdapter.getFilter().filter(cs.toString());
|
arrayAdapter.getFilter().filter(cs.toString());
|
||||||
|
setSelection(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void afterTextChanged(Editable edtbl) {
|
public void afterTextChanged(Editable edtbl) {
|
||||||
@ -307,4 +333,58 @@ public class MainActivity extends Activity implements OnItemClickListener, View.
|
|||||||
editFilterText.removeTextChangedListener(this);
|
editFilterText.removeTextChangedListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
MenuInflater inflater = getMenuInflater();
|
||||||
|
inflater.inflate(R.menu.optionsmenu, menu);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onPrepareOptionsMenu (Menu menu) {
|
||||||
|
MenuItem item;
|
||||||
|
|
||||||
|
item = menu.findItem(R.id.optionEnableMouseEvents);
|
||||||
|
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.optionEnableJoystickEvents);
|
||||||
|
if (item != null) {
|
||||||
|
Log.i(TAG, "Found EnableJoystickEvents menu item");
|
||||||
|
if (enableJoystickEvents) {
|
||||||
|
item.setTitle(R.string.strOptionDisableJoystickEventsTitle);
|
||||||
|
} else {
|
||||||
|
item.setTitle(R.string.strOptionEnableJoystickEventsTitle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
switch (item.getItemId()) {
|
||||||
|
case R.id.optionEnableMouseEvents:
|
||||||
|
enableMouseEvents = !enableMouseEvents;
|
||||||
|
Log.i(TAG, "enableMouseEvents set to: " + enableMouseEvents);
|
||||||
|
break;
|
||||||
|
case R.id.optionEnableJoystickEvents:
|
||||||
|
enableJoystickEvents = !enableJoystickEvents;
|
||||||
|
Log.i(TAG, "enableJoystickEvents set to: " + enableJoystickEvents);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,8 @@ public class TestsHarness extends AndroidHarness{
|
|||||||
// Enable verbose logging
|
// Enable verbose logging
|
||||||
eglConfigVerboseLogging = false;
|
eglConfigVerboseLogging = false;
|
||||||
// Choose screen orientation
|
// Choose screen orientation
|
||||||
|
// This test project also set the Activity to Landscape in the AndroidManifest.xml
|
||||||
|
// If you modify this, also modify AndroidManifest.xml
|
||||||
screenOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
|
screenOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
|
||||||
// Invert the MouseEvents X (default = true)
|
// Invert the MouseEvents X (default = true)
|
||||||
mouseEventsInvertX = true;
|
mouseEventsInvertX = true;
|
||||||
@ -37,12 +39,17 @@ public class TestsHarness extends AndroidHarness{
|
|||||||
joystickEventsEnabled = false;
|
joystickEventsEnabled = false;
|
||||||
// Simulate mouse events with Android touch input (default = true)
|
// Simulate mouse events with Android touch input (default = true)
|
||||||
mouseEventsEnabled = true;
|
mouseEventsEnabled = true;
|
||||||
|
mouseEventsInvertX = false;
|
||||||
|
mouseEventsInvertY = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
appClass = intent.getStringExtra(MainActivity.SELECTED_APP_CLASS);
|
appClass = intent.getStringExtra(MainActivity.SELECTED_APP_CLASS);
|
||||||
|
mouseEventsEnabled = intent.getBooleanExtra(MainActivity.ENABLE_MOUSE_EVENTS, mouseEventsEnabled);
|
||||||
|
joystickEventsEnabled = intent.getBooleanExtra(MainActivity.ENABLE_JOYSTICK_EVENTS, joystickEventsEnabled);
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
}
|
}
|
||||||
|
@ -63,8 +63,10 @@
|
|||||||
<zip basedir="JME3TestsTemplateAndroid/" destfile="jme3-templates/src/com/jme3/gde/templates/JME3TestsAndroidProject.zip">
|
<zip basedir="JME3TestsTemplateAndroid/" destfile="jme3-templates/src/com/jme3/gde/templates/JME3TestsAndroidProject.zip">
|
||||||
<exclude name="**/build/"/>
|
<exclude name="**/build/"/>
|
||||||
<exclude name="**/dist/"/>
|
<exclude name="**/dist/"/>
|
||||||
<exclude name="**/mobile/libs/"/>
|
<exclude name="**/mobile/assets/"/>
|
||||||
|
<exclude name="**/mobile/bin/"/>
|
||||||
<exclude name="**/mobile/gen/"/>
|
<exclude name="**/mobile/gen/"/>
|
||||||
|
<exclude name="**/mobile/libs/"/>
|
||||||
<exclude name="**/mobile/local.properties"/>
|
<exclude name="**/mobile/local.properties"/>
|
||||||
<exclude name="**/mobile/private/"/>
|
<exclude name="**/mobile/private/"/>
|
||||||
<exclude name="**/nbproject/private/"/>
|
<exclude name="**/nbproject/private/"/>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user