hex/android/app/src/main/AndroidManifest.xml
Ryan Vogel 30cad0da2e
Android keyboard: key haptics play on the vibrator, so they work on Samsung (#2699)
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:26:33 -05:00

33 lines
2 KiB
XML

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE" />
<!-- Hex registers no non-exported dynamic receivers through ContextCompat. -->
<permission android:name="${applicationId}.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION" tools:node="remove" />
<uses-permission android:name="${applicationId}.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION" tools:node="remove" />
<uses-feature android:name="android.hardware.microphone" android:required="false" />
<!-- The keyboard reads Android's personal dictionary (UserDictionary.Words), which only the enabled
input method may read; declared so package visibility never hides the provider. -->
<queries>
<provider android:authorities="user_dictionary" />
</queries>
<application android:label="@string/app_name" android:icon="@mipmap/ic_launcher"
android:theme="@style/HexApp" android:allowBackup="false" android:usesCleartextTraffic="false" android:supportsRtl="true">
<activity android:name=".MainActivity" android:exported="true"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name=".keyboard.HexKeyboard" android:label="@string/app_name"
android:theme="@style/HexIme" android:exported="true"
android:permission="android.permission.BIND_INPUT_METHOD">
<intent-filter>
<action android:name="android.view.InputMethod" />
</intent-filter>
<meta-data android:name="android.view.im" android:resource="@xml/input_method" />
</service>
</application>
</manifest>