Add test for assets stored in drawable / mipmap directories and add verbose logging menu option support.

Still need to add the menu to the layout file for the MainActivity.
define_list_fix
iwgeric 9 years ago
parent c219ce1b4f
commit 8c08010233
  1. 2
      jme3-android-examples/build.gradle
  2. 2
      jme3-android-examples/src/main/AndroidManifest.xml
  3. 49
      jme3-android-examples/src/main/java/jme3test/android/TestAndroidResources.java
  4. 9
      jme3-android-examples/src/main/java/org/jmonkeyengine/jme3androidexamples/JmeFragment.java
  5. 29
      jme3-android-examples/src/main/java/org/jmonkeyengine/jme3androidexamples/MainActivity.java
  6. 4
      jme3-android-examples/src/main/java/org/jmonkeyengine/jme3androidexamples/TestActivity.java
  7. BIN
      jme3-android-examples/src/main/res/drawable-hdpi/drawable_monkey.png
  8. BIN
      jme3-android-examples/src/main/res/drawable-ldpi/drawable_monkey.png
  9. BIN
      jme3-android-examples/src/main/res/drawable-mdpi/drawable_monkey.png
  10. BIN
      jme3-android-examples/src/main/res/drawable-xhdpi/drawable_monkey.png
  11. 24
      jme3-android-examples/src/main/res/menu/menu_items.xml
  12. BIN
      jme3-android-examples/src/main/res/mipmap-hdpi/mipmap_monkey.png
  13. BIN
      jme3-android-examples/src/main/res/mipmap-hdpi/smartmonkey.png
  14. BIN
      jme3-android-examples/src/main/res/mipmap-mdpi/mipmap_monkey.png
  15. BIN
      jme3-android-examples/src/main/res/mipmap-mdpi/smartmonkey.png
  16. BIN
      jme3-android-examples/src/main/res/mipmap-xhdpi/mipmap_monkey.png
  17. BIN
      jme3-android-examples/src/main/res/mipmap-xhdpi/smartmonkey.png
  18. BIN
      jme3-android-examples/src/main/res/mipmap-xxhdpi/mipmap_monkey.png
  19. BIN
      jme3-android-examples/src/main/res/mipmap-xxhdpi/smartmonkey.png
  20. BIN
      jme3-android-examples/src/main/res/mipmap-xxxhdpi/mipmap_monkey.png
  21. BIN
      jme3-android-examples/src/main/res/mipmap-xxxhdpi/smartmonkey.png
  22. 2
      jme3-android-examples/src/main/res/values/strings.xml

@ -12,7 +12,7 @@ android {
defaultConfig {
applicationId "org.jmonkeyengine.jme3androidexamples"
minSdkVersion 11 // Android 2.3 GINGERBREAD
minSdkVersion 15 // Android 4.0.3 ICE CREAM SANDWICH
targetSdkVersion 22 // Android 5.1 LOLLIPOP
versionCode 1
versionName "1.0" // TODO: from settings.gradle

@ -4,7 +4,7 @@
<application
android:allowBackup="true"
android:icon="@mipmap/smartmonkey"
android:icon="@mipmap/mipmap_monkey"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">

@ -0,0 +1,49 @@
package jme3test.android;
import com.jme3.app.SimpleApplication;
import com.jme3.light.AmbientLight;
import com.jme3.light.PointLight;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
import com.jme3.scene.shape.Sphere;
import com.jme3.util.TangentBinormalGenerator;
/**
* Created by potterec on 4/29/2016.
*/
public class TestAndroidResources extends SimpleApplication {
@Override
public void simpleInitApp() {
// Create boxes with textures that are stored in the Android Resources Folders
// Images are stored in multiple Drawable and Mipmap directories. Android picks the ones that
// match the device size and density.
Box box1Mesh = new Box(1, 1, 1);
Geometry box1 = new Geometry("Monkey Box 1", box1Mesh);
Material mat1 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat1.setTexture("ColorMap", assetManager.loadTexture("drawable_monkey.png"));
box1.setMaterial(mat1);
box1.setLocalTranslation(-2, 0, 0);
rootNode.attachChild(box1);
Box box2Mesh = new Box(1, 1, 1);
Geometry box2 = new Geometry("Monkey Box 2", box2Mesh);
Material mat2 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat2.setTexture("ColorMap", assetManager.loadTexture("mipmap_monkey.png"));
box2.setMaterial(mat2);
box2.setLocalTranslation(2, 0, 0);
rootNode.attachChild(box2);
PointLight pl = new PointLight();
pl.setColor(ColorRGBA.White);
pl.setPosition(new Vector3f(4f, 0f, 0f));
rootNode.addLight(pl);
AmbientLight al = new AmbientLight();
al.setColor(ColorRGBA.White);
rootNode.addLight(al);
}
}

@ -74,6 +74,15 @@ public class JmeFragment extends AndroidHarnessFragment {
// Log.d(this.getClass().getSimpleName(), "KeyEventsEnabled: " + keyEventsEnabled);
mouseEventsEnabled = bundle.getBoolean(ENABLE_MOUSE_EVENTS);
// Log.d(this.getClass().getSimpleName(), "MouseEventsEnabled: " + mouseEventsEnabled);
boolean verboseLogging = bundle.getBoolean(VERBOSE_LOGGING);
// Log.d(this.getClass().getSimpleName(), "VerboseLogging: " + verboseLogging);
if (verboseLogging) {
// Set the default logging level (default=Level.INFO, Level.ALL=All Debug Info)
LogManager.getLogManager().getLogger("").setLevel(Level.ALL);
} else {
// Set the default logging level (default=Level.INFO, Level.ALL=All Debug Info)
LogManager.getLogManager().getLogger("").setLevel(Level.INFO);
}
super.onCreate(savedInstanceState);
}

@ -65,6 +65,12 @@ public class MainActivity extends Activity implements OnItemClickListener, View.
*/
public static final String ENABLE_KEY_EVENTS = "Enable_Key_Events";
/**
* Static String to pass the key for the setting for verbose logging to the
* savedInstanceState Bundle.
*/
public static final String VERBOSE_LOGGING = "Verbose_Logging";
/* Fields to contain the current position and display contents of the spinner */
private int currentPosition = 0;
private String currentSelection = "";
@ -89,6 +95,7 @@ public class MainActivity extends Activity implements OnItemClickListener, View.
private boolean enableMouseEvents = true;
private boolean enableJoystickEvents = false;
private boolean enableKeyEvents = true;
private boolean verboseLogging = true;
/**
@ -108,6 +115,7 @@ public class MainActivity extends Activity implements OnItemClickListener, View.
enableMouseEvents = savedInstanceState.getBoolean(ENABLE_MOUSE_EVENTS, true);
enableJoystickEvents = savedInstanceState.getBoolean(ENABLE_JOYSTICK_EVENTS, false);
enableKeyEvents = savedInstanceState.getBoolean(ENABLE_KEY_EVENTS, true);
verboseLogging = savedInstanceState.getBoolean(VERBOSE_LOGGING, true);
}
@ -232,6 +240,9 @@ public class MainActivity extends Activity implements OnItemClickListener, View.
args.putBoolean(MainActivity.ENABLE_KEY_EVENTS, enableKeyEvents);
// Log.d(TestActivity.class.getSimpleName(), "KeyEnabled="+enableKeyEvents);
args.putBoolean(MainActivity.VERBOSE_LOGGING, verboseLogging);
// Log.d(TestActivity.class.getSimpleName(), "VerboseLogging="+verboseLogging);
intent.putExtras(args);
startActivity(intent);
@ -314,6 +325,8 @@ public class MainActivity extends Activity implements OnItemClickListener, View.
+ "class: " + currentSelection + ", "
+ "mouseEvents: " + enableMouseEvents + ", "
+ "joystickEvents: " + enableJoystickEvents + ", "
+ "keyEvents: " + enableKeyEvents + ", "
+ "VerboseLogging: " + verboseLogging + ", "
);
// Save current selections to the savedInstanceState.
// This bundle will be passed to onCreate if the process is
@ -322,6 +335,8 @@ public class MainActivity extends Activity implements OnItemClickListener, View.
savedInstanceState.putInt(SELECTED_LIST_POSITION, currentPosition);
savedInstanceState.putBoolean(ENABLE_MOUSE_EVENTS, enableMouseEvents);
savedInstanceState.putBoolean(ENABLE_JOYSTICK_EVENTS, enableJoystickEvents);
savedInstanceState.putBoolean(ENABLE_KEY_EVENTS, enableKeyEvents);
savedInstanceState.putBoolean(VERBOSE_LOGGING, verboseLogging);
}
@Override
@ -397,6 +412,16 @@ public class MainActivity extends Activity implements OnItemClickListener, View.
}
}
item = menu.findItem(R.id.optionVerboseLogging);
if (item != null) {
Log.i(TAG, "Found EnableVerboseLogging menu item");
if (verboseLogging) {
item.setTitle(R.string.strOptionDisableVerboseLoggingTitle);
} else {
item.setTitle(R.string.strOptionEnableVerboseLoggingTitle);
}
}
return true;
}
@ -415,6 +440,10 @@ public class MainActivity extends Activity implements OnItemClickListener, View.
enableKeyEvents = !enableKeyEvents;
Log.i(TAG, "enableKeyEvents set to: " + enableKeyEvents);
break;
case R.id.optionVerboseLogging:
verboseLogging = !verboseLogging;
Log.i(TAG, "verboseLogging set to: " + verboseLogging);
break;
default:
return super.onOptionsItemSelected(item);
}

@ -37,6 +37,10 @@ public class TestActivity extends AppCompatActivity {
args.putBoolean(MainActivity.ENABLE_KEY_EVENTS, keyEnabled);
// Log.d(TestActivity.class.getSimpleName(), "KeyEnabled="+keyEnabled);
boolean verboseLogging = bundle.getBoolean(MainActivity.VERBOSE_LOGGING, true);
args.putBoolean(MainActivity.VERBOSE_LOGGING, verboseLogging);
// Log.d(TestActivity.class.getSimpleName(), "VerboseLogging="+verboseLogging);
fragment.setArguments(args);

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 294 KiB

@ -16,14 +16,20 @@
android:title="@string/strOptionEnableJoystickEventsTitle"
app:showAsAction="ifRoom" />
<item
android:id="@+id/optionKeyEvents"
android:orderInCategory="300"
android:title="@string/strOptionEnableKeyEventsTitle"
app:showAsAction="ifRoom" />
android:id="@+id/optionKeyEvents"
android:orderInCategory="300"
android:title="@string/strOptionEnableKeyEventsTitle"
app:showAsAction="ifRoom" />
<item
android:id="@+id/optionVerboseLogging"
android:orderInCategory="300"
android:title="@string/strOptionEnableVerboseLoggingTitle"
app:showAsAction="ifRoom" />
<!--
android:icon="@mipmap/redmonkey"
android:icon="@mipmap/greenmonkey"
android:icon="@mipmap/bluemonkey"
-->
<!--
android:icon="@mipmap/redmonkey"
android:icon="@mipmap/greenmonkey"
android:icon="@mipmap/bluemonkey"
-->
</menu>

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 67 KiB

@ -16,4 +16,6 @@
<string name="strOptionDisableJoystickEventsTitle">Disable Joystick Events</string>
<string name="strOptionEnableKeyEventsTitle">Enable Key Events</string>
<string name="strOptionDisableKeyEventsTitle">Disable Key Events</string>
<string name="strOptionEnableVerboseLoggingTitle">Enable Verbose Logging</string>
<string name="strOptionDisableVerboseLoggingTitle">Disable Verbose Logging</string>
</resources>

Loading…
Cancel
Save