notedeck icon indicating copy to clipboard operation
notedeck copied to clipboard

Android softkeyboard support

Open jb55 opened this issue 1 year ago • 8 comments

For input on android, we need to pop up the keyboard. This isn't directly supported by egui, since egui doesn't handle such things. egui delegates such tasks to winit, but winit does not support it yet.

External tracking issues:

  • https://github.com/emilk/egui/issues/3890
  • https://github.com/rust-windowing/winit/issues/1823
  • https://github.com/emilk/egui/discussions/2975
  • https://github.com/rust-mobile/android-activity/issues/44
  • https://github.com/rust-mobile/android-activity/pull/24
  • https://github.com/rust-mobile/android-activity/issues/18
  • https://github.com/rust-windowing/winit/pull/2993

Progress in this area:

  • https://github.com/rust-mobile/android-activity/issues/44#issuecomment-1627240142 by @lucasmerlin

@xorgy was able to make progress in winit without requiring GameActivity:

  • https://github.com/rust-windowing/winit/pull/3787

Our progress:

  • [x] https://github.com/damus-io/android/issues/74
  • [ ] https://github.com/damus-io/notedeck/issues/171
  • [x] https://github.com/damus-io/notedeck/issues/187
  • [x] https://github.com/damus-io/notedeck/issues/189
  • [x] https://github.com/damus-io/notedeck/issues/190

jb55 avatar Mar 23 '24 09:03 jb55

I looked into this all yesterday. It looks like we might need to switch over to GameActivity to get this working. There is some initial work from @rib in android-activity (https://github.com/rust-mobile/android-activity/pull/24) for soft keyboard + GameActivity, but it looks like we'll will still need winit/egui support. There are some demos by @lucasmerlin at https://github.com/lucasmerlin/rust-android-examples/tree/ime_support_showcase/agdk-eframe which demo this in egui.

The current build tooling we're using assumes its a NativeActivity, I have yet to get GameActivity working. It seems there are many build tools: cargo-apk (what we're using now), cargo-ndk, cargo-xbuild, cargo-mobile2. I'm not sure what to use. The GameActivity demos use cargo-ndk but it requires some gradle step which I have yet to get working.

Somewhat surprised the rust mobile ecosystem still can't present a keyboard for input, oh well, I guess banging my head against this a bit more is easier than building an entirely new android kotlin codebase from scratch.

jb55 avatar Mar 27 '24 10:03 jb55

I can report that I'm still using the method from the showcase in my app and I regularly update my fork of winit and egui with the keyboard changes to the newest versions.

The current versions of my fork are here:

https://github.com/lucasmerlin/egui/tree/hp_improvements_0.26

https://github.com/lucasmerlin/winit/tree/hp-fixes-0.29.x

They also contain changes unrelated to keyboard input, but maybe it will still be helpful.

lucasmerlin avatar Mar 27 '24 11:03 lucasmerlin

I saw those! Thank you! I will try to get these working.

jb55 avatar Mar 27 '24 13:03 jb55

Since this is a large task I will split it into specific deliverables for this sprint

jb55 avatar Apr 08 '24 17:04 jb55

@jb55 with issues transferred over from old android repo to notedeck repo, I am adding an 'android' label to every android specific issue

alltheseas avatar Jul 25 '24 10:07 alltheseas

@ksedgwic

alltheseas avatar Sep 16 '24 15:09 alltheseas

Testing a comment post from Linear

alltheseas avatar Feb 25 '25 22:02 alltheseas

From what I noticed after updating egui 0.29 > 0.31.1 GameActivity is no longer receiving dispatchKeyEvent with text (only numbers) at Java code, it helped to pass events from soft keyboard to native code before. Also GameActivity::onKeyDown is not calling at all after focusing on input field, will wait more progress on winit integration it seems.

ardocrat avatar Mar 14 '25 18:03 ardocrat

This is mostly done… just have one more keyboard issue to fix which I will open another issue for

jb55 avatar Jun 17 '25 20:06 jb55