From 533e072a592826df53b90491bcaa606dfddaf646 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 21 Jun 2012 19:43:59 +0200 Subject: NEWT: Add virtual on-screen keyboard visibility interface methods incl. Android implementation. Note: Currently only w/ Android implementation. Note: On Android there is no way to reliably be notified of the current keyboard state. It would be best, if your code does not rely on this information Window adds: - setKeyboardVisible(boolean) - isKeyboardVisible() // unreliable on Android --- src/test/com/jogamp/opengl/test/android/MovieCubeActivity0.java | 8 +------- src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java | 8 +------- .../jogamp/opengl/test/android/NEWTGearsES2ActivityLauncher.java | 2 +- 3 files changed, 3 insertions(+), 15 deletions(-) (limited to 'src/test/com') diff --git a/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0.java b/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0.java index 59e78936d..a30262ee3 100644 --- a/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0.java +++ b/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0.java @@ -34,7 +34,6 @@ import java.util.Arrays; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLProfile; -import jogamp.newt.driver.android.AndroidWindow; import jogamp.newt.driver.android.NewtBaseActivity; import com.jogamp.common.util.IOUtil; @@ -46,10 +45,8 @@ import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube; import com.jogamp.opengl.util.Animator; -import android.content.Context; import android.os.Bundle; import android.util.Log; -import android.view.inputmethod.InputMethodManager; public class MovieCubeActivity0 extends NewtBaseActivity { static String TAG = "MovieCubeActivity0"; @@ -58,10 +55,7 @@ public class MovieCubeActivity0 extends NewtBaseActivity { @Override public void mousePressed(MouseEvent e) { if(e.getPressure()>2f) { - final AndroidWindow win = (AndroidWindow)e.getSource(); - InputMethodManager mgr = (InputMethodManager) win.getAndroidView().getContext().getSystemService(Context.INPUT_METHOD_SERVICE); - mgr.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0); // shows keyboard .. - win.getAndroidView().requestFocus(); + ((com.jogamp.newt.Window) e.getSource()).setKeyboardVisible(true); } } }; diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java index 592ecf5d6..4468868f6 100644 --- a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java +++ b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java @@ -30,7 +30,6 @@ package com.jogamp.opengl.test.android; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLProfile; -import jogamp.newt.driver.android.AndroidWindow; import jogamp.newt.driver.android.NewtBaseActivity; import com.jogamp.newt.ScreenMode; @@ -42,10 +41,8 @@ import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; import com.jogamp.opengl.util.Animator; -import android.content.Context; import android.os.Bundle; import android.util.Log; -import android.view.inputmethod.InputMethodManager; public class NEWTGearsES2Activity extends NewtBaseActivity { static String TAG = "NEWTGearsES2Activity"; @@ -65,10 +62,7 @@ public class NEWTGearsES2Activity extends NewtBaseActivity { @Override public void mousePressed(MouseEvent e) { if(e.getPressure()>2f) { // show Keyboard - final AndroidWindow win = (AndroidWindow)e.getSource(); - InputMethodManager mgr = (InputMethodManager) win.getAndroidView().getContext().getSystemService(Context.INPUT_METHOD_SERVICE); - mgr.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0); // shows keyboard .. - win.getAndroidView().requestFocus(); + ((com.jogamp.newt.Window) e.getSource()).setKeyboardVisible(true); } } }); diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2ActivityLauncher.java b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2ActivityLauncher.java index 0454d543c..907be5092 100644 --- a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2ActivityLauncher.java +++ b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2ActivityLauncher.java @@ -59,7 +59,7 @@ public class NEWTGearsES2ActivityLauncher extends LauncherUtil.BaseActivityLaunc // properties.setProperty("newt.debug", "all"); // props.setProperty("newt.debug.Window", "true"); // props.setProperty("newt.debug.Window.MouseEvent", "true"); - // props.setProperty("newt.debug.Window.KeyEvent", "true"); + props.setProperty("newt.debug.Window.KeyEvent", "true"); } @Override -- cgit v1.2.3