Skip to content

Commit 6a9f28a

Browse files
authored
Merge pull request kivy#2405 from dwmoffatt/Rebase-added-ability-to-set-input-type
Added ability to set input type on android
2 parents 1518d9c + 4fc5de8 commit 6a9f28a

File tree

2 files changed

+40
-14
lines changed

2 files changed

+40
-14
lines changed

pythonforandroid/bootstraps/sdl2/build/src/main/java/org/kivy/android/PythonActivity.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import android.os.Bundle;
2626
import android.os.PowerManager;
2727
import android.util.Log;
28+
import android.view.inputmethod.InputMethodManager;
2829
import android.view.SurfaceView;
2930
import android.view.ViewGroup;
3031
import android.view.View;
@@ -632,4 +633,12 @@ public void requestPermissionsWithRequestCode(String[] permissions, int requestC
632633
public void requestPermissions(String[] permissions) {
633634
requestPermissionsWithRequestCode(permissions, 1);
634635
}
636+
637+
public static void changeKeyboard(int inputType) {
638+
if (SDLActivity.keyboardInputType != inputType){
639+
SDLActivity.keyboardInputType = inputType;
640+
InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
641+
imm.restartInput(mTextEdit);
642+
}
643+
}
635644
}

pythonforandroid/bootstraps/sdl2/build/src/patches/SDLActivity.java.patch

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
--- a/src/main/java/org/libsdl/app/SDLActivity.java
22
+++ b/src/main/java/org/libsdl/app/SDLActivity.java
3-
@@ -196,6 +196,15 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
3+
@@ -94,6 +94,8 @@
4+
// This is what SDL runs in. It invokes SDL_main(), eventually
5+
protected static Thread mSDLThread;
6+
7+
+ public static int keyboardInputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD;
8+
+
9+
protected static SDLGenericMotionListener_API12 getMotionListener() {
10+
if (mMotionListener == null) {
11+
if (Build.VERSION.SDK_INT >= 26) {
12+
@@ -196,6 +198,15 @@
413
Log.v(TAG, "onCreate()");
514
super.onCreate(savedInstanceState);
6-
15+
716
+ SDLActivity.initialize();
817
+ // So we can call stuff from static callbacks
918
+ mSingleton = this;
@@ -16,19 +25,19 @@
1625
// Load shared libraries
1726
String errorMsgBrokenLib = "";
1827
try {
19-
@@ -639,7 +648,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
28+
@@ -639,7 +650,7 @@
2029
Handler commandHandler = new SDLCommandHandler();
21-
30+
2231
// Send a message from the SDLMain thread
2332
- boolean sendCommand(int command, Object data) {
2433
+ protected boolean sendCommand(int command, Object data) {
2534
Message msg = commandHandler.obtainMessage();
2635
msg.arg1 = command;
2736
msg.obj = data;
28-
@@ -1051,6 +1061,21 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
37+
@@ -1051,6 +1062,21 @@
2938
return Arrays.copyOf(filtered, used);
3039
}
31-
40+
3241
+ /**
3342
+ * Calls turnActive() on singleton to keep loading screen active
3443
+ */
@@ -45,11 +54,11 @@
4554
+
4655
+
4756
// APK expansion files support
48-
57+
4958
/** com.android.vending.expansion.zipfile.ZipResourceFile object or null. */
50-
@@ -1341,14 +1366,13 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
59+
@@ -1341,14 +1367,13 @@
5160
};
52-
61+
5362
public void onSystemUiVisibilityChange(int visibility) {
5463
- if (SDLActivity.mFullscreenModeActive && (visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0 || (visibility & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0) {
5564
-
@@ -62,13 +71,21 @@
6271
}
6372
-
6473
}
65-
}
66-
67-
@@ -1475,6 +1499,7 @@ class SDLMain implements Runnable {
74+
}
75+
76+
@@ -1475,6 +1500,7 @@
6877
String[] arguments = SDLActivity.mSingleton.getArguments();
69-
78+
7079
Log.v("SDL", "Running main function " + function + " from library " + library);
7180
+ SDLActivity.mSingleton.appConfirmedActive();
7281
SDLActivity.nativeRunMain(library, function, arguments);
73-
82+
7483
Log.v("SDL", "Finished main function");
84+
@@ -2002,7 +2028,7 @@
85+
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
86+
ic = new SDLInputConnection(this, true);
87+
88+
- outAttrs.inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD;
89+
+ outAttrs.inputType = SDLActivity.keyboardInputType;
90+
outAttrs.imeOptions = EditorInfo.IME_FLAG_NO_EXTRACT_UI
91+
| EditorInfo.IME_FLAG_NO_FULLSCREEN /* API 11 */;

0 commit comments

Comments
 (0)