diff --git a/build b/build index d1fe3fe6..6db445d6 160000 --- a/build +++ b/build @@ -1 +1 @@ -Subproject commit d1fe3fe6c3a3e128dc5aa5515980f0367a8c5ab4 +Subproject commit 6db445d6ee504d00c63955b33ca5137296052cc1 diff --git a/sources/android/src/org/ewol/Ewol.java b/sources/android/src/org/ewol/Ewol.java index 206d2cf8..a3dd7a4d 100644 --- a/sources/android/src/org/ewol/Ewol.java +++ b/sources/android/src/org/ewol/Ewol.java @@ -26,7 +26,7 @@ public class Ewol { } public static native void setJavaVirtualMachineStart(T activityInstance); - public static native void setJavaVirtualMachineStartWallpaperEngine(T serviceInstance); + public static native void setJavaVirtualMachineStartWallpaperEngine(T serviceInstance); public static native void setJavaVirtualMachineStop(); public static native void paramSetArchiveDir(int mode, String myString); diff --git a/sources/android/src/org/ewol/EwolActivity.java b/sources/android/src/org/ewol/EwolActivity.java index b6f7a31c..bded73ca 100644 --- a/sources/android/src/org/ewol/EwolActivity.java +++ b/sources/android/src/org/ewol/EwolActivity.java @@ -76,10 +76,10 @@ public abstract class EwolActivity extends Activity implements EwolCallback, Ewo @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - + // set the java evironement in the C sources : Ewol.setJavaVirtualMachineStart(this); - + // Load the application directory Ewol.paramSetArchiveDir(1, getFilesDir().toString()); Ewol.paramSetArchiveDir(2, getCacheDir().toString()); @@ -104,7 +104,7 @@ public abstract class EwolActivity extends Activity implements EwolCallback, Ewo getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); // create bsurface system - mGLView = new EwolSurfaceViewGL(this, 2); + mGLView = new EwolSurfaceViewGL(this); // create element audio ... mStreams = new EwolAudioTask(); diff --git a/sources/android/src/org/ewol/EwolConstants.java b/sources/android/src/org/ewol/EwolConstants.java index 890ff4b6..8ad7e4b2 100644 --- a/sources/android/src/org/ewol/EwolConstants.java +++ b/sources/android/src/org/ewol/EwolConstants.java @@ -9,19 +9,18 @@ package org.ewol; public interface EwolConstants { - public static final int NATIVE_AUDIO_BUFFER_SIZE = 512; - public static final int EWOL_SYSTEM_KEY_VOLUME_UP = 1; - public static final int EWOL_SYSTEM_KEY_VOLUME_DOWN = 2; - public static final int EWOL_SYSTEM_KEY_MENU = 3; - public static final int EWOL_SYSTEM_KEY_CAMERA = 4; - public static final int EWOL_SYSTEM_KEY_HOME = 5; - public static final int EWOL_SYSTEM_KEY_POWER = 6; - // the back key is wrapped in the key to simplify PC validation ... - public static final int EWOL_SYSTEM_KEY_BACK = 0x1B; - public static final int EWOL_SYSTEM_KEY_DEL = 0x08; - - public static final int EWOL_ORIENTATION_AUTO = 0; - public static final int EWOL_ORIENTATION_LANDSCAPE = 1; - public static final int EWOL_ORIENTATION_PORTRAIT = 2; - + public static final int NATIVE_AUDIO_BUFFER_SIZE = 512; + public static final int EWOL_SYSTEM_KEY_VOLUME_UP = 1; + public static final int EWOL_SYSTEM_KEY_VOLUME_DOWN = 2; + public static final int EWOL_SYSTEM_KEY_MENU = 3; + public static final int EWOL_SYSTEM_KEY_CAMERA = 4; + public static final int EWOL_SYSTEM_KEY_HOME = 5; + public static final int EWOL_SYSTEM_KEY_POWER = 6; + // the back key is wrapped in the key to simplify PC validation ... + public static final int EWOL_SYSTEM_KEY_BACK = 0x1B; + public static final int EWOL_SYSTEM_KEY_DEL = 0x08; + + public static final int EWOL_ORIENTATION_AUTO = 0; + public static final int EWOL_ORIENTATION_LANDSCAPE = 1; + public static final int EWOL_ORIENTATION_PORTRAIT = 2; } diff --git a/sources/android/src/org/ewol/EwolSurfaceViewGL.java b/sources/android/src/org/ewol/EwolSurfaceViewGL.java index 0371c29a..93d0bb42 100644 --- a/sources/android/src/org/ewol/EwolSurfaceViewGL.java +++ b/sources/android/src/org/ewol/EwolSurfaceViewGL.java @@ -27,275 +27,272 @@ import static org.ewol.Ewol.EWOL; * */ public class EwolSurfaceViewGL extends GLSurfaceView implements EwolConstants { - public static final int SDK_VERSION = android.os.Build.VERSION.SDK_INT; - private EwolRendererGL m_ewolDrawer = null; - private boolean inputDown1 = false; - private boolean inputDown2 = false; - private boolean inputDown3 = false; + public static final int SDK_VERSION = android.os.Build.VERSION.SDK_INT; + private EwolRendererGL m_ewolDrawer = null; + private boolean inputDown1 = false; + private boolean inputDown2 = false; + private boolean inputDown3 = false; + + public EwolSurfaceViewGL(Context context) { + // super must be first statement in constructor + super(context); + /* + List of the Android API : + Android 4.1, 4.1.1 16 JELLY_BEAN Platform Highlights + Android 4.0.3, 4.0.4 15 ICE_CREAM_SANDWICH_MR1 Platform Highlights + Android 4.0, 4.0.1, 4.0.2 14 ICE_CREAM_SANDWICH + Android 3.2 13 HONEYCOMB_MR2 + Android 3.1.x 12 HONEYCOMB_MR1 Platform Highlights + Android 3.0.x 11 HONEYCOMB Platform Highlights + Android 2.3.4 + Android 2.3.3 10 GINGERBREAD_MR1 Platform Highlights + Android 2.3.2 + Android 2.3.1 + Android 2.3 9 GINGERBREAD + Android 2.2.x 8 FROYO Platform Highlights + Android 2.1.x 7 ECLAIR_MR1 Platform Highlights + Android 2.0.1 6 ECLAIR_0_1 + Android 2.0 5 ECLAIR + Android 1.6 4 DONUT Platform Highlights + Android 1.5 3 CUPCAKE Platform Highlights + Android 1.1 2 BASE_1_1 + Android 1.0 1 BASE + */ + // Create an OpenGL ES 2.0 context + setEGLContextClientVersion(2); + + // je n'ai pas compris ... + m_ewolDrawer = new EwolRendererGL(); + setRenderer(m_ewolDrawer); + + // Can get the focus ==> get keyboard from JAVA : + setFocusable(true); + setFocusableInTouchMode(true); + } - public EwolSurfaceViewGL(Context context, int openGlVersion) { - // super must be first statement in constructor - super(context); - /* - List of the Android API : - Android 4.1, 4.1.1 16 JELLY_BEAN Platform Highlights - Android 4.0.3, 4.0.4 15 ICE_CREAM_SANDWICH_MR1 Platform Highlights - Android 4.0, 4.0.1, 4.0.2 14 ICE_CREAM_SANDWICH - Android 3.2 13 HONEYCOMB_MR2 - Android 3.1.x 12 HONEYCOMB_MR1 Platform Highlights - Android 3.0.x 11 HONEYCOMB Platform Highlights - Android 2.3.4 - Android 2.3.3 10 GINGERBREAD_MR1 Platform Highlights - Android 2.3.2 - Android 2.3.1 - Android 2.3 9 GINGERBREAD - Android 2.2.x 8 FROYO Platform Highlights - Android 2.1.x 7 ECLAIR_MR1 Platform Highlights - Android 2.0.1 6 ECLAIR_0_1 - Android 2.0 5 ECLAIR - Android 1.6 4 DONUT Platform Highlights - Android 1.5 3 CUPCAKE Platform Highlights - Android 1.1 2 BASE_1_1 - Android 1.0 1 BASE - */ - // Create an OpenGL ES 2.0 context - if (openGlVersion == 2) { - setEGLContextClientVersion(2); + public boolean onTouchEvent(final MotionEvent event) { + // Wrapper on input events : + + int tmpActionType = event.getAction(); + + if (tmpActionType == MotionEvent.ACTION_MOVE) { + final int pointerCount = event.getPointerCount(); + for (int p = 0; p < pointerCount; p++) { + if (SDK_VERSION>=14) { + final int typeOfPointer = event.getToolType(p); + if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER + || typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) { + EWOL.inputEventMotion(event.getPointerId(p), (float)event.getX(p), (float)event.getY(p)); + } else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) { + EWOL.mouseEventMotion(event.getPointerId(p), (float)event.getX(p), (float)event.getY(p)); + } + } else { + EWOL.inputEventMotion(event.getPointerId(p), (float)event.getX(p), (float)event.getY(p)); + } + } + } else if( tmpActionType == MotionEvent.ACTION_POINTER_1_DOWN + || tmpActionType == MotionEvent.ACTION_DOWN) { + if (SDK_VERSION>=14) { + final int typeOfPointer = event.getToolType(0); + if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER + || typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) { + EWOL.inputEventState(event.getPointerId(0), true, (float)event.getX(0), (float)event.getY(0)); + } else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) { + EWOL.mouseEventState(event.getPointerId(0), true, (float)event.getX(0), (float)event.getY(0)); + } + } else { + EWOL.inputEventState(event.getPointerId(0), true, (float)event.getX(0), (float)event.getY(0)); + } + inputDown1 = true; + } else if(tmpActionType == MotionEvent.ACTION_POINTER_1_UP) { + if (SDK_VERSION>=14) { + final int typeOfPointer = event.getToolType(0); + if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER + || typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) { + EWOL.inputEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0)); + } else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) { + EWOL.mouseEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0)); + } + } else { + EWOL.inputEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0)); + } + inputDown1 = false; + } else if (tmpActionType == MotionEvent.ACTION_POINTER_2_DOWN) { + if (SDK_VERSION>=14) { + final int typeOfPointer = event.getToolType(1); + if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER + || typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) { + EWOL.inputEventState(event.getPointerId(1), true, (float)event.getX(1), (float)event.getY(1)); + } else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) { + EWOL.mouseEventState(event.getPointerId(1), true, (float)event.getX(1), (float)event.getY(1)); + } + } else { + EWOL.inputEventState(event.getPointerId(1), true, (float)event.getX(1), (float)event.getY(1)); + } + inputDown2 = true; + } else if (tmpActionType == MotionEvent.ACTION_POINTER_2_UP) { + if (SDK_VERSION>=14) { + final int typeOfPointer = event.getToolType(1); + if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER + || typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) { + EWOL.inputEventState(event.getPointerId(1), false, (float)event.getX(1), (float)event.getY(1)); + } else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) { + EWOL.mouseEventState(event.getPointerId(1), false, (float)event.getX(1), (float)event.getY(1)); + } + } else { + EWOL.inputEventState(event.getPointerId(1), false, (float)event.getX(1), (float)event.getY(1)); + } + inputDown2 = false; + } else if (tmpActionType == MotionEvent.ACTION_POINTER_3_DOWN) { + if (SDK_VERSION>=14) { + final int typeOfPointer = event.getToolType(2); + if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER + || typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) { + EWOL.inputEventState(event.getPointerId(2), true, (float)event.getX(2), (float)event.getY(2)); + } else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) { + EWOL.mouseEventState(event.getPointerId(2), true, (float)event.getX(2), (float)event.getY(2)); + } + } else { + EWOL.inputEventState(event.getPointerId(2), true, (float)event.getX(2), (float)event.getY(2)); + } + inputDown3 = true; + } else if (tmpActionType == MotionEvent.ACTION_POINTER_3_UP) { + if (SDK_VERSION>=14) { + final int typeOfPointer = event.getToolType(2); + if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER + || typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) { + EWOL.inputEventState(event.getPointerId(2), false, (float)event.getX(2), (float)event.getY(2)); + } else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) { + EWOL.mouseEventState(event.getPointerId(2), false, (float)event.getX(2), (float)event.getY(2)); + } + } else { + EWOL.inputEventState(event.getPointerId(2), false, (float)event.getX(2), (float)event.getY(2)); + } + inputDown3 = false; + } else if(tmpActionType == MotionEvent.ACTION_UP){ + if (inputDown1) { + if (SDK_VERSION>=14) { + final int typeOfPointer = event.getToolType(0); + if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER + || typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) { + EWOL.inputEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0)); + } else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) { + EWOL.mouseEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0)); + } + } else { + EWOL.inputEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0)); + } + inputDown1 = false; + } else if (inputDown2) { + if (SDK_VERSION>=14) { + final int typeOfPointer = event.getToolType(0); + if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER + || typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) { + EWOL.inputEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0)); + } else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) { + EWOL.mouseEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0)); + } + } else { + EWOL.inputEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0)); + } + inputDown2 = false; + } else { + if (SDK_VERSION>=14) { + final int typeOfPointer = event.getToolType(0); + if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER + || typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) { + EWOL.inputEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0)); + } else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) { + EWOL.mouseEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0)); + } + } else { + EWOL.inputEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0)); + } + inputDown3 = false; + } + } + return true; } - // je n'ai pas compris ... - m_ewolDrawer = new EwolRendererGL(); - setRenderer(m_ewolDrawer); - - // Can get the focus ==> get keyboard from JAVA : - setFocusable(true); - setFocusableInTouchMode(true); - } - - public boolean onTouchEvent(final MotionEvent event) { - // Wrapper on input events : - - int tmpActionType = event.getAction(); - - if (tmpActionType == MotionEvent.ACTION_MOVE) { - final int pointerCount = event.getPointerCount(); - for (int p = 0; p < pointerCount; p++) { - if (SDK_VERSION>=14) { - final int typeOfPointer = event.getToolType(p); - if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER - || typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) { - EWOL.inputEventMotion(event.getPointerId(p), (float)event.getX(p), (float)event.getY(p)); - } else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) { - EWOL.mouseEventMotion(event.getPointerId(p), (float)event.getX(p), (float)event.getY(p)); - } - } else { - EWOL.inputEventMotion(event.getPointerId(p), (float)event.getX(p), (float)event.getY(p)); - } - } - } else if( tmpActionType == MotionEvent.ACTION_POINTER_1_DOWN - || tmpActionType == MotionEvent.ACTION_DOWN) { - if (SDK_VERSION>=14) { - final int typeOfPointer = event.getToolType(0); - if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER - || typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) { - EWOL.inputEventState(event.getPointerId(0), true, (float)event.getX(0), (float)event.getY(0)); - } else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) { - EWOL.mouseEventState(event.getPointerId(0), true, (float)event.getX(0), (float)event.getY(0)); - } - } else { - EWOL.inputEventState(event.getPointerId(0), true, (float)event.getX(0), (float)event.getY(0)); - } - inputDown1 = true; - } else if(tmpActionType == MotionEvent.ACTION_POINTER_1_UP) { - if (SDK_VERSION>=14) { - final int typeOfPointer = event.getToolType(0); - if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER - || typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) { - EWOL.inputEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0)); - } else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) { - EWOL.mouseEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0)); - } - } else { - EWOL.inputEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0)); - } - inputDown1 = false; - } else if (tmpActionType == MotionEvent.ACTION_POINTER_2_DOWN) { - if (SDK_VERSION>=14) { - final int typeOfPointer = event.getToolType(1); - if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER - || typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) { - EWOL.inputEventState(event.getPointerId(1), true, (float)event.getX(1), (float)event.getY(1)); - } else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) { - EWOL.mouseEventState(event.getPointerId(1), true, (float)event.getX(1), (float)event.getY(1)); - } - } else { - EWOL.inputEventState(event.getPointerId(1), true, (float)event.getX(1), (float)event.getY(1)); - } - inputDown2 = true; - } else if (tmpActionType == MotionEvent.ACTION_POINTER_2_UP) { - if (SDK_VERSION>=14) { - final int typeOfPointer = event.getToolType(1); - if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER - || typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) { - EWOL.inputEventState(event.getPointerId(1), false, (float)event.getX(1), (float)event.getY(1)); - } else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) { - EWOL.mouseEventState(event.getPointerId(1), false, (float)event.getX(1), (float)event.getY(1)); - } - } else { - EWOL.inputEventState(event.getPointerId(1), false, (float)event.getX(1), (float)event.getY(1)); - } - inputDown2 = false; - } else if (tmpActionType == MotionEvent.ACTION_POINTER_3_DOWN) { - if (SDK_VERSION>=14) { - final int typeOfPointer = event.getToolType(2); - if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER - || typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) { - EWOL.inputEventState(event.getPointerId(2), true, (float)event.getX(2), (float)event.getY(2)); - } else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) { - EWOL.mouseEventState(event.getPointerId(2), true, (float)event.getX(2), (float)event.getY(2)); - } - } else { - EWOL.inputEventState(event.getPointerId(2), true, (float)event.getX(2), (float)event.getY(2)); - } - inputDown3 = true; - } else if (tmpActionType == MotionEvent.ACTION_POINTER_3_UP) { - if (SDK_VERSION>=14) { - final int typeOfPointer = event.getToolType(2); - if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER - || typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) { - EWOL.inputEventState(event.getPointerId(2), false, (float)event.getX(2), (float)event.getY(2)); - } else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) { - EWOL.mouseEventState(event.getPointerId(2), false, (float)event.getX(2), (float)event.getY(2)); - } - - } else { - EWOL.inputEventState(event.getPointerId(2), false, (float)event.getX(2), (float)event.getY(2)); - } - inputDown3 = false; - } else if(tmpActionType == MotionEvent.ACTION_UP){ - if (inputDown1) { - if (SDK_VERSION>=14) { - final int typeOfPointer = event.getToolType(0); - if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER - || typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) { - EWOL.inputEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0)); - } else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) { - EWOL.mouseEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0)); - } - } else { - EWOL.inputEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0)); - } - inputDown1 = false; - } else if (inputDown2) { - if (SDK_VERSION>=14) { - final int typeOfPointer = event.getToolType(0); - if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER - || typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) { - EWOL.inputEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0)); - } else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) { - EWOL.mouseEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0)); - } - } else { - EWOL.inputEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0)); - } - inputDown2 = false; - } else { - if (SDK_VERSION>=14) { - final int typeOfPointer = event.getToolType(0); - if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER - || typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) { - EWOL.inputEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0)); - } else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) { - EWOL.mouseEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0)); - } - } else { - EWOL.inputEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0)); - } - inputDown3 = false; - } + private boolean keyboardEvent(int keyCode, KeyEvent event, boolean isDown) + { + int actionDone = event.getAction(); + switch(keyCode) + { + case KeyEvent.KEYCODE_VOLUME_DOWN: + EWOL.keyboardEventKeySystem(EWOL_SYSTEM_KEY_VOLUME_DOWN, isDown); + return false; + case KeyEvent.KEYCODE_VOLUME_UP: + EWOL.keyboardEventKeySystem(EWOL_SYSTEM_KEY_VOLUME_UP, isDown); + return false; + case KeyEvent.KEYCODE_MENU: + EWOL.keyboardEventKeySystem(EWOL_SYSTEM_KEY_MENU, isDown); + return false; + case KeyEvent.KEYCODE_CAMERA: + EWOL.keyboardEventKeySystem(EWOL_SYSTEM_KEY_CAMERA, isDown); + return false; + case KeyEvent.KEYCODE_HOME: + EWOL.keyboardEventKeySystem(EWOL_SYSTEM_KEY_HOME, isDown); + return false; + case KeyEvent.KEYCODE_POWER: + EWOL.keyboardEventKeySystem(EWOL_SYSTEM_KEY_POWER, isDown); + return false; + case KeyEvent.KEYCODE_BACK: + // the back key is wrapped in the key to simplify PC validation ... + EWOL.keyboardEventKey(EWOL_SYSTEM_KEY_BACK, isDown); + return false; + case KeyEvent.KEYCODE_DEL: + EWOL.keyboardEventKey(EWOL_SYSTEM_KEY_DEL, isDown); + return true; + case KeyEvent.KEYCODE_ALT_LEFT: + // TODO : ... + break; + case KeyEvent.KEYCODE_SHIFT_LEFT: + // TODO : ... + break; + case KeyEvent.KEYCODE_ENTER: + // TODO : ... + break; + // Joystick event : + case KeyEvent.KEYCODE_DPAD_UP: + break; + case KeyEvent.KEYCODE_DPAD_DOWN: + break; + case KeyEvent.KEYCODE_DPAD_LEFT: + break; + case KeyEvent.KEYCODE_DPAD_RIGHT: + break; + case KeyEvent.KEYCODE_DPAD_CENTER: + break; + default: + break; + } + // key wrapping : + if( (actionDone == KeyEvent.ACTION_DOWN) + || (actionDone == KeyEvent.ACTION_MULTIPLE) + || (actionDone == KeyEvent.ACTION_UP)) + { + // convert the key in UniChar to prevent errors ... + int uchar = event.getUnicodeChar(); + // pb on the return methode ... in java it is like windows ... + if (uchar == '\r') { + uchar = '\n'; + } + // send it to ewol ... + EWOL.keyboardEventKey(uchar, isDown); + return true; + } + return false; } - return true; - } - - private boolean keyboardEvent(int keyCode, KeyEvent event, boolean isDown) - { - int actionDone = event.getAction(); - switch(keyCode) - { - case KeyEvent.KEYCODE_VOLUME_DOWN: - EWOL.keyboardEventKeySystem(EWOL_SYSTEM_KEY_VOLUME_DOWN, isDown); - return false; - case KeyEvent.KEYCODE_VOLUME_UP: - EWOL.keyboardEventKeySystem(EWOL_SYSTEM_KEY_VOLUME_UP, isDown); - return false; - case KeyEvent.KEYCODE_MENU: - EWOL.keyboardEventKeySystem(EWOL_SYSTEM_KEY_MENU, isDown); - return false; - case KeyEvent.KEYCODE_CAMERA: - EWOL.keyboardEventKeySystem(EWOL_SYSTEM_KEY_CAMERA, isDown); - return false; - case KeyEvent.KEYCODE_HOME: - EWOL.keyboardEventKeySystem(EWOL_SYSTEM_KEY_HOME, isDown); - return false; - case KeyEvent.KEYCODE_POWER: - EWOL.keyboardEventKeySystem(EWOL_SYSTEM_KEY_POWER, isDown); - return false; - case KeyEvent.KEYCODE_BACK: - // the back key is wrapped in the key to simplify PC validation ... - EWOL.keyboardEventKey(EWOL_SYSTEM_KEY_BACK, isDown); - return false; - case KeyEvent.KEYCODE_DEL: - EWOL.keyboardEventKey(EWOL_SYSTEM_KEY_DEL, isDown); - return true; - case KeyEvent.KEYCODE_ALT_LEFT: - // TODO : ... - break; - case KeyEvent.KEYCODE_SHIFT_LEFT: - // TODO : ... - break; - case KeyEvent.KEYCODE_ENTER: - // TODO : ... - break; - // Joystick event : - case KeyEvent.KEYCODE_DPAD_UP: - break; - case KeyEvent.KEYCODE_DPAD_DOWN: - break; - case KeyEvent.KEYCODE_DPAD_LEFT: - break; - case KeyEvent.KEYCODE_DPAD_RIGHT: - break; - case KeyEvent.KEYCODE_DPAD_CENTER: - break; - default: - break; - } - // key wrapping : - if( (actionDone == KeyEvent.ACTION_DOWN) - || (actionDone == KeyEvent.ACTION_MULTIPLE) - || (actionDone == KeyEvent.ACTION_UP)) - { - // convert the key in UniChar to prevent errors ... - int uchar = event.getUnicodeChar(); - // pb on the return methode ... in java it is like windows ... - if (uchar == '\r') { - uchar = '\n'; - } - // send it to ewol ... - EWOL.keyboardEventKey(uchar, isDown); - return true; - } - return false; - } - - public boolean onKeyDown(int keyCode, KeyEvent event) - { - return keyboardEvent(keyCode, event, true); - } - - public boolean onKeyUp(int keyCode, KeyEvent event) - { - return keyboardEvent(keyCode, event, false); - } - + + public boolean onKeyDown(int keyCode, KeyEvent event) + { + return keyboardEvent(keyCode, event, true); + } + + public boolean onKeyUp(int keyCode, KeyEvent event) + { + return keyboardEvent(keyCode, event, false); + } + } diff --git a/sources/android/src/org/ewol/EwolWallpaper.java b/sources/android/src/org/ewol/EwolWallpaper.java index d5358a3e..5824692a 100644 --- a/sources/android/src/org/ewol/EwolWallpaper.java +++ b/sources/android/src/org/ewol/EwolWallpaper.java @@ -1,231 +1,192 @@ /** - * @author Edouard DUPIN, Kevin BILLONNEAU + * @author Edouard DUPIN * * @copyright 2011, Edouard DUPIN, all right reserved * * @license BSD v3 (see license file) */ - - package org.ewol; -import android.service.wallpaper.WallpaperService; -//import android.app.Activity; -import android.content.Context; -import android.opengl.GLSurfaceView; -import android.os.Bundle; -import android.view.MotionEvent; -import android.view.KeyEvent; -// For No Title : -import android.view.Window; - -// For the full screen : -import android.view.WindowManager; -// for the keyboard event : -import android.view.inputmethod.InputMethodManager; - -import java.io.File; -import android.content.Context; -import android.content.res.Configuration; - -// For the getting apk name : -import android.content.pm.ActivityInfo; +import android.app.ActivityManager; import android.content.pm.ApplicationInfo; +import android.content.pm.ConfigurationInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; -import android.content.res.AssetFileDescriptor; -import android.content.res.AssetManager; -import android.util.DisplayMetrics; +import android.content.Context; +import android.opengl.GLSurfaceView; +import android.opengl.GLSurfaceView.Renderer; +import android.os.Build; +import android.service.wallpaper.WallpaperService; +import android.util.Log; import android.view.SurfaceHolder; - - -import java.io.IOException; +import org.ewol.EwolSurfaceViewGL; +import android.view.MotionEvent; import static org.ewol.Ewol.EWOL; -/** - * @brief Class : - * - */ -public abstract class EwolWallpaper extends WallpaperService +public abstract class EwolWallpaper extends WallpaperService implements EwolCallback, EwolConstants { - private TestPatternEngine tmpEngine; - + private GLEngine mGLView; static { System.loadLibrary("ewol"); } - @Override public void onCreate() - { - super.onCreate(); - } - - @Override public void onDestroy() - { - super.onDestroy(); - } - - @Override public Engine onCreateEngine() - { - tmpEngine = new TestPatternEngine(); - return tmpEngine; - } - - protected void initApkPath(String org, String vendor, String project) - { - tmpEngine.initApkPath(org, vendor, project); - } - - class TestPatternEngine extends Engine implements EwolCallback, EwolConstants // implements SharedPreferences.OnSharedPreferenceChangeListener - { - private EwolSurfaceViewGL mGLView; - - - public void initApkPath(String org, String vendor, String project) { - StringBuilder sb = new StringBuilder(); - sb.append(org).append("."); - sb.append(vendor).append("."); - sb.append(project); - String apkFilePath = null; - ApplicationInfo appInfo = null; - PackageManager packMgmr = getPackageManager(); - try { - appInfo = packMgmr.getApplicationInfo(sb.toString(), 0); - } catch (NameNotFoundException e) { - e.printStackTrace(); - throw new RuntimeException("Unable to locate assets, aborting..."); - } - apkFilePath = appInfo.sourceDir; - Ewol.paramSetArchiveDir(0, apkFilePath); + protected void initApkPath(String org, String vendor, String project) { + StringBuilder sb = new StringBuilder(); + sb.append(org).append("."); + sb.append(vendor).append("."); + sb.append(project); + String apkFilePath = null; + ApplicationInfo appInfo = null; + PackageManager packMgmr = getPackageManager(); + try { + appInfo = packMgmr.getApplicationInfo(sb.toString(), 0); + } catch (NameNotFoundException e) { + e.printStackTrace(); + throw new RuntimeException("Unable to locate assets, aborting..."); } + apkFilePath = appInfo.sourceDir; + Ewol.paramSetArchiveDir(0, apkFilePath); + } + + @Override public Engine onCreateEngine() { + + // set the java evironement in the C sources : + Ewol.setJavaVirtualMachineStartWallpaperEngine(this); + + // Load the application directory + Ewol.paramSetArchiveDir(1, getFilesDir().toString()); + Ewol.paramSetArchiveDir(2, getCacheDir().toString()); + // to enable extarnal storage: add in the manifest the restriction needed ... + //packageManager.checkPermission("android.permission.READ_SMS", myPackage) == PERMISSION_GRANTED; + //Ewol.paramSetArchiveDir(3, getExternalCacheDir().toString()); + + + //! DisplayMetrics metrics = new DisplayMetrics(); + //! getWindowManager().getDefaultDisplay().getMetrics(metrics); + //! EWOL.displayPropertyMetrics(metrics.xdpi, metrics.ydpi); + + // call C init ... + EWOL.onCreate(); + + // create bsurface system + mGLView = new GLEngine(); + + return mGLView; + } + + + + public class GLEngine extends Engine + { + class WallpaperGLSurfaceView extends EwolSurfaceViewGL + { + private static final String TAG = "WallpaperGLSurfaceView"; + WallpaperGLSurfaceView(Context context) + { + super(context); + Log.d(TAG, "WallpaperGLSurfaceView(" + context + ")"); + } + @Override + public SurfaceHolder getHolder() + { + Log.d(TAG, "getHolder(): returning " + getSurfaceHolder()); + return getSurfaceHolder(); + } + public void onDestroy() + { + Log.d(TAG, "onDestroy()"); + super.onDetachedFromWindow(); + } + } + + private static final String TAG = "GLEngine"; + private WallpaperGLSurfaceView glSurfaceView; @Override public void onCreate(SurfaceHolder surfaceHolder) { + Log.d(TAG, "onCreate(" + surfaceHolder + ")"); super.onCreate(surfaceHolder); - // set the java evironement in the C sources : - Ewol.setJavaVirtualMachineStartWallpaperEngine(this); + glSurfaceView = new WallpaperGLSurfaceView(EwolWallpaper.this); - // Load the application directory - Ewol.paramSetArchiveDir(1, getFilesDir().toString()); - Ewol.paramSetArchiveDir(2, getCacheDir().toString()); - // to enable extarnal storage: add in the manifest the restriction needed ... - //packageManager.checkPermission("android.permission.READ_SMS", myPackage) == PERMISSION_GRANTED; - //Ewol.paramSetArchiveDir(3, getExternalCacheDir().toString()); + // Check if the system supports OpenGL ES 2.0. + final ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); + final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); + final boolean supportsEs2 = configurationInfo.reqGlEsVersion >= 0x20000; - DisplayMetrics metrics = new DisplayMetrics(); - //!getWindowManager().getDefaultDisplay().getMetrics(metrics); - //!EWOL.displayPropertyMetrics(metrics.xdpi, metrics.ydpi); + if (false==supportsEs2) { + Log.d("LiveWallpaper", "does not support board with only open GL ES 1"); + return; + } + // Request an OpenGL ES 2.0 compatible context. + //setEGLContextClientVersion(2); - // call C init ... - EWOL.onCreate(); + // On Honeycomb+ devices, this improves the performance when + // leaving and resuming the live wallpaper. + setPreserveEGLContextOnPause(true); - // Remove the title of the current display : - //!requestWindowFeature(Window.FEATURE_NO_TITLE); - // set full screen Mode : - //!getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); - // display keyboard: - //getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); - // hide keyboard : - //!getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); - - // create bsurface system - mGLView = new EwolSurfaceViewGL(this, 2); - - setContentView(mGLView); } - @Override public void onStart() + @Override public void onTouchEvent(MotionEvent event) { - super.onStart(); - // call C - EWOL.onStart(); + glSurfaceView.onTouchEvent(event); } - - @Override public void onRestart() + + @Override public void onVisibilityChanged(boolean visible) { - super.onRestart(); - // call C - EWOL.onReStart(); - } - - @Override public void onResume() - { - super.onResume(); - mGLView.onResume(); - // call C - EWOL.onResume(); - } - - @Override public void onPause() - { - super.onPause(); - mGLView.onPause(); - // call C - EWOL.onPause(); - } - - @Override public void onStop() - { - super.onStop(); - // call C - EWOL.onStop(); + Log.d(TAG, "onVisibilityChanged(" + visible + ")"); + super.onVisibilityChanged(visible); + if (true==visible) { + glSurfaceView.onResume(); + // call C + EWOL.onResume(); + } else { + glSurfaceView.onPause(); + // call C + EWOL.onPause(); + } } + @Override public void onDestroy() { + Log.d(TAG, "onDestroy()"); super.onDestroy(); // call C + EWOL.onStop(); EWOL.onDestroy(); - // Remove the java Virtual machine pointer form the C code - Ewol.setJavaVirtualMachineStop(); - } - - @Override protected void finalize() throws Throwable - { - super.finalize(); - // cleanup your object here - } - - public void onConfigurationChanged(Configuration newConfig) - { - super.onConfigurationChanged(newConfig); - } - - public void keyboardUpdate(boolean show) - { - final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); - if(show) { - //EWOL.touchEvent(); - imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,0); - } else { - imm.toggleSoftInput(0 ,InputMethodManager.HIDE_IMPLICIT_ONLY + InputMethodManager.HIDE_NOT_ALWAYS); - //imm.hideSoftInputFromWindow(view.getWindowToken(),0); - } - } - - public void eventNotifier(String[] args) - { - // just for the test ... - EWOL.touchEvent(); + glSurfaceView.onDestroy(); } - public void orientationUpdate(int screenMode) + protected void setPreserveEGLContextOnPause(boolean preserve) { - /* - if (screenMode == EWOL_ORIENTATION_LANDSCAPE) { - //Force landscape - setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); - } else if (screenMode == EWOL_ORIENTATION_PORTRAIT) { - //Force portrait - setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); - } else { - //Force auto Rotation - setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { + Log.d(TAG, "setPreserveEGLContextOnPause(" + preserve + ")"); + glSurfaceView.setPreserveEGLContextOnPause(preserve); } - */ } + + protected void setEGLContextClientVersion(int version) + { + Log.d(TAG, "setEGLContextClientVersion(" + version + ")"); + glSurfaceView.setEGLContextClientVersion(version); + } + } + + public void keyboardUpdate(boolean show) + { + // never display keyboard on wallpaer... + } + + public void eventNotifier(String[] args) + { + // just for the test ... + EWOL.touchEvent(); + } + + public void orientationUpdate(int screenMode) + { + } } - - diff --git a/sources/android/src/org/ewol/EwolWallpaperService.java b/sources/android/src/org/ewol/EwolWallpaperService.java index b7fb90e8..50a3c96c 100644 --- a/sources/android/src/org/ewol/EwolWallpaperService.java +++ b/sources/android/src/org/ewol/EwolWallpaperService.java @@ -1,7 +1,17 @@ - - +/** + * @author Edouard DUPIN + * + * @copyright 2011, Edouard DUPIN, all right reserved + * + * @license BSD v3 (see license file) + */ package org.ewol; +import android.app.ActivityManager; +import android.content.pm.ApplicationInfo; +import android.content.pm.ConfigurationInfo; +import android.content.pm.PackageManager; +import android.content.pm.PackageManager.NameNotFoundException; import android.content.Context; import android.opengl.GLSurfaceView; import android.opengl.GLSurfaceView.Renderer; @@ -9,20 +19,13 @@ import android.os.Build; import android.service.wallpaper.WallpaperService; import android.util.Log; import android.view.SurfaceHolder; +import org.ewol.EwolSurfaceViewGL; -//import com.learnopengles.android.util.LoggerConfig; +import static org.ewol.Ewol.EWOL; -public abstract class EwolWallpaperService extends WallpaperService +public abstract class EwolWallpaperService extends WallpaperService implements EwolCallback, EwolConstants { - private EwolSurfaceViewGL mGLView; - /* - // moi ... - @Override - public abstract Engine onCreateEngine(Context context) { - return new GLEngine(Context context); - } - */ - /* + private GLEngine mGLView; static { System.loadLibrary("ewol"); } @@ -44,11 +47,38 @@ public abstract class EwolWallpaperService extends WallpaperService apkFilePath = appInfo.sourceDir; Ewol.paramSetArchiveDir(0, apkFilePath); } - */ + + @Override public Engine onCreateEngine() { + + // set the java evironement in the C sources : + Ewol.setJavaVirtualMachineStartWallpaperEngine(this); + + // Load the application directory + Ewol.paramSetArchiveDir(1, getFilesDir().toString()); + Ewol.paramSetArchiveDir(2, getCacheDir().toString()); + // to enable extarnal storage: add in the manifest the restriction needed ... + //packageManager.checkPermission("android.permission.READ_SMS", myPackage) == PERMISSION_GRANTED; + //Ewol.paramSetArchiveDir(3, getExternalCacheDir().toString()); + + + //! DisplayMetrics metrics = new DisplayMetrics(); + //! getWindowManager().getDefaultDisplay().getMetrics(metrics); + //! EWOL.displayPropertyMetrics(metrics.xdpi, metrics.ydpi); + + // call C init ... + EWOL.onCreate(); + + // create bsurface system + mGLView = new GLEngine(); + + return mGLView; + } + + public class GLEngine extends Engine { - class WallpaperGLSurfaceView extends GLSurfaceView + class WallpaperGLSurfaceView extends EwolSurfaceViewGL { private static final String TAG = "WallpaperGLSurfaceView"; WallpaperGLSurfaceView(Context context) @@ -73,15 +103,32 @@ public abstract class EwolWallpaperService extends WallpaperService private WallpaperGLSurfaceView glSurfaceView; private boolean rendererHasBeenSet; - @Override - public void onCreate(SurfaceHolder surfaceHolder) + @Override public void onCreate(SurfaceHolder surfaceHolder) { Log.d(TAG, "onCreate(" + surfaceHolder + ")"); super.onCreate(surfaceHolder); + glSurfaceView = new WallpaperGLSurfaceView(EwolWallpaperService.this); + + // Check if the system supports OpenGL ES 2.0. + final ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); + final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); + final boolean supportsEs2 = configurationInfo.reqGlEsVersion >= 0x20000; + + if (false==supportsEs2) { + Log.d("LiveWallpaper", "does not support board with only open GL ES 1"); + return; + } + // Request an OpenGL ES 2.0 compatible context. + //setEGLContextClientVersion(2); + + // On Honeycomb+ devices, this improves the performance when + // leaving and resuming the live wallpaper. + setPreserveEGLContextOnPause(true); + } - @Override - public void onVisibilityChanged(boolean visible) + + @Override public void onVisibilityChanged(boolean visible) { Log.d(TAG, "onVisibilityChanged(" + visible + ")"); super.onVisibilityChanged(visible); @@ -93,19 +140,21 @@ public abstract class EwolWallpaperService extends WallpaperService } } } - @Override - public void onDestroy() + + @Override public void onDestroy() { Log.d(TAG, "onDestroy()"); super.onDestroy(); glSurfaceView.onDestroy(); } + protected void setRenderer(Renderer renderer) { Log.d(TAG, "setRenderer(" + renderer + ")"); glSurfaceView.setRenderer(renderer); rendererHasBeenSet = true; } + protected void setPreserveEGLContextOnPause(boolean preserve) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { @@ -113,11 +162,28 @@ public abstract class EwolWallpaperService extends WallpaperService glSurfaceView.setPreserveEGLContextOnPause(preserve); } } + protected void setEGLContextClientVersion(int version) { Log.d(TAG, "setEGLContextClientVersion(" + version + ")"); glSurfaceView.setEGLContextClientVersion(version); } } + + public void keyboardUpdate(boolean show) + { + // never display keyboard on wallpaer... + } + + public void eventNotifier(String[] args) + { + // just for the test ... + EWOL.touchEvent(); + } + + public void orientationUpdate(int screenMode) + { + + } } diff --git a/sources/ewol/renderer/os/gui.Android.cpp b/sources/ewol/renderer/os/gui.Android.cpp index f5b7a56d..98534d5c 100644 --- a/sources/ewol/renderer/os/gui.Android.cpp +++ b/sources/ewol/renderer/os/gui.Android.cpp @@ -19,6 +19,13 @@ /* include auto generated file */ #include +typedef enum { + appl_unknow, + appl_application, + appl_wallpaper +} application_te; +static application_te javaApplicationType = appl_unknow; + // get a resources from the java environement : static JNIEnv* JavaVirtualMachinePointer = NULL; // the JVM static jclass javaClassEwol = 0; // main activity class (android ...) @@ -127,23 +134,27 @@ void SendJavaOrientationUpdate(int32_t mode) void SendJavaSetTitle(const char * dataString) { EWOL_DEBUG("C->java : send message to the java : \"" << dataString << "\""); - int status; - if(!java_attach_current_thread(&status)) { - return; + if (javaApplicationType == appl_application) { + int status; + if(!java_attach_current_thread(&status)) { + return; + } + EWOL_DEBUG("C->java : 222"); + if (NULL == dataString) { + EWOL_ERROR("C->java : No data to send ..."); + return; + } + + //Call java ... + jstring title = JavaVirtualMachinePointer->NewStringUTF(dataString); + JavaVirtualMachinePointer->CallVoidMethod(javaObjectEwolCallbackAndActivity, javaMethodEwolActivitySetTitle, title); + JavaVirtualMachinePointer->DeleteLocalRef(title); + // manage execption : + java_check_exception(JavaVirtualMachinePointer); + java_detach_current_thread(status); + } else { + EWOL_ERROR("C->java : can not set title on appliation that is not real application"); } - EWOL_DEBUG("C->java : 222"); - if (NULL == dataString) { - EWOL_ERROR("C->java : No data to send ..."); - return; - } - - //Call java ... - jstring title = JavaVirtualMachinePointer->NewStringUTF(dataString); - JavaVirtualMachinePointer->CallVoidMethod(javaObjectEwolCallbackAndActivity, javaMethodEwolActivitySetTitle, title); - JavaVirtualMachinePointer->DeleteLocalRef(title); - // manage execption : - java_check_exception(JavaVirtualMachinePointer); - java_detach_current_thread(status); } @@ -223,7 +234,11 @@ extern "C" static void setJavaVirtualMachineStart(JNIEnv* env, jclass classBase, jobject objCallback) { EWOL_DEBUG("*******************************************"); - EWOL_DEBUG("** Set JVM Pointer **"); + if (javaApplicationType == appl_application) { + EWOL_DEBUG("** Set JVM Pointer (application) **"); + } else { + EWOL_DEBUG("** Set JVM Pointer (LiveWallpaper) **"); + } EWOL_DEBUG("*******************************************"); JavaVirtualMachinePointer = env; // get default needed all time elements : @@ -245,25 +260,27 @@ extern "C" return; } - __jni_safe_init_method_id( - javaMethodEwolActivitySetTitle, - javaClassEwolCallbackAndActivity, - "setTitle", "(Ljava/lang/CharSequence;)V"); + if (javaApplicationType == appl_application) { + __jni_safe_init_method_id(javaMethodEwolActivitySetTitle, + javaClassEwolCallbackAndActivity, + "setTitle", + "(Ljava/lang/CharSequence;)V"); + } - __jni_safe_init_method_id( - javaMethodEwolCallbackEventNotifier, - javaClassEwolCallbackAndActivity, - "eventNotifier", "([Ljava/lang/String;)V"); + __jni_safe_init_method_id(javaMethodEwolCallbackEventNotifier, + javaClassEwolCallbackAndActivity, + "eventNotifier", + "([Ljava/lang/String;)V"); - __jni_safe_init_method_id( - javaMethodEwolCallbackKeyboardUpdate, - javaClassEwolCallbackAndActivity, - "keyboardUpdate", "(Z)V"); + __jni_safe_init_method_id(javaMethodEwolCallbackKeyboardUpdate, + javaClassEwolCallbackAndActivity, + "keyboardUpdate", + "(Z)V"); - __jni_safe_init_method_id( - javaMethodEwolCallbackOrientationUpdate, - javaClassEwolCallbackAndActivity, - "orientationUpdate", "(I)V"); + __jni_safe_init_method_id(javaMethodEwolCallbackOrientationUpdate, + javaClassEwolCallbackAndActivity, + "orientationUpdate", + "(I)V"); javaObjectEwolCallbackAndActivity = env->NewGlobalRef(objCallback); //javaObjectEwolCallbackAndActivity = objCallback; @@ -280,11 +297,13 @@ extern "C" void Java_org_ewol_Ewol_setJavaVirtualMachineStart(JNIEnv* _env, jclass _classBase, jobject _objCallback) { + javaApplicationType = appl_application; setJavaVirtualMachineStart(_env, _classBase, _objCallback); } void Java_org_ewol_Ewol_setJavaVirtualMachineStartWallpaperEngine(JNIEnv* _env, jclass _classBase, jobject _objCallback) { + javaApplicationType = appl_wallpaper; setJavaVirtualMachineStart(_env, _classBase, _objCallback); }