• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Main repository of MikuMikuStudio


Commit MetaInfo

Revisionbccaf3d1a6feeee1711ba4ea1158b1f04bb84ebc (tree)
Time2013-02-12 11:45:21
Authoriwgeric <iwgeric@75d0...>
Commiteriwgeric

Log Message

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: http://jmonkeyengine.googlecode.com/svn/trunk@10392 75d07b2b-3a1a-0410-a2c5-0572b91ccdca

Change Summary

Incremental Difference

--- a/sdk/JME3TestsTemplateAndroid/mobile/res/layout/test_chooser_layout.xml
+++ b/sdk/JME3TestsTemplateAndroid/mobile/res/layout/test_chooser_layout.xml
@@ -15,7 +15,7 @@
1515 android:layout_marginTop="10dp"
1616 android:layout_marginLeft="10dp"
1717 android:layout_marginRight="10dp"
18- android:text="Choose a demo to start:"
18+ android:text="@string/strLblTitle"
1919 android:textSize="20sp"
2020 android:textColor="#000000"
2121 />
@@ -37,7 +37,7 @@
3737 android:layout_width="wrap_content"
3838 android:layout_height="wrap_content"
3939 android:layout_marginRight="10dp"
40- android:text="Find:"
40+ android:text="@string/strLblFindTitle"
4141 android:textSize="20sp"
4242 android:textColor="#000000"
4343 />
@@ -48,7 +48,7 @@
4848 android:layout_height="wrap_content"
4949 android:layout_weight="1"
5050 android:ems="10"
51- android:hint="Enter a Filter"
51+ android:hint="@string/strTxtFilterHint"
5252 android:inputType="text"
5353 android:textSize="20sp"
5454 android:textColor="#000000"
@@ -71,7 +71,7 @@
7171 android:id="@+id/btnOK"
7272 android:layout_width="100dp"
7373 android:layout_height="wrap_content"
74- android:text="OK"
74+ android:text="@string/strBtnOK"
7575 android:layout_marginRight="20dp"
7676 android:textSize="20sp"
7777 android:textColor="#000000"
@@ -81,7 +81,7 @@
8181 android:id="@+id/btnCancel"
8282 android:layout_width="100dp"
8383 android:layout_height="wrap_content"
84- android:text="Cancel"
84+ android:text="@string/strBtnCancel"
8585 android:layout_marginLeft="20dp"
8686 android:textSize="20sp"
8787 android:textColor="#000000"
--- /dev/null
+++ b/sdk/JME3TestsTemplateAndroid/mobile/res/menu/optionsmenu.xml
@@ -0,0 +1,9 @@
1+<?xml version="1.0" encoding="utf-8"?>
2+<menu xmlns:android="http://schemas.android.com/apk/res/android">
3+ <item
4+ android:id="@+id/optionEnableMouseEvents"
5+ android:title="@string/strOptionEnableMouseEventsTitle"
6+ />
7+ <item android:id="@+id/optionEnableJoystickEvents"
8+ android:title="@string/strOptionEnableJoystickEventsTitle" />
9+</menu>
\ No newline at end of file
--- a/sdk/JME3TestsTemplateAndroid/mobile/res/values/strings.xml
+++ b/sdk/JME3TestsTemplateAndroid/mobile/res/values/strings.xml
@@ -1,4 +1,18 @@
11 <?xml version="1.0" encoding="UTF-8"?>
22 <resources>
3+ <!-- Main Application Title -->
34 <string name="app_name">jMonkeyEngine Test Applications</string>
5+
6+ <!-- MainActivity UIF Labels -->
7+ <string name="strLblTitle">Choose a demo to start:</string>
8+ <string name="strLblFindTitle">Find:</string>
9+ <string name="strTxtFilterHint">Enter a Filter</string>
10+ <string name="strBtnOK">OK</string>
11+ <string name="strBtnCancel">Cancel</string>
12+
13+ <!-- MainActivity Menu Labels -->
14+ <string name="strOptionEnableMouseEventsTitle">Enable Mouse Events</string>
15+ <string name="strOptionDisableMouseEventsTitle">Disable Mouse Events</string>
16+ <string name="strOptionEnableJoystickEventsTitle">Enable Joystick Events</string>
17+ <string name="strOptionDisableJoystickEventsTitle">Disable Joystick Events</string>
418 </resources>
--- a/sdk/JME3TestsTemplateAndroid/mobile/src/com/jmonkeyengine/tests/CustomArrayAdapter.java
+++ b/sdk/JME3TestsTemplateAndroid/mobile/src/com/jmonkeyengine/tests/CustomArrayAdapter.java
@@ -49,6 +49,7 @@ public class CustomArrayAdapter extends ArrayAdapter<String> {
4949 /** Setter for selected item position */
5050 public void setSelectedPosition(int selectedPosition) {
5151 this.selectedPosition = selectedPosition;
52+ Log.i(TAG, "Setting position to: " + this.selectedPosition);
5253 }
5354
5455 /** Setter for selected item background color */
--- a/sdk/JME3TestsTemplateAndroid/mobile/src/com/jmonkeyengine/tests/MainActivity.java
+++ b/sdk/JME3TestsTemplateAndroid/mobile/src/com/jmonkeyengine/tests/MainActivity.java
@@ -11,13 +11,15 @@ import android.os.Bundle;
1111 import android.text.Editable;
1212 import android.text.TextWatcher;
1313 import android.util.Log;
14+import android.view.Menu;
15+import android.view.MenuInflater;
16+import android.view.MenuItem;
1417 import android.view.View;
1518 import android.widget.AdapterView;
1619 import android.widget.AdapterView.OnItemClickListener;
1720 import android.widget.Button;
1821 import android.widget.EditText;
1922 import android.widget.ListView;
20-import android.widget.Toast;
2123 import com.jme3.app.Application;
2224 import dalvik.system.DexFile;
2325 import java.io.IOException;
@@ -25,9 +27,7 @@ import java.util.ArrayList;
2527 import java.util.Enumeration;
2628 import java.util.List;
2729
28-//TODO: Add settings menu items for MouseEvents, JoystickEvents, and device orientation
2930 //TODO: Create onscreen virtual keypad for triggering normal mapped keys used by test apps or modify test apps for touch with onscreen keypad
30-//TODO: Go through each test and see if any classes need to be added to the exclusions list
3131
3232 /**
3333 * Main Activity started by the application. Users select different jME3 test
@@ -51,6 +51,18 @@ public class MainActivity extends Activity implements OnItemClickListener, View.
5151 */
5252 public static final String SELECTED_LIST_POSITION = "Selected_List_Position";
5353
54+ /**
55+ * Static String to pass the key for the setting for enabling mouse events to the
56+ * savedInstanceState Bundle.
57+ */
58+ public static final String ENABLE_MOUSE_EVENTS = "Enable_Mouse_Events";
59+
60+ /**
61+ * Static String to pass the key for the setting for enabling joystick events to the
62+ * savedInstanceState Bundle.
63+ */
64+ public static final String ENABLE_JOYSTICK_EVENTS = "Enable_Joystick_Events";
65+
5466 /* Fields to contain the current position and display contents of the spinner */
5567 private int currentPosition = 0;
5668 private String currentSelection = "";
@@ -71,6 +83,10 @@ public class MainActivity extends Activity implements OnItemClickListener, View.
7183 /* Filter Edit Box */
7284 EditText editFilterText;
7385
86+ /* Custom settings for the test app */
87+ private boolean enableMouseEvents = true;
88+ private boolean enableJoystickEvents = false;
89+
7490
7591 /**
7692 * Called when the activity is first created.
@@ -86,6 +102,8 @@ public class MainActivity extends Activity implements OnItemClickListener, View.
86102 );
87103 currentPosition = savedInstanceState.getInt(SELECTED_LIST_POSITION, 0);
88104 currentSelection = savedInstanceState.getString(SELECTED_APP_CLASS);
105+ enableMouseEvents = savedInstanceState.getBoolean(ENABLE_MOUSE_EVENTS, true);
106+ enableJoystickEvents = savedInstanceState.getBoolean(ENABLE_JOYSTICK_EVENTS, false);
89107 }
90108
91109
@@ -192,6 +210,8 @@ public class MainActivity extends Activity implements OnItemClickListener, View.
192210 Log.i(TAG, "User selected OK for class: " + currentSelection);
193211 Intent intent = new Intent(this, TestsHarness.class);
194212 intent.putExtra(SELECTED_APP_CLASS, currentSelection);
213+ intent.putExtra(ENABLE_MOUSE_EVENTS, enableMouseEvents);
214+ intent.putExtra(ENABLE_JOYSTICK_EVENTS, enableJoystickEvents);
195215 startActivity(intent);
196216 } else if (view.equals(btnCancel)) {
197217 /* Exit */
@@ -250,14 +270,16 @@ public class MainActivity extends Activity implements OnItemClickListener, View.
250270
251271 private void setSelection(int position) {
252272 if (position == -1) {
253- arrayAdapter.setSelectedPosition(0);
273+ arrayAdapter.setSelectedPosition(-1);
254274 currentPosition = -1;
255275 currentSelection = "";
276+ btnOK.setEnabled(false);
256277 listClasses.invalidateViews();
257278 } else {
258279 arrayAdapter.setSelectedPosition(position);
259280 currentPosition = position;
260281 currentSelection = arrayAdapter.getItem(position);
282+ btnOK.setEnabled(true);
261283 listClasses.invalidateViews();
262284 }
263285 }
@@ -267,13 +289,17 @@ public class MainActivity extends Activity implements OnItemClickListener, View.
267289 super.onSaveInstanceState(savedInstanceState);
268290 Log.i(TAG, "Saving selections in onSaveInstanceState: "
269291 + "position: " + currentPosition + ", "
270- + "class: " + currentSelection
292+ + "class: " + currentSelection + ", "
293+ + "mouseEvents: " + enableMouseEvents + ", "
294+ + "joystickEvents: " + enableJoystickEvents + ", "
271295 );
272296 // Save current selections to the savedInstanceState.
273297 // This bundle will be passed to onCreate if the process is
274298 // killed and restarted.
275299 savedInstanceState.putString(SELECTED_APP_CLASS, currentSelection);
276300 savedInstanceState.putInt(SELECTED_LIST_POSITION, currentPosition);
301+ savedInstanceState.putBoolean(ENABLE_MOUSE_EVENTS, enableMouseEvents);
302+ savedInstanceState.putBoolean(ENABLE_JOYSTICK_EVENTS, enableJoystickEvents);
277303 }
278304
279305 @Override
@@ -294,8 +320,8 @@ public class MainActivity extends Activity implements OnItemClickListener, View.
294320
295321 public void onTextChanged(CharSequence cs, int startPos, int beforePos, int count) {
296322 Log.i(TAG, "onTextChanged with cs: " + cs + ", startPos: " + startPos + ", beforePos: " + beforePos + ", count: " + count);
297-// setSelection(-1);
298323 arrayAdapter.getFilter().filter(cs.toString());
324+ setSelection(-1);
299325 }
300326
301327 public void afterTextChanged(Editable edtbl) {
@@ -307,4 +333,58 @@ public class MainActivity extends Activity implements OnItemClickListener, View.
307333 editFilterText.removeTextChangedListener(this);
308334 }
309335
336+ @Override
337+ public boolean onCreateOptionsMenu(Menu menu) {
338+ MenuInflater inflater = getMenuInflater();
339+ inflater.inflate(R.menu.optionsmenu, menu);
340+
341+ return true;
342+}
343+
344+ @Override
345+ public boolean onPrepareOptionsMenu (Menu menu) {
346+ MenuItem item;
347+
348+ item = menu.findItem(R.id.optionEnableMouseEvents);
349+ if (item != null) {
350+ Log.i(TAG, "Found EnableMouseEvents menu item");
351+ if (enableMouseEvents) {
352+ item.setTitle(R.string.strOptionDisableMouseEventsTitle);
353+ } else {
354+ item.setTitle(R.string.strOptionEnableMouseEventsTitle);
355+ }
356+ }
357+
358+ item = menu.findItem(R.id.optionEnableJoystickEvents);
359+ if (item != null) {
360+ Log.i(TAG, "Found EnableJoystickEvents menu item");
361+ if (enableJoystickEvents) {
362+ item.setTitle(R.string.strOptionDisableJoystickEventsTitle);
363+ } else {
364+ item.setTitle(R.string.strOptionEnableJoystickEventsTitle);
365+ }
366+ }
367+
368+ return true;
369+ }
370+
371+ @Override
372+ public boolean onOptionsItemSelected(MenuItem item) {
373+ switch (item.getItemId()) {
374+ case R.id.optionEnableMouseEvents:
375+ enableMouseEvents = !enableMouseEvents;
376+ Log.i(TAG, "enableMouseEvents set to: " + enableMouseEvents);
377+ break;
378+ case R.id.optionEnableJoystickEvents:
379+ enableJoystickEvents = !enableJoystickEvents;
380+ Log.i(TAG, "enableJoystickEvents set to: " + enableJoystickEvents);
381+ break;
382+ default:
383+ return super.onOptionsItemSelected(item);
384+ }
385+
386+ return true;
387+
388+ }
389+
310390 }
--- a/sdk/JME3TestsTemplateAndroid/mobile/src/com/jmonkeyengine/tests/TestsHarness.java
+++ b/sdk/JME3TestsTemplateAndroid/mobile/src/com/jmonkeyengine/tests/TestsHarness.java
@@ -26,6 +26,8 @@ public class TestsHarness extends AndroidHarness{
2626 // Enable verbose logging
2727 eglConfigVerboseLogging = false;
2828 // Choose screen orientation
29+ // This test project also set the Activity to Landscape in the AndroidManifest.xml
30+ // If you modify this, also modify AndroidManifest.xml
2931 screenOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
3032 // Invert the MouseEvents X (default = true)
3133 mouseEventsInvertX = true;
@@ -37,12 +39,17 @@ public class TestsHarness extends AndroidHarness{
3739 joystickEventsEnabled = false;
3840 // Simulate mouse events with Android touch input (default = true)
3941 mouseEventsEnabled = true;
42+ mouseEventsInvertX = false;
43+ mouseEventsInvertY = false;
44+
4045 }
4146
4247 @Override
4348 public void onCreate(Bundle savedInstanceState) {
4449 Intent intent = getIntent();
4550 appClass = intent.getStringExtra(MainActivity.SELECTED_APP_CLASS);
51+ mouseEventsEnabled = intent.getBooleanExtra(MainActivity.ENABLE_MOUSE_EVENTS, mouseEventsEnabled);
52+ joystickEventsEnabled = intent.getBooleanExtra(MainActivity.ENABLE_JOYSTICK_EVENTS, joystickEventsEnabled);
4653
4754 super.onCreate(savedInstanceState);
4855 }
--- a/sdk/build.xml
+++ b/sdk/build.xml
@@ -63,8 +63,10 @@
6363 <zip basedir="JME3TestsTemplateAndroid/" destfile="jme3-templates/src/com/jme3/gde/templates/JME3TestsAndroidProject.zip">
6464 <exclude name="**/build/"/>
6565 <exclude name="**/dist/"/>
66- <exclude name="**/mobile/libs/"/>
66+ <exclude name="**/mobile/assets/"/>
67+ <exclude name="**/mobile/bin/"/>
6768 <exclude name="**/mobile/gen/"/>
69+ <exclude name="**/mobile/libs/"/>
6870 <exclude name="**/mobile/local.properties"/>
6971 <exclude name="**/mobile/private/"/>
7072 <exclude name="**/nbproject/private/"/>