feat(keyboard): unify assistant voice and AI workflows
Merge dictation and AI controls into one assistant surface, preserve safe insertion and clipboard actions, and align settings and tests with the new flow.
This commit is contained in:
@@ -22,6 +22,14 @@ enum AppPermissions {
|
||||
case restricted
|
||||
}
|
||||
|
||||
enum PasteAccessResult: Equatable {
|
||||
case verified
|
||||
case noTextAvailable
|
||||
case unavailable
|
||||
}
|
||||
|
||||
private static let pasteAccessVerifiedKey = "clipboard.pasteAccessVerified.v1"
|
||||
|
||||
static var micStatus: MicStatus {
|
||||
switch AVAudioApplication.shared.recordPermission {
|
||||
case .granted: return .granted
|
||||
@@ -46,6 +54,12 @@ enum AppPermissions {
|
||||
micStatus == .granted && speechStatus == .granted
|
||||
}
|
||||
|
||||
/// iOS does not expose the current "Paste from Other Apps" setting.
|
||||
/// This records the last explicit, successful user-initiated read instead.
|
||||
static var hasVerifiedPasteAccess: Bool {
|
||||
UserDefaults.standard.bool(forKey: pasteAccessVerifiedKey)
|
||||
}
|
||||
|
||||
/// Show guided permission pages when any Flow permission is not granted.
|
||||
static var needsPermissionGuidance: Bool {
|
||||
micStatus != .granted || speechStatus != .granted
|
||||
@@ -82,10 +96,15 @@ enum AppPermissions {
|
||||
/// and create the app's "Paste from Other Apps" settings entry.
|
||||
@MainActor
|
||||
@discardableResult
|
||||
static func requestPasteAccess() -> Bool {
|
||||
static func requestPasteAccess() -> PasteAccessResult {
|
||||
let pasteboard = UIPasteboard.general
|
||||
guard pasteboard.hasStrings else { return false }
|
||||
return pasteboard.string != nil
|
||||
guard pasteboard.hasStrings else { return .noTextAvailable }
|
||||
guard pasteboard.string != nil else {
|
||||
UserDefaults.standard.set(false, forKey: pasteAccessVerifiedKey)
|
||||
return .unavailable
|
||||
}
|
||||
UserDefaults.standard.set(true, forKey: pasteAccessVerifiedKey)
|
||||
return .verified
|
||||
}
|
||||
|
||||
/// Home-screen guidance when Flow permissions are missing after onboarding.
|
||||
|
||||
Reference in New Issue
Block a user