Skip to content

Commit

Permalink
Add Is Call Active action
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Oct 30, 2023
1 parent 8e46b68 commit 1573224
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 3 deletions.
4 changes: 4 additions & 0 deletions Actions.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@
E3DB885728E727E200FEE8D6 /* ChooseFromListExtended.swift in Sources */ = {isa = PBXBuildFile; fileRef = E3DB885528E727E200FEE8D6 /* ChooseFromListExtended.swift */; };
E3DB886C28E7549800FEE8D6 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = E3DB886B28E7549800FEE8D6 /* Constants.swift */; };
E3EA7D7B28EAC2210043F782 /* BlurImages.swift in Sources */ = {isa = PBXBuildFile; fileRef = E3EA7D7A28EAC2210043F782 /* BlurImages.swift */; };
E3EF8AE82AEFC431007B0F32 /* IsCallActive.swift in Sources */ = {isa = PBXBuildFile; fileRef = E3EF8AE72AEFC431007B0F32 /* IsCallActive.swift */; };
E3F64D7628D9F9930009B500 /* CreateColorImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = E3F64D7528D9F9930009B500 /* CreateColorImage.swift */; };
E3F64D7928D9FCA20009B500 /* GetSymbolImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = E3F64D7728D9FCA20009B500 /* GetSymbolImage.swift */; };
E3FC71DD271EBE5C00C9D255 /* Utilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = E3FC71DC271EBE5B00C9D255 /* Utilities.swift */; };
Expand Down Expand Up @@ -329,6 +330,7 @@
E3EC2DE528D25DF900A88E25 /* AddToList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddToList.swift; sourceTree = "<group>"; };
E3EC2DE728D2DB1000A88E25 /* GenerateRandomText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GenerateRandomText.swift; sourceTree = "<group>"; };
E3EC2DE928D2E5B900A88E25 /* RemoveFromList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RemoveFromList.swift; sourceTree = "<group>"; };
E3EF8AE72AEFC431007B0F32 /* IsCallActive.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IsCallActive.swift; sourceTree = "<group>"; };
E3F64D6B28D9EDFE0009B500 /* FormatDuration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormatDuration.swift; sourceTree = "<group>"; };
E3F64D7128D9F3810009B500 /* EditURL.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditURL.swift; sourceTree = "<group>"; };
E3F64D7528D9F9930009B500 /* CreateColorImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreateColorImage.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -389,6 +391,7 @@
E3DB884F28E6EE7B00FEE8D6 /* HideShortcutsApp.swift */,
E34839A02A885DD90040DF6E /* InvertImages.swift */,
E375A5CE2ADEE387004BCBFA /* IsAccessibilityFeatureOn.swift */,
E3EF8AE72AEFC431007B0F32 /* IsCallActive.swift */,
E3C33CA928D3A81700386C59 /* IsDarkMode.swift */,
E350B2512AC3005800BFC34D /* IsDeviceLocked.swift */,
E3CB448A28D71A180031D55F /* IsScreenLocked.swift */,
Expand Down Expand Up @@ -731,6 +734,7 @@
E317491A2916A20C00F6319E /* IsConnectedToVPN.swift in Sources */,
E31749402916A20C00F6319E /* CreateURL.swift in Sources */,
E31749542916A20C00F6319E /* GetUniformTypeIdentifier.swift in Sources */,
E3EF8AE82AEFC431007B0F32 /* IsCallActive.swift in Sources */,
E317491C2916A20C00F6319E /* GetHighResolutionTimestamp.swift in Sources */,
E31748A92916A0B200F6319E /* Main.swift in Sources */,
E31749512916A20C00F6319E /* TransformLists.swift in Sources */,
Expand Down
5 changes: 2 additions & 3 deletions Shared/Actions/CreateMenuItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,13 @@ Add an "Add to Variable" action below this one to populate a list and then use t
title: "SF Symbol",
description: "Find symbol names here: https://developer.apple.com/sf-symbols/",
inputOptions: .init(
keyboardType: .asciiCapable,
capitalizationType: .none,
autocorrect: false,
smartQuotes: false,
smartDashes: false
)
)
var sfSymbolName: String
var sfSymbolName: String?

@Parameter(
title: "Emoji",
Expand Down Expand Up @@ -142,7 +141,7 @@ Add an "Add to Variable" action below this one to populate a list and then use t
switch iconType {
case .sfSymbol:
await IconContainerView(
sfSymbol: sfSymbolName,
sfSymbol: sfSymbolName ?? "",
foregroundColor: foreground.color(),
backgroundColor: background.color(isBackground: true),
backgroundShape: backgroundShape
Expand Down
18 changes: 18 additions & 0 deletions Shared/Actions/IsCallActive.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import AppIntents

struct IsCallActive: AppIntent {
static let title: LocalizedStringResource = "Is Call Active"

static let description = IntentDescription(
"""
Returns whether the device is on a call (phone, FaceTime, VoIP, etc).
On macOS, it always returns “false”.
""",
categoryName: "Device"
)

func perform() async throws -> some IntentResult & ReturnsValue<Bool> {
.result(value: Device.hasActiveCall)
}
}
14 changes: 14 additions & 0 deletions Shared/Utilities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ typealias WindowIfMacOS = Window
#else
import VisionKit
import CoreMotion
import CallKit

typealias XColor = UIColor
typealias XFont = UIFont
Expand Down Expand Up @@ -633,6 +634,19 @@ enum Device {
CMMotionManager().isAccelerometerAvailable
#endif
}

/**
Check if the device currently has an active call.
On macOS, it's always `false`.
*/
static var hasActiveCall: Bool {
#if os(macOS)
false
#else
CXCallObserver().calls.contains { !$0.hasEnded }
#endif
}
}


Expand Down
1 change: 1 addition & 0 deletions app-store-description.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ The app is free without ads because I love making apps. Consider leaving a nice
- Is Accessibility Feature On
- Is Audio Playing (iOS-only)
- Is Bluetooth On
- Is Call Active (iOS-only)
- Is Cellular Data On
- Is Cellular Low Data Mode On
- Is Connected to VPN (iOS-only)
Expand Down
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ And for high-quality transcription, see my [Aiko](https://sindresorhus.com/aiko)
- Is Accessibility Feature On
- Is Audio Playing <sup>(iOS-only)</sup>
- Is Bluetooth On
- Is Call Active <sup>(iOS-only)</sup>
- Is Cellular Data On
- Is Cellular Low Data Mode On
- Is Connected to VPN <sup>(iOS-only)</sup>
Expand Down

0 comments on commit 1573224

Please sign in to comment.