Files
buzz/mobile/lib/shared/recording_haptics.dart
klopez4212 5bd9d2c5d2 Transcribe Bestie hold recordings into text on device (#9645)
Hold Bestie to record with the waveform and slide-up cancel interaction
from #8665, then release to send an on-device transcript as a normal
text message. Stay on Home with a loader inside Bestie until delivery
succeeds, then open chat. Failures expose Retry/Discard; saved
recordings and signed messages remain recoverable without duplicate
sends. Saved audio is excluded from OS backup. Existing composer voice
notes are unchanged.

Separate exploration from #8665. Transcription requires iOS 26 and a
supported language. Android reports unavailable before capture because
its generic recognizer cannot guarantee saved-file input.

Validation: at `b5dc83bbf5`, 5,046 Flutter tests (71 skipped), 27 crypto
tests, analysis and required push checks pass. Prior native changes at
`30a397f83c`: Android build and 33 tests pass; iOS simulator compilation
and backup-exclusion test pass, with one unchanged document-picker
timeout passing on isolated rerun. Earlier iPhone preview was tested
with saved profile preserved; these latest fixes have not been installed
on the physical phone.

---------

Signed-off-by: kenny lopez <klopez4212@gmail.com>
Signed-off-by: Tom Brow <tomb@block.xyz>
Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz>
Co-authored-by: Tom Brow <tomb@block.xyz>
Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@buzz.block.builderlab.xyz>
Co-authored-by: corey <2dafccf60ea6d431a568f6d67fc600160d92a51e415e09dc8b213b8e360663d5@buzz.block.builderlab.xyz>
2026-11-19 10:32:12 +00:00

38 lines
1.1 KiB
Dart

import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
const _channel = MethodChannel('buzz/haptics');
Future<bool> _native(String method) async {
if (kIsWeb || defaultTargetPlatform != TargetPlatform.iOS) return false;
try {
await _channel.invokeMethod<void>(method);
return true;
} on PlatformException {
return false;
} on MissingPluginException {
return false;
}
}
/// Warms the iPhone feedback engine before the hold or cancel threshold.
Future<void> prepareRecordingHaptic({bool cancel = false}) async {
await _native(cancel ? 'voicePrepareCancel' : 'voicePrepareStart');
}
/// Delivers recording feedback without allowing platform errors to stop capture.
Future<void> recordingHaptic({bool cancel = false}) async {
if (await _native(cancel ? 'voiceCancel' : 'voiceStart')) return;
try {
if (cancel) {
await HapticFeedback.selectionClick();
} else {
await HapticFeedback.mediumImpact();
}
} on PlatformException {
// Recording must work even if feedback is unavailable.
} on MissingPluginException {
// Some embedders have no haptic engine.
}
}