Application can modify text input hint message
This commit is contained in:
@@ -455,10 +455,23 @@ public class MainActivity extends Activity
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
_screenKeyboard = new EditText(this);
|
_screenKeyboard = new EditText(this);
|
||||||
_videoLayout.addView(_screenKeyboard);
|
// This code does not work
|
||||||
_screenKeyboard.setOnKeyListener(new simpleKeyListener(this, sendBackspace));
|
/*
|
||||||
_screenKeyboard.setHint(R.string.text_edit_click_here);
|
_screenKeyboard.setMaxLines(100);
|
||||||
|
ViewGroup.LayoutParams layout = _screenKeyboard.getLayoutParams();
|
||||||
|
if( layout != null )
|
||||||
|
{
|
||||||
|
layout.width = ViewGroup.LayoutParams.FILL_PARENT;
|
||||||
|
layout.height = ViewGroup.LayoutParams.FILL_PARENT;
|
||||||
|
_screenKeyboard.setLayoutParams(layout);
|
||||||
|
}
|
||||||
|
_screenKeyboard.setGravity(android.view.Gravity.BOTTOM | android.view.Gravity.LEFT);
|
||||||
|
*/
|
||||||
|
String hint = _screenKeyboardHintMessage;
|
||||||
|
_screenKeyboard.setHint(hint != null ? hint : getString(R.string.text_edit_click_here));
|
||||||
_screenKeyboard.setText(oldText);
|
_screenKeyboard.setText(oldText);
|
||||||
|
_screenKeyboard.setOnKeyListener(new simpleKeyListener(this, sendBackspace));
|
||||||
|
_videoLayout.addView(_screenKeyboard);
|
||||||
//_screenKeyboard.setKeyListener(new TextKeyListener(TextKeyListener.Capitalize.NONE, false));
|
//_screenKeyboard.setKeyListener(new TextKeyListener(TextKeyListener.Capitalize.NONE, false));
|
||||||
_screenKeyboard.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
|
_screenKeyboard.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
|
||||||
_screenKeyboard.setFocusableInTouchMode(true);
|
_screenKeyboard.setFocusableInTouchMode(true);
|
||||||
@@ -493,6 +506,23 @@ public class MainActivity extends Activity
|
|||||||
{
|
{
|
||||||
return _screenKeyboard != null;
|
return _screenKeyboard != null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public void setScreenKeyboardHintMessage(String s)
|
||||||
|
{
|
||||||
|
_screenKeyboardHintMessage = s;
|
||||||
|
//System.out.println("setScreenKeyboardHintMessage: " + (_screenKeyboardHintMessage != null ? _screenKeyboardHintMessage : getString(R.string.text_edit_click_here)));
|
||||||
|
runOnUiThread(new Runnable()
|
||||||
|
{
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
if( _screenKeyboard != null )
|
||||||
|
{
|
||||||
|
String hint = _screenKeyboardHintMessage;
|
||||||
|
_screenKeyboard.setHint(hint != null ? hint : getString(R.string.text_edit_click_here));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
final static int ADVERTISEMENT_POSITION_RIGHT = -1;
|
final static int ADVERTISEMENT_POSITION_RIGHT = -1;
|
||||||
final static int ADVERTISEMENT_POSITION_BOTTOM = -1;
|
final static int ADVERTISEMENT_POSITION_BOTTOM = -1;
|
||||||
@@ -1023,6 +1053,7 @@ public class MainActivity extends Activity
|
|||||||
|
|
||||||
private FrameLayout _videoLayout = null;
|
private FrameLayout _videoLayout = null;
|
||||||
private EditText _screenKeyboard = null;
|
private EditText _screenKeyboard = null;
|
||||||
|
private String _screenKeyboardHintMessage = null;
|
||||||
private boolean sdlInited = false;
|
private boolean sdlInited = false;
|
||||||
public Settings.TouchEventsListener touchListener = null;
|
public Settings.TouchEventsListener touchListener = null;
|
||||||
public Settings.KeyEventsListener keyListener = null;
|
public Settings.KeyEventsListener keyListener = null;
|
||||||
|
|||||||
@@ -464,7 +464,7 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
Thread.sleep(50); // Give some time to the keyboard input thread
|
Thread.sleep(50); // Give some time to the keyboard input thread
|
||||||
catch(Exception e) { };
|
} catch(Exception e) { };
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -523,6 +523,11 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer
|
|||||||
return context.isScreenKeyboardShown() ? 1 : 0;
|
return context.isScreenKeyboardShown() ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setScreenKeyboardHintMessage(String s)
|
||||||
|
{
|
||||||
|
context.setScreenKeyboardHintMessage(s);
|
||||||
|
}
|
||||||
|
|
||||||
public void startAccelerometerGyroscope(int started)
|
public void startAccelerometerGyroscope(int started)
|
||||||
{
|
{
|
||||||
accelerometer.openedBySDL = (started != 0);
|
accelerometer.openedBySDL = (started != 0);
|
||||||
|
|||||||
Submodule project/jni/application/openarena/vm updated: f629e90155...157d48a0c0
@@ -111,6 +111,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 */
|
/* 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(void);
|
extern DECLSPEC int SDLCALL SDL_ANDROID_GetScreenKeyboardRedefinedByUser(void);
|
||||||
|
|
||||||
|
/* Set hint message for the text input field, it may be multi-line, set NULL to reset hint to default */
|
||||||
|
extern DECLSPEC int SDLCALL SDL_ANDROID_SetScreenKeyboardHintMesage(const char * hint);
|
||||||
|
|
||||||
/* API compatible to SDL2, it's a wrapper to the SDL_ANDROID_ToggleScreenKeyboardWithoutTextInput(), it does not block */
|
/* API compatible to SDL2, it's a wrapper to the SDL_ANDROID_ToggleScreenKeyboardWithoutTextInput(), it does not block */
|
||||||
|
|
||||||
extern DECLSPEC int SDLCALL SDL_HasScreenKeyboardSupport(void *unused);
|
extern DECLSPEC int SDLCALL SDL_HasScreenKeyboardSupport(void *unused);
|
||||||
|
|||||||
@@ -293,7 +293,7 @@ int ANDROID_VideoInit(_THIS, SDL_PixelFormat *vformat)
|
|||||||
SDL_modelist[20]->w = 640; SDL_modelist[20]->h = 270; // For UAE4ALL2
|
SDL_modelist[20]->w = 640; SDL_modelist[20]->h = 270; // For UAE4ALL2
|
||||||
SDL_modelist[21]->w = 320; SDL_modelist[21]->h = 216; // For UAE4ALL2
|
SDL_modelist[21]->w = 320; SDL_modelist[21]->h = 216; // For UAE4ALL2
|
||||||
SDL_modelist[22]->w = 640; SDL_modelist[22]->h = 216; // For UAE4ALL2
|
SDL_modelist[22]->w = 640; SDL_modelist[22]->h = 216; // For UAE4ALL2
|
||||||
SDL_modelist[23]->w = 384; SDL_modelist[23]->h = 272; // For VCMI
|
SDL_modelist[23]->w = 384; SDL_modelist[23]->h = 272; // For VICE
|
||||||
SDL_modelist[24] = NULL;
|
SDL_modelist[24] = NULL;
|
||||||
|
|
||||||
SDL_VideoInit_1_3(NULL, 0);
|
SDL_VideoInit_1_3(NULL, 0);
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ static jmethodID JavaShowScreenKeyboard = NULL;
|
|||||||
static jmethodID JavaToggleScreenKeyboardWithoutTextInput = NULL;
|
static jmethodID JavaToggleScreenKeyboardWithoutTextInput = NULL;
|
||||||
static jmethodID JavaHideScreenKeyboard = NULL;
|
static jmethodID JavaHideScreenKeyboard = NULL;
|
||||||
static jmethodID JavaIsScreenKeyboardShown = NULL;
|
static jmethodID JavaIsScreenKeyboardShown = NULL;
|
||||||
|
static jmethodID JavaSetScreenKeyboardHintMessage = NULL;
|
||||||
static jmethodID JavaStartAccelerometerGyroscope = NULL;
|
static jmethodID JavaStartAccelerometerGyroscope = NULL;
|
||||||
static jmethodID JavaGetAdvertisementParams = NULL;
|
static jmethodID JavaGetAdvertisementParams = NULL;
|
||||||
static jmethodID JavaSetAdvertisementVisible = NULL;
|
static jmethodID JavaSetAdvertisementVisible = NULL;
|
||||||
@@ -295,9 +296,25 @@ void SDL_ANDROID_CallJavaHideScreenKeyboard()
|
|||||||
|
|
||||||
int SDL_ANDROID_IsScreenKeyboardShown()
|
int SDL_ANDROID_IsScreenKeyboardShown()
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
// Efficient implementation sometimes fails for no real reason, so poll Java from time to time
|
||||||
|
// Or maybe not, this was when I've added some debug code, not observed anymore
|
||||||
|
static int safetyCounter = 0;
|
||||||
|
if( safetyCounter >= 60 ) {
|
||||||
|
safetyCounter = 0;
|
||||||
|
SDL_ANDROID_IsScreenKeyboardShownFlag = (*JavaEnv)->CallIntMethod( JavaEnv, JavaRenderer, JavaIsScreenKeyboardShown );
|
||||||
|
}
|
||||||
|
safetyCounter ++;
|
||||||
|
*/
|
||||||
|
|
||||||
return SDL_ANDROID_IsScreenKeyboardShownFlag;
|
return SDL_ANDROID_IsScreenKeyboardShownFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SDL_ANDROID_CallJavaSetScreenKeyboardHintMessage(const char *hint)
|
||||||
|
{
|
||||||
|
(*JavaEnv)->CallVoidMethod( JavaEnv, JavaRenderer, JavaSetScreenKeyboardHintMessage, hint ? (*JavaEnv)->NewStringUTF(JavaEnv, hint) : NULL );
|
||||||
|
}
|
||||||
|
|
||||||
void SDL_ANDROID_CallJavaStartAccelerometerGyroscope(int start)
|
void SDL_ANDROID_CallJavaStartAccelerometerGyroscope(int start)
|
||||||
{
|
{
|
||||||
(*JavaEnv)->CallVoidMethod( JavaEnv, JavaRenderer, JavaStartAccelerometerGyroscope, (jint) start );
|
(*JavaEnv)->CallVoidMethod( JavaEnv, JavaRenderer, JavaStartAccelerometerGyroscope, (jint) start );
|
||||||
@@ -315,6 +332,7 @@ JAVA_EXPORT_NAME(DemoRenderer_nativeInitJavaCallbacks) ( JNIEnv* env, jobject t
|
|||||||
JavaToggleScreenKeyboardWithoutTextInput = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "showScreenKeyboardWithoutTextInputField", "()V");
|
JavaToggleScreenKeyboardWithoutTextInput = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "showScreenKeyboardWithoutTextInputField", "()V");
|
||||||
JavaHideScreenKeyboard = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "hideScreenKeyboard", "()V");
|
JavaHideScreenKeyboard = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "hideScreenKeyboard", "()V");
|
||||||
JavaIsScreenKeyboardShown = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "isScreenKeyboardShown", "()I");
|
JavaIsScreenKeyboardShown = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "isScreenKeyboardShown", "()I");
|
||||||
|
JavaSetScreenKeyboardHintMessage = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "setScreenKeyboardHintMessage", "(Ljava/lang/String;)V");
|
||||||
JavaStartAccelerometerGyroscope = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "startAccelerometerGyroscope", "(I)V");
|
JavaStartAccelerometerGyroscope = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "startAccelerometerGyroscope", "(I)V");
|
||||||
|
|
||||||
JavaGetAdvertisementParams = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "getAdvertisementParams", "([I)V");
|
JavaGetAdvertisementParams = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "getAdvertisementParams", "([I)V");
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ extern SDL_Rect SDL_ANDROID_ShowScreenUnderFingerRect, SDL_ANDROID_ShowScreenUnd
|
|||||||
extern int SDL_ANDROID_CallJavaSwapBuffers();
|
extern int SDL_ANDROID_CallJavaSwapBuffers();
|
||||||
extern void SDL_ANDROID_CallJavaShowScreenKeyboard(const char * oldText, char * outBuf, int outBufLen);
|
extern void SDL_ANDROID_CallJavaShowScreenKeyboard(const char * oldText, char * outBuf, int outBufLen);
|
||||||
extern void SDL_ANDROID_CallJavaHideScreenKeyboard();
|
extern void SDL_ANDROID_CallJavaHideScreenKeyboard();
|
||||||
|
extern void SDL_ANDROID_CallJavaSetScreenKeyboardHintMessage(const char *hint);
|
||||||
extern int SDL_ANDROID_IsScreenKeyboardShown();
|
extern int SDL_ANDROID_IsScreenKeyboardShown();
|
||||||
extern int SDL_ANDROID_IsScreenKeyboardShownFlag;
|
extern int SDL_ANDROID_IsScreenKeyboardShownFlag;
|
||||||
extern int SDL_ANDROID_drawTouchscreenKeyboard();
|
extern int SDL_ANDROID_drawTouchscreenKeyboard();
|
||||||
|
|||||||
@@ -1134,3 +1134,9 @@ int SDL_ANDROID_GetScreenKeyboardRedefinedByUser()
|
|||||||
{
|
{
|
||||||
return ScreenKbRedefinedByUser;
|
return ScreenKbRedefinedByUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int SDL_ANDROID_SetScreenKeyboardHintMesage(const char * hint)
|
||||||
|
{
|
||||||
|
SDL_ANDROID_CallJavaSetScreenKeyboardHintMessage(hint);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user