hex/android/app
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Ryan Vogel eb0f3f5ff2 Android keyboard: key haptics play on the vibrator, so they work on Samsung
Key haptics were silent on a Galaxy S23 (One UI 9, Hex Preview 2348) with
the phone's vibration and Hex's Haptics switch on. Hex only asked Android for
its stock effect (View.performHapticFeedback KEYBOARD_TAP / KEYBOARD_RELEASE,
GESTURE_START / GESTURE_END), and One UI ties that effect to Samsung's own
keyboard settings. Gboard and other keyboards drive the vibrator themselves.

Changed:
- New KeyHaptics.kt: tap() plays EFFECT_TICK (key press, key release,
  emoji pick, dictation end) or EFFECT_CLICK (dictation start) through
  VibratorManager.defaultVibrator when the vibrator reports the effect as
  supported, and a 12 ms (20 ms) one-shot at amplitude 80 otherwise.
- Attributes: VibrationAttributes.USAGE_TOUCH on API 33+; before that,
  AudioAttributes USAGE_ASSISTANCE_SONIFICATION / CONTENT_TYPE_SONIFICATION,
  which Android maps to touch. Android decides when to drop the tick.
- Hex's Haptics switch and the system Keyboard vibration switch
  (keyboard_vibration_enabled, kept) still gate every tick.
- Manifest: android.permission.VIBRATE, nothing else.
- README: the haptics line describes the tick and the settings that apply.

Removed: every performHapticFeedback call (KeyCap press and release,
KeyPlaneView emoji pick, KeyboardView dictation start/end). Only the direct
path plays, so a press is one tick on every phone, never the stock effect
plus ours. The press is now a tick rather than the stock click, and the
release tick is the same tick (EFFECT_TEXTURE_TICK is hidden from apps).
Behaviour change on Android 16: the stock keyboard effect used the hidden
IME usage, which ignores Touch feedback; Hex's tick is touch usage, so
Touch feedback off now silences Hex's keys.

Verified: :app:testDebugUnitTest green, assembleDebug and assemblePreview
green, aapt2 shows VIBRATE as the only new permission. On an Android 16
emulator (API 36), five taps per case, dumpsys vibrator_manager:
- Haptics on: 5 USAGE_TOUCH Prebaked=TICK requests, finished (text field
  and password field); dev build: 5 USAGE_IME CLICK in both fields, so
  password fields behave as before (one tick per press).
- Hex Haptics off: none. keyboard_vibration_enabled=0: none.
- haptic_feedback_enabled=0: 5 requests, ignored_for_settings.
- Do Not Disturb on (zen_mode 2): 5 finished, as the stock effect did.
2026-11-24 09:14:41 -05:00
..
src Android keyboard: key haptics play on the vibrator, so they work on Samsung 2026-11-24 09:14:41 -05:00
build.gradle.kts Android: Send feedback form that posts to Bellhop (#2582) 2026-11-23 15:51:14 -05:00
proguard-rules.pro Hex for Android: on-device dictation keyboard (#2074) 2026-11-20 17:27:17 +00:00