kivyforge 3.0.0.dev0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- kivyforge/__init__.py +9 -0
- kivyforge/artifacts/__init__.py +41 -0
- kivyforge/artifacts/cache.py +81 -0
- kivyforge/artifacts/collect.py +354 -0
- kivyforge/artifacts/download.py +125 -0
- kivyforge/artifacts/frameworks.py +240 -0
- kivyforge/artifacts/native_stage_util.py +346 -0
- kivyforge/artifacts/runtime.py +65 -0
- kivyforge/artifacts/verify.py +45 -0
- kivyforge/artifacts/wheels.py +89 -0
- kivyforge/bundle/__init__.py +1 -0
- kivyforge/bundle/pycompile.py +161 -0
- kivyforge/cli/__init__.py +52 -0
- kivyforge/cli/_common.py +62 -0
- kivyforge/cli/_platform.py +84 -0
- kivyforge/cli/build.py +111 -0
- kivyforge/cli/clean.py +135 -0
- kivyforge/cli/doctor.py +52 -0
- kivyforge/cli/init.py +612 -0
- kivyforge/cli/init_writer.py +716 -0
- kivyforge/cli/lock.py +261 -0
- kivyforge/cli/open_cmd.py +15 -0
- kivyforge/cli/package.py +134 -0
- kivyforge/cli/run.py +162 -0
- kivyforge/cli/status.py +20 -0
- kivyforge/cli/upgrade.py +314 -0
- kivyforge/config/__init__.py +46 -0
- kivyforge/config/errors.py +43 -0
- kivyforge/config/icons.py +60 -0
- kivyforge/config/loader.py +3079 -0
- kivyforge/config/model.py +817 -0
- kivyforge/doctor/__init__.py +19 -0
- kivyforge/doctor/checks_common.py +95 -0
- kivyforge/doctor/probe.py +357 -0
- kivyforge/doctor/result.py +41 -0
- kivyforge/lock/__init__.py +42 -0
- kivyforge/lock/_pip_shim.py +63 -0
- kivyforge/lock/find_links.py +182 -0
- kivyforge/lock/model.py +69 -0
- kivyforge/lock/pep751.py +111 -0
- kivyforge/lock/reader.py +30 -0
- kivyforge/lock/resolver.py +124 -0
- kivyforge/lock/wheelruntime/__init__.py +70 -0
- kivyforge/lock/wheelruntime/builder.py +280 -0
- kivyforge/lock/wheelruntime/model.py +94 -0
- kivyforge/lock/wheelruntime/native_binaries.py +127 -0
- kivyforge/lock/wheelruntime/pbs_github.py +133 -0
- kivyforge/lock/wheelruntime/profile.py +104 -0
- kivyforge/lock/wheelruntime/resolver.py +248 -0
- kivyforge/lock/wheelruntime/runtime.py +161 -0
- kivyforge/lock/wheelruntime/serialize.py +245 -0
- kivyforge/platforms/__init__.py +114 -0
- kivyforge/platforms/android/__init__.py +140 -0
- kivyforge/platforms/android/adb.py +215 -0
- kivyforge/platforms/android/bootstrap/__init__.py +7 -0
- kivyforge/platforms/android/bootstrap/contract.py +166 -0
- kivyforge/platforms/android/bootstrap/render.py +244 -0
- kivyforge/platforms/android/bootstrap/templates/androidtest/KivyforgeContractTest.java +76 -0
- kivyforge/platforms/android/bootstrap/templates/bootstrap_py/_kivy_bootstrap.py +50 -0
- kivyforge/platforms/android/bootstrap/templates/bootstrap_py/_kivyforge_bootstrap.py +54 -0
- kivyforge/platforms/android/bootstrap/templates/bootstrap_py/_kivyforge_selftest.py +97 -0
- kivyforge/platforms/android/bootstrap/templates/cpp/CMakeLists.txt +20 -0
- kivyforge/platforms/android/bootstrap/templates/cpp/main.c +150 -0
- kivyforge/platforms/android/bootstrap/templates/java/org/jnius/NativeInvocationHandler.java +48 -0
- kivyforge/platforms/android/bootstrap/templates/java/org/kivy/android/PythonActivity.java +75 -0
- kivyforge/platforms/android/bootstrap/templates/java/org/kivy/android/PythonBundle.java +132 -0
- kivyforge/platforms/android/bootstrap/templates/java/org/kivy/android/PythonService.java +189 -0
- kivyforge/platforms/android/bootstrap/templates/java/org/renpy/android/Hardware.java +276 -0
- kivyforge/platforms/android/bootstrap/templates/sdl2/LICENSE-SDL.txt +18 -0
- kivyforge/platforms/android/bootstrap/templates/sdl2/SDL_REVISION.txt +3 -0
- kivyforge/platforms/android/bootstrap/templates/sdl2/org/libsdl/app/HIDDevice.java +22 -0
- kivyforge/platforms/android/bootstrap/templates/sdl2/org/libsdl/app/HIDDeviceBLESteamController.java +650 -0
- kivyforge/platforms/android/bootstrap/templates/sdl2/org/libsdl/app/HIDDeviceManager.java +698 -0
- kivyforge/platforms/android/bootstrap/templates/sdl2/org/libsdl/app/HIDDeviceUSB.java +309 -0
- kivyforge/platforms/android/bootstrap/templates/sdl2/org/libsdl/app/SDL.java +90 -0
- kivyforge/platforms/android/bootstrap/templates/sdl2/org/libsdl/app/SDLActivity.java +2120 -0
- kivyforge/platforms/android/bootstrap/templates/sdl2/org/libsdl/app/SDLAudioManager.java +514 -0
- kivyforge/platforms/android/bootstrap/templates/sdl2/org/libsdl/app/SDLControllerManager.java +856 -0
- kivyforge/platforms/android/bootstrap/templates/sdl2/org/libsdl/app/SDLSurface.java +405 -0
- kivyforge/platforms/android/bootstrap/templates/sdl3/LICENSE-SDL.txt +18 -0
- kivyforge/platforms/android/bootstrap/templates/sdl3/SDL_REVISION.txt +3 -0
- kivyforge/platforms/android/bootstrap/templates/sdl3/org/libsdl/app/HIDDevice.java +21 -0
- kivyforge/platforms/android/bootstrap/templates/sdl3/org/libsdl/app/HIDDeviceBLESteamController.java +829 -0
- kivyforge/platforms/android/bootstrap/templates/sdl3/org/libsdl/app/HIDDeviceManager.java +698 -0
- kivyforge/platforms/android/bootstrap/templates/sdl3/org/libsdl/app/HIDDeviceUSB.java +354 -0
- kivyforge/platforms/android/bootstrap/templates/sdl3/org/libsdl/app/SDL.java +90 -0
- kivyforge/platforms/android/bootstrap/templates/sdl3/org/libsdl/app/SDLActivity.java +2240 -0
- kivyforge/platforms/android/bootstrap/templates/sdl3/org/libsdl/app/SDLAudioManager.java +126 -0
- kivyforge/platforms/android/bootstrap/templates/sdl3/org/libsdl/app/SDLControllerManager.java +1010 -0
- kivyforge/platforms/android/bootstrap/templates/sdl3/org/libsdl/app/SDLDummyEdit.java +66 -0
- kivyforge/platforms/android/bootstrap/templates/sdl3/org/libsdl/app/SDLInputConnection.java +136 -0
- kivyforge/platforms/android/bootstrap/templates/sdl3/org/libsdl/app/SDLSensorManager.java +73 -0
- kivyforge/platforms/android/bootstrap/templates/sdl3/org/libsdl/app/SDLSurface.java +464 -0
- kivyforge/platforms/android/cli.py +1023 -0
- kivyforge/platforms/android/doctor.py +899 -0
- kivyforge/platforms/android/elf.py +148 -0
- kivyforge/platforms/android/generate/__init__.py +1 -0
- kivyforge/platforms/android/generate/manifest.py +261 -0
- kivyforge/platforms/android/generate/project.py +462 -0
- kivyforge/platforms/android/generate/services.py +187 -0
- kivyforge/platforms/android/gradle_wrapper/NOTICE +3 -0
- kivyforge/platforms/android/gradle_wrapper/SHA256SUMS +1 -0
- kivyforge/platforms/android/gradle_wrapper/gradle-wrapper.jar +0 -0
- kivyforge/platforms/android/gradle_wrapper/gradlew +164 -0
- kivyforge/platforms/android/gradle_wrapper/gradlew.bat +90 -0
- kivyforge/platforms/android/gradlew.py +60 -0
- kivyforge/platforms/android/icons.py +237 -0
- kivyforge/platforms/android/lock/__init__.py +1 -0
- kivyforge/platforms/android/lock/archives.py +109 -0
- kivyforge/platforms/android/lock/builder.py +387 -0
- kivyforge/platforms/android/lock/markers.py +71 -0
- kivyforge/platforms/android/lock/maven.py +252 -0
- kivyforge/platforms/android/lock/model.py +113 -0
- kivyforge/platforms/android/lock/python_meta.py +199 -0
- kivyforge/platforms/android/lock/reader.py +206 -0
- kivyforge/platforms/android/lock/resolver.py +276 -0
- kivyforge/platforms/android/lock/writer.py +121 -0
- kivyforge/platforms/android/policy.py +214 -0
- kivyforge/platforms/android/signing.py +145 -0
- kivyforge/platforms/android/smoke.py +43 -0
- kivyforge/platforms/android/splash.py +293 -0
- kivyforge/platforms/android/stage/__init__.py +1 -0
- kivyforge/platforms/android/stage/bundle.py +295 -0
- kivyforge/platforms/android/stage/jnilibs.py +186 -0
- kivyforge/platforms/android/stage/runtime.py +61 -0
- kivyforge/platforms/android/stage/wheels.py +106 -0
- kivyforge/platforms/android/toolchain.py +29 -0
- kivyforge/platforms/base.py +157 -0
- kivyforge/platforms/ios/__init__.py +129 -0
- kivyforge/platforms/ios/assets.py +193 -0
- kivyforge/platforms/ios/buildsettings.py +128 -0
- kivyforge/platforms/ios/cli.py +543 -0
- kivyforge/platforms/ios/doctor.py +410 -0
- kivyforge/platforms/ios/entitlements.py +34 -0
- kivyforge/platforms/ios/generator.py +318 -0
- kivyforge/platforms/ios/lock/__init__.py +71 -0
- kivyforge/platforms/ios/lock/builder.py +393 -0
- kivyforge/platforms/ios/lock/markers.py +69 -0
- kivyforge/platforms/ios/lock/model.py +95 -0
- kivyforge/platforms/ios/lock/python_meta.py +187 -0
- kivyforge/platforms/ios/lock/reader.py +191 -0
- kivyforge/platforms/ios/lock/resolver.py +304 -0
- kivyforge/platforms/ios/lock/spm.py +217 -0
- kivyforge/platforms/ios/lock/writer.py +114 -0
- kivyforge/platforms/ios/lock/xcframework.py +188 -0
- kivyforge/platforms/ios/materialize.py +59 -0
- kivyforge/platforms/ios/plist.py +91 -0
- kivyforge/platforms/ios/privacy.py +39 -0
- kivyforge/platforms/ios/skeleton.py +165 -0
- kivyforge/platforms/ios/sources.py +63 -0
- kivyforge/platforms/ios/staging.py +225 -0
- kivyforge/platforms/ios/swift_packages.py +324 -0
- kivyforge/platforms/ios/templates/kivyforge_bootstrap.h +34 -0
- kivyforge/platforms/ios/templates/kivyforge_bootstrap.m +146 -0
- kivyforge/platforms/ios/templates/main.m +15 -0
- kivyforge/platforms/ios/templates/main_config.h.in +12 -0
- kivyforge/platforms/ios/xcframeworks.py +194 -0
- kivyforge/platforms/ios/xcode/__init__.py +76 -0
- kivyforge/platforms/ios/xcode/commands.py +296 -0
- kivyforge/platforms/ios/xcode/runner.py +316 -0
- kivyforge/platforms/linux/__init__.py +120 -0
- kivyforge/platforms/linux/appimage.py +169 -0
- kivyforge/platforms/linux/bundle.py +235 -0
- kivyforge/platforms/linux/cli.py +232 -0
- kivyforge/platforms/linux/desktop.py +71 -0
- kivyforge/platforms/linux/doctor.py +438 -0
- kivyforge/platforms/linux/elftools.py +95 -0
- kivyforge/platforms/linux/icons.py +129 -0
- kivyforge/platforms/linux/launcher.py +107 -0
- kivyforge/platforms/linux/lock/__init__.py +126 -0
- kivyforge/platforms/linux/lock/profile.py +254 -0
- kivyforge/platforms/linux/lock/runtime.py +75 -0
- kivyforge/platforms/linux/native_stage.py +47 -0
- kivyforge/platforms/linux/runtime_stage.py +107 -0
- kivyforge/platforms/linux/wheels_stage.py +103 -0
- kivyforge/platforms/macos/__init__.py +121 -0
- kivyforge/platforms/macos/bundle.py +255 -0
- kivyforge/platforms/macos/cli.py +269 -0
- kivyforge/platforms/macos/doctor.py +480 -0
- kivyforge/platforms/macos/icns.py +75 -0
- kivyforge/platforms/macos/launcher.py +118 -0
- kivyforge/platforms/macos/lock/__init__.py +112 -0
- kivyforge/platforms/macos/lock/profile.py +119 -0
- kivyforge/platforms/macos/lock/runtime.py +58 -0
- kivyforge/platforms/macos/machotools.py +138 -0
- kivyforge/platforms/macos/native_stage.py +47 -0
- kivyforge/platforms/macos/notarize.py +143 -0
- kivyforge/platforms/macos/plist.py +37 -0
- kivyforge/platforms/macos/runtime_stage.py +110 -0
- kivyforge/platforms/macos/signing.py +78 -0
- kivyforge/platforms/macos/wheels_stage.py +108 -0
- kivyforge/platforms/windows/__init__.py +133 -0
- kivyforge/platforms/windows/assets.py +76 -0
- kivyforge/platforms/windows/bundle.py +298 -0
- kivyforge/platforms/windows/cli.py +314 -0
- kivyforge/platforms/windows/doctor.py +563 -0
- kivyforge/platforms/windows/fsswap.py +87 -0
- kivyforge/platforms/windows/icons.py +64 -0
- kivyforge/platforms/windows/launcher/__init__.py +193 -0
- kivyforge/platforms/windows/launcher/build_launcher.py +507 -0
- kivyforge/platforms/windows/launcher/launcher.c +379 -0
- kivyforge/platforms/windows/lock/__init__.py +112 -0
- kivyforge/platforms/windows/lock/profile.py +101 -0
- kivyforge/platforms/windows/lock/runtime.py +64 -0
- kivyforge/platforms/windows/naming.py +52 -0
- kivyforge/platforms/windows/native_stage.py +66 -0
- kivyforge/platforms/windows/petools.py +98 -0
- kivyforge/platforms/windows/rcedit.py +116 -0
- kivyforge/platforms/windows/runtime_stage.py +221 -0
- kivyforge/platforms/windows/signing.py +168 -0
- kivyforge/platforms/windows/vendor/LICENSE.rcedit +29 -0
- kivyforge/platforms/windows/vendor/NOTICE +17 -0
- kivyforge/platforms/windows/vendor/SHA256SUMS +4 -0
- kivyforge/platforms/windows/vendor/TOOLSET.txt +4 -0
- kivyforge/platforms/windows/vendor/__init__.py +12 -0
- kivyforge/platforms/windows/vendor/fetch_rcedit.py +97 -0
- kivyforge/platforms/windows/vendor/launcher-amd64.exe +0 -0
- kivyforge/platforms/windows/vendor/rcedit-x64.exe +0 -0
- kivyforge/platforms/windows/wheels_stage.py +139 -0
- kivyforge-3.0.0.dev0.dist-info/METADATA +609 -0
- kivyforge-3.0.0.dev0.dist-info/RECORD +225 -0
- kivyforge-3.0.0.dev0.dist-info/WHEEL +5 -0
- kivyforge-3.0.0.dev0.dist-info/entry_points.txt +3 -0
- kivyforge-3.0.0.dev0.dist-info/licenses/LICENSE +21 -0
- kivyforge-3.0.0.dev0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
package org.libsdl.app;
|
|
2
|
+
|
|
3
|
+
import android.content.*;
|
|
4
|
+
import android.text.InputType;
|
|
5
|
+
import android.view.*;
|
|
6
|
+
import android.view.inputmethod.EditorInfo;
|
|
7
|
+
import android.view.inputmethod.InputConnection;
|
|
8
|
+
|
|
9
|
+
/* This is a fake invisible editor view that receives the input and defines the
|
|
10
|
+
* pan&scan region
|
|
11
|
+
*/
|
|
12
|
+
public class SDLDummyEdit extends View implements View.OnKeyListener
|
|
13
|
+
{
|
|
14
|
+
InputConnection ic;
|
|
15
|
+
int input_type;
|
|
16
|
+
|
|
17
|
+
SDLDummyEdit(Context context) {
|
|
18
|
+
super(context);
|
|
19
|
+
setFocusableInTouchMode(true);
|
|
20
|
+
setFocusable(true);
|
|
21
|
+
setOnKeyListener(this);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
void setInputType(int input_type) {
|
|
25
|
+
this.input_type = input_type;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@Override
|
|
29
|
+
public boolean onCheckIsTextEditor() {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@Override
|
|
34
|
+
public boolean onKey(View v, int keyCode, KeyEvent event) {
|
|
35
|
+
return SDLActivity.handleKeyEvent(v, keyCode, event, ic);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
//
|
|
39
|
+
@Override
|
|
40
|
+
public boolean onKeyPreIme (int keyCode, KeyEvent event) {
|
|
41
|
+
// As seen on StackOverflow: http://stackoverflow.com/questions/7634346/keyboard-hide-event
|
|
42
|
+
// FIXME: Discussion at http://bugzilla.libsdl.org/show_bug.cgi?id=1639
|
|
43
|
+
// FIXME: This is not a 100% effective solution to the problem of detecting if the keyboard is showing or not
|
|
44
|
+
// FIXME: A more effective solution would be to assume our Layout to be RelativeLayout or LinearLayout
|
|
45
|
+
// FIXME: And determine the keyboard presence doing this: http://stackoverflow.com/questions/2150078/how-to-check-visibility-of-software-keyboard-in-android
|
|
46
|
+
// FIXME: An even more effective way would be if Android provided this out of the box, but where would the fun be in that :)
|
|
47
|
+
if (event.getAction()==KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) {
|
|
48
|
+
if (SDLActivity.mTextEdit != null && SDLActivity.mTextEdit.getVisibility() == View.VISIBLE) {
|
|
49
|
+
SDLActivity.onNativeKeyboardFocusLost();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return super.onKeyPreIme(keyCode, event);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@Override
|
|
56
|
+
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
|
|
57
|
+
ic = new SDLInputConnection(this, true);
|
|
58
|
+
|
|
59
|
+
outAttrs.inputType = input_type;
|
|
60
|
+
outAttrs.imeOptions = EditorInfo.IME_FLAG_NO_EXTRACT_UI |
|
|
61
|
+
EditorInfo.IME_FLAG_NO_FULLSCREEN /* API 11 */;
|
|
62
|
+
|
|
63
|
+
return ic;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
package org.libsdl.app;
|
|
2
|
+
|
|
3
|
+
import android.content.*;
|
|
4
|
+
import android.os.Build;
|
|
5
|
+
import android.text.Editable;
|
|
6
|
+
import android.view.*;
|
|
7
|
+
import android.view.inputmethod.BaseInputConnection;
|
|
8
|
+
import android.widget.EditText;
|
|
9
|
+
|
|
10
|
+
class SDLInputConnection extends BaseInputConnection
|
|
11
|
+
{
|
|
12
|
+
protected EditText mEditText;
|
|
13
|
+
protected String mCommittedText = "";
|
|
14
|
+
|
|
15
|
+
SDLInputConnection(View targetView, boolean fullEditor) {
|
|
16
|
+
super(targetView, fullEditor);
|
|
17
|
+
mEditText = new EditText(SDL.getContext());
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@Override
|
|
21
|
+
public Editable getEditable() {
|
|
22
|
+
return mEditText.getEditableText();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@Override
|
|
26
|
+
public boolean sendKeyEvent(KeyEvent event) {
|
|
27
|
+
/*
|
|
28
|
+
* This used to handle the keycodes from soft keyboard (and IME-translated input from hardkeyboard)
|
|
29
|
+
* However, as of Ice Cream Sandwich and later, almost all soft keyboard doesn't generate key presses
|
|
30
|
+
* and so we need to generate them ourselves in commitText. To avoid duplicates on the handful of keys
|
|
31
|
+
* that still do, we empty this out.
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
/*
|
|
35
|
+
* Return DOES still generate a key event, however. So rather than using it as the 'click a button' key
|
|
36
|
+
* as we do with physical keyboards, let's just use it to hide the keyboard.
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
if (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
|
|
40
|
+
if (SDLActivity.onNativeSoftReturnKey()) {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return super.sendKeyEvent(event);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@Override
|
|
49
|
+
public boolean commitText(CharSequence text, int newCursorPosition) {
|
|
50
|
+
if (!super.commitText(text, newCursorPosition)) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
updateText();
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@Override
|
|
58
|
+
public boolean setComposingText(CharSequence text, int newCursorPosition) {
|
|
59
|
+
if (!super.setComposingText(text, newCursorPosition)) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
updateText();
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
@Override
|
|
67
|
+
public boolean deleteSurroundingText(int beforeLength, int afterLength) {
|
|
68
|
+
// Workaround to capture backspace key. Ref: http://stackoverflow.com/questions>/14560344/android-backspace-in-webview-baseinputconnection
|
|
69
|
+
// and https://bugzilla.libsdl.org/show_bug.cgi?id=2265
|
|
70
|
+
if (beforeLength > 0 && afterLength == 0) {
|
|
71
|
+
// backspace(s)
|
|
72
|
+
while (beforeLength-- > 0) {
|
|
73
|
+
nativeGenerateScancodeForUnichar('\b');
|
|
74
|
+
}
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (!super.deleteSurroundingText(beforeLength, afterLength)) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
updateText();
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
protected void updateText() {
|
|
86
|
+
final Editable content = getEditable();
|
|
87
|
+
if (content == null) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
String text = content.toString();
|
|
92
|
+
int compareLength = Math.min(text.length(), mCommittedText.length());
|
|
93
|
+
int matchLength, offset;
|
|
94
|
+
|
|
95
|
+
/* Backspace over characters that are no longer in the string */
|
|
96
|
+
for (matchLength = 0; matchLength < compareLength; ) {
|
|
97
|
+
int codePoint = mCommittedText.codePointAt(matchLength);
|
|
98
|
+
if (codePoint != text.codePointAt(matchLength)) {
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
matchLength += Character.charCount(codePoint);
|
|
102
|
+
}
|
|
103
|
+
/* FIXME: This doesn't handle graphemes, like '🌬️' */
|
|
104
|
+
for (offset = matchLength; offset < mCommittedText.length(); ) {
|
|
105
|
+
int codePoint = mCommittedText.codePointAt(offset);
|
|
106
|
+
nativeGenerateScancodeForUnichar('\b');
|
|
107
|
+
offset += Character.charCount(codePoint);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (matchLength < text.length()) {
|
|
111
|
+
String pendingText = text.subSequence(matchLength, text.length()).toString();
|
|
112
|
+
if (!SDLActivity.dispatchingKeyEvent()) {
|
|
113
|
+
for (offset = 0; offset < pendingText.length(); ) {
|
|
114
|
+
int codePoint = pendingText.codePointAt(offset);
|
|
115
|
+
if (codePoint == '\n') {
|
|
116
|
+
if (SDLActivity.onNativeSoftReturnKey()) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/* Higher code points don't generate simulated scancodes */
|
|
121
|
+
if (codePoint > 0 && codePoint < 128) {
|
|
122
|
+
nativeGenerateScancodeForUnichar((char)codePoint);
|
|
123
|
+
}
|
|
124
|
+
offset += Character.charCount(codePoint);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
SDLInputConnection.nativeCommitText(pendingText, 0);
|
|
128
|
+
}
|
|
129
|
+
mCommittedText = text;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
public static native void nativeCommitText(String text, int newCursorPosition);
|
|
133
|
+
|
|
134
|
+
public static native void nativeGenerateScancodeForUnichar(char c);
|
|
135
|
+
}
|
|
136
|
+
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
package org.libsdl.app;
|
|
2
|
+
|
|
3
|
+
import android.hardware.Sensor;
|
|
4
|
+
import android.hardware.SensorEventListener;
|
|
5
|
+
import android.hardware.SensorManager;
|
|
6
|
+
import android.util.Log;
|
|
7
|
+
|
|
8
|
+
// This class coordinates synchronized access to sensor manager registration
|
|
9
|
+
//
|
|
10
|
+
// This prevents a java.util.ConcurrentModificationException exception on
|
|
11
|
+
// Android 16, specifically on the Samsung Tab S9 Ultra.
|
|
12
|
+
|
|
13
|
+
class SDLSensorManager
|
|
14
|
+
{
|
|
15
|
+
static private SDLSensorManager mManager = new SDLSensorManager();
|
|
16
|
+
|
|
17
|
+
static final int RETRY_COUNT = 3;
|
|
18
|
+
|
|
19
|
+
public static void registerListener(SensorManager manager, SensorEventListener listener, Sensor sensor, int samplingPeriodUs) {
|
|
20
|
+
mManager.RegisterListener(manager, listener, sensor, samplingPeriodUs);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public static void unregisterListener(SensorManager manager, SensorEventListener listener, Sensor sensor) {
|
|
24
|
+
mManager.UnregisterListener(manager, listener, sensor);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
private synchronized void RegisterListener(SensorManager manager, SensorEventListener listener, Sensor sensor, int samplingPeriodUs) {
|
|
28
|
+
int retries = 0;
|
|
29
|
+
boolean complete = false;
|
|
30
|
+
while (!complete) {
|
|
31
|
+
try {
|
|
32
|
+
manager.registerListener(listener, sensor, samplingPeriodUs, null);
|
|
33
|
+
complete = true;
|
|
34
|
+
} catch (java.util.ConcurrentModificationException e) {
|
|
35
|
+
++retries;
|
|
36
|
+
if (retries <= RETRY_COUNT) {
|
|
37
|
+
// Sleep a bit and try again
|
|
38
|
+
try {
|
|
39
|
+
Thread.sleep(1);
|
|
40
|
+
} catch (Exception e2) {
|
|
41
|
+
}
|
|
42
|
+
} else {
|
|
43
|
+
Log.v("SDL", "Multiple ConcurrentModificationException caught while registering sensor listener, canceling operation");
|
|
44
|
+
complete = true;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
private synchronized void UnregisterListener(SensorManager manager, SensorEventListener listener, Sensor sensor) {
|
|
51
|
+
int retries = 0;
|
|
52
|
+
boolean complete = false;
|
|
53
|
+
while (!complete) {
|
|
54
|
+
try {
|
|
55
|
+
manager.unregisterListener(listener, sensor);
|
|
56
|
+
complete = true;
|
|
57
|
+
} catch (java.util.ConcurrentModificationException e) {
|
|
58
|
+
++retries;
|
|
59
|
+
if (retries <= RETRY_COUNT) {
|
|
60
|
+
// Sleep a bit and try again
|
|
61
|
+
try {
|
|
62
|
+
Thread.sleep(1);
|
|
63
|
+
} catch (Exception e2) {
|
|
64
|
+
}
|
|
65
|
+
} else {
|
|
66
|
+
Log.v("SDL", "Multiple ConcurrentModificationException caught while unregistering sensor listener, canceling operation");
|
|
67
|
+
complete = true;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|