mirror of
https://github.com/anomalyco/hex.git
synced 2026-11-22 21:23:02 +01:00
* iOS: plainer interface wording (copy pass)
A TestFlight tester on build 121 said the interface reads as machine-written.
This rewrites 84 user-facing strings (80 catalog entries, the two permission
prompts, two keyboard-only errors) in flat, short, Apple-Settings style and
updates every changed zh-Hans value to match.
What changed:
- Notes that explained the mechanism, restated the row title, or reassured
are cut to the one fact people need (e.g. Hide word suggestions now says
"Autocorrect still works"; Learn how I type, Record typing logs, the
Experiments rows, the Languages hint, onboarding notes, intents).
- Removed notes that said nothing: Auto-capitalization, Key pop-ups, and
the iPad-only "The full keyboard works on iPad too" (its runsOnPad helper
went with it). Haptics and the dictation bar now say "Needs Full Access"
only while Full Access is off, instead of "Needs Full Access, which isn't
on yet" / a note that repeated the requirement while it was on.
- One name per thing: "speech model" and "multilingual model" instead of
Parakeet V2/Ultra in errors; "Apple's speech recognition" instead of
Apple Speech / Apple's on-device speech; "No speech heard." for every
empty recording; "Hex Keyboard" for iOS's name, "the Hex keyboard" in
prose; US spelling (off-center, key centers).
- Permission prompts drop the sentence that restated "on this iPhone"
(Info.plist, project.yml, zh-Hans InfoPlist.strings).
- Wording only: no settings keys, layout or behaviour changed. Catalog
edits are confined to the changed entries; stale entries and the
unlocalized UIKit strip strings are left as they were.
Verified: built before (8583160e) and after; screenshots of 21 scenes on
iPhone 17 Pro and iPhone SE (3rd gen) iOS 27.2 sims, EN before/after and
zh-Hans after, at default and AX5 text sizes, no truncation. xcodebuild test
on a fresh iPhone 17 Pro sim: TEST SUCCEEDED (DictationControllerTests
updated where they asserted the old wording; README quotes updated).
* iOS: Onboarding's doc comment quotes the new optimizing status
Matches the wording changed in the copy pass; comment only.
* iOS: keep the privacy facts in the copy pass; translate the keyboard strip
Review on #2345: for Hex, "on this iPhone", "never leaves" and "not sent"
are facts people need at that moment, not reassurance.
Restored:
- Microphone prompt: "...Audio never leaves it and is deleted once it's
transcribed." Speech Recognition prompt keeps "Nothing you say is sent to
a server." (Info.plist, project.yml, zh-Hans InfoPlist.strings)
- Learn how I type and Record typing logs say "on this iPhone" again.
- Clean up what I say is back to "Drops ums, repeats and corrected words".
- "Allow Speech Recognition. It stays on this iPhone." and "...in Settings.
It runs on this iPhone." back to the originals.
- On-device put back in the shortest form: Checking on-device speech
recognition; the Parakeet memory fallback names Apple's on-device speech
recognition; Adaptive touch learns "on this iPhone"; the Shortcut, Control
Center and Live Activity descriptions say "on device" / "on-device" (not
"iPhone": KeyboardBridgeTests forbids Apple platform names in intent
strings).
Keyboard strip: Undo dictation, Paste, Paste dictation, Code from Messages
(and its VoiceOver hint), Undoes the autocorrection, the Full Access hint
(title, Settings path, spoken path, Open Hex, its hint) and the dictation
bar's Full Access path were plain strings, so Chinese users saw English.
They now go through String(localized:); the keyboard extension already
bundles HEXMobile/Localizable.xcstrings, so no wiring was needed. 10 new
catalog entries with zh-Hans, using the app's terms (粘贴听写, 完全访问).
Verified: the built HEXKeyboard.appex zh-Hans Localizable.strings carries the
new keys; zh screenshots show 撤销听写 in the strip and the translated path
in the dictation bar; scripts/code-shape.py has no hard problems;
xcodebuild test on a fresh iPhone 17 Pro sim: TEST SUCCEEDED.
88 lines
3.9 KiB
Swift
88 lines
3.9 KiB
Swift
import AVFAudio
|
||
|
||
/// Settings › Dictation › Microphone: what dictation records from while a car, headset or
|
||
/// headphones are connected. The app's recorder and the keyboard's capture page both follow it.
|
||
nonisolated enum MicrophoneChoice: String, CaseIterable, Sendable {
|
||
/// A wired or USB headset's microphone, the car's in CarPlay, otherwise the iPhone's:
|
||
/// Bluetooth headphones keep playing at full quality, and nothing waits for call audio.
|
||
case automatic
|
||
/// Always the iPhone's own microphone.
|
||
case iPhone
|
||
/// Bluetooth hands-free microphones too: AirPods, headsets and Bluetooth car kits, which
|
||
/// switch to call audio (8–16 kHz, other audio in call quality) while dictating.
|
||
case bluetooth
|
||
|
||
var label: String {
|
||
switch self {
|
||
case .automatic: String(localized: "Automatic")
|
||
case .iPhone: String(localized: "iPhone")
|
||
case .bluetooth: String(localized: "Bluetooth")
|
||
}
|
||
}
|
||
|
||
var detail: String {
|
||
switch self {
|
||
case .automatic: String(localized: "Car mic in CarPlay, otherwise iPhone")
|
||
case .iPhone: String(localized: "Keeps music playing and starts faster")
|
||
case .bluetooth: String(localized: "AirPods and car mics, in call quality")
|
||
}
|
||
}
|
||
|
||
/// Whether a capture may record from a Bluetooth hands-free microphone, which needs
|
||
/// `.allowBluetoothHFP` in the session's category.
|
||
var allowsBluetooth: Bool { self == .bluetooth }
|
||
}
|
||
|
||
/// An input iOS offers (`AVAudioSessionPortDescription`), as a value tests can make.
|
||
nonisolated struct Microphone: Equatable, Sendable {
|
||
let uid: String
|
||
let name: String
|
||
let port: AVAudioSession.Port
|
||
|
||
init(uid: String, name: String, port: AVAudioSession.Port) {
|
||
self.uid = uid
|
||
self.name = name
|
||
self.port = port
|
||
}
|
||
|
||
init(_ description: AVAudioSessionPortDescription) {
|
||
self.init(uid: description.uid, name: description.portName, port: description.portType)
|
||
}
|
||
}
|
||
|
||
/// Which of the inputs iOS offers a dictation and the warm session record from.
|
||
nonisolated enum MicrophoneRoute {
|
||
/// The input a dictation records from; nil when none of the choice's kinds is offered.
|
||
///
|
||
/// Automatic takes a wired or USB headset's microphone (close to the mouth, no call audio)
|
||
/// and, in CarPlay, the car's: the one the car has for its driver, which Siri and calls
|
||
/// use, where the iPhone's would hear the car's speakers and the road. A Bluetooth car kit
|
||
/// can't be told from headphones, so it takes `bluetooth`.
|
||
static func capture(_ choice: MicrophoneChoice, from inputs: [Microphone]) -> Microphone? {
|
||
let order: [AVAudioSession.Port] = switch choice {
|
||
case .iPhone: [.builtInMic]
|
||
case .automatic: [.headsetMic, .usbAudio, .carAudio, .builtInMic]
|
||
case .bluetooth: [.headsetMic, .usbAudio, .carAudio, .bluetoothHFP, .bluetoothLE, .builtInMic]
|
||
}
|
||
for port in order {
|
||
if let input = inputs.first(where: { $0.port == port }) { return input }
|
||
}
|
||
return nil
|
||
}
|
||
|
||
/// The warm session's keepalive, which holds the microphone between dictations: always the
|
||
/// iPhone's, so a warm session never keeps a car or headset in call audio for its minutes.
|
||
/// Each dictation moves to its own input as it starts.
|
||
static func keepalive(from inputs: [Microphone]) -> Microphone? {
|
||
inputs.first { $0.port == .builtInMic }
|
||
}
|
||
|
||
/// The category options for recording: `.mixWithOthers` keeps other apps' video and music
|
||
/// playing, and A2DP keeps headphones in stereo while another microphone records.
|
||
/// Bluetooth hands-free inputs are offered only when allowed.
|
||
static func categoryOptions(allowingBluetooth: Bool) -> AVAudioSession.CategoryOptions {
|
||
allowingBluetooth
|
||
? [.mixWithOthers, .allowBluetoothHFP, .allowBluetoothA2DP, .defaultToSpeaker]
|
||
: [.mixWithOthers, .allowBluetoothA2DP, .defaultToSpeaker]
|
||
}
|
||
}
|