Skip to content

Commit

Permalink
CarPlay implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
LuisFALopes committed Mar 9, 2023
1 parent 618e6f6 commit 8edb214
Show file tree
Hide file tree
Showing 10 changed files with 937 additions and 5 deletions.
2 changes: 2 additions & 0 deletions Configuration/Entitlements/App-ios.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.developer.carplay-driving-task</key>
<true/>
<key>aps-environment</key>
<string>development</string>
<key>com.apple.developer.associated-domains</key>
Expand Down
44 changes: 44 additions & 0 deletions HomeAssistant.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,11 @@
D0FF79D220D87D200034574D /* ClientEventTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0FF79D120D87D200034574D /* ClientEventTableViewController.swift */; };
D0FF79D520D87DB10034574D /* ClientEvents.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D0FF79D420D87DB10034574D /* ClientEvents.storyboard */; };
FC8E9421FDB864726918B612 /* Pods-watchOS-WatchExtension-Watch-metadata.plist in Resources */ = {isa = PBXBuildFile; fileRef = 9249824D575933DFA1530BB2 /* Pods-watchOS-WatchExtension-Watch-metadata.plist */; };
FD3BC66329B9FF8F00B19FBE /* CarPlaySceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD3BC66229B9FF8F00B19FBE /* CarPlaySceneDelegate.swift */; };
FD3BC66729BA003B00B19FBE /* HAEntityExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD3BC66629BA003B00B19FBE /* HAEntityExtension.swift */; };
FD3BC66929BA008900B19FBE /* ServerManagerExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD3BC66829BA008900B19FBE /* ServerManagerExtension.swift */; };
FD3BC66C29BA00D600B19FBE /* EntitiesGridTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD3BC66B29BA00D600B19FBE /* EntitiesGridTemplate.swift */; };
FD3BC66E29BA010A00B19FBE /* DomainsListTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD3BC66D29BA010A00B19FBE /* DomainsListTemplate.swift */; };
FD5FEB304713F1E6BFE498DC /* Pods_iOS_Extensions_NotificationService.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CE950A9D74B3E7FF5665CB38 /* Pods_iOS_Extensions_NotificationService.framework */; };
/* End PBXBuildFile section */

Expand Down Expand Up @@ -2019,6 +2024,11 @@
F3A0FB3BD04C582E655168D0 /* Pods-Tests-App.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Tests-App.release.xcconfig"; path = "Pods/Target Support Files/Pods-Tests-App/Pods-Tests-App.release.xcconfig"; sourceTree = "<group>"; };
F3E55AA06795782F04D0B261 /* Pods-iOS-Extensions-Intents.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-iOS-Extensions-Intents.release.xcconfig"; path = "Pods/Target Support Files/Pods-iOS-Extensions-Intents/Pods-iOS-Extensions-Intents.release.xcconfig"; sourceTree = "<group>"; };
F534C18A6FD4884F258341C9 /* Pods-iOS-Shared-iOS.beta.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-iOS-Shared-iOS.beta.xcconfig"; path = "Pods/Target Support Files/Pods-iOS-Shared-iOS/Pods-iOS-Shared-iOS.beta.xcconfig"; sourceTree = "<group>"; };
FD3BC66229B9FF8F00B19FBE /* CarPlaySceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CarPlaySceneDelegate.swift; sourceTree = "<group>"; };
FD3BC66629BA003B00B19FBE /* HAEntityExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HAEntityExtension.swift; sourceTree = "<group>"; };
FD3BC66829BA008900B19FBE /* ServerManagerExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServerManagerExtension.swift; sourceTree = "<group>"; };
FD3BC66B29BA00D600B19FBE /* EntitiesGridTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EntitiesGridTemplate.swift; sourceTree = "<group>"; };
FD3BC66D29BA010A00B19FBE /* DomainsListTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DomainsListTemplate.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -2217,6 +2227,7 @@
1115018C2528411200DCFA94 /* Sources */ = {
isa = PBXGroup;
children = (
FD3BC66429BA000A00B19FBE /* Vehicle */,
B657A8E81CA646EB00121384 /* App */,
111501A72528412C00DCFA94 /* Extensions */,
11DE9D8425B6103C0081C0ED /* Launcher */,
Expand Down Expand Up @@ -2816,6 +2827,7 @@
11EFCDDB24F6065F00314D85 /* AboutSceneDelegate.swift */,
11EFCDDF24F60E5900314D85 /* BasicSceneDelegate.swift */,
118261F424F8C7C1000795C6 /* SceneManager.swift */,
FD3BC66229B9FF8F00B19FBE /* CarPlaySceneDelegate.swift */,
);
path = Scenes;
sourceTree = "<group>";
Expand Down Expand Up @@ -3782,6 +3794,33 @@
path = Common;
sourceTree = "<group>";
};
FD3BC66429BA000A00B19FBE /* Vehicle */ = {
isa = PBXGroup;
children = (
FD3BC66A29BA00B100B19FBE /* Templates */,
FD3BC66529BA001A00B19FBE /* Extensions */,
);
path = Vehicle;
sourceTree = "<group>";
};
FD3BC66529BA001A00B19FBE /* Extensions */ = {
isa = PBXGroup;
children = (
FD3BC66629BA003B00B19FBE /* HAEntityExtension.swift */,
FD3BC66829BA008900B19FBE /* ServerManagerExtension.swift */,
);
path = Extensions;
sourceTree = "<group>";
};
FD3BC66A29BA00B100B19FBE /* Templates */ = {
isa = PBXGroup;
children = (
FD3BC66B29BA00D600B19FBE /* EntitiesGridTemplate.swift */,
FD3BC66D29BA010A00B19FBE /* DomainsListTemplate.swift */,
);
path = Templates;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXHeadersBuildPhase section */
Expand Down Expand Up @@ -5403,13 +5442,16 @@
1187DE4224D77CCC00F0A6A6 /* NFCTagViewController.swift in Sources */,
D0EEF324214DF2B700D1D360 /* Utils.swift in Sources */,
1101D7F92621479200AAE617 /* SettingsButtonRow.swift in Sources */,
FD3BC66C29BA00D600B19FBE /* EntitiesGridTemplate.swift in Sources */,
B641BC251E20A17B002CCBC1 /* OpenInChromeController.swift in Sources */,
B661FB6A226BBDA900E541DD /* SettingsViewController.swift in Sources */,
119D765F2492F8FA00183C5F /* UIApplication+BackgroundTask.swift in Sources */,
11195F6F267EFC8E003DF674 /* NotificationManagerLocalPushInterfaceDirect.swift in Sources */,
FD3BC66329B9FF8F00B19FBE /* CarPlaySceneDelegate.swift in Sources */,
11C4629424B189B100031902 /* NotificationRateLimitsAPI.swift in Sources */,
1161C01B24D7634300A0E3C4 /* NFCListViewController.swift in Sources */,
11A71C6B24A463FC00D9565F /* ZoneManagerState.swift in Sources */,
FD3BC66E29BA010A00B19FBE /* DomainsListTemplate.swift in Sources */,
1185DFAF271FF53800ED7D9A /* OnboardingAuthStepRegister.swift in Sources */,
11F20BC5274B06C100DFB163 /* ServerSelectRow.swift in Sources */,
1130F532253A1E7400F371BE /* ComplicationListViewController.swift in Sources */,
Expand All @@ -5436,6 +5478,7 @@
11A71C7124A4648000D9565F /* ZoneManagerEquatableRegion.swift in Sources */,
11E99A5027156854003C8A65 /* OnboardingTerminalViewController.swift in Sources */,
1101568424D770B2009424C9 /* NFCWriter.swift in Sources */,
FD3BC66929BA008900B19FBE /* ServerManagerExtension.swift in Sources */,
11E7C4B02702E03000667342 /* WidgetOpenPageIntent+Observation.swift in Sources */,
1187DE4624D7E1BD00F0A6A6 /* SimulatorNFCManager.swift in Sources */,
1185DF96271FBB9800ED7D9A /* OnboardingAuthLogin.swift in Sources */,
Expand Down Expand Up @@ -5491,6 +5534,7 @@
1101568324D770B2009424C9 /* iOSTagManager.swift in Sources */,
11B1FFC524CCD72F00F9BCB2 /* VoiceShortcutRow.swift in Sources */,
1168BF33271809C600DD4D15 /* OnboardingAuthError.swift in Sources */,
FD3BC66729BA003B00B19FBE /* HAEntityExtension.swift in Sources */,
B661FB6F226BCCAD00E541DD /* ConnectionSettingsViewController.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
14 changes: 10 additions & 4 deletions Sources/App/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,16 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
configurationForConnecting connectingSceneSession: UISceneSession,
options: UIScene.ConnectionOptions
) -> UISceneConfiguration {
let activity = options.userActivities
.compactMap { SceneActivity(activityIdentifier: $0.activityType) }
.first ?? .webView
return activity.configuration
if #available(iOS 16.0, *), connectingSceneSession.role == UISceneSession.Role.carTemplateApplication {
let scene = UISceneConfiguration(name: "CarPlay", sessionRole: connectingSceneSession.role)
scene.delegateClass = CarPlayDelegate.self
return scene

Check warning on line 207 in Sources/App/AppDelegate.swift

View check run for this annotation

Codecov / codecov/patch

Sources/App/AppDelegate.swift#L205-L207

Added lines #L205 - L207 were not covered by tests
} else {
let activity = options.userActivities
.compactMap { SceneActivity(activityIdentifier: $0.activityType) }
.first ?? .webView
return activity.configuration
}
}

func application(_ application: UIApplication, shouldRestoreSecureApplicationState coder: NSCoder) -> Bool {
Expand Down
42 changes: 41 additions & 1 deletion Sources/App/Resources/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -759,4 +759,44 @@ Home Assistant is free and open source home automation software with a focus on
"widgets.open_page.description" = "Open a frontend page in Home Assistant.";
"widgets.open_page.not_configured" = "No Pages Available";
"widgets.open_page.title" = "Open Page";
"yes_label" = "Yes";
"yes_label" = "Yes";
"carplay.labels.buttons" = "Buttons";
"carplay.labels.covers" = "Covers";
"carplay.labels.input_booleans" = "Input Booleans";
"carplay.labels.input_buttons" = "Input Buttons";
"carplay.labels.lights" = "Lights";
"carplay.labels.locks" = "Locks";
"carplay.labels.scenes" = "Scenes";
"carplay.labels.scripts" = "Scripts";
"carplay.labels.switches" = "Switches";
"carplay.labels.servers" = "Servers";
"carplay.labels.empty_domain_list" = "No domains available";
"carplay.labels.no_servers_available" = "No servers available. Add a server at home assistant Companion App.";
"carplay.labels.already_added_server" = "Already added";
"state.auto" = "Auto";
"state.cleaning" = "Cleaning";
"state.closed" = "Closed";
"state.closing" = "Closing";
"state.cool" = "Cool";
"state.docked" = "Docked";
"state.dry" = "Dry";
"state.error" = "Error";
"state.fan_only" = "Fan Only";
"state.heat_cool" = "Heat Cool";
"state.heat" = "Heat";
"state.idle" = "Idle";
"state.jammed" = "Jammed";
"state.locked" = "Locked";
"state.locking"= "Locking";
"state.off" = "Off";
"state.on" = "On";
"state.open" = "Open";
"state.opening" = "Opening";
"state.paused" = "Paused";
"state.returning" = "Returning";
"state.unavailable" = "Unavailable";
"state.unknown" = "Unknown";
"state.unlocked" = "Unlocked";
"state.unlocking" = "Unlocking";
"state.recording" = "Recording";
"state.streaming" = "Streaming";
Loading

0 comments on commit 8edb214

Please sign in to comment.