From 926c4b2527b50d01c9ff01a96697c48b292c9d40 Mon Sep 17 00:00:00 2001 From: Hung-ying Tyan Date: Wed, 30 Sep 2009 16:02:17 +0800 Subject: [PATCH 4/7] make vpn type strings i18n ready. --- vpn/java/android/net/vpn/VpnType.java | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/vpn/java/android/net/vpn/VpnType.java b/vpn/java/android/net/vpn/VpnType.java index c7df9438c..322f2bfbe 100644 --- a/vpn/java/android/net/vpn/VpnType.java +++ b/vpn/java/android/net/vpn/VpnType.java @@ -16,26 +16,28 @@ package android.net.vpn; +import com.android.internal.R; + /** * Enumeration of all supported VPN types. * {@hide} */ public enum VpnType { - PPTP("PPTP", "", PptpProfile.class), - L2TP("L2TP", "", L2tpProfile.class), - L2TP_IPSEC_PSK("L2TP/IPSec PSK", "Pre-shared key based L2TP/IPSec VPN", + PPTP("PPTP", R.string.pptp_vpn_description, PptpProfile.class), + L2TP("L2TP", R.string.l2tp_vpn_description, L2tpProfile.class), + L2TP_IPSEC_PSK("L2TP/IPSec PSK", R.string.l2tp_ipsec_psk_vpn_description, L2tpIpsecPskProfile.class), - L2TP_IPSEC("L2TP/IPSec CRT", "Certificate based L2TP/IPSec VPN", + L2TP_IPSEC("L2TP/IPSec CRT", R.string.l2tp_ipsec_crt_vpn_description, L2tpIpsecProfile.class); private String mDisplayName; - private String mDescription; + private int mDescriptionId; private Class mClass; - VpnType(String displayName, String description, + VpnType(String displayName, int descriptionId, Class klass) { mDisplayName = displayName; - mDescription = description; + mDescriptionId = descriptionId; mClass = klass; } @@ -43,8 +45,12 @@ public enum VpnType { return mDisplayName; } + public int getDescriptionId() { + return mDescriptionId; + } + public String getDescription() { - return mDescription; + return ""; } public Class getProfileClass() { From baf911d720b195f9bcdf2bbf11673fc0cc20de1e Mon Sep 17 00:00:00 2001 From: Hung-ying Tyan Date: Wed, 30 Sep 2009 18:00:36 +0800 Subject: [PATCH 5/7] Remove deprecated VpnType.getDescription(). --- vpn/java/android/net/vpn/VpnType.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/vpn/java/android/net/vpn/VpnType.java b/vpn/java/android/net/vpn/VpnType.java index 322f2bfbe..356f8b1b0 100644 --- a/vpn/java/android/net/vpn/VpnType.java +++ b/vpn/java/android/net/vpn/VpnType.java @@ -49,10 +49,6 @@ public enum VpnType { return mDescriptionId; } - public String getDescription() { - return ""; - } - public Class getProfileClass() { return mClass; } From e5810d1f98557cbcf0f533215b1d76724b182e79 Mon Sep 17 00:00:00 2001 From: Jack Palevich Date: Wed, 30 Sep 2009 06:14:24 -0700 Subject: [PATCH 6/7] Add very simple input path. Fix end-of-line issues. --- opengl/tests/gl_jni/jni/gl_code.cpp | 114 +++++++++--------- .../src/com/android/gljni/GLJNIActivity.java | 17 ++- .../src/com/android/gljni/GLJNILib.java | 1 + .../src/com/android/gljni/GLJNIView.java | 6 + 4 files changed, 75 insertions(+), 63 deletions(-) diff --git a/opengl/tests/gl_jni/jni/gl_code.cpp b/opengl/tests/gl_jni/jni/gl_code.cpp index b85a43300..33b25ab6c 100644 --- a/opengl/tests/gl_jni/jni/gl_code.cpp +++ b/opengl/tests/gl_jni/jni/gl_code.cpp @@ -2,16 +2,19 @@ #include #define LOG_TAG "GLJNI gl_code.cpp" -#include +#include + #include -#include +#include + #include #include - -GLuint texture; - -#define FIXED_ONE 0x10000 + +GLuint texture; +GLfloat background; + +#define FIXED_ONE 0x10000 static void printGLString(const char *name, GLenum s) { const char *v = (const char *) glGetString(s); @@ -77,38 +80,38 @@ static void gluLookAt(float eyeX, float eyeY, float eyeZ, glTranslatef(-eyeX, -eyeY, -eyeZ); } -void init_scene(int width, int height) +void init_scene(int width, int height) { printGLString("Version", GL_VERSION); printGLString("Vendor", GL_VENDOR); printGLString("Renderer", GL_RENDERER); - printGLString("Extensions", GL_EXTENSIONS); + printGLString("Extensions", GL_EXTENSIONS); + glDisable(GL_DITHER); glEnable(GL_CULL_FACE); - float ratio = width / height; glViewport(0, 0, width, height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); - glFrustumf(-ratio, ratio, -1, 1, 1, 10); + glFrustumf(-ratio, ratio, -1, 1, 1, 10); + glMatrixMode(GL_MODELVIEW); - glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt( 0, 0, 3, // eye 0, 0, 0, // center 0, 1, 0); // up - - glEnable(GL_TEXTURE_2D); - glEnableClientState(GL_VERTEX_ARRAY); + + glEnable(GL_TEXTURE_2D); + glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); -} - -void create_texture() -{ +} + +void create_texture() +{ const unsigned int on = 0xff0000ff; const unsigned int off = 0xffffffff; const unsigned int pixels[] = @@ -121,57 +124,60 @@ void create_texture() off, on, off, on, off, on, off, on, on, off, on, off, on, off, on, off, off, on, off, on, off, on, off, on, - }; - glGenTextures(1, &texture); - glBindTexture(GL_TEXTURE_2D, texture); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels); - glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + }; + + glGenTextures(1, &texture); + glBindTexture(GL_TEXTURE_2D, texture); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels); + glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); } extern "C" { JNIEXPORT void JNICALL Java_com_android_gljni_GLJNILib_init(JNIEnv * env, jobject obj, jint width, jint height); JNIEXPORT void JNICALL Java_com_android_gljni_GLJNILib_step(JNIEnv * env, jobject obj); + JNIEXPORT void JNICALL Java_com_android_gljni_GLJNILib_changeBackground(JNIEnv * env, jobject obj); }; - - -JNIEXPORT void JNICALL Java_com_android_gljni_GLJNILib_init(JNIEnv * env, jobject obj, jint width, jint height) -{ - init_scene(width, height); - create_texture(); -} -JNIEXPORT void JNICALL Java_com_android_gljni_GLJNILib_step(JNIEnv * env, jobject obj) -{ - const GLfloat vertices[] = { - -1, -1, 0, - 1, -1, 0, - 1, 1, 0, - -1, 1, 0 - }; - - const GLfixed texCoords[] = { - 0, 0, - FIXED_ONE, 0, - FIXED_ONE, FIXED_ONE, - 0, FIXED_ONE - }; - +JNIEXPORT void JNICALL Java_com_android_gljni_GLJNILib_init(JNIEnv * env, jobject obj, jint width, jint height) +{ + init_scene(width, height); + create_texture(); +} + +JNIEXPORT void JNICALL Java_com_android_gljni_GLJNILib_step(JNIEnv * env, jobject obj) +{ + const GLfloat vertices[] = { + -1, -1, 0, + 1, -1, 0, + 1, 1, 0, + -1, 1, 0 + }; + + const GLfixed texCoords[] = { + 0, 0, + FIXED_ONE, 0, + FIXED_ONE, FIXED_ONE, + 0, FIXED_ONE + }; + const GLushort quadIndices[] = { 0, 1, 2, 0, 2, 3 }; - - glVertexPointer(3, GL_FLOAT, 0, vertices); + glVertexPointer(3, GL_FLOAT, 0, vertices); glTexCoordPointer(2, GL_FIXED, 0, texCoords); - int nelem = sizeof(quadIndices)/sizeof(quadIndices[0]); static float grey; grey += 0.01f; if (grey > 1.0f) { grey = 0.0f; } - glClearColor(grey, grey, grey, 1.0f); + glClearColor(background, grey, grey, 1.0f); glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); - glDrawElements(GL_TRIANGLES, nelem, GL_UNSIGNED_SHORT, quadIndices); -} + glDrawElements(GL_TRIANGLES, nelem, GL_UNSIGNED_SHORT, quadIndices); +} +JNIEXPORT void JNICALL Java_com_android_gljni_GLJNILib_changeBackground(JNIEnv * env, jobject obj) +{ + background = 1.0f - background; +} \ No newline at end of file diff --git a/opengl/tests/gl_jni/src/com/android/gljni/GLJNIActivity.java b/opengl/tests/gl_jni/src/com/android/gljni/GLJNIActivity.java index df1f957df..c6f53134f 100644 --- a/opengl/tests/gl_jni/src/com/android/gljni/GLJNIActivity.java +++ b/opengl/tests/gl_jni/src/com/android/gljni/GLJNIActivity.java @@ -18,28 +18,27 @@ package com.android.gljni; import android.app.Activity; import android.os.Bundle; -import android.util.Log; -import android.view.WindowManager; - -import java.io.File; - public class GLJNIActivity extends Activity { GLJNIView mView; - @Override protected void onCreate(Bundle icicle) { + @Override + protected void onCreate(Bundle icicle) { super.onCreate(icicle); mView = new GLJNIView(getApplication()); - setContentView(mView); + mView.setFocusableInTouchMode(true); + setContentView(mView); } - @Override protected void onPause() { + @Override + protected void onPause() { super.onPause(); mView.onPause(); } - @Override protected void onResume() { + @Override + protected void onResume() { super.onResume(); mView.onResume(); } diff --git a/opengl/tests/gl_jni/src/com/android/gljni/GLJNILib.java b/opengl/tests/gl_jni/src/com/android/gljni/GLJNILib.java index 86627256b..f56d2af95 100644 --- a/opengl/tests/gl_jni/src/com/android/gljni/GLJNILib.java +++ b/opengl/tests/gl_jni/src/com/android/gljni/GLJNILib.java @@ -30,4 +30,5 @@ public class GLJNILib { */ public static native void init(int width, int height); public static native void step(); + public static native void changeBackground(); } diff --git a/opengl/tests/gl_jni/src/com/android/gljni/GLJNIView.java b/opengl/tests/gl_jni/src/com/android/gljni/GLJNIView.java index 9ea10597b..9a2c8c454 100644 --- a/opengl/tests/gl_jni/src/com/android/gljni/GLJNIView.java +++ b/opengl/tests/gl_jni/src/com/android/gljni/GLJNIView.java @@ -80,5 +80,11 @@ class GLJNIView extends GLSurfaceView { // Do nothing. } } + + @Override + public boolean onKeyDown(int keyCode, KeyEvent event) { + GLJNILib.changeBackground(); + return true; + } }