[DEV] basic wallpaper will work

This commit is contained in:
Edouard DUPIN 2013-08-26 22:07:12 +02:00
parent 010586a0fa
commit 7cb1648d6e
8 changed files with 565 additions and 523 deletions

2
build

@ -1 +1 @@
Subproject commit d1fe3fe6c3a3e128dc5aa5515980f0367a8c5ab4
Subproject commit 6db445d6ee504d00c63955b33ca5137296052cc1

View File

@ -26,7 +26,7 @@ public class Ewol {
}
public static native <T extends Activity & EwolCallback> void setJavaVirtualMachineStart(T activityInstance);
public static native <T extends Engine & EwolCallback> void setJavaVirtualMachineStartWallpaperEngine(T serviceInstance);
public static native <T extends WallpaperService & EwolCallback> void setJavaVirtualMachineStartWallpaperEngine(T serviceInstance);
public static native void setJavaVirtualMachineStop();
public static native void paramSetArchiveDir(int mode, String myString);

View File

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

View File

@ -23,5 +23,4 @@ public interface EwolConstants {
public static final int EWOL_ORIENTATION_AUTO = 0;
public static final int EWOL_ORIENTATION_LANDSCAPE = 1;
public static final int EWOL_ORIENTATION_PORTRAIT = 2;
}

View File

@ -33,7 +33,7 @@ public class EwolSurfaceViewGL extends GLSurfaceView implements EwolConstants {
private boolean inputDown2 = false;
private boolean inputDown3 = false;
public EwolSurfaceViewGL(Context context, int openGlVersion) {
public EwolSurfaceViewGL(Context context) {
// super must be first statement in constructor
super(context);
/*
@ -59,9 +59,7 @@ public class EwolSurfaceViewGL extends GLSurfaceView implements EwolConstants {
Android 1.0 1 BASE
*/
// Create an OpenGL ES 2.0 context
if (openGlVersion == 2) {
setEGLContextClientVersion(2);
}
// je n'ai pas compris ...
m_ewolDrawer = new EwolRendererGL();
@ -167,7 +165,6 @@ public class EwolSurfaceViewGL extends GLSurfaceView implements EwolConstants {
} 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));
}

View File

@ -1,87 +1,37 @@
/**
* @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) {
protected void initApkPath(String org, String vendor, String project) {
StringBuilder sb = new StringBuilder();
sb.append(org).append(".");
sb.append(vendor).append(".");
@ -99,9 +49,7 @@ public abstract class EwolWallpaper extends WallpaperService
Ewol.paramSetArchiveDir(0, apkFilePath);
}
@Override public void onCreate(SurfaceHolder surfaceHolder)
{
super.onCreate(surfaceHolder);
@Override public Engine onCreateEngine() {
// set the java evironement in the C sources :
Ewol.setJavaVirtualMachineStartWallpaperEngine(this);
@ -113,94 +61,121 @@ public abstract class EwolWallpaper extends WallpaperService
//packageManager.checkPermission("android.permission.READ_SMS", myPackage) == PERMISSION_GRANTED;
//Ewol.paramSetArchiveDir(3, getExternalCacheDir().toString());
DisplayMetrics metrics = new DisplayMetrics();
//! DisplayMetrics metrics = new DisplayMetrics();
//! getWindowManager().getDefaultDisplay().getMetrics(metrics);
//! EWOL.displayPropertyMetrics(metrics.xdpi, metrics.ydpi);
// call C init ...
EWOL.onCreate();
// 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);
mGLView = new GLEngine();
setContentView(mGLView);
return mGLView;
}
@Override public void onStart()
public class GLEngine extends Engine
{
super.onStart();
// call C
EWOL.onStart();
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();
}
}
@Override public void onRestart()
private static final String TAG = "GLEngine";
private WallpaperGLSurfaceView glSurfaceView;
@Override public void onCreate(SurfaceHolder surfaceHolder)
{
super.onRestart();
// call C
EWOL.onReStart();
Log.d(TAG, "onCreate(" + surfaceHolder + ")");
super.onCreate(surfaceHolder);
glSurfaceView = new WallpaperGLSurfaceView(EwolWallpaper.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 onResume()
@Override public void onTouchEvent(MotionEvent event)
{
super.onResume();
mGLView.onResume();
glSurfaceView.onTouchEvent(event);
}
@Override public void onVisibilityChanged(boolean visible)
{
Log.d(TAG, "onVisibilityChanged(" + visible + ")");
super.onVisibilityChanged(visible);
if (true==visible) {
glSurfaceView.onResume();
// call C
EWOL.onResume();
}
@Override public void onPause()
{
super.onPause();
mGLView.onPause();
} else {
glSurfaceView.onPause();
// call C
EWOL.onPause();
}
@Override public void onStop()
{
super.onStop();
// call C
EWOL.onStop();
}
@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();
glSurfaceView.onDestroy();
}
@Override protected void finalize() throws Throwable
protected void setPreserveEGLContextOnPause(boolean preserve)
{
super.finalize();
// cleanup your object here
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
Log.d(TAG, "setPreserveEGLContextOnPause(" + preserve + ")");
glSurfaceView.setPreserveEGLContextOnPause(preserve);
}
}
public void onConfigurationChanged(Configuration newConfig)
protected void setEGLContextClientVersion(int version)
{
super.onConfigurationChanged(newConfig);
Log.d(TAG, "setEGLContextClientVersion(" + version + ")");
glSurfaceView.setEGLContextClientVersion(version);
}
}
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);
}
// never display keyboard on wallpaer...
}
public void eventNotifier(String[] args)
@ -211,21 +186,7 @@ public abstract class EwolWallpaper extends WallpaperService
public void orientationUpdate(int screenMode)
{
/*
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);
}
*/
}
}
}

View File

@ -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;
}
@Override
public void onVisibilityChanged(boolean visible)
// 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)
{
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)
{
}
}

View File

@ -19,6 +19,13 @@
/* include auto generated file */
#include <ewol/renderer/os/org_ewol_EwolConstants.h>
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,6 +134,7 @@ void SendJavaOrientationUpdate(int32_t mode)
void SendJavaSetTitle(const char * dataString)
{
EWOL_DEBUG("C->java : send message to the java : \"" << dataString << "\"");
if (javaApplicationType == appl_application) {
int status;
if(!java_attach_current_thread(&status)) {
return;
@ -144,6 +152,9 @@ void SendJavaSetTitle(const char * dataString)
// 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");
}
}
@ -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,
if (javaApplicationType == appl_application) {
__jni_safe_init_method_id(javaMethodEwolActivitySetTitle,
javaClassEwolCallbackAndActivity,
"setTitle", "(Ljava/lang/CharSequence;)V");
"setTitle",
"(Ljava/lang/CharSequence;)V");
}
__jni_safe_init_method_id(
javaMethodEwolCallbackEventNotifier,
__jni_safe_init_method_id(javaMethodEwolCallbackEventNotifier,
javaClassEwolCallbackAndActivity,
"eventNotifier", "([Ljava/lang/String;)V");
"eventNotifier",
"([Ljava/lang/String;)V");
__jni_safe_init_method_id(
javaMethodEwolCallbackKeyboardUpdate,
__jni_safe_init_method_id(javaMethodEwolCallbackKeyboardUpdate,
javaClassEwolCallbackAndActivity,
"keyboardUpdate", "(Z)V");
"keyboardUpdate",
"(Z)V");
__jni_safe_init_method_id(
javaMethodEwolCallbackOrientationUpdate,
__jni_safe_init_method_id(javaMethodEwolCallbackOrientationUpdate,
javaClassEwolCallbackAndActivity,
"orientationUpdate", "(I)V");
"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);
}