[DEV] basic wallpaper will work
This commit is contained in:
parent
010586a0fa
commit
7cb1648d6e
2
build
2
build
@ -1 +1 @@
|
|||||||
Subproject commit d1fe3fe6c3a3e128dc5aa5515980f0367a8c5ab4
|
Subproject commit 6db445d6ee504d00c63955b33ca5137296052cc1
|
@ -26,7 +26,7 @@ public class Ewol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static native <T extends Activity & EwolCallback> void setJavaVirtualMachineStart(T activityInstance);
|
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 setJavaVirtualMachineStop();
|
||||||
public static native void paramSetArchiveDir(int mode, String myString);
|
public static native void paramSetArchiveDir(int mode, String myString);
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ public abstract class EwolActivity extends Activity implements EwolCallback, Ewo
|
|||||||
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
|
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
|
||||||
|
|
||||||
// create bsurface system
|
// create bsurface system
|
||||||
mGLView = new EwolSurfaceViewGL(this, 2);
|
mGLView = new EwolSurfaceViewGL(this);
|
||||||
|
|
||||||
// create element audio ...
|
// create element audio ...
|
||||||
mStreams = new EwolAudioTask();
|
mStreams = new EwolAudioTask();
|
||||||
|
@ -23,5 +23,4 @@ public interface EwolConstants {
|
|||||||
public static final int EWOL_ORIENTATION_AUTO = 0;
|
public static final int EWOL_ORIENTATION_AUTO = 0;
|
||||||
public static final int EWOL_ORIENTATION_LANDSCAPE = 1;
|
public static final int EWOL_ORIENTATION_LANDSCAPE = 1;
|
||||||
public static final int EWOL_ORIENTATION_PORTRAIT = 2;
|
public static final int EWOL_ORIENTATION_PORTRAIT = 2;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ public class EwolSurfaceViewGL extends GLSurfaceView implements EwolConstants {
|
|||||||
private boolean inputDown2 = false;
|
private boolean inputDown2 = false;
|
||||||
private boolean inputDown3 = false;
|
private boolean inputDown3 = false;
|
||||||
|
|
||||||
public EwolSurfaceViewGL(Context context, int openGlVersion) {
|
public EwolSurfaceViewGL(Context context) {
|
||||||
// super must be first statement in constructor
|
// super must be first statement in constructor
|
||||||
super(context);
|
super(context);
|
||||||
/*
|
/*
|
||||||
@ -59,9 +59,7 @@ public class EwolSurfaceViewGL extends GLSurfaceView implements EwolConstants {
|
|||||||
Android 1.0 1 BASE
|
Android 1.0 1 BASE
|
||||||
*/
|
*/
|
||||||
// Create an OpenGL ES 2.0 context
|
// Create an OpenGL ES 2.0 context
|
||||||
if (openGlVersion == 2) {
|
|
||||||
setEGLContextClientVersion(2);
|
setEGLContextClientVersion(2);
|
||||||
}
|
|
||||||
|
|
||||||
// je n'ai pas compris ...
|
// je n'ai pas compris ...
|
||||||
m_ewolDrawer = new EwolRendererGL();
|
m_ewolDrawer = new EwolRendererGL();
|
||||||
@ -167,7 +165,6 @@ public class EwolSurfaceViewGL extends GLSurfaceView implements EwolConstants {
|
|||||||
} else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) {
|
} else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) {
|
||||||
EWOL.mouseEventState(event.getPointerId(2), false, (float)event.getX(2), (float)event.getY(2));
|
EWOL.mouseEventState(event.getPointerId(2), false, (float)event.getX(2), (float)event.getY(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
EWOL.inputEventState(event.getPointerId(2), false, (float)event.getX(2), (float)event.getY(2));
|
EWOL.inputEventState(event.getPointerId(2), false, (float)event.getX(2), (float)event.getY(2));
|
||||||
}
|
}
|
||||||
|
@ -1,87 +1,37 @@
|
|||||||
/**
|
/**
|
||||||
* @author Edouard DUPIN, Kevin BILLONNEAU
|
* @author Edouard DUPIN
|
||||||
*
|
*
|
||||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||||
*
|
*
|
||||||
* @license BSD v3 (see license file)
|
* @license BSD v3 (see license file)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
package org.ewol;
|
package org.ewol;
|
||||||
|
|
||||||
import android.service.wallpaper.WallpaperService;
|
import android.app.ActivityManager;
|
||||||
//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.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
|
import android.content.pm.ConfigurationInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.PackageManager.NameNotFoundException;
|
import android.content.pm.PackageManager.NameNotFoundException;
|
||||||
import android.content.res.AssetFileDescriptor;
|
import android.content.Context;
|
||||||
import android.content.res.AssetManager;
|
import android.opengl.GLSurfaceView;
|
||||||
import android.util.DisplayMetrics;
|
import android.opengl.GLSurfaceView.Renderer;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.service.wallpaper.WallpaperService;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.SurfaceHolder;
|
import android.view.SurfaceHolder;
|
||||||
|
import org.ewol.EwolSurfaceViewGL;
|
||||||
|
import android.view.MotionEvent;
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import static org.ewol.Ewol.EWOL;
|
import static org.ewol.Ewol.EWOL;
|
||||||
|
|
||||||
/**
|
public abstract class EwolWallpaper extends WallpaperService implements EwolCallback, EwolConstants
|
||||||
* @brief Class :
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public abstract class EwolWallpaper extends WallpaperService
|
|
||||||
{
|
{
|
||||||
private TestPatternEngine tmpEngine;
|
private GLEngine mGLView;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
System.loadLibrary("ewol");
|
System.loadLibrary("ewol");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void onCreate()
|
protected void initApkPath(String org, String vendor, String project) {
|
||||||
{
|
|
||||||
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();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append(org).append(".");
|
sb.append(org).append(".");
|
||||||
sb.append(vendor).append(".");
|
sb.append(vendor).append(".");
|
||||||
@ -99,9 +49,7 @@ public abstract class EwolWallpaper extends WallpaperService
|
|||||||
Ewol.paramSetArchiveDir(0, apkFilePath);
|
Ewol.paramSetArchiveDir(0, apkFilePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void onCreate(SurfaceHolder surfaceHolder)
|
@Override public Engine onCreateEngine() {
|
||||||
{
|
|
||||||
super.onCreate(surfaceHolder);
|
|
||||||
|
|
||||||
// set the java evironement in the C sources :
|
// set the java evironement in the C sources :
|
||||||
Ewol.setJavaVirtualMachineStartWallpaperEngine(this);
|
Ewol.setJavaVirtualMachineStartWallpaperEngine(this);
|
||||||
@ -113,94 +61,121 @@ public abstract class EwolWallpaper extends WallpaperService
|
|||||||
//packageManager.checkPermission("android.permission.READ_SMS", myPackage) == PERMISSION_GRANTED;
|
//packageManager.checkPermission("android.permission.READ_SMS", myPackage) == PERMISSION_GRANTED;
|
||||||
//Ewol.paramSetArchiveDir(3, getExternalCacheDir().toString());
|
//Ewol.paramSetArchiveDir(3, getExternalCacheDir().toString());
|
||||||
|
|
||||||
DisplayMetrics metrics = new DisplayMetrics();
|
|
||||||
//!getWindowManager().getDefaultDisplay().getMetrics(metrics);
|
//! DisplayMetrics metrics = new DisplayMetrics();
|
||||||
//!EWOL.displayPropertyMetrics(metrics.xdpi, metrics.ydpi);
|
//! getWindowManager().getDefaultDisplay().getMetrics(metrics);
|
||||||
|
//! EWOL.displayPropertyMetrics(metrics.xdpi, metrics.ydpi);
|
||||||
|
|
||||||
// call C init ...
|
// call C init ...
|
||||||
EWOL.onCreate();
|
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
|
// 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();
|
class WallpaperGLSurfaceView extends EwolSurfaceViewGL
|
||||||
// call C
|
{
|
||||||
EWOL.onStart();
|
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();
|
Log.d(TAG, "onCreate(" + surfaceHolder + ")");
|
||||||
// call C
|
super.onCreate(surfaceHolder);
|
||||||
EWOL.onReStart();
|
|
||||||
|
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();
|
glSurfaceView.onTouchEvent(event);
|
||||||
mGLView.onResume();
|
}
|
||||||
|
|
||||||
|
@Override public void onVisibilityChanged(boolean visible)
|
||||||
|
{
|
||||||
|
Log.d(TAG, "onVisibilityChanged(" + visible + ")");
|
||||||
|
super.onVisibilityChanged(visible);
|
||||||
|
if (true==visible) {
|
||||||
|
glSurfaceView.onResume();
|
||||||
// call C
|
// call C
|
||||||
EWOL.onResume();
|
EWOL.onResume();
|
||||||
}
|
} else {
|
||||||
|
glSurfaceView.onPause();
|
||||||
@Override public void onPause()
|
|
||||||
{
|
|
||||||
super.onPause();
|
|
||||||
mGLView.onPause();
|
|
||||||
// call C
|
// call C
|
||||||
EWOL.onPause();
|
EWOL.onPause();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void onStop()
|
|
||||||
{
|
|
||||||
super.onStop();
|
|
||||||
// call C
|
|
||||||
EWOL.onStop();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void onDestroy()
|
@Override public void onDestroy()
|
||||||
{
|
{
|
||||||
|
Log.d(TAG, "onDestroy()");
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
// call C
|
// call C
|
||||||
|
EWOL.onStop();
|
||||||
EWOL.onDestroy();
|
EWOL.onDestroy();
|
||||||
// Remove the java Virtual machine pointer form the C code
|
glSurfaceView.onDestroy();
|
||||||
Ewol.setJavaVirtualMachineStop();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override protected void finalize() throws Throwable
|
protected void setPreserveEGLContextOnPause(boolean preserve)
|
||||||
{
|
{
|
||||||
super.finalize();
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
|
||||||
// cleanup your object here
|
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)
|
public void keyboardUpdate(boolean show)
|
||||||
{
|
{
|
||||||
final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
// never display keyboard on wallpaer...
|
||||||
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)
|
public void eventNotifier(String[] args)
|
||||||
@ -211,21 +186,7 @@ public abstract class EwolWallpaper extends WallpaperService
|
|||||||
|
|
||||||
public void orientationUpdate(int screenMode)
|
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);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,17 @@
|
|||||||
|
/**
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
*
|
||||||
|
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||||
|
*
|
||||||
|
* @license BSD v3 (see license file)
|
||||||
|
*/
|
||||||
package org.ewol;
|
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.content.Context;
|
||||||
import android.opengl.GLSurfaceView;
|
import android.opengl.GLSurfaceView;
|
||||||
import android.opengl.GLSurfaceView.Renderer;
|
import android.opengl.GLSurfaceView.Renderer;
|
||||||
@ -9,20 +19,13 @@ import android.os.Build;
|
|||||||
import android.service.wallpaper.WallpaperService;
|
import android.service.wallpaper.WallpaperService;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.SurfaceHolder;
|
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;
|
private GLEngine mGLView;
|
||||||
/*
|
|
||||||
// moi ...
|
|
||||||
@Override
|
|
||||||
public abstract Engine onCreateEngine(Context context) {
|
|
||||||
return new GLEngine(Context context);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
static {
|
static {
|
||||||
System.loadLibrary("ewol");
|
System.loadLibrary("ewol");
|
||||||
}
|
}
|
||||||
@ -44,11 +47,38 @@ public abstract class EwolWallpaperService extends WallpaperService
|
|||||||
apkFilePath = appInfo.sourceDir;
|
apkFilePath = appInfo.sourceDir;
|
||||||
Ewol.paramSetArchiveDir(0, apkFilePath);
|
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
|
public class GLEngine extends Engine
|
||||||
{
|
{
|
||||||
class WallpaperGLSurfaceView extends GLSurfaceView
|
class WallpaperGLSurfaceView extends EwolSurfaceViewGL
|
||||||
{
|
{
|
||||||
private static final String TAG = "WallpaperGLSurfaceView";
|
private static final String TAG = "WallpaperGLSurfaceView";
|
||||||
WallpaperGLSurfaceView(Context context)
|
WallpaperGLSurfaceView(Context context)
|
||||||
@ -73,15 +103,32 @@ public abstract class EwolWallpaperService extends WallpaperService
|
|||||||
private WallpaperGLSurfaceView glSurfaceView;
|
private WallpaperGLSurfaceView glSurfaceView;
|
||||||
private boolean rendererHasBeenSet;
|
private boolean rendererHasBeenSet;
|
||||||
|
|
||||||
@Override
|
@Override public void onCreate(SurfaceHolder surfaceHolder)
|
||||||
public void onCreate(SurfaceHolder surfaceHolder)
|
|
||||||
{
|
{
|
||||||
Log.d(TAG, "onCreate(" + surfaceHolder + ")");
|
Log.d(TAG, "onCreate(" + surfaceHolder + ")");
|
||||||
super.onCreate(surfaceHolder);
|
super.onCreate(surfaceHolder);
|
||||||
|
|
||||||
glSurfaceView = new WallpaperGLSurfaceView(EwolWallpaperService.this);
|
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
|
// Request an OpenGL ES 2.0 compatible context.
|
||||||
public void onVisibilityChanged(boolean visible)
|
//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 + ")");
|
Log.d(TAG, "onVisibilityChanged(" + visible + ")");
|
||||||
super.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()");
|
Log.d(TAG, "onDestroy()");
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
glSurfaceView.onDestroy();
|
glSurfaceView.onDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setRenderer(Renderer renderer)
|
protected void setRenderer(Renderer renderer)
|
||||||
{
|
{
|
||||||
Log.d(TAG, "setRenderer(" + renderer + ")");
|
Log.d(TAG, "setRenderer(" + renderer + ")");
|
||||||
glSurfaceView.setRenderer(renderer);
|
glSurfaceView.setRenderer(renderer);
|
||||||
rendererHasBeenSet = true;
|
rendererHasBeenSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setPreserveEGLContextOnPause(boolean preserve)
|
protected void setPreserveEGLContextOnPause(boolean preserve)
|
||||||
{
|
{
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
|
||||||
@ -113,11 +162,28 @@ public abstract class EwolWallpaperService extends WallpaperService
|
|||||||
glSurfaceView.setPreserveEGLContextOnPause(preserve);
|
glSurfaceView.setPreserveEGLContextOnPause(preserve);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setEGLContextClientVersion(int version)
|
protected void setEGLContextClientVersion(int version)
|
||||||
{
|
{
|
||||||
Log.d(TAG, "setEGLContextClientVersion(" + version + ")");
|
Log.d(TAG, "setEGLContextClientVersion(" + version + ")");
|
||||||
glSurfaceView.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)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,13 @@
|
|||||||
/* include auto generated file */
|
/* include auto generated file */
|
||||||
#include <ewol/renderer/os/org_ewol_EwolConstants.h>
|
#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 :
|
// get a resources from the java environement :
|
||||||
static JNIEnv* JavaVirtualMachinePointer = NULL; // the JVM
|
static JNIEnv* JavaVirtualMachinePointer = NULL; // the JVM
|
||||||
static jclass javaClassEwol = 0; // main activity class (android ...)
|
static jclass javaClassEwol = 0; // main activity class (android ...)
|
||||||
@ -127,6 +134,7 @@ void SendJavaOrientationUpdate(int32_t mode)
|
|||||||
void SendJavaSetTitle(const char * dataString)
|
void SendJavaSetTitle(const char * dataString)
|
||||||
{
|
{
|
||||||
EWOL_DEBUG("C->java : send message to the java : \"" << dataString << "\"");
|
EWOL_DEBUG("C->java : send message to the java : \"" << dataString << "\"");
|
||||||
|
if (javaApplicationType == appl_application) {
|
||||||
int status;
|
int status;
|
||||||
if(!java_attach_current_thread(&status)) {
|
if(!java_attach_current_thread(&status)) {
|
||||||
return;
|
return;
|
||||||
@ -144,6 +152,9 @@ void SendJavaSetTitle(const char * dataString)
|
|||||||
// manage execption :
|
// manage execption :
|
||||||
java_check_exception(JavaVirtualMachinePointer);
|
java_check_exception(JavaVirtualMachinePointer);
|
||||||
java_detach_current_thread(status);
|
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)
|
static void setJavaVirtualMachineStart(JNIEnv* env, jclass classBase, jobject objCallback)
|
||||||
{
|
{
|
||||||
EWOL_DEBUG("*******************************************");
|
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("*******************************************");
|
EWOL_DEBUG("*******************************************");
|
||||||
JavaVirtualMachinePointer = env;
|
JavaVirtualMachinePointer = env;
|
||||||
// get default needed all time elements :
|
// get default needed all time elements :
|
||||||
@ -245,25 +260,27 @@ extern "C"
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
__jni_safe_init_method_id(
|
if (javaApplicationType == appl_application) {
|
||||||
javaMethodEwolActivitySetTitle,
|
__jni_safe_init_method_id(javaMethodEwolActivitySetTitle,
|
||||||
javaClassEwolCallbackAndActivity,
|
javaClassEwolCallbackAndActivity,
|
||||||
"setTitle", "(Ljava/lang/CharSequence;)V");
|
"setTitle",
|
||||||
|
"(Ljava/lang/CharSequence;)V");
|
||||||
|
}
|
||||||
|
|
||||||
__jni_safe_init_method_id(
|
__jni_safe_init_method_id(javaMethodEwolCallbackEventNotifier,
|
||||||
javaMethodEwolCallbackEventNotifier,
|
|
||||||
javaClassEwolCallbackAndActivity,
|
javaClassEwolCallbackAndActivity,
|
||||||
"eventNotifier", "([Ljava/lang/String;)V");
|
"eventNotifier",
|
||||||
|
"([Ljava/lang/String;)V");
|
||||||
|
|
||||||
__jni_safe_init_method_id(
|
__jni_safe_init_method_id(javaMethodEwolCallbackKeyboardUpdate,
|
||||||
javaMethodEwolCallbackKeyboardUpdate,
|
|
||||||
javaClassEwolCallbackAndActivity,
|
javaClassEwolCallbackAndActivity,
|
||||||
"keyboardUpdate", "(Z)V");
|
"keyboardUpdate",
|
||||||
|
"(Z)V");
|
||||||
|
|
||||||
__jni_safe_init_method_id(
|
__jni_safe_init_method_id(javaMethodEwolCallbackOrientationUpdate,
|
||||||
javaMethodEwolCallbackOrientationUpdate,
|
|
||||||
javaClassEwolCallbackAndActivity,
|
javaClassEwolCallbackAndActivity,
|
||||||
"orientationUpdate", "(I)V");
|
"orientationUpdate",
|
||||||
|
"(I)V");
|
||||||
|
|
||||||
javaObjectEwolCallbackAndActivity = env->NewGlobalRef(objCallback);
|
javaObjectEwolCallbackAndActivity = env->NewGlobalRef(objCallback);
|
||||||
//javaObjectEwolCallbackAndActivity = objCallback;
|
//javaObjectEwolCallbackAndActivity = objCallback;
|
||||||
@ -280,11 +297,13 @@ extern "C"
|
|||||||
|
|
||||||
void Java_org_ewol_Ewol_setJavaVirtualMachineStart(JNIEnv* _env, jclass _classBase, jobject _objCallback)
|
void Java_org_ewol_Ewol_setJavaVirtualMachineStart(JNIEnv* _env, jclass _classBase, jobject _objCallback)
|
||||||
{
|
{
|
||||||
|
javaApplicationType = appl_application;
|
||||||
setJavaVirtualMachineStart(_env, _classBase, _objCallback);
|
setJavaVirtualMachineStart(_env, _classBase, _objCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Java_org_ewol_Ewol_setJavaVirtualMachineStartWallpaperEngine(JNIEnv* _env, jclass _classBase, jobject _objCallback)
|
void Java_org_ewol_Ewol_setJavaVirtualMachineStartWallpaperEngine(JNIEnv* _env, jclass _classBase, jobject _objCallback)
|
||||||
{
|
{
|
||||||
|
javaApplicationType = appl_wallpaper;
|
||||||
setJavaVirtualMachineStart(_env, _classBase, _objCallback);
|
setJavaVirtualMachineStart(_env, _classBase, _objCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user