Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
198 changes: 112 additions & 86 deletions Loop.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions Loop.xcodeproj/xcshareddata/xcschemes/WatchApp.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@
BuildableIdentifier = "primary"
BlueprintIdentifier = "43A943711B926B7B0051FA24"
BuildableName = "WatchApp.app"
BlueprintName = "WatchApp"
ReferencedContainer = "container:Loop.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
Expand All @@ -102,7 +101,6 @@
BuildableIdentifier = "primary"
BlueprintIdentifier = "43A943711B926B7B0051FA24"
BuildableName = "WatchApp.app"
BlueprintName = "WatchApp"
ReferencedContainer = "container:Loop.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
Expand Down
62 changes: 7 additions & 55 deletions Loop/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
import UIKit
import LoopKit

final class AppDelegate: UIResponder, UIApplicationDelegate, WindowProvider {
var window: UIWindow?
final class AppDelegate: UIResponder, UIApplicationDelegate {

let loopAppManager = LoopAppManager()

private(set) var launchOptions: [UIApplication.LaunchOptionsKey: Any]?

private let loopAppManager = LoopAppManager()
private let log = DiagnosticLog(category: "AppDelegate")

// MARK: - UIApplicationDelegate - Initialization
Expand All @@ -22,45 +24,9 @@ final class AppDelegate: UIResponder, UIApplicationDelegate, WindowProvider {

setenv("CFNETWORK_DIAGNOSTICS", "3", 1)

log.default("lastPathComponent = %{public}@", String(describing: Bundle.main.appStoreReceiptURL?.lastPathComponent))

loopAppManager.initialize(windowProvider: self, launchOptions: launchOptions)
loopAppManager.launch()
return loopAppManager.isLaunchComplete
// Avoid doing full initialization when running tests
if ProcessInfo.processInfo.environment["XCTestConfigurationFilePath"] == nil {
loopAppManager.initialize(windowProvider: self, launchOptions: launchOptions)
loopAppManager.launch()
return loopAppManager.isLaunchComplete
} else {
return true
}
}

// MARK: - UIApplicationDelegate - Life Cycle

func applicationDidBecomeActive(_ application: UIApplication) {
log.default(#function)
self.launchOptions = launchOptions

loopAppManager.didBecomeActive()
}

func applicationWillResignActive(_ application: UIApplication) {
log.default(#function)
}

func applicationDidEnterBackground(_ application: UIApplication) {
log.default(#function)
}

func applicationWillEnterForeground(_ application: UIApplication) {
log.default(#function)

loopAppManager.askUserToConfirmLoopReset()
}

func applicationWillTerminate(_ application: UIApplication) {
log.default(#function)
return true
}

// MARK: - UIApplicationDelegate - Environment
Expand Down Expand Up @@ -91,20 +57,6 @@ final class AppDelegate: UIResponder, UIApplicationDelegate, WindowProvider {

completionHandler(loopAppManager.handleRemoteNotification(userInfo as? [String: AnyObject]) ? .noData : .failed)
}

// MARK: - UIApplicationDelegate - Deeplinking

func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
loopAppManager.handle(url)
}

// MARK: - UIApplicationDelegate - Continuity

func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
log.default(#function)

return loopAppManager.userActivity(userActivity, restorationHandler: restorationHandler)
}

// MARK: - UIApplicationDelegate - Interface

Expand Down
20 changes: 0 additions & 20 deletions Loop/Extensions/Image+Optional.swift

This file was deleted.

35 changes: 12 additions & 23 deletions Loop/Extensions/UIAlertController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,6 @@ import LoopKitUI


extension UIAlertController {
/**
Initializes an ActionSheet-styled controller for selecting a pre-meal preset duration

- parameter handler: A closure to execute when the sheet is dismissed after selection. The closure has a single argument:
- duration: The duration for which the pre-meal preset is to be enabled
*/
internal convenience init(premealDurationSelectionHandler handler: @escaping (_ duration: TimeInterval) -> Void) {
self.init(
title: NSLocalizedString("Use Pre-Meal Preset", comment: "The title of the alert controller used to select a duration for pre-meal targets"),
message: nil,
preferredStyle: .actionSheet
)

let distantFuture = NSLocalizedString("Until I enter carbs", comment: "The title of a target alert action specifying pre-meal targets duration for 1 hour or until the user enters carbs (whichever comes first).")
addAction(UIAlertAction(title: distantFuture, style: .default) { _ in
handler(.hours(1))
})

addCancelAction()
}

/// Initializes an action sheet-styled controller for selecting a PumpManager
///
/// - Parameters:
Expand All @@ -55,6 +34,8 @@ extension UIAlertController {
}
))
}

addCancelAction()
}

/// Initializes an action sheet-styled controller for selecting a CGMManager
Expand All @@ -79,6 +60,8 @@ extension UIAlertController {
}
))
}

addCancelAction()
}

internal convenience init(deleteCGMManagerHandler handler: @escaping (_ isDeleted: Bool) -> Void) {
Expand Down Expand Up @@ -108,10 +91,12 @@ extension UIAlertController {
/// - selectionHandler: A closure to execute when a service is selected.
/// - identifier: The identifier of the selected service.
internal convenience init(availableServices: [ServiceDescriptor], selectionHandler: @escaping (_ identifier: String) -> Void) {
let preferredStyle: UIAlertController.Style = .alert

self.init(
title: NSLocalizedString("Add Service", comment: "Action sheet title selecting service"),
message: nil,
preferredStyle: .actionSheet
preferredStyle: preferredStyle
)

for availableService in availableServices {
Expand All @@ -123,11 +108,15 @@ extension UIAlertController {
}
))
}

if #available(iOS 26.0, *) {
addCancelAction()
}
}

internal func addCancelAction(handler: ((UIAlertAction) -> Void)? = nil) {
let cancel = NSLocalizedString("Cancel", comment: "The title of the cancel action in an action sheet")
addAction(UIAlertAction(title: cancel, style: .cancel, handler: handler))
addAction(UIAlertAction(title: cancel, style: .destructive, handler: handler))
}
}

Expand Down
23 changes: 19 additions & 4 deletions Loop/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,34 @@
<string>NewCarbEntryIntent</string>
<string>ViewLoopStatus</string>
</array>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<false/>
<key>UISceneConfigurations</key>
<dict>
<key>UIWindowSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneConfigurationName</key>
<string>Default Configuration</string>
<key>UISceneDelegateClassName</key>
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
<key>UISceneStoryboardFile</key>
<string>Main</string>
</dict>
</array>
</dict>
</dict>
<key>UIBackgroundModes</key>
<array>
<string>bluetooth-central</string>
<string>processing</string>
<string>remote-notification</string>
<string>audio</string>
</array>
<key>UIDesignRequiresCompatibility</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
Expand Down
Loading