Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions jme3-android-examples/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,12 @@ tasks.register('runAndroidExamples', Exec) {

def exampleClass = project.findProperty('example')?.toString()?.trim()
if (exampleClass) {
def verboseLogging = project.findProperty('verboseLogging')?.toString()?.trim() ?: 'false'

args 'shell', 'am', 'start',
'-n', 'org.jmonkeyengine.jme3androidexamples/.TestActivity',
'--es', 'Selected_App_Class', exampleClass,
'--ez', 'Enable_Mouse_Events', 'true',
'--ez', 'Enable_Joystick_Events', 'false',
'--ez', 'Enable_Key_Events', 'true',
'--ez', 'Verbose_Logging', 'false'
'--ez', 'Verbose_Logging', verboseLogging
} else {
args 'shell', 'am', 'start',
'-n', 'org.jmonkeyengine.jme3androidexamples/.MainActivity'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
*/
public class JmeFragment extends AndroidHarnessFragment {
private String appClass;
private boolean joystickEventsEnabled;
private boolean keyEventsEnabled = true;
private boolean mouseEventsEnabled = true;

public JmeFragment() {
finishOnAppStop = true;
Expand All @@ -27,13 +24,8 @@ public void onCreate(Bundle savedInstanceState) {

appClass = bundle.getString(MainActivity.SELECTED_APP_CLASS);
// Log.d(this.getClass().getSimpleName(), "AppClass: " + appClass);
joystickEventsEnabled = bundle.getBoolean(MainActivity.ENABLE_JOYSTICK_EVENTS);
// Log.d(this.getClass().getSimpleName(), "JoystickEventsEnabled: " + joystickEventsEnabled);
keyEventsEnabled = bundle.getBoolean(MainActivity.ENABLE_KEY_EVENTS);
// Log.d(this.getClass().getSimpleName(), "KeyEventsEnabled: " + keyEventsEnabled);
mouseEventsEnabled = bundle.getBoolean(MainActivity.ENABLE_MOUSE_EVENTS);
// Log.d(this.getClass().getSimpleName(), "MouseEventsEnabled: " + mouseEventsEnabled);
boolean verboseLogging = bundle.getBoolean(MainActivity.VERBOSE_LOGGING);
boolean verboseLogging = bundle.getBoolean(MainActivity.VERBOSE_LOGGING,
MainActivity.DEFAULT_VERBOSE_LOGGING);
// Log.d(this.getClass().getSimpleName(), "VerboseLogging: " + verboseLogging);
if (verboseLogging) {
// Set the default logging level (default=Level.INFO, Level.ALL=All Debug Info)
Expand All @@ -49,21 +41,12 @@ public void onCreate(Bundle savedInstanceState) {
@Override
protected LegacyApplication createApplication() throws Exception {
Class<?> clazz = Class.forName(appClass);
return (LegacyApplication) clazz.getDeclaredConstructor().newInstance();
LegacyApplication application = (LegacyApplication) clazz.getDeclaredConstructor().newInstance();
AppSettings settings = new AppSettings(true);
settings.setEmulateMouse(true);
settings.setEmulateKeyboard(true);
application.setSettings(settings);
return application;
}

@Override
protected void configureSettings(AppSettings settings) {
settings.setEmulateMouse(mouseEventsEnabled);
settings.setUseJoysticks(joystickEventsEnabled);
settings.setEmulateKeyboard(keyEventsEnabled);

settings.setBitsPerPixel(24);
settings.setAlphaBits(0);
settings.setGammaCorrection(true);
settings.setDepthBits(16);
settings.setSamples(4);
settings.setStencilBits(0);
settings.setFrameRate(-1);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,29 +48,12 @@ public class MainActivity extends Activity implements OnItemClickListener, View.
*/
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";

/**
* Static String to pass the key for the setting for enabling key events to the
* savedInstanceState Bundle.
*/
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";
public static final boolean DEFAULT_VERBOSE_LOGGING = false;

/* Fields to contain the current position and display contents of the spinner */
private int currentPosition = 0;
Expand All @@ -93,10 +76,7 @@ public class MainActivity extends Activity implements OnItemClickListener, View.
EditText editFilterText;

/* Custom settings for the test app */
private boolean enableMouseEvents = true;
private boolean enableJoystickEvents = false;
private boolean enableKeyEvents = true;
private boolean verboseLogging = false;
private boolean verboseLogging = DEFAULT_VERBOSE_LOGGING;


/**
Expand All @@ -113,10 +93,7 @@ public void onCreate(Bundle savedInstanceState) {
);
currentPosition = savedInstanceState.getInt(SELECTED_LIST_POSITION, 0);
currentSelection = savedInstanceState.getString(SELECTED_APP_CLASS);
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);
verboseLogging = savedInstanceState.getBoolean(VERBOSE_LOGGING, DEFAULT_VERBOSE_LOGGING);
}


Expand Down Expand Up @@ -224,25 +201,12 @@ public void onClick(View view) {
/* Get selected class, pack it in the intent and start the test app */
Log.d(TAG, "User selected OK for class: " + currentSelection);
Intent intent = new Intent(this, TestActivity.class);
// intent.putExtra(SELECTED_APP_CLASS, currentSelection);
// intent.putExtra(ENABLE_MOUSE_EVENTS, enableMouseEvents);
// intent.putExtra(ENABLE_JOYSTICK_EVENTS, enableJoystickEvents);
// intent.putExtra(ENABLE_KEY_EVENTS, enableKeyEvents);

Bundle args = new Bundle();

args.putString(MainActivity.SELECTED_APP_CLASS, currentSelection);
// Log.d(this.getClass().getSimpleName(), "AppClass="+currentSelection);

args.putBoolean(MainActivity.ENABLE_MOUSE_EVENTS, enableMouseEvents);
// Log.d(TestActivity.class.getSimpleName(), "MouseEnabled="+enableMouseEvents);

args.putBoolean(MainActivity.ENABLE_JOYSTICK_EVENTS, enableJoystickEvents);
// Log.d(TestActivity.class.getSimpleName(), "JoystickEnabled="+enableJoystickEvents);

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);

Expand Down Expand Up @@ -329,19 +293,13 @@ public void onSaveInstanceState(Bundle savedInstanceState) {
Log.d(TAG, "Saving selections in onSaveInstanceState: "
+ "position: " + currentPosition + ", "
+ "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
// killed and restarted.
savedInstanceState.putString(SELECTED_APP_CLASS, currentSelection);
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);
}

Expand Down Expand Up @@ -388,36 +346,6 @@ public boolean onCreateOptionsMenu(Menu menu) {
public boolean onPrepareOptionsMenu (Menu menu) {
MenuItem item;

item = menu.findItem(R.id.optionMouseEvents);
if (item != null) {
Log.d(TAG, "Found EnableMouseEvents menu item");
if (enableMouseEvents) {
item.setTitle(R.string.strOptionDisableMouseEventsTitle);
} else {
item.setTitle(R.string.strOptionEnableMouseEventsTitle);
}
}

item = menu.findItem(R.id.optionJoystickEvents);
if (item != null) {
Log.d(TAG, "Found EnableJoystickEvents menu item");
if (enableJoystickEvents) {
item.setTitle(R.string.strOptionDisableJoystickEventsTitle);
} else {
item.setTitle(R.string.strOptionEnableJoystickEventsTitle);
}
}

item = menu.findItem(R.id.optionKeyEvents);
if (item != null) {
Log.d(TAG, "Found EnableKeyEvents menu item");
if (enableKeyEvents) {
item.setTitle(R.string.strOptionDisableKeyEventsTitle);
} else {
item.setTitle(R.string.strOptionEnableKeyEventsTitle);
}
}

item = menu.findItem(R.id.optionVerboseLogging);
if (item != null) {
Log.d(TAG, "Found EnableVerboseLogging menu item");
Expand All @@ -434,16 +362,7 @@ public boolean onPrepareOptionsMenu (Menu menu) {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int itemId = item.getItemId();
if (itemId == R.id.optionMouseEvents) {
enableMouseEvents = !enableMouseEvents;
Log.d(TAG, "enableMouseEvents set to: " + enableMouseEvents);
} else if (itemId == R.id.optionJoystickEvents) {
enableJoystickEvents = !enableJoystickEvents;
Log.d(TAG, "enableJoystickEvents set to: " + enableJoystickEvents);
} else if (itemId == R.id.optionKeyEvents) {
enableKeyEvents = !enableKeyEvents;
Log.d(TAG, "enableKeyEvents set to: " + enableKeyEvents);
} else if (itemId == R.id.optionVerboseLogging) {
if (itemId == R.id.optionVerboseLogging) {
verboseLogging = !verboseLogging;
Log.d(TAG, "verboseLogging set to: " + verboseLogging);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,8 @@ protected void onCreate(Bundle savedInstanceState) {
args.putString(MainActivity.SELECTED_APP_CLASS, appClass);
// Log.d(TestActivity.class.getSimpleName(), "AppClass="+appClass);

boolean mouseEnabled = bundle.getBoolean(MainActivity.ENABLE_MOUSE_EVENTS, true);
args.putBoolean(MainActivity.ENABLE_MOUSE_EVENTS, mouseEnabled);
// Log.d(TestActivity.class.getSimpleName(), "MouseEnabled="+mouseEnabled);

boolean joystickEnabled = bundle.getBoolean(MainActivity.ENABLE_JOYSTICK_EVENTS, true);
args.putBoolean(MainActivity.ENABLE_JOYSTICK_EVENTS, joystickEnabled);
// Log.d(TestActivity.class.getSimpleName(), "JoystickEnabled="+joystickEnabled);

boolean keyEnabled = bundle.getBoolean(MainActivity.ENABLE_KEY_EVENTS, true);
args.putBoolean(MainActivity.ENABLE_KEY_EVENTS, keyEnabled);
// Log.d(TestActivity.class.getSimpleName(), "KeyEnabled="+keyEnabled);

boolean verboseLogging = bundle.getBoolean(MainActivity.VERBOSE_LOGGING, true);
boolean verboseLogging = bundle.getBoolean(MainActivity.VERBOSE_LOGGING,
MainActivity.DEFAULT_VERBOSE_LOGGING);
args.putBoolean(MainActivity.VERBOSE_LOGGING, verboseLogging);
// Log.d(TestActivity.class.getSimpleName(), "VerboseLogging="+verboseLogging);

Expand Down
16 changes: 0 additions & 16 deletions jme3-android-examples/src/main/res/menu/menu_items.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,6 @@
xmlns:tools="http://schemas.android.com/tools"
tools:context="org.jmonkeyengine.jme3androidexamples.MainActivity">

<item
android:id="@+id/optionMouseEvents"
android:orderInCategory="100"
android:title="@string/strOptionEnableMouseEventsTitle"
android:showAsAction="never" />
<item
android:id="@+id/optionJoystickEvents"
android:orderInCategory="200"
android:title="@string/strOptionEnableJoystickEventsTitle"
android:showAsAction="never" />
<item
android:id="@+id/optionKeyEvents"
android:orderInCategory="300"
android:title="@string/strOptionEnableKeyEventsTitle"
android:showAsAction="never" />

<item
android:id="@+id/optionVerboseLogging"
android:orderInCategory="300"
Expand Down
6 changes: 0 additions & 6 deletions jme3-android-examples/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@
<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>
<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>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,7 @@ public void onCreate(Bundle savedInstanceState) {

try {
app = createApplication();

AppSettings settings = createSettings();
configureSettings(settings);
app.setSettings(settings);
app.start();

OGLESContext context = (OGLESContext) app.getContext();
context.setSystemListener(this);
} catch (Exception exception) {
Expand All @@ -117,25 +112,6 @@ public void onCreate(Bundle savedInstanceState) {
*/
protected abstract LegacyApplication createApplication() throws Exception;

/**
* Creates the default Android settings. Subclasses can override this when
* they need to replace the settings object rather than adjust it.
*
* @return default settings for Android
*/
protected AppSettings createSettings() {
AppSettings settings = new AppSettings(true);
settings.setAudioRenderer(AppSettings.ANDROID_OPENAL_SOFT);
return settings;
}

/**
* Customizes the settings before the application starts.
*
* @param settings the settings to customize
*/
protected void configureSettings(AppSettings settings) {
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
public class JmeAndroidSystem extends JmeSystemDelegate {

private static View view;
private static String audioRendererType = AppSettings.ANDROID_OPENAL_SOFT;

static {
try {
Expand Down Expand Up @@ -79,16 +78,6 @@ public void writeImageFile(OutputStream outStream, String format, ByteBuffer ima

@Override
public JmeContext newContext(AppSettings settings, Type contextType) {
if (settings.getAudioRenderer() == null) {
audioRendererType = null;
} else if (settings.getAudioRenderer().equals(AppSettings.ANDROID_MEDIAPLAYER)) {
audioRendererType = AppSettings.ANDROID_MEDIAPLAYER;
} else if (settings.getAudioRenderer().equals(AppSettings.ANDROID_OPENAL_SOFT)) {
audioRendererType = AppSettings.ANDROID_OPENAL_SOFT;
} else {
logger.log(Level.INFO, "AudioRenderer not set. Defaulting to OpenAL Soft");
audioRendererType = AppSettings.ANDROID_OPENAL_SOFT;
}
initialize(settings);
JmeContext ctx = new OGLESContext();
ctx.setSettings(settings);
Expand Down Expand Up @@ -206,10 +195,6 @@ public static View getView() {
return view;
}

public static String getAudioRendererType() {
return audioRendererType;
}

@Override
public void showSoftKeyboard(final boolean show) {
view.getHandler().post(new Runnable() {
Expand Down
36 changes: 0 additions & 36 deletions jme3-android/src/main/java/com/jme3/view/package-info.java

This file was deleted.

Loading