summaryrefslogtreecommitdiffstats
path: root/src/imgui/examples/example_android_opengl3/android/app
diff options
context:
space:
mode:
authorNao Pross <np@0hm.ch>2024-02-12 14:52:43 +0100
committerNao Pross <np@0hm.ch>2024-02-12 14:52:43 +0100
commiteda5bc26f44ee9a6f83dcf8c91f17296d7fc509d (patch)
treebc2efa38ff4e350f9a111ac87065cd7ae9a911c7 /src/imgui/examples/example_android_opengl3/android/app
downloadfsisotool-eda5bc26f44ee9a6f83dcf8c91f17296d7fc509d.tar.gz
fsisotool-eda5bc26f44ee9a6f83dcf8c91f17296d7fc509d.zip
Move into version control
Diffstat (limited to 'src/imgui/examples/example_android_opengl3/android/app')
-rw-r--r--src/imgui/examples/example_android_opengl3/android/app/build.gradle46
-rw-r--r--src/imgui/examples/example_android_opengl3/android/app/src/main/AndroidManifest.xml24
-rw-r--r--src/imgui/examples/example_android_opengl3/android/app/src/main/java/MainActivity.kt40
3 files changed, 110 insertions, 0 deletions
diff --git a/src/imgui/examples/example_android_opengl3/android/app/build.gradle b/src/imgui/examples/example_android_opengl3/android/app/build.gradle
new file mode 100644
index 0000000..53181ba
--- /dev/null
+++ b/src/imgui/examples/example_android_opengl3/android/app/build.gradle
@@ -0,0 +1,46 @@
+apply plugin: 'com.android.application'
+apply plugin: 'kotlin-android'
+
+android {
+ compileSdkVersion 33
+ buildToolsVersion "33.0.2"
+ ndkVersion "25.2.9519653"
+
+ defaultConfig {
+ applicationId "imgui.example.android"
+ namespace "imgui.example.android"
+ minSdkVersion 24
+ targetSdkVersion 33
+ versionCode 1
+ versionName "1.0"
+ }
+
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt')
+ }
+ }
+
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_11
+ targetCompatibility JavaVersion.VERSION_11
+ }
+
+ kotlinOptions {
+ jvmTarget="11"
+ }
+
+ externalNativeBuild {
+ cmake {
+ path "../../CMakeLists.txt"
+ version '3.22.1'
+ }
+ }
+}
+repositories {
+ mavenCentral()
+}
+dependencies {
+ implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
+}
diff --git a/src/imgui/examples/example_android_opengl3/android/app/src/main/AndroidManifest.xml b/src/imgui/examples/example_android_opengl3/android/app/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..a87b95b
--- /dev/null
+++ b/src/imgui/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="false">
+ <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/src/imgui/examples/example_android_opengl3/android/app/src/main/java/MainActivity.kt b/src/imgui/examples/example_android_opengl3/android/app/src/main/java/MainActivity.kt
new file mode 100644
index 0000000..896a88c
--- /dev/null
+++ b/src/imgui/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
+ }
+}