Provide the correct state of the on-screen keyboard to the API (patch from Sylvain)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
diff --git a/android-project/src/org/libsdl/app/SDLActivity.java b/android-project/src/org/libsdl/app/SDLActivity.java
index 1d8eb2c..d500b6d 100644
--- a/android-project/src/org/libsdl/app/SDLActivity.java
+++ b/android-project/src/org/libsdl/app/SDLActivity.java
@@ -59,6 +59,7 @@ public class SDLActivity extends Activity {
protected static SDLActivity mSingleton;
protected static SDLSurface mSurface;
protected static View mTextEdit;
+ protected static boolean mScreenKeyboardShown;
protected static ViewGroup mLayout;
protected static SDLJoystickHandler mJoystickHandler;
protected static SDLHapticHandler mHapticHandler;
@@ -440,6 +441,8 @@ public class SDLActivity extends Activity {
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(mTextEdit.getWindowToken(), 0);
+
+ mScreenKeyboardShown = false;
}
break;
case COMMAND_SET_KEEP_SCREEN_ON:
@@ -568,6 +571,45 @@ public class SDLActivity extends Activity {
return;
}
+
+ /**
+ * This method is called by SDL using JNI.
+ */
+ public static boolean isScreenKeyboardShown()
+ {
+ if (mTextEdit == null) {
+ return false;
+ }
+
+ if (mScreenKeyboardShown == false) {
+ return false;
+ }
+
+ InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
+ if (imm.isAcceptingText()) {
+ return true;
+ }
+
+ return false;
+ }
+
+
+
+ /**
+ * This method is called by SDL using JNI.
+ */
+ public static int openURL(String url)
+ {
+ try {
+ Intent i = new Intent(Intent.ACTION_VIEW);
+ i.setData(Uri.parse(url));
+ mSingleton.startActivity(i);
+ } catch (Exception ex) {
+ return -1;
+ }
+ return 0;
+ }
+
/**
* This method is called by SDL using JNI.
*/
@@ -647,6 +689,8 @@ public class SDLActivity extends Activity {
InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(mTextEdit, 0);
+
+ mScreenKeyboardShown = true;
}
}
diff --git a/src/core/android/SDL_android.c b/src/core/android/SDL_android.c
index 1d7d159..c6178ee 100644
--- a/src/core/android/SDL_android.c
+++ b/src/core/android/SDL_android.c
@@ -1684,6 +1684,20 @@ void Android_JNI_HideTextInput(void)
Android_JNI_SendMessage(COMMAND_TEXTEDIT_HIDE, 0);
}
+SDL_bool Android_JNI_IsScreenKeyboardShown()
+{
+ jmethodID mid;
+ jboolean is_shown = 0;
+ JNIEnv *mEnv = Android_JNI_GetEnv();
+ mid = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,"isScreenKeyboardShown","()Z");
+ if (mid) {
+ is_shown = (*mEnv)->CallStaticBooleanMethod(mEnv, mActivityClass, mid);
+ }
+
+ return is_shown;
+}
+
+
int Android_JNI_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
{
JNIEnv *env;
diff --git a/src/core/android/SDL_android.h b/src/core/android/SDL_android.h
index 7d4ded8..aae7180 100644
--- a/src/core/android/SDL_android.h
+++ b/src/core/android/SDL_android.h
@@ -38,6 +38,7 @@ extern void Android_JNI_SetOrientation(int w, int h, int resizable, const char *
extern SDL_bool Android_JNI_GetAccelerometerValues(float values[3]);
extern void Android_JNI_ShowTextInput(SDL_Rect *inputRect);
extern void Android_JNI_HideTextInput(void);
+extern SDL_bool Android_JNI_IsScreenKeyboardShown(void);
extern ANativeWindow* Android_JNI_GetNativeWindow(void);
/* Audio support */
diff --git a/src/video/android/SDL_androidkeyboard.c b/src/video/android/SDL_androidkeyboard.c
index 07119ac..888b1b1 100644
--- a/src/video/android/SDL_androidkeyboard.c
+++ b/src/video/android/SDL_androidkeyboard.c
@@ -357,7 +357,7 @@ Android_HasScreenKeyboardSupport(_THIS)
SDL_bool
Android_IsScreenKeyboardShown(_THIS, SDL_Window * window)
{
- return SDL_IsTextInputActive();
+ return Android_JNI_IsScreenKeyboardShown();
}
void