Show the soft keyboard provided by Android without a text field
for pure text input for editing the name of the savegame.
This commit is contained in:
@@ -307,6 +307,12 @@ public class MainActivity extends Activity {
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
public void togglePlainAndroidSoftKeyboardInput()
|
||||
{
|
||||
InputMethodManager imm = (InputMethodManager) getApplicationContext().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
|
||||
}
|
||||
|
||||
public void showScreenKeyboard(final String oldText, boolean sendBackspace)
|
||||
{
|
||||
if(Globals.CompatibilityHacksTextInputEmulatesHwKeyboard)
|
||||
|
||||
@@ -524,6 +524,21 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer
|
||||
return 1;
|
||||
}
|
||||
|
||||
public void togglePlainAndroidSoftKeyboardInput() // Called from native code
|
||||
{
|
||||
class Callback implements Runnable
|
||||
{
|
||||
public MainActivity parent;
|
||||
public void run()
|
||||
{
|
||||
parent.togglePlainAndroidSoftKeyboardInput();
|
||||
}
|
||||
}
|
||||
Callback cb = new Callback();
|
||||
cb.parent = context;
|
||||
context.runOnUiThread(cb);
|
||||
}
|
||||
|
||||
public void showScreenKeyboard(final String oldText, int sendBackspace) // Called from native code
|
||||
{
|
||||
class Callback implements Runnable
|
||||
|
||||
@@ -48,6 +48,8 @@
|
||||
#include "vga256d.h"
|
||||
#include "video.h"
|
||||
|
||||
#include "SDL_screenkeyboard.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
|
||||
@@ -2398,7 +2400,9 @@ void JE_operation( JE_byte slot )
|
||||
wait_noinput(false, true, false);
|
||||
|
||||
JE_barShade(VGAScreen, 65, 55, 255, 155);
|
||||
|
||||
#ifdef ANDROID
|
||||
SDL_ANDROID_CallJavaTogglePlainAndroidSoftKeyboardInput();
|
||||
#endif
|
||||
bool quit = false;
|
||||
while (!quit)
|
||||
{
|
||||
@@ -2510,6 +2514,9 @@ void JE_operation( JE_byte slot )
|
||||
case SDLK_RETURN:
|
||||
case SDLK_SPACE:
|
||||
quit = true;
|
||||
#ifdef ANDROID
|
||||
SDL_ANDROID_CallJavaTogglePlainAndroidSoftKeyboardInput();
|
||||
#endif
|
||||
JE_saveGame(slot, stemp);
|
||||
JE_playSampleNum(S_SELECT);
|
||||
break;
|
||||
|
||||
@@ -105,6 +105,9 @@ extern DECLSPEC int SDLCALL SDL_ANDROID_GetScreenKeyboardTextInput(char * textBu
|
||||
/* Whether user redefined on-screen keyboard layout via SDL menu, app should not enforce it's own layout in that case */
|
||||
extern DECLSPEC int SDLCALL SDL_ANDROID_GetScreenKeyboardRedefinedByUser();
|
||||
|
||||
/* Show only the bare Android on-screen keyboard without any text input field */
|
||||
extern DECLSPEC void SDLCALL SDL_ANDROID_CallJavaTogglePlainAndroidSoftKeyboardInput();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -61,6 +61,7 @@ static jclass JavaRendererClass = NULL;
|
||||
static jobject JavaRenderer = NULL;
|
||||
static jmethodID JavaSwapBuffers = NULL;
|
||||
static jmethodID JavaShowScreenKeyboard = NULL;
|
||||
static jmethodID JavaTogglePlainAndroidSoftKeyboardInput = NULL;
|
||||
static int glContextLost = 0;
|
||||
static int showScreenKeyboardDeferred = 0;
|
||||
static const char * showScreenKeyboardOldText = "";
|
||||
@@ -225,6 +226,11 @@ JAVA_EXPORT_NAME(DemoRenderer_nativeGlContextRecreated) ( JNIEnv* env, jobject
|
||||
#endif
|
||||
}
|
||||
|
||||
void SDL_ANDROID_CallJavaTogglePlainAndroidSoftKeyboardInput()
|
||||
{
|
||||
(*JavaEnv)->CallVoidMethod( JavaEnv, JavaRenderer, JavaTogglePlainAndroidSoftKeyboardInput );
|
||||
}
|
||||
|
||||
volatile static textInputFinished = 0;
|
||||
void SDL_ANDROID_TextInputFinished()
|
||||
{
|
||||
@@ -283,6 +289,7 @@ JAVA_EXPORT_NAME(DemoRenderer_nativeInitJavaCallbacks) ( JNIEnv* env, jobject t
|
||||
JavaRendererClass = (*JavaEnv)->GetObjectClass(JavaEnv, thiz);
|
||||
JavaSwapBuffers = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "swapBuffers", "()I");
|
||||
JavaShowScreenKeyboard = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "showScreenKeyboard", "(Ljava/lang/String;I)V");
|
||||
JavaTogglePlainAndroidSoftKeyboardInput = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "togglePlainAndroidSoftKeyboardInput", "()V");
|
||||
|
||||
ANDROID_InitOSKeymap();
|
||||
}
|
||||
|
||||
@@ -68,6 +68,7 @@ extern void SDL_ANDROID_ProcessDeferredEvents();
|
||||
extern void SDL_ANDROID_WarpMouse(int x, int y);
|
||||
extern void SDL_ANDROID_DrawMouseCursor(int x, int y, int size, int alpha);
|
||||
extern void SDL_ANDROID_DrawMouseCursorIfNeeded();
|
||||
extern void SDL_ANDROID_CallJavaTogglePlainAndroidSoftKeyboardInput();
|
||||
|
||||
|
||||
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||
|
||||
Reference in New Issue
Block a user