Added new API for toggling text input via Android EditText widget

This commit is contained in:
pelya
2011-02-24 16:21:54 +00:00
parent 4de240dc27
commit 99f734c61c
17 changed files with 174 additions and 40 deletions

View File

@@ -242,6 +242,7 @@ public class MainActivity extends Activity {
DemoRenderer.nativeTextInput( (int)text.charAt(i), (int)text.codePointAt(i) );
}
}
DemoRenderer.nativeTextInputFinished();
_videoLayout.removeView(_screenKeyboard);
_screenKeyboard = null;
mGLView.setFocusableInTouchMode(true);
@@ -249,7 +250,7 @@ public class MainActivity extends Activity {
mGLView.requestFocus();
};
public void showScreenKeyboard()
public void showScreenKeyboard(final String oldText)
{
if(_screenKeyboard != null)
return;
@@ -283,6 +284,8 @@ public class MainActivity extends Activity {
};
_screenKeyboard = new EditText(this);
_screenKeyboard.setOnKeyListener(new myKeyListener(this));
_screenKeyboard.setHint(R.string.text_edit_click_here);
_screenKeyboard.setText(oldText);
_videoLayout.addView(_screenKeyboard);
_screenKeyboard.setFocusableInTouchMode(true);
_screenKeyboard.setFocusable(true);

View File

@@ -45,7 +45,7 @@ class Settings
static boolean settingsLoaded = false;
static boolean settingsChanged = false;
static final int SETTINGS_FILE_VERSION = 4;
static final int SETTINGS_FILE_VERSION = 5;
static void Save(final MainActivity p)
{

View File

@@ -253,18 +253,20 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer {
return 1;
}
public void showScreenKeyboard() // Called from native code
public void showScreenKeyboard(final String oldText) // Called from native code
{
class Callback implements Runnable
{
public MainActivity parent;
public String oldText;
public void run()
{
parent.showScreenKeyboard();
parent.showScreenKeyboard(oldText);
}
}
Callback cb = new Callback();
cb.parent = context;
cb.oldText = oldText;
context.runOnUiThread(cb);
}
@@ -279,6 +281,7 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer {
private native void nativeGlContextLost();
public native void nativeGlContextRecreated();
public static native void nativeTextInput( int ascii, int unicode );
public static native void nativeTextInputFinished();
private MainActivity context = null;
private AccelerometerReader accelerometer = null;

View File

@@ -143,4 +143,6 @@
<string name="video_smooth">Smooth the video</string>
<string name="video_separatethread">Separate thread for video, will increase FPS on some devices</string>
<string name="text_edit_click_here">Tap to start typing, press Back when done</string>
</resources>