Skip to content

Commit 6808858

Browse files
committed
transfer v2.2.3 updates from LF to LF_3
1 parent f9395d3 commit 6808858

18 files changed

Lines changed: 909 additions & 442 deletions

Config.xcconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
unique_id = ${DEVELOPMENT_TEAM}
77

88
//Version (DEFAULT)
9-
LOOP_FOLLOW_MARKETING_VERSION = 2.2.2
9+
LOOP_FOLLOW_MARKETING_VERSION = 2.2.3

LoopFollow.xcodeproj/project.pbxproj

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
DD493AE52ACF2383009A6922 /* Treatments.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD493AE42ACF2383009A6922 /* Treatments.swift */; };
2222
DD493AE72ACF23CF009A6922 /* DeviceStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD493AE62ACF23CF009A6922 /* DeviceStatus.swift */; };
2323
DD493AE92ACF2445009A6922 /* BGData.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD493AE82ACF2445009A6922 /* BGData.swift */; };
24+
DD608A082C1F584900F91132 /* DeviceStatusLoop.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD608A072C1F584900F91132 /* DeviceStatusLoop.swift */; };
25+
DD608A0C2C27415C00F91132 /* BackgroundAlertManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD608A0B2C27415C00F91132 /* BackgroundAlertManager.swift */; };
26+
DD608A0A2C23593900F91132 /* SMB.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD608A092C23593900F91132 /* SMB.swift */; };
27+
DD6A935E2BFA6FA2003FFB8E /* DeviceStatusOpenAPS.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD6A935D2BFA6FA2003FFB8E /* DeviceStatusOpenAPS.swift */; };
2428
DD7E19842ACDA50C00DBD158 /* Overrides.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD7E19832ACDA50C00DBD158 /* Overrides.swift */; };
2529
DD7E19862ACDA59700DBD158 /* BGCheck.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD7E19852ACDA59700DBD158 /* BGCheck.swift */; };
2630
DD7E19882ACDA5DA00DBD158 /* Notes.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD7E19872ACDA5DA00DBD158 /* Notes.swift */; };
@@ -211,6 +215,10 @@
211215
DD493AE42ACF2383009A6922 /* Treatments.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Treatments.swift; sourceTree = "<group>"; };
212216
DD493AE62ACF23CF009A6922 /* DeviceStatus.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeviceStatus.swift; sourceTree = "<group>"; };
213217
DD493AE82ACF2445009A6922 /* BGData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BGData.swift; sourceTree = "<group>"; };
218+
DD608A072C1F584900F91132 /* DeviceStatusLoop.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeviceStatusLoop.swift; sourceTree = "<group>"; };
219+
DD608A0B2C27415C00F91132 /* BackgroundAlertManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BackgroundAlertManager.swift; sourceTree = "<group>"; };
220+
DD608A092C23593900F91132 /* SMB.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SMB.swift; sourceTree = "<group>"; };
221+
DD6A935D2BFA6FA2003FFB8E /* DeviceStatusOpenAPS.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeviceStatusOpenAPS.swift; sourceTree = "<group>"; };
214222
DD7E19832ACDA50C00DBD158 /* Overrides.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Overrides.swift; sourceTree = "<group>"; };
215223
DD7E19852ACDA59700DBD158 /* BGCheck.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BGCheck.swift; sourceTree = "<group>"; };
216224
DD7E19872ACDA5DA00DBD158 /* Notes.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Notes.swift; sourceTree = "<group>"; };
@@ -436,6 +444,7 @@
436444
DD493ADA2ACF21A3009A6922 /* Bolus.swift */,
437445
DD493AD42ACF2109009A6922 /* ResumePump.swift */,
438446
DDF9676D2AD08C6E00C5EB95 /* SiteChange.swift */,
447+
DD608A092C23593900F91132 /* SMB.swift */,
439448
);
440449
path = Treatments;
441450
sourceTree = "<group>";
@@ -450,6 +459,8 @@
450459
DD493AE42ACF2383009A6922 /* Treatments.swift */,
451460
DD493AE62ACF23CF009A6922 /* DeviceStatus.swift */,
452461
DD493AE82ACF2445009A6922 /* BGData.swift */,
462+
DD6A935D2BFA6FA2003FFB8E /* DeviceStatusOpenAPS.swift */,
463+
DD608A072C1F584900F91132 /* DeviceStatusLoop.swift */,
453464
);
454465
path = Nightscout;
455466
sourceTree = "<group>";
@@ -495,6 +506,7 @@
495506
FC1BDD2A24A22650001B652C /* Stats.swift */,
496507
FC1BDD2C24A23204001B652C /* StatsView.swift */,
497508
FCA2DDE52501095000254A8C /* Timers.swift */,
509+
DD608A0B2C27415C00F91132 /* BackgroundAlertManager.swift */,
498510
);
499511
path = Controllers;
500512
sourceTree = "<group>";
@@ -983,6 +995,7 @@
983995
FCC6886724898F8000A0279D /* UserDefaultsValue.swift in Sources */,
984996
DDCF979E24C2382A002C9752 /* AppStateController.swift in Sources */,
985997
FC97881E2485969B00A7906C /* NightScoutViewController.swift in Sources */,
998+
DD608A0A2C23593900F91132 /* SMB.swift in Sources */,
986999
DDCF979824C1489C002C9752 /* GraphSettingsViewController.swift in Sources */,
9871000
FC3AE7B5249E8E0E00AAE1E0 /* LoopFollow.xcdatamodeld in Sources */,
9881001
FCC6886F2489A53800A0279D /* AppConstants.swift in Sources */,
@@ -1013,14 +1026,17 @@
10131026
DDF9676E2AD08C6E00C5EB95 /* SiteChange.swift in Sources */,
10141027
DDCF979C24C14EFB002C9752 /* AdvancedSettingsViewController.swift in Sources */,
10151028
FC97881C2485969B00A7906C /* MainViewController.swift in Sources */,
1029+
DD6A935E2BFA6FA2003FFB8E /* DeviceStatusOpenAPS.swift in Sources */,
10161030
DD493AD52ACF2109009A6922 /* ResumePump.swift in Sources */,
10171031
DDCF979624C1443C002C9752 /* GeneralSettingsViewController.swift in Sources */,
10181032
FCC0FAC224922A22003E610E /* DictionaryKeyPath.swift in Sources */,
10191033
DD493AD72ACF2139009A6922 /* SuspendPump.swift in Sources */,
10201034
FC9788182485969B00A7906C /* AppDelegate.swift in Sources */,
1035+
DD608A0C2C27415C00F91132 /* BackgroundAlertManager.swift in Sources */,
10211036
DD493AD92ACF2171009A6922 /* Carbs.swift in Sources */,
10221037
DD493AE92ACF2445009A6922 /* BGData.swift in Sources */,
10231038
FCC6886B24898FD800A0279D /* ObservationToken.swift in Sources */,
1039+
DD608A082C1F584900F91132 /* DeviceStatusLoop.swift in Sources */,
10241040
DD98F54424BCEFEE0007425A /* ShareClientExtension.swift in Sources */,
10251041
DD91E4DD2BDEC3F8002D9E97 /* GlucoseConversion.swift in Sources */,
10261042
FCC6886D2489909D00A0279D /* AnyConvertible.swift in Sources */,

LoopFollow/Application/AppDelegate.swift

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
1616

1717
var window: UIWindow?
1818
let notificationCenter = UNUserNotificationCenter.current()
19-
19+
2020
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
2121
// Override point for customization after application launch.
2222

23-
2423
let options: UNAuthorizationOptions = [.alert, .sound, .badge]
2524
notificationCenter.requestAuthorization(options: options) {
2625
(didAllow, error) in
@@ -37,11 +36,15 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
3736
}
3837
}
3938

39+
let action = UNNotificationAction(identifier: "OPEN_APP_ACTION", title: "Open App", options: .foreground)
40+
let category = UNNotificationCategory(identifier: "loopfollow.background.alert", actions: [action], intentIdentifiers: [], options: [])
41+
UNUserNotificationCenter.current().setNotificationCategories([category])
42+
4043
UNUserNotificationCenter.current().delegate = self
41-
42-
return true
43-
}
44-
44+
45+
return true
46+
}
47+
4548
func applicationWillTerminate(_ application: UIApplication) {
4649
if UserDefaultsRepository.alertAppInactive.value {
4750
AlarmSound.setSoundFile(str: "Alarm_Buzzer")
@@ -53,7 +56,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
5356

5457
func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
5558

56-
5759
// This application should be called in background every X Minutes
5860
UIApplication.shared.setMinimumBackgroundFetchInterval(
5961
TimeInterval(UserDefaultsRepository.backgroundRefreshFrequency.value * 60)
@@ -91,13 +93,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
9193
creates and returns a container, having loaded the store for the
9294
application to it. This property is optional since there are legitimate
9395
error conditions that could cause the creation of the store to fail.
94-
*/
96+
*/
9597
let container = NSPersistentCloudKitContainer(name: "LoopFollow")
9698
container.loadPersistentStores(completionHandler: { (storeDescription, error) in
9799
if let error = error as NSError? {
98100
// Replace this implementation with code to handle the error appropriately.
99101
// fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
100-
102+
101103
/*
102104
Typical reasons for an error here include:
103105
* The parent directory does not exist, cannot be created, or disallows writing.
@@ -128,13 +130,21 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
128130
}
129131
}
130132

133+
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
134+
if response.actionIdentifier == "OPEN_APP_ACTION" {
135+
if let window = window {
136+
window.rootViewController?.dismiss(animated: true, completion: nil)
137+
window.rootViewController?.present(MainViewController(), animated: true, completion: nil)
138+
}
139+
}
140+
completionHandler()
141+
}
131142
}
132143

133144
extension AppDelegate: UNUserNotificationCenterDelegate {
134-
135145
func userNotificationCenter(_ center: UNUserNotificationCenter,
136-
willPresent notification: UNNotification,
137-
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void)
146+
willPresent notification: UNNotification,
147+
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void)
138148
{
139149
completionHandler(.alert)
140150
}

LoopFollow/Application/Base.lproj/Main.storyboard

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -529,14 +529,6 @@
529529
<view key="view" contentMode="scaleToFill" id="ljg-dW-5uR">
530530
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
531531
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
532-
<subviews>
533-
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="6gS-Ff-qPd">
534-
<rect key="frame" x="0.0" y="44" width="414" height="769"/>
535-
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
536-
<viewLayoutGuide key="contentLayoutGuide" id="1wh-Gg-Auv"/>
537-
<viewLayoutGuide key="frameLayoutGuide" id="lqA-iJ-wdZ"/>
538-
</scrollView>
539-
</subviews>
540532
<viewLayoutGuide key="safeArea" id="aVb-ap-Pwt"/>
541533
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
542534
</view>
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
//
2+
// BackgroundAlertManager.swift
3+
// LoopFollow
4+
//
5+
// Created by Jonas Björkert on 2024-06-22.
6+
// Copyright © 2024 Jon Fawcett. All rights reserved.
7+
//
8+
9+
import Foundation
10+
import UserNotifications
11+
12+
class BackgroundAlertManager {
13+
static let shared = BackgroundAlertManager()
14+
15+
private init() {}
16+
17+
private var isAlertScheduled: Bool = false
18+
19+
func startBackgroundAlert() {
20+
isAlertScheduled = true
21+
scheduleBackgroundAlert()
22+
}
23+
24+
func stopBackgroundAlert() {
25+
isAlertScheduled = false
26+
cancelBackgroundAlert()
27+
}
28+
29+
func scheduleBackgroundAlert() {
30+
guard isAlertScheduled, UserDefaultsRepository.backgroundRefresh.value else { return }
31+
32+
let content = UNMutableNotificationContent()
33+
content.title = "LoopFollow Background Refresh"
34+
content.body = "The app is not active, open the app to resume."
35+
content.sound = .defaultCritical
36+
content.categoryIdentifier = "loopfollow.background.alert"
37+
38+
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 360, repeats: false)
39+
40+
let request = UNNotificationRequest(identifier: "loopfollow.background.alert", content: content, trigger: trigger)
41+
42+
UNUserNotificationCenter.current().add(request) { error in
43+
if let error = error {
44+
print("Error scheduling background alert: \(error)")
45+
}
46+
}
47+
}
48+
49+
private func cancelBackgroundAlert() {
50+
UNUserNotificationCenter.current().removePendingNotificationRequests(withIdentifiers: ["loopfollow.background.alert"])
51+
}
52+
}

0 commit comments

Comments
 (0)