18 Commits

Author SHA1 Message Date
Turtle Dove
2f36763169 Android: Move JNI keyboard/clipboard into backend, add sensors + display metrics (#3446)
Backend improvements (imgui_impl_android.h/.cpp):
- Moved JNI soft-keyboard and Unicode char polling from the example into the backend.
  The backend automatically shows/hides the soft keyboard based on io.WantTextInput
  during NewFrame().
- Moved JNI Unicode character polling from the example into the backend.
  Characters are polled and fed to io.AddInputCharacter() automatically.
- Added clipboard support via JNI to Android ClipboardManager.
  io.SetClipboardTextFn / io.GetClipboardTextFn are now set by the backend.
- Added ImGui_ImplAndroid_ShowSoftKeyboard() / HideSoftKeyboard() public API.
- Init() now accepts optional asset_manager and native_activity params.
  When native_activity is provided, JNI features are enabled automatically.
  When nullptr, the backend degrades gracefully (no keyboard/clipboard).
- Added sensor support via NDK ASensor API (no JNI needed):
  Accelerometer, Gyroscope, Magnetometer, Light, Proximity, Pressure,
  Humidity, Ambient Temperature.
  API: EnableSensor(), DisableSensor(), GetSensorData(), IsSensorAvailable().
  Sensor events are drained non-blocking in NewFrame().
- Added display metrics via JNI:
  DPI, density, xdpi/ydpi, refresh rate, orientation, resolution.
  API: GetDisplayMetrics().
  Used to auto-scale ImGui style to the device's actual density.

Example cleanup (main.cpp):
- Removed ~120 lines of JNI boilerplate (ShowSoftKeyboardInput, PollUnicodeChars,
  GetAssetData). The example is now a clean Init -> Loop -> Render -> Shutdown.
- Single ImGui_ImplAndroid_Init() call passes the activity object; the backend
  handles the rest.
- Added sensor window: live accelerometer, gyroscope, magnetometer, light, proximity
  readouts with visual progress bars.
- Added display window: resolution, DPI, density, refresh rate, orientation.
- Uses actual device density for style scaling instead of hardcoded 2.0f.

CMakeLists.txt: added 'sensor' to target_link_libraries for ASensor API.

Kotlin activity (MainActivity.kt):
- Kept the three JNI-bridge methods (showSoftInput/hideSoftInput/pollUnicodeChar)
  since Android's native API does not provide these. Cleaned up and documented
  that they are called by the backend, not by app code.
2026-07-13 12:20:21 -05:00
ocornut
9c33672e5c Examples: reword a comment to not mention AddFontDefault() explicitly. 2026-02-12 18:37:31 +01:00
ocornut
8c0b410371 Docs: tweaks. 2026-01-20 18:25:18 +01:00
ocornut
b7b8f52437 Examples: Android: update for consistency (untested). 2025-12-23 18:16:33 +01:00
ocornut
fe03035112 Docs: advertise ProggyVector font as an alternative. 2025-08-20 20:02:49 +02:00
ocornut
d72e66cdee Examples: remove comments/references about baking and GetGlyphRangesJapanese(). 2025-06-11 16:11:03 +02:00
ocornut
f77d22837c Examples: Android+OpenGL: Using ALooper_pollOnce() instead of ALooper_pollAll(). (#8013) 2024-11-04 14:24:54 +01:00
Hubert Maier
07dbcf1f70 Fixed typos. (#7593) 2024-05-16 16:13:01 +02:00
ocornut
357f752bed Docs: add more links to the top of every examples and backends files. 2023-09-11 14:01:40 +02:00
Michael Martz
506f7e0074 Using nullptr in locations where warning disable is not convenient. (#6313, #4537) 2023-04-11 11:33:50 +02:00
ocornut
bb224c8aa1 Examples: Updated all examples application to enable ImGuiConfigFlags_NavEnableKeyboard and ImGuiConfigFlags_NavEnableGamepad by default. 2023-03-10 18:35:52 +01:00
ocornut
96ab68eee0 Examples: refactor all examples with a MainLoopStep() function, to facilitate use with Emscripten. (#2492, #3699)
Aligned all examples.
2023-02-02 17:30:48 +01:00
Rewtio
c2694ef75e Examples: Android: Using LoadIniSettingsFromMemory() / SaveIniSettingsToMemory() to save in appropriate location for Android. (#5836) 2022-10-31 11:47:05 +01:00
ocornut
5c8041b4d7 Update gif in README + font names in examples 2022-09-19 17:45:05 +02:00
tocic
2b1d8e3eaf Fix more typos in sources and docs (#5681) 2022-09-14 20:36:45 +02:00
ocornut
92d0924b82 Fixed build with IMGUI_DISABLE_OBSOLETE_KEYIO + made all examples comments refer to StyleColorsLight(). 2022-07-06 20:58:20 +02:00
ocornut
8dd692c29c Android: Amend backend and examples with minor consistency tweaks. (#3446) 2021-03-04 11:07:03 +01:00
duddel
fb85c0341b
Add Android backend and example (#3446) 2021-03-04 10:35:44 +01:00