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.
@ -12,7 +12,7 @@ android {
|
|||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "org.jmonkeyengine.jme3androidexamples"
|
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
|
targetSdkVersion 22 // Android 5.1 LOLLIPOP
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "1.0" // TODO: from settings.gradle
|
versionName "1.0" // TODO: from settings.gradle
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<application
|
<application
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
android:icon="@mipmap/smartmonkey"
|
android:icon="@mipmap/mipmap_monkey"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/AppTheme">
|
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);
|
// Log.d(this.getClass().getSimpleName(), "KeyEventsEnabled: " + keyEventsEnabled);
|
||||||
mouseEventsEnabled = bundle.getBoolean(ENABLE_MOUSE_EVENTS);
|
mouseEventsEnabled = bundle.getBoolean(ENABLE_MOUSE_EVENTS);
|
||||||
// Log.d(this.getClass().getSimpleName(), "MouseEventsEnabled: " + mouseEventsEnabled);
|
// 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);
|
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";
|
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 */
|
/* 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 = "";
|
||||||
@ -89,6 +95,7 @@ public class MainActivity extends Activity implements OnItemClickListener, View.
|
|||||||
private boolean enableMouseEvents = true;
|
private boolean enableMouseEvents = true;
|
||||||
private boolean enableJoystickEvents = false;
|
private boolean enableJoystickEvents = false;
|
||||||
private boolean enableKeyEvents = true;
|
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);
|
enableMouseEvents = savedInstanceState.getBoolean(ENABLE_MOUSE_EVENTS, true);
|
||||||
enableJoystickEvents = savedInstanceState.getBoolean(ENABLE_JOYSTICK_EVENTS, false);
|
enableJoystickEvents = savedInstanceState.getBoolean(ENABLE_JOYSTICK_EVENTS, false);
|
||||||
enableKeyEvents = savedInstanceState.getBoolean(ENABLE_KEY_EVENTS, true);
|
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);
|
args.putBoolean(MainActivity.ENABLE_KEY_EVENTS, enableKeyEvents);
|
||||||
// Log.d(TestActivity.class.getSimpleName(), "KeyEnabled="+enableKeyEvents);
|
// Log.d(TestActivity.class.getSimpleName(), "KeyEnabled="+enableKeyEvents);
|
||||||
|
|
||||||
|
args.putBoolean(MainActivity.VERBOSE_LOGGING, verboseLogging);
|
||||||
|
// Log.d(TestActivity.class.getSimpleName(), "VerboseLogging="+verboseLogging);
|
||||||
|
|
||||||
intent.putExtras(args);
|
intent.putExtras(args);
|
||||||
|
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
@ -314,6 +325,8 @@ public class MainActivity extends Activity implements OnItemClickListener, View.
|
|||||||
+ "class: " + currentSelection + ", "
|
+ "class: " + currentSelection + ", "
|
||||||
+ "mouseEvents: " + enableMouseEvents + ", "
|
+ "mouseEvents: " + enableMouseEvents + ", "
|
||||||
+ "joystickEvents: " + enableJoystickEvents + ", "
|
+ "joystickEvents: " + enableJoystickEvents + ", "
|
||||||
|
+ "keyEvents: " + enableKeyEvents + ", "
|
||||||
|
+ "VerboseLogging: " + verboseLogging + ", "
|
||||||
);
|
);
|
||||||
// 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
|
||||||
@ -322,6 +335,8 @@ public class MainActivity extends Activity implements OnItemClickListener, View.
|
|||||||
savedInstanceState.putInt(SELECTED_LIST_POSITION, currentPosition);
|
savedInstanceState.putInt(SELECTED_LIST_POSITION, currentPosition);
|
||||||
savedInstanceState.putBoolean(ENABLE_MOUSE_EVENTS, enableMouseEvents);
|
savedInstanceState.putBoolean(ENABLE_MOUSE_EVENTS, enableMouseEvents);
|
||||||
savedInstanceState.putBoolean(ENABLE_JOYSTICK_EVENTS, enableJoystickEvents);
|
savedInstanceState.putBoolean(ENABLE_JOYSTICK_EVENTS, enableJoystickEvents);
|
||||||
|
savedInstanceState.putBoolean(ENABLE_KEY_EVENTS, enableKeyEvents);
|
||||||
|
savedInstanceState.putBoolean(VERBOSE_LOGGING, verboseLogging);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -415,6 +440,10 @@ public class MainActivity extends Activity implements OnItemClickListener, View.
|
|||||||
enableKeyEvents = !enableKeyEvents;
|
enableKeyEvents = !enableKeyEvents;
|
||||||
Log.i(TAG, "enableKeyEvents set to: " + enableKeyEvents);
|
Log.i(TAG, "enableKeyEvents set to: " + enableKeyEvents);
|
||||||
break;
|
break;
|
||||||
|
case R.id.optionVerboseLogging:
|
||||||
|
verboseLogging = !verboseLogging;
|
||||||
|
Log.i(TAG, "verboseLogging set to: " + verboseLogging);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,10 @@ public class TestActivity extends AppCompatActivity {
|
|||||||
args.putBoolean(MainActivity.ENABLE_KEY_EVENTS, keyEnabled);
|
args.putBoolean(MainActivity.ENABLE_KEY_EVENTS, keyEnabled);
|
||||||
// Log.d(TestActivity.class.getSimpleName(), "KeyEnabled="+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);
|
fragment.setArguments(args);
|
||||||
|
|
||||||
|
|
||||||
|
After Width: | Height: | Size: 105 KiB |
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 33 KiB |
After Width: | Height: | Size: 294 KiB |
@ -21,6 +21,12 @@
|
|||||||
android:title="@string/strOptionEnableKeyEventsTitle"
|
android:title="@string/strOptionEnableKeyEventsTitle"
|
||||||
app:showAsAction="ifRoom" />
|
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/redmonkey"
|
||||||
android:icon="@mipmap/greenmonkey"
|
android:icon="@mipmap/greenmonkey"
|
||||||
|
BIN
jme3-android-examples/src/main/res/mipmap-hdpi/mipmap_monkey.png
Normal file
After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 5.2 KiB |
BIN
jme3-android-examples/src/main/res/mipmap-mdpi/mipmap_monkey.png
Normal file
After Width: | Height: | Size: 7.1 KiB |
Before Width: | Height: | Size: 3.5 KiB |
After Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 67 KiB |
After Width: | Height: | Size: 48 KiB |
Before Width: | Height: | Size: 67 KiB |
@ -16,4 +16,6 @@
|
|||||||
<string name="strOptionDisableJoystickEventsTitle">Disable Joystick Events</string>
|
<string name="strOptionDisableJoystickEventsTitle">Disable Joystick Events</string>
|
||||||
<string name="strOptionEnableKeyEventsTitle">Enable Key Events</string>
|
<string name="strOptionEnableKeyEventsTitle">Enable Key Events</string>
|
||||||
<string name="strOptionDisableKeyEventsTitle">Disable 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>
|
</resources>
|
||||||
|