aboutsummaryrefslogtreecommitdiff
path: root/engine/src/android/com/jme3/system/android
diff options
context:
space:
mode:
Diffstat (limited to 'engine/src/android/com/jme3/system/android')
-rw-r--r--engine/src/android/com/jme3/system/android/AndroidConfigChooser.java359
-rw-r--r--engine/src/android/com/jme3/system/android/OGLESContext.java94
2 files changed, 250 insertions, 203 deletions
diff --git a/engine/src/android/com/jme3/system/android/AndroidConfigChooser.java b/engine/src/android/com/jme3/system/android/AndroidConfigChooser.java
index e55fa55..56ed415 100644
--- a/engine/src/android/com/jme3/system/android/AndroidConfigChooser.java
+++ b/engine/src/android/com/jme3/system/android/AndroidConfigChooser.java
@@ -2,6 +2,7 @@ package com.jme3.system.android;
import android.graphics.PixelFormat;
import android.opengl.GLSurfaceView.EGLConfigChooser;
+import java.util.logging.Level;
import java.util.logging.Logger;
import javax.microedition.khronos.egl.EGL10;
import javax.microedition.khronos.egl.EGLConfig;
@@ -9,26 +10,23 @@ import javax.microedition.khronos.egl.EGLDisplay;
/**
* AndroidConfigChooser is used to determine the best suited EGL Config
- * @author larynx
*
+ * @author larynx
*/
-public class AndroidConfigChooser implements EGLConfigChooser
-{
+public class AndroidConfigChooser implements EGLConfigChooser {
+
private static final Logger logger = Logger.getLogger(AndroidConfigChooser.class.getName());
-
protected int clientOpenGLESVersion = 0;
protected EGLConfig bestConfig = null;
protected EGLConfig fastestConfig = null;
protected EGLConfig choosenConfig = null;
protected ConfigType type;
protected int pixelFormat;
-
protected boolean verbose = false;
-
private final static int EGL_OPENGL_ES2_BIT = 4;
- public enum ConfigType
- {
+ public enum ConfigType {
+
/**
* RGB565, 0 alpha, 16 depth, 0 stencil
*/
@@ -39,94 +37,79 @@ public class AndroidConfigChooser implements EGLConfigChooser
BEST,
/**
* Turn off config chooser and use hardcoded
- * setEGLContextClientVersion(2);
- * setEGLConfigChooser(5, 6, 5, 0, 16, 0);
+ * setEGLContextClientVersion(2); setEGLConfigChooser(5, 6, 5, 0, 16,
+ * 0);
*/
LEGACY
}
-
- public AndroidConfigChooser(ConfigType type, boolean verbose)
- {
+
+ public AndroidConfigChooser(ConfigType type) {
this.type = type;
- this.verbose = verbose;
}
-
+
/**
* Gets called by the GLSurfaceView class to return the best config
- */
+ */
@Override
- public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display)
- {
+ public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {
logger.info("GLSurfaceView asks for egl config, returning: ");
logEGLConfig(choosenConfig, display, egl);
return choosenConfig;
}
-
+
/**
* findConfig is used to locate the best config and init the chooser with
+ *
* @param egl
* @param display
* @return true if successfull, false if no config was found
*/
- public boolean findConfig(EGL10 egl, EGLDisplay display)
- {
-
- if (type == ConfigType.BEST)
- {
- ComponentSizeChooser compChooser = new ComponentSizeChooser(8, 8, 8, 8, 32, 0);
- choosenConfig = compChooser.chooseConfig(egl, display);
+ public boolean findConfig(EGL10 egl, EGLDisplay display) {
+
+ if (type == ConfigType.BEST) {
+ ComponentSizeChooser compChooser = new ComponentSizeChooser(8, 8, 8, 8, 32, 0);
+ choosenConfig = compChooser.chooseConfig(egl, display);
- if (choosenConfig == null)
- {
+ if (choosenConfig == null) {
compChooser = new ComponentSizeChooser(8, 8, 8, 0, 32, 0);
choosenConfig = compChooser.chooseConfig(egl, display);
- if (choosenConfig == null)
- {
+ if (choosenConfig == null) {
compChooser = new ComponentSizeChooser(8, 8, 8, 8, 16, 0);
choosenConfig = compChooser.chooseConfig(egl, display);
- if (choosenConfig == null)
- {
+ if (choosenConfig == null) {
compChooser = new ComponentSizeChooser(8, 8, 8, 0, 16, 0);
choosenConfig = compChooser.chooseConfig(egl, display);
}
}
- }
-
+ }
+
logger.info("JME3 using best EGL configuration available here: ");
- }
- else
- {
- ComponentSizeChooser compChooser = new ComponentSizeChooser(5, 6, 5, 0, 16, 0);
- choosenConfig = compChooser.chooseConfig(egl, display);
+ } else {
+ ComponentSizeChooser compChooser = new ComponentSizeChooser(5, 6, 5, 0, 16, 0);
+ choosenConfig = compChooser.chooseConfig(egl, display);
logger.info("JME3 using fastest EGL configuration available here: ");
}
-
- if (choosenConfig != null)
- {
- logger.info("JME3 using choosen config: ");
- logEGLConfig(choosenConfig, display, egl);
+
+ if (choosenConfig != null) {
+ logger.info("JME3 using choosen config: ");
+ logEGLConfig(choosenConfig, display, egl);
pixelFormat = getPixelFormat(choosenConfig, display, egl);
clientOpenGLESVersion = getOpenGLVersion(choosenConfig, display, egl);
return true;
- }
- else
- {
+ } else {
logger.severe("###ERROR### Unable to get a valid OpenGL ES 2.0 config, nether Fastest nor Best found! Bug. Please report this.");
clientOpenGLESVersion = 1;
pixelFormat = PixelFormat.UNKNOWN;
return false;
- }
+ }
}
-
-
- private int getPixelFormat(EGLConfig conf, EGLDisplay display, EGL10 egl)
- {
+
+ private int getPixelFormat(EGLConfig conf, EGLDisplay display, EGL10 egl) {
int[] value = new int[1];
- int result = PixelFormat.RGB_565;
+ int result = PixelFormat.RGB_565;
egl.eglGetConfigAttrib(display, conf, EGL10.EGL_RED_SIZE, value);
- if (value[0] == 8)
- {
+ if (value[0] == 8) {
result = PixelFormat.RGBA_8888;
/*
egl.eglGetConfigAttrib(display, conf, EGL10.EGL_ALPHA_SIZE, value);
@@ -139,165 +122,163 @@ public class AndroidConfigChooser implements EGLConfigChooser
result = PixelFormat.RGB_888;
}*/
}
-
- if (verbose)
- {
- logger.info("Using PixelFormat " + result);
+
+ if (verbose) {
+ logger.log(Level.INFO, "Using PixelFormat {0}", result);
}
-
+
//return result; TODO Test pixelformat
return PixelFormat.TRANSPARENT;
}
-
- private int getOpenGLVersion(EGLConfig conf, EGLDisplay display, EGL10 egl)
- {
+
+ private int getOpenGLVersion(EGLConfig conf, EGLDisplay display, EGL10 egl) {
int[] value = new int[1];
int result = 1;
-
+
egl.eglGetConfigAttrib(display, conf, EGL10.EGL_RENDERABLE_TYPE, value);
// Check if conf is OpenGL ES 2.0
- if ((value[0] & EGL_OPENGL_ES2_BIT) != 0)
- {
+ if ((value[0] & EGL_OPENGL_ES2_BIT) != 0) {
result = 2;
}
- return result;
+ return result;
}
-
+
/**
* log output with egl config details
+ *
* @param conf
* @param display
* @param egl
*/
- public void logEGLConfig(EGLConfig conf, EGLDisplay display, EGL10 egl)
- {
+ public void logEGLConfig(EGLConfig conf, EGLDisplay display, EGL10 egl) {
int[] value = new int[1];
egl.eglGetConfigAttrib(display, conf, EGL10.EGL_RED_SIZE, value);
- logger.info(String.format("EGL_RED_SIZE = %d", value[0] ) );
-
+ logger.info(String.format("EGL_RED_SIZE = %d", value[0]));
+
egl.eglGetConfigAttrib(display, conf, EGL10.EGL_GREEN_SIZE, value);
- logger.info(String.format("EGL_GREEN_SIZE = %d", value[0] ) );
-
+ logger.info(String.format("EGL_GREEN_SIZE = %d", value[0]));
+
egl.eglGetConfigAttrib(display, conf, EGL10.EGL_BLUE_SIZE, value);
- logger.info(String.format("EGL_BLUE_SIZE = %d", value[0] ) );
-
+ logger.info(String.format("EGL_BLUE_SIZE = %d", value[0]));
+
egl.eglGetConfigAttrib(display, conf, EGL10.EGL_ALPHA_SIZE, value);
- logger.info(String.format("EGL_ALPHA_SIZE = %d", value[0] ) );
-
+ logger.info(String.format("EGL_ALPHA_SIZE = %d", value[0]));
+
egl.eglGetConfigAttrib(display, conf, EGL10.EGL_DEPTH_SIZE, value);
- logger.info(String.format("EGL_DEPTH_SIZE = %d", value[0] ) );
-
+ logger.info(String.format("EGL_DEPTH_SIZE = %d", value[0]));
+
egl.eglGetConfigAttrib(display, conf, EGL10.EGL_STENCIL_SIZE, value);
- logger.info(String.format("EGL_STENCIL_SIZE = %d", value[0] ) );
+ logger.info(String.format("EGL_STENCIL_SIZE = %d", value[0]));
egl.eglGetConfigAttrib(display, conf, EGL10.EGL_RENDERABLE_TYPE, value);
- logger.info(String.format("EGL_RENDERABLE_TYPE = %d", value[0] ) );
-
+ logger.info(String.format("EGL_RENDERABLE_TYPE = %d", value[0]));
+
egl.eglGetConfigAttrib(display, conf, EGL10.EGL_SURFACE_TYPE, value);
- logger.info(String.format("EGL_SURFACE_TYPE = %d", value[0] ) );
+ logger.info(String.format("EGL_SURFACE_TYPE = %d", value[0]));
}
-
- public int getClientOpenGLESVersion()
- {
+
+ public int getClientOpenGLESVersion() {
return clientOpenGLESVersion;
}
- public void setClientOpenGLESVersion(int clientOpenGLESVersion)
- {
+ public void setClientOpenGLESVersion(int clientOpenGLESVersion) {
this.clientOpenGLESVersion = clientOpenGLESVersion;
}
-
- public int getPixelFormat()
- {
+
+ public int getPixelFormat() {
return pixelFormat;
}
-
-
-
- private abstract class BaseConfigChooser implements EGLConfigChooser
- {
+
+ private abstract class BaseConfigChooser implements EGLConfigChooser {
+
private boolean bClientOpenGLESVersionSet;
-
- public BaseConfigChooser(int[] configSpec)
- {
- bClientOpenGLESVersionSet = false;
- mConfigSpec = filterConfigSpec(configSpec);
- }
-
- public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display)
- {
- int[] num_config = new int[1];
- if (!egl.eglChooseConfig(display, mConfigSpec, null, 0,
- num_config)) {
- throw new IllegalArgumentException("eglChooseConfig failed");
- }
-
- int numConfigs = num_config[0];
-
- if (numConfigs <= 0)
- {
- //throw new IllegalArgumentException("No configs match configSpec");
-
- return null;
- }
-
- EGLConfig[] configs = new EGLConfig[numConfigs];
- if (!egl.eglChooseConfig(display, mConfigSpec, configs, numConfigs,
- num_config)) {
- throw new IllegalArgumentException("eglChooseConfig#2 failed");
- }
- EGLConfig config = chooseConfig(egl, display, configs);
- //if (config == null) {
- // throw new IllegalArgumentException("No config chosen");
- //}
- return config;
- }
-
- abstract EGLConfig chooseConfig(EGL10 egl, EGLDisplay display,
- EGLConfig[] configs);
-
- protected int[] mConfigSpec;
-
- private int[] filterConfigSpec(int[] configSpec)
- {
- if (bClientOpenGLESVersionSet == true) {
- return configSpec;
- }
- /* We know none of the subclasses define EGL_RENDERABLE_TYPE.
- * And we know the configSpec is well formed.
- */
- int len = configSpec.length;
- int[] newConfigSpec = new int[len + 2];
- System.arraycopy(configSpec, 0, newConfigSpec, 0, len-1);
- newConfigSpec[len-1] = EGL10.EGL_RENDERABLE_TYPE;
- newConfigSpec[len] = 4; /* EGL_OPENGL_ES2_BIT */
- newConfigSpec[len+1] = EGL10.EGL_NONE;
-
- bClientOpenGLESVersionSet = true;
-
- return newConfigSpec;
- }
+
+ public BaseConfigChooser(int[] configSpec) {
+ bClientOpenGLESVersionSet = false;
+ mConfigSpec = filterConfigSpec(configSpec);
+ }
+
+ public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {
+ int[] num_config = new int[1];
+ if (!egl.eglChooseConfig(display, mConfigSpec, null, 0,
+ num_config)) {
+ throw new IllegalArgumentException("eglChooseConfig failed");
+ }
+
+ int numConfigs = num_config[0];
+
+ if (numConfigs <= 0) {
+ //throw new IllegalArgumentException("No configs match configSpec");
+
+ return null;
+ }
+
+ EGLConfig[] configs = new EGLConfig[numConfigs];
+ if (!egl.eglChooseConfig(display, mConfigSpec, configs, numConfigs,
+ num_config)) {
+ throw new IllegalArgumentException("eglChooseConfig#2 failed");
+ }
+ EGLConfig config = chooseConfig(egl, display, configs);
+ //if (config == null) {
+ // throw new IllegalArgumentException("No config chosen");
+ //}
+ return config;
+ }
+
+ abstract EGLConfig chooseConfig(EGL10 egl, EGLDisplay display,
+ EGLConfig[] configs);
+ protected int[] mConfigSpec;
+
+ private int[] filterConfigSpec(int[] configSpec) {
+ if (bClientOpenGLESVersionSet == true) {
+ return configSpec;
+ }
+ /*
+ * We know none of the subclasses define EGL_RENDERABLE_TYPE. And we
+ * know the configSpec is well formed.
+ */
+ int len = configSpec.length;
+ int[] newConfigSpec = new int[len + 2];
+ System.arraycopy(configSpec, 0, newConfigSpec, 0, len - 1);
+ newConfigSpec[len - 1] = EGL10.EGL_RENDERABLE_TYPE;
+ newConfigSpec[len] = 4; /*
+ * EGL_OPENGL_ES2_BIT
+ */
+ newConfigSpec[len + 1] = EGL10.EGL_NONE;
+
+ bClientOpenGLESVersionSet = true;
+
+ return newConfigSpec;
+ }
}
-
+
/**
- * Choose a configuration with exactly the specified r,g,b,a sizes,
- * and at least the specified depth and stencil sizes.
+ * Choose a configuration with exactly the specified r,g,b,a sizes, and at
+ * least the specified depth and stencil sizes.
*/
- private class ComponentSizeChooser extends BaseConfigChooser
- {
+ private class ComponentSizeChooser extends BaseConfigChooser {
+
+ private int[] mValue;
+ // Subclasses can adjust these values:
+ protected int mRedSize;
+ protected int mGreenSize;
+ protected int mBlueSize;
+ protected int mAlphaSize;
+ protected int mDepthSize;
+ protected int mStencilSize;
+
public ComponentSizeChooser(int redSize, int greenSize, int blueSize,
- int alphaSize, int depthSize, int stencilSize)
- {
- super(new int[] {
- EGL10.EGL_RED_SIZE, redSize,
- EGL10.EGL_GREEN_SIZE, greenSize,
- EGL10.EGL_BLUE_SIZE, blueSize,
- EGL10.EGL_ALPHA_SIZE, alphaSize,
- EGL10.EGL_DEPTH_SIZE, depthSize,
- EGL10.EGL_STENCIL_SIZE, stencilSize,
- EGL10.EGL_NONE});
+ int alphaSize, int depthSize, int stencilSize) {
+ super(new int[]{
+ EGL10.EGL_RED_SIZE, redSize,
+ EGL10.EGL_GREEN_SIZE, greenSize,
+ EGL10.EGL_BLUE_SIZE, blueSize,
+ EGL10.EGL_ALPHA_SIZE, alphaSize,
+ EGL10.EGL_DEPTH_SIZE, depthSize,
+ EGL10.EGL_STENCIL_SIZE, stencilSize,
+ EGL10.EGL_NONE});
mValue = new int[1];
mRedSize = redSize;
mGreenSize = greenSize;
@@ -305,25 +286,22 @@ public class AndroidConfigChooser implements EGLConfigChooser
mAlphaSize = alphaSize;
mDepthSize = depthSize;
mStencilSize = stencilSize;
- }
+ }
@Override
- public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display, EGLConfig[] configs)
- {
- for (EGLConfig config : configs)
- {
+ public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display, EGLConfig[] configs) {
+ for (EGLConfig config : configs) {
int d = findConfigAttrib(egl, display, config,
EGL10.EGL_DEPTH_SIZE, 0);
int s = findConfigAttrib(egl, display, config,
EGL10.EGL_STENCIL_SIZE, 0);
- if ((d >= mDepthSize) && (s >= mStencilSize))
- {
+ if ((d >= mDepthSize) && (s >= mStencilSize)) {
int r = findConfigAttrib(egl, display, config,
EGL10.EGL_RED_SIZE, 0);
int g = findConfigAttrib(egl, display, config,
- EGL10.EGL_GREEN_SIZE, 0);
+ EGL10.EGL_GREEN_SIZE, 0);
int b = findConfigAttrib(egl, display, config,
- EGL10.EGL_BLUE_SIZE, 0);
+ EGL10.EGL_BLUE_SIZE, 0);
int a = findConfigAttrib(egl, display, config,
EGL10.EGL_ALPHA_SIZE, 0);
if ((r == mRedSize) && (g == mGreenSize)
@@ -336,27 +314,12 @@ public class AndroidConfigChooser implements EGLConfigChooser
}
private int findConfigAttrib(EGL10 egl, EGLDisplay display,
- EGLConfig config, int attribute, int defaultValue)
- {
+ EGLConfig config, int attribute, int defaultValue) {
- if (egl.eglGetConfigAttrib(display, config, attribute, mValue))
- {
+ if (egl.eglGetConfigAttrib(display, config, attribute, mValue)) {
return mValue[0];
}
return defaultValue;
}
-
- private int[] mValue;
- // Subclasses can adjust these values:
- protected int mRedSize;
- protected int mGreenSize;
- protected int mBlueSize;
- protected int mAlphaSize;
- protected int mDepthSize;
- protected int mStencilSize;
}
-
-
-
-
}
diff --git a/engine/src/android/com/jme3/system/android/OGLESContext.java b/engine/src/android/com/jme3/system/android/OGLESContext.java
index 668b68d..1ecf2e1 100644
--- a/engine/src/android/com/jme3/system/android/OGLESContext.java
+++ b/engine/src/android/com/jme3/system/android/OGLESContext.java
@@ -32,26 +32,37 @@
package com.jme3.system.android;
import android.app.Activity;
+import android.app.AlertDialog;
import android.content.Context;
+import android.content.DialogInterface;
import android.opengl.GLSurfaceView;
+import android.text.InputType;
+import android.view.Gravity;
import android.view.SurfaceHolder;
+import android.view.ViewGroup.LayoutParams;
+import android.widget.EditText;
+import android.widget.FrameLayout;
import com.jme3.app.AndroidHarness;
import com.jme3.app.Application;
import com.jme3.input.JoyInput;
import com.jme3.input.KeyInput;
import com.jme3.input.MouseInput;
+import com.jme3.input.SoftTextDialogInput;
import com.jme3.input.TouchInput;
import com.jme3.input.android.AndroidInput;
+import com.jme3.input.controls.SoftTextDialogInputListener;
import com.jme3.input.controls.TouchTrigger;
import com.jme3.input.dummy.DummyKeyInput;
import com.jme3.input.dummy.DummyMouseInput;
import com.jme3.renderer.android.OGLESShaderRenderer;
import com.jme3.system.AppSettings;
import com.jme3.system.JmeContext;
+import com.jme3.system.JmeSystem;
import com.jme3.system.SystemListener;
import com.jme3.system.Timer;
import com.jme3.system.android.AndroidConfigChooser.ConfigType;
import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.logging.Level;
import java.util.logging.Logger;
import javax.microedition.khronos.egl.EGL10;
import javax.microedition.khronos.egl.EGLConfig;
@@ -59,7 +70,7 @@ import javax.microedition.khronos.egl.EGLContext;
import javax.microedition.khronos.egl.EGLDisplay;
import javax.microedition.khronos.opengles.GL10;
-public class OGLESContext implements JmeContext, GLSurfaceView.Renderer {
+public class OGLESContext implements JmeContext, GLSurfaceView.Renderer, SoftTextDialogInput {
private static final Logger logger = Logger.getLogger(OGLESContext.class.getName());
protected final AtomicBoolean created = new AtomicBoolean(false);
@@ -76,7 +87,6 @@ public class OGLESContext implements JmeContext, GLSurfaceView.Renderer {
protected boolean autoFlush = true;
protected AndroidInput view;
private boolean firstDrawFrame = true;
-
//protected int minFrameDuration = 1000 / frameRate; // Set a max FPS of 33
protected int minFrameDuration = 0; // No FPS cap
/**
@@ -145,12 +155,12 @@ public class OGLESContext implements JmeContext, GLSurfaceView.Renderer {
int[] version = new int[2];
if (egl.eglInitialize(display, version) == true) {
- logger.info("Display EGL Version: " + version[0] + "." + version[1]);
+ logger.log(Level.INFO, "Display EGL Version: {0}.{1}", new Object[]{version[0], version[1]});
}
try {
// Create a config chooser
- AndroidConfigChooser configChooser = new AndroidConfigChooser(configType, eglConfigVerboseLogging);
+ AndroidConfigChooser configChooser = new AndroidConfigChooser(configType);
// Init chooser
if (!configChooser.findConfig(egl, display)) {
listener.handleError("Unable to find suitable EGL config", null);
@@ -162,7 +172,7 @@ public class OGLESContext implements JmeContext, GLSurfaceView.Renderer {
listener.handleError("OpenGL ES 2.0 is not supported on this device", null);
return null;
}
-
+
// Requesting client version from GLSurfaceView which is extended by
// AndroidInput.
view.setEGLContextClientVersion(clientOpenGLESVersion);
@@ -210,12 +220,14 @@ public class OGLESContext implements JmeContext, GLSurfaceView.Renderer {
// Setup unhandled Exception Handler
if (ctx instanceof AndroidHarness) {
Thread.currentThread().setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
+
public void uncaughtException(Thread thread, Throwable thrown) {
((AndroidHarness) ctx).handleError("Exception thrown in " + thread.toString(), thrown);
}
});
} else {
Thread.currentThread().setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
+
public void uncaughtException(Thread thread, Throwable thrown) {
listener.handleError("Exception thrown in " + thread.toString(), thrown);
}
@@ -244,6 +256,8 @@ public class OGLESContext implements JmeContext, GLSurfaceView.Renderer {
}
}
+ JmeSystem.setSoftTextDialogInput(this);
+
needClose.set(false);
renderable.set(true);
}
@@ -268,6 +282,13 @@ public class OGLESContext implements JmeContext, GLSurfaceView.Renderer {
logger.info("Display destroyed.");
renderable.set(false);
+ final Context ctx = this.view.getContext();
+ if (ctx instanceof AndroidHarness) {
+ AndroidHarness harness = (AndroidHarness) ctx;
+ if (harness.isFinishOnAppStop()) {
+ harness.finish();
+ }
+ }
}
}
@@ -442,4 +463,67 @@ public class OGLESContext implements JmeContext, GLSurfaceView.Renderer {
public int getClientOpenGLESVersion() {
return clientOpenGLESVersion;
}
+
+ public void requestDialog(final int id, final String title, final String initialValue, final SoftTextDialogInputListener listener) {
+ logger.log(Level.INFO, "requestDialog: title: {0}, initialValue: {1}",
+ new Object[]{title, initialValue});
+
+ JmeAndroidSystem.getActivity().runOnUiThread(new Runnable() {
+
+ @Override
+ public void run() {
+
+ final FrameLayout layoutTextDialogInput = new FrameLayout(JmeAndroidSystem.getActivity());
+ final EditText editTextDialogInput = new EditText(JmeAndroidSystem.getActivity());
+ editTextDialogInput.setWidth(LayoutParams.FILL_PARENT);
+ editTextDialogInput.setHeight(LayoutParams.FILL_PARENT);
+ editTextDialogInput.setPadding(20, 20, 20, 20);
+ editTextDialogInput.setGravity(Gravity.FILL_HORIZONTAL);
+
+ editTextDialogInput.setText(initialValue);
+
+ switch (id) {
+ case SoftTextDialogInput.TEXT_ENTRY_DIALOG:
+
+ editTextDialogInput.setInputType(InputType.TYPE_CLASS_TEXT);
+ break;
+
+ case SoftTextDialogInput.NUMERIC_ENTRY_DIALOG:
+
+ editTextDialogInput.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL | InputType.TYPE_NUMBER_FLAG_SIGNED);
+ break;
+
+ case SoftTextDialogInput.NUMERIC_KEYPAD_DIALOG:
+
+ editTextDialogInput.setInputType(InputType.TYPE_CLASS_PHONE);
+ break;
+
+ default:
+ break;
+ }
+
+ layoutTextDialogInput.addView(editTextDialogInput);
+
+ AlertDialog dialogTextInput = new AlertDialog.Builder(JmeAndroidSystem.getActivity()).setTitle(title).setView(layoutTextDialogInput).setPositiveButton("OK",
+ new DialogInterface.OnClickListener() {
+
+ public void onClick(DialogInterface dialog, int whichButton) {
+ /* User clicked OK, send COMPLETE action
+ * and text */
+ listener.onSoftText(SoftTextDialogInputListener.COMPLETE, editTextDialogInput.getText().toString());
+ }
+ }).setNegativeButton("Cancel",
+ new DialogInterface.OnClickListener() {
+
+ public void onClick(DialogInterface dialog, int whichButton) {
+ /* User clicked CANCEL, send CANCEL action
+ * and text */
+ listener.onSoftText(SoftTextDialogInputListener.CANCEL, editTextDialogInput.getText().toString());
+ }
+ }).create();
+
+ dialogTextInput.show();
+ }
+ });
+ }
}