From 60cbbdec07ab7a5636eac5b3c024ae44e937f4d4 Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 13 Dec 2021 00:07:19 +0800 Subject: +init --- .../example_android_opengl3/android/.gitignore | 12 +++++++ .../android/app/build.gradle | 34 ++++++++++++++++++ .../android/app/src/main/AndroidManifest.xml | 24 +++++++++++++ .../android/app/src/main/java/MainActivity.kt | 40 ++++++++++++++++++++++ .../example_android_opengl3/android/build.gradle | 24 +++++++++++++ .../android/settings.gradle | 1 + 6 files changed, 135 insertions(+) create mode 100644 Client/ThirdParty/imgui/examples/example_android_opengl3/android/.gitignore create mode 100644 Client/ThirdParty/imgui/examples/example_android_opengl3/android/app/build.gradle create mode 100644 Client/ThirdParty/imgui/examples/example_android_opengl3/android/app/src/main/AndroidManifest.xml create mode 100644 Client/ThirdParty/imgui/examples/example_android_opengl3/android/app/src/main/java/MainActivity.kt create mode 100644 Client/ThirdParty/imgui/examples/example_android_opengl3/android/build.gradle create mode 100644 Client/ThirdParty/imgui/examples/example_android_opengl3/android/settings.gradle (limited to 'Client/ThirdParty/imgui/examples/example_android_opengl3/android') diff --git a/Client/ThirdParty/imgui/examples/example_android_opengl3/android/.gitignore b/Client/ThirdParty/imgui/examples/example_android_opengl3/android/.gitignore new file mode 100644 index 0000000..3c7a619 --- /dev/null +++ b/Client/ThirdParty/imgui/examples/example_android_opengl3/android/.gitignore @@ -0,0 +1,12 @@ +.cxx +.externalNativeBuild +build/ +*.iml + +.idea +.gradle +local.properties + +# Android Studio puts a Gradle wrapper here, that we don't want: +gradle/ +gradlew* diff --git a/Client/ThirdParty/imgui/examples/example_android_opengl3/android/app/build.gradle b/Client/ThirdParty/imgui/examples/example_android_opengl3/android/app/build.gradle new file mode 100644 index 0000000..aa7f0ea --- /dev/null +++ b/Client/ThirdParty/imgui/examples/example_android_opengl3/android/app/build.gradle @@ -0,0 +1,34 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' + +android { + compileSdkVersion 29 + buildToolsVersion "30.0.3" + ndkVersion "21.4.7075529" + defaultConfig { + applicationId "imgui.example.android" + minSdkVersion 23 + targetSdkVersion 29 + versionCode 1 + versionName "1.0" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt') + } + } + + externalNativeBuild { + cmake { + path "../../CMakeLists.txt" + } + } +} +repositories { + mavenCentral() +} +dependencies { + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" +} diff --git a/Client/ThirdParty/imgui/examples/example_android_opengl3/android/app/src/main/AndroidManifest.xml b/Client/ThirdParty/imgui/examples/example_android_opengl3/android/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..c4009e5 --- /dev/null +++ b/Client/ThirdParty/imgui/examples/example_android_opengl3/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + diff --git a/Client/ThirdParty/imgui/examples/example_android_opengl3/android/app/src/main/java/MainActivity.kt b/Client/ThirdParty/imgui/examples/example_android_opengl3/android/app/src/main/java/MainActivity.kt new file mode 100644 index 0000000..896a88c --- /dev/null +++ b/Client/ThirdParty/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 = 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 + } +} diff --git a/Client/ThirdParty/imgui/examples/example_android_opengl3/android/build.gradle b/Client/ThirdParty/imgui/examples/example_android_opengl3/android/build.gradle new file mode 100644 index 0000000..59f9c78 --- /dev/null +++ b/Client/ThirdParty/imgui/examples/example_android_opengl3/android/build.gradle @@ -0,0 +1,24 @@ +buildscript { + ext.kotlin_version = '1.4.31' + repositories { + google() + mavenCentral() + + } + dependencies { + classpath 'com.android.tools.build:gradle:4.1.0' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + + } +} + +allprojects { + repositories { + google() + mavenCentral() + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/Client/ThirdParty/imgui/examples/example_android_opengl3/android/settings.gradle b/Client/ThirdParty/imgui/examples/example_android_opengl3/android/settings.gradle new file mode 100644 index 0000000..e7b4def --- /dev/null +++ b/Client/ThirdParty/imgui/examples/example_android_opengl3/android/settings.gradle @@ -0,0 +1 @@ +include ':app' -- cgit v1.1-26-g67d0