diff options
| author | Aldrik Ramaekers <aldrikboy@gmail.com> | 2025-08-03 19:22:36 +0200 |
|---|---|---|
| committer | Aldrik Ramaekers <aldrikboy@gmail.com> | 2025-08-03 19:22:36 +0200 |
| commit | 853bbb3752a5fa2f58ef456ffb6e3a552e13cb11 (patch) | |
| tree | ce49a533f82a42a65fa6a4771a7b8fbfe33798cf /imgui-1.92.1/examples/example_android_opengl3/android/app/src | |
initial commit
Diffstat (limited to 'imgui-1.92.1/examples/example_android_opengl3/android/app/src')
| -rw-r--r-- | imgui-1.92.1/examples/example_android_opengl3/android/app/src/main/AndroidManifest.xml | 24 | ||||
| -rw-r--r-- | imgui-1.92.1/examples/example_android_opengl3/android/app/src/main/java/MainActivity.kt | 40 |
2 files changed, 64 insertions, 0 deletions
diff --git a/imgui-1.92.1/examples/example_android_opengl3/android/app/src/main/AndroidManifest.xml b/imgui-1.92.1/examples/example_android_opengl3/android/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..5a1e2d9 --- /dev/null +++ b/imgui-1.92.1/examples/example_android_opengl3/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android"> + + <application + android:label="ImGuiExample" + android:allowBackup="false" + android:fullBackupContent="false" + android:hasCode="true"> + + <activity + android:name="imgui.example.android.MainActivity" + android:theme="@android:style/Theme.NoTitleBar.Fullscreen" + android:configChanges="orientation|keyboardHidden|screenSize" + android:exported="true"> + <meta-data android:name="android.app.lib_name" + android:value="ImGuiExample" /> + + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + <category android:name="android.intent.category.LAUNCHER" /> + </intent-filter> + </activity> + </application> +</manifest> diff --git a/imgui-1.92.1/examples/example_android_opengl3/android/app/src/main/java/MainActivity.kt b/imgui-1.92.1/examples/example_android_opengl3/android/app/src/main/java/MainActivity.kt new file mode 100644 index 0000000..896a88c --- /dev/null +++ b/imgui-1.92.1/examples/example_android_opengl3/android/app/src/main/java/MainActivity.kt @@ -0,0 +1,40 @@ +package imgui.example.android + +import android.app.NativeActivity +import android.os.Bundle +import android.content.Context +import android.view.inputmethod.InputMethodManager +import android.view.KeyEvent +import java.util.concurrent.LinkedBlockingQueue + +class MainActivity : NativeActivity() { + public override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + } + + fun showSoftInput() { + val inputMethodManager = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager + inputMethodManager.showSoftInput(this.window.decorView, 0) + } + + fun hideSoftInput() { + val inputMethodManager = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager + inputMethodManager.hideSoftInputFromWindow(this.window.decorView.windowToken, 0) + } + + // Queue for the Unicode characters to be polled from native code (via pollUnicodeChar()) + private var unicodeCharacterQueue: LinkedBlockingQueue<Int> = LinkedBlockingQueue() + + // We assume dispatchKeyEvent() of the NativeActivity is actually called for every + // KeyEvent and not consumed by any View before it reaches here + override fun dispatchKeyEvent(event: KeyEvent): Boolean { + if (event.action == KeyEvent.ACTION_DOWN) { + unicodeCharacterQueue.offer(event.getUnicodeChar(event.metaState)) + } + return super.dispatchKeyEvent(event) + } + + fun pollUnicodeChar(): Int { + return unicodeCharacterQueue.poll() ?: 0 + } +} |
