Main repository of MikuMikuStudio
Revision | bccaf3d1a6feeee1711ba4ea1158b1f04bb84ebc (tree) |
---|---|
Time | 2013-02-12 11:45:21 |
Author | iwgeric <iwgeric@75d0...> |
Commiter | iwgeric |
SDK: Updates to JME3 Tests for Android Template
git-svn-id: http://jmonkeyengine.googlecode.com/svn/trunk@10392 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
@@ -15,7 +15,7 @@ | ||
15 | 15 | android:layout_marginTop="10dp" |
16 | 16 | android:layout_marginLeft="10dp" |
17 | 17 | android:layout_marginRight="10dp" |
18 | - android:text="Choose a demo to start:" | |
18 | + android:text="@string/strLblTitle" | |
19 | 19 | android:textSize="20sp" |
20 | 20 | android:textColor="#000000" |
21 | 21 | /> |
@@ -37,7 +37,7 @@ | ||
37 | 37 | android:layout_width="wrap_content" |
38 | 38 | android:layout_height="wrap_content" |
39 | 39 | android:layout_marginRight="10dp" |
40 | - android:text="Find:" | |
40 | + android:text="@string/strLblFindTitle" | |
41 | 41 | android:textSize="20sp" |
42 | 42 | android:textColor="#000000" |
43 | 43 | /> |
@@ -48,7 +48,7 @@ | ||
48 | 48 | android:layout_height="wrap_content" |
49 | 49 | android:layout_weight="1" |
50 | 50 | android:ems="10" |
51 | - android:hint="Enter a Filter" | |
51 | + android:hint="@string/strTxtFilterHint" | |
52 | 52 | android:inputType="text" |
53 | 53 | android:textSize="20sp" |
54 | 54 | android:textColor="#000000" |
@@ -71,7 +71,7 @@ | ||
71 | 71 | android:id="@+id/btnOK" |
72 | 72 | android:layout_width="100dp" |
73 | 73 | android:layout_height="wrap_content" |
74 | - android:text="OK" | |
74 | + android:text="@string/strBtnOK" | |
75 | 75 | android:layout_marginRight="20dp" |
76 | 76 | android:textSize="20sp" |
77 | 77 | android:textColor="#000000" |
@@ -81,7 +81,7 @@ | ||
81 | 81 | android:id="@+id/btnCancel" |
82 | 82 | android:layout_width="100dp" |
83 | 83 | android:layout_height="wrap_content" |
84 | - android:text="Cancel" | |
84 | + android:text="@string/strBtnCancel" | |
85 | 85 | android:layout_marginLeft="20dp" |
86 | 86 | android:textSize="20sp" |
87 | 87 | android:textColor="#000000" |
@@ -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 |
@@ -1,4 +1,18 @@ | ||
1 | 1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | 2 | <resources> |
3 | + <!-- Main Application Title --> | |
3 | 4 | <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> | |
4 | 18 | </resources> |
@@ -49,6 +49,7 @@ public class CustomArrayAdapter extends ArrayAdapter<String> { | ||
49 | 49 | /** Setter for selected item position */ |
50 | 50 | public void setSelectedPosition(int selectedPosition) { |
51 | 51 | this.selectedPosition = selectedPosition; |
52 | + Log.i(TAG, "Setting position to: " + this.selectedPosition); | |
52 | 53 | } |
53 | 54 | |
54 | 55 | /** Setter for selected item background color */ |
@@ -11,13 +11,15 @@ import android.os.Bundle; | ||
11 | 11 | import android.text.Editable; |
12 | 12 | import android.text.TextWatcher; |
13 | 13 | import android.util.Log; |
14 | +import android.view.Menu; | |
15 | +import android.view.MenuInflater; | |
16 | +import android.view.MenuItem; | |
14 | 17 | import android.view.View; |
15 | 18 | import android.widget.AdapterView; |
16 | 19 | import android.widget.AdapterView.OnItemClickListener; |
17 | 20 | import android.widget.Button; |
18 | 21 | import android.widget.EditText; |
19 | 22 | import android.widget.ListView; |
20 | -import android.widget.Toast; | |
21 | 23 | import com.jme3.app.Application; |
22 | 24 | import dalvik.system.DexFile; |
23 | 25 | import java.io.IOException; |
@@ -25,9 +27,7 @@ import java.util.ArrayList; | ||
25 | 27 | import java.util.Enumeration; |
26 | 28 | import java.util.List; |
27 | 29 | |
28 | -//TODO: Add settings menu items for MouseEvents, JoystickEvents, and device orientation | |
29 | 30 | //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 | |
31 | 31 | |
32 | 32 | /** |
33 | 33 | * Main Activity started by the application. Users select different jME3 test |
@@ -51,6 +51,18 @@ public class MainActivity extends Activity implements OnItemClickListener, View. | ||
51 | 51 | */ |
52 | 52 | public static final String SELECTED_LIST_POSITION = "Selected_List_Position"; |
53 | 53 | |
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 | + | |
54 | 66 | /* Fields to contain the current position and display contents of the spinner */ |
55 | 67 | private int currentPosition = 0; |
56 | 68 | private String currentSelection = ""; |
@@ -71,6 +83,10 @@ public class MainActivity extends Activity implements OnItemClickListener, View. | ||
71 | 83 | /* Filter Edit Box */ |
72 | 84 | EditText editFilterText; |
73 | 85 | |
86 | + /* Custom settings for the test app */ | |
87 | + private boolean enableMouseEvents = true; | |
88 | + private boolean enableJoystickEvents = false; | |
89 | + | |
74 | 90 | |
75 | 91 | /** |
76 | 92 | * Called when the activity is first created. |
@@ -86,6 +102,8 @@ public class MainActivity extends Activity implements OnItemClickListener, View. | ||
86 | 102 | ); |
87 | 103 | currentPosition = savedInstanceState.getInt(SELECTED_LIST_POSITION, 0); |
88 | 104 | currentSelection = savedInstanceState.getString(SELECTED_APP_CLASS); |
105 | + enableMouseEvents = savedInstanceState.getBoolean(ENABLE_MOUSE_EVENTS, true); | |
106 | + enableJoystickEvents = savedInstanceState.getBoolean(ENABLE_JOYSTICK_EVENTS, false); | |
89 | 107 | } |
90 | 108 | |
91 | 109 |
@@ -192,6 +210,8 @@ public class MainActivity extends Activity implements OnItemClickListener, View. | ||
192 | 210 | Log.i(TAG, "User selected OK for class: " + currentSelection); |
193 | 211 | Intent intent = new Intent(this, TestsHarness.class); |
194 | 212 | intent.putExtra(SELECTED_APP_CLASS, currentSelection); |
213 | + intent.putExtra(ENABLE_MOUSE_EVENTS, enableMouseEvents); | |
214 | + intent.putExtra(ENABLE_JOYSTICK_EVENTS, enableJoystickEvents); | |
195 | 215 | startActivity(intent); |
196 | 216 | } else if (view.equals(btnCancel)) { |
197 | 217 | /* Exit */ |
@@ -250,14 +270,16 @@ public class MainActivity extends Activity implements OnItemClickListener, View. | ||
250 | 270 | |
251 | 271 | private void setSelection(int position) { |
252 | 272 | if (position == -1) { |
253 | - arrayAdapter.setSelectedPosition(0); | |
273 | + arrayAdapter.setSelectedPosition(-1); | |
254 | 274 | currentPosition = -1; |
255 | 275 | currentSelection = ""; |
276 | + btnOK.setEnabled(false); | |
256 | 277 | listClasses.invalidateViews(); |
257 | 278 | } else { |
258 | 279 | arrayAdapter.setSelectedPosition(position); |
259 | 280 | currentPosition = position; |
260 | 281 | currentSelection = arrayAdapter.getItem(position); |
282 | + btnOK.setEnabled(true); | |
261 | 283 | listClasses.invalidateViews(); |
262 | 284 | } |
263 | 285 | } |
@@ -267,13 +289,17 @@ public class MainActivity extends Activity implements OnItemClickListener, View. | ||
267 | 289 | super.onSaveInstanceState(savedInstanceState); |
268 | 290 | Log.i(TAG, "Saving selections in onSaveInstanceState: " |
269 | 291 | + "position: " + currentPosition + ", " |
270 | - + "class: " + currentSelection | |
292 | + + "class: " + currentSelection + ", " | |
293 | + + "mouseEvents: " + enableMouseEvents + ", " | |
294 | + + "joystickEvents: " + enableJoystickEvents + ", " | |
271 | 295 | ); |
272 | 296 | // Save current selections to the savedInstanceState. |
273 | 297 | // This bundle will be passed to onCreate if the process is |
274 | 298 | // killed and restarted. |
275 | 299 | savedInstanceState.putString(SELECTED_APP_CLASS, currentSelection); |
276 | 300 | savedInstanceState.putInt(SELECTED_LIST_POSITION, currentPosition); |
301 | + savedInstanceState.putBoolean(ENABLE_MOUSE_EVENTS, enableMouseEvents); | |
302 | + savedInstanceState.putBoolean(ENABLE_JOYSTICK_EVENTS, enableJoystickEvents); | |
277 | 303 | } |
278 | 304 | |
279 | 305 | @Override |
@@ -294,8 +320,8 @@ public class MainActivity extends Activity implements OnItemClickListener, View. | ||
294 | 320 | |
295 | 321 | public void onTextChanged(CharSequence cs, int startPos, int beforePos, int count) { |
296 | 322 | Log.i(TAG, "onTextChanged with cs: " + cs + ", startPos: " + startPos + ", beforePos: " + beforePos + ", count: " + count); |
297 | -// setSelection(-1); | |
298 | 323 | arrayAdapter.getFilter().filter(cs.toString()); |
324 | + setSelection(-1); | |
299 | 325 | } |
300 | 326 | |
301 | 327 | public void afterTextChanged(Editable edtbl) { |
@@ -307,4 +333,58 @@ public class MainActivity extends Activity implements OnItemClickListener, View. | ||
307 | 333 | editFilterText.removeTextChangedListener(this); |
308 | 334 | } |
309 | 335 | |
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 | + | |
310 | 390 | } |
@@ -26,6 +26,8 @@ public class TestsHarness extends AndroidHarness{ | ||
26 | 26 | // Enable verbose logging |
27 | 27 | eglConfigVerboseLogging = false; |
28 | 28 | // 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 | |
29 | 31 | screenOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; |
30 | 32 | // Invert the MouseEvents X (default = true) |
31 | 33 | mouseEventsInvertX = true; |
@@ -37,12 +39,17 @@ public class TestsHarness extends AndroidHarness{ | ||
37 | 39 | joystickEventsEnabled = false; |
38 | 40 | // Simulate mouse events with Android touch input (default = true) |
39 | 41 | mouseEventsEnabled = true; |
42 | + mouseEventsInvertX = false; | |
43 | + mouseEventsInvertY = false; | |
44 | + | |
40 | 45 | } |
41 | 46 | |
42 | 47 | @Override |
43 | 48 | public void onCreate(Bundle savedInstanceState) { |
44 | 49 | Intent intent = getIntent(); |
45 | 50 | 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); | |
46 | 53 | |
47 | 54 | super.onCreate(savedInstanceState); |
48 | 55 | } |
@@ -63,8 +63,10 @@ | ||
63 | 63 | <zip basedir="JME3TestsTemplateAndroid/" destfile="jme3-templates/src/com/jme3/gde/templates/JME3TestsAndroidProject.zip"> |
64 | 64 | <exclude name="**/build/"/> |
65 | 65 | <exclude name="**/dist/"/> |
66 | - <exclude name="**/mobile/libs/"/> | |
66 | + <exclude name="**/mobile/assets/"/> | |
67 | + <exclude name="**/mobile/bin/"/> | |
67 | 68 | <exclude name="**/mobile/gen/"/> |
69 | + <exclude name="**/mobile/libs/"/> | |
68 | 70 | <exclude name="**/mobile/local.properties"/> |
69 | 71 | <exclude name="**/mobile/private/"/> |
70 | 72 | <exclude name="**/nbproject/private/"/> |