Skip to content

feat(android): touch input, system long-press delay, and LayerHost popup fallback - #2709

Merged
Hona merged 1 commit into
devfrom
feat/android-s2-touch
Nov 28, 2026
Merged

Hona merged 1 commit into
devfrom
feat/android-s2-touch

Conversation

@Hona

@Hona Hona commented Nov 28, 2026

Copy link
Copy Markdown
Member

Implements Android slice S2 (#2649): native touch forwarding, configurable system long-press delay, LayerHost App::on_popup_menu fallback support, and examples/android-gallery.

Summary

  • Android touch forwarding (RuneView.onTouchEvent -> platform::android):
    • Forwards primary/secondary pointer down/up, ACTION_MOVE (including all batched historical samples in chronological order before the current sample), and ACTION_CANCEL across JNI (nativeTouch).
    • Pure cross-platform Android action-to-phase, coordinate, pointer-id, and timestamp mapping in crates/rune/src/platform/android/touch.rs (including API 33+ MotionEvent.FLAG_CANCELED mapped to TouchPhase::Cancelled).
    • Deduplicates Choreographer frame scheduling across batched touch samples in platform::android::machine and separates timer wakes from background thread wakes in RuneView.kt.
  • Configurable system long-press delay (Runtime::set_touch_long_press / Runtime::touch_long_press):
    • Replaces the hardcoded 0.5 s hold timeout in runtime/input/touch.rs with a host-configurable delay (default 0.5 s; zero, negative, or non-finite values restore the default).
    • RuneView forwards ViewConfiguration.getLongPressTimeout() on init and resume (nativeLongPressTimeout), picking up Android's default 400 ms delay and accessibility Touch & hold delay changes (up to 1500 ms).
  • Shared fling curve: Keeps Rune's existing touch fling momentum curve (SCROLL_DECAY = 2.002, ±8000 pt/s) for S2, matching iOS and web.
  • App::on_popup_menu on LayerHost (platform/embed_frame.rs):
    • Keeps popup_menu_supported() false on Android and iOS.
    • Updates embed_frame::flush_requests to honor App::on_popup_menu when popup_menu_fallback_active is true (matching desktop Linux) instead of unconditionally cancelling open/queued fallback pop-up menus; apps without on_popup_menu still resolve to None immediately.
  • examples/android-gallery: Splits examples/kit-gallery into lib.rs + thin main.rs, adds examples/android-gallery (cdylib + AndroidManifest.xml), and adds -p android-gallery to .github/workflows/android.yml.

Verification

  • Local Windows host tests:
    • cargo test -p rune --lib runtime::input::touch (53 passed, including set_touch_long_press 400 ms / 1500 ms / invalid-value fallback).
    • cargo test -p rune --lib platform::android (12 passed: Android action/flag mapping, coordinate/time conversions, batched touch pipeline, state-machine frame deduplication and cached timeout replay).
    • cargo test -p rune --lib platform::embed_frame (10 passed, including App::on_popup_menu kept alive across frames and delivered on missed_step vs cancelled when unregistered).
    • cargo test -p rune --doc set_touch_long_press (1 passed).
    • cargo test -p android-gallery (1 passed) and cargo check -p kit-gallery --all-targets.
  • CI verifies Android cross-compilation (aarch64-linux-android, x86_64-linux-android including android-gallery), Kotlin compilation (kotlinc + d8 + APK packaging), check, and size.
  • Not run locally on a physical Android device or emulator (no Android SDK/emulator on this Windows host).

Fixes #2649

@Hona
Hona force-pushed the feat/android-s2-touch branch 2 times, most recently from 05f7ca4 to 959a125 Compare November 28, 2026 02:32
@Hona
Hona force-pushed the feat/android-s2-touch branch from 959a125 to bca79ba Compare November 28, 2026 02:33
@Hona
Hona merged commit 8618962 into dev Nov 28, 2026
5 checks passed
@Hona
Hona deleted the feat/android-s2-touch branch November 28, 2026 02:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Android (S2): touch input and the system long-press delay

1 participant