Skip to content

Commit

Permalink
Merge branch 'master' into feature/268-do-not-let-screen-sleep-when-t…
Browse files Browse the repository at this point in the history
…imer-running
  • Loading branch information
krugerk authored Dec 26, 2024
2 parents 42a3e54 + 7571f7d commit a757ef6
Show file tree
Hide file tree
Showing 18 changed files with 255 additions and 221 deletions.
4 changes: 2 additions & 2 deletions BeeKit/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>6.7</string>
<string>6.8</string>
<key>CFBundleVersion</key>
<string>53</string>
<string>55</string>
</dict>
</plist>
4 changes: 2 additions & 2 deletions BeeKitTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>6.7</string>
<string>6.8</string>
<key>CFBundleVersion</key>
<string>53</string>
<string>55</string>
</dict>
</plist>
44 changes: 12 additions & 32 deletions BeeSwift.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
9B65F2322CFA6427009674A7 /* DeeplinkGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B65F2312CFA6418009674A7 /* DeeplinkGenerator.swift */; };
9B8CA57D24B120CA009C86C2 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9B8CA57C24B120CA009C86C2 /* LaunchScreen.storyboard */; };
A10D4E931B07948500A72D29 /* DatapointsTableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A10D4E921B07948500A72D29 /* DatapointsTableView.swift */; };
A10DC2DF207BFCBA00FB7B3A /* RemoveHKMetricViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A10DC2DE207BFCBA00FB7B3A /* RemoveHKMetricViewController.swift */; };
Expand All @@ -24,7 +25,6 @@
A17E930C1B09032F0098FCA0 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A17E930B1B09032F0098FCA0 /* QuartzCore.framework */; };
A196CB1A1AE4142E00B90A3E /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = A196CB191AE4142E00B90A3E /* AppDelegate.swift */; };
A196CB1F1AE4142F00B90A3E /* GalleryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A196CB1E1AE4142F00B90A3E /* GalleryViewController.swift */; };
A196CB221AE4142F00B90A3E /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A196CB201AE4142F00B90A3E /* Main.storyboard */; };
A196CB241AE4142F00B90A3E /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A196CB231AE4142F00B90A3E /* Images.xcassets */; };
A196CB331AE4142F00B90A3E /* BeeSwiftTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A196CB321AE4142F00B90A3E /* BeeSwiftTests.swift */; };
A1A8BDE61FEAE8DD007D61D6 /* ConfigureNotificationsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1A8BDE51FEAE8DD007D61D6 /* ConfigureNotificationsViewController.swift */; };
Expand All @@ -38,6 +38,7 @@
A1E618E41E7934C700D8ED93 /* HealthKitConfigTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1E618E31E7934C700D8ED93 /* HealthKitConfigTableViewCell.swift */; };
A1EA154D1B01E6EC0052A6E6 /* DatapointTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1EA154C1B01E6EC0052A6E6 /* DatapointTableViewCell.swift */; };
A1F9D1EA211B9B7600E2BC93 /* EditDatapointViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1F9D1E9211B9B7600E2BC93 /* EditDatapointViewController.swift */; };
E4015D9F2D10DC4D00F58D94 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = E4015D9E2D10DC4D00F58D94 /* SceneDelegate.swift */; };
E41286F12A62E6840093D598 /* KeychainSwift in Frameworks */ = {isa = PBXBuildFile; productRef = E41286F02A62E6840093D598 /* KeychainSwift */; };
E41286F32A62E97B0093D598 /* KeychainSwift in Frameworks */ = {isa = PBXBuildFile; productRef = E41286F22A62E97B0093D598 /* KeychainSwift */; };
E412DADF2B869E1E0099E483 /* BeeLemniscateView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E412DADE2B869E1E0099E483 /* BeeLemniscateView.swift */; };
Expand Down Expand Up @@ -168,13 +169,6 @@
remoteGlobalIDString = A196CB131AE4142E00B90A3E;
remoteInfo = BeeSwift;
};
E57BE6F32655EBE000BA540B /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = A196CB0C1AE4142E00B90A3E /* Project object */;
proxyType = 1;
remoteGlobalIDString = E57BE6DF2655EBD900BA540B;
remoteInfo = BeeKit;
};
E57BE7122655F00200BA540B /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = A196CB0C1AE4142E00B90A3E /* Project object */;
Expand Down Expand Up @@ -224,6 +218,7 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
9B65F2312CFA6418009674A7 /* DeeplinkGenerator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeeplinkGenerator.swift; sourceTree = "<group>"; };
9B8CA57C24B120CA009C86C2 /* LaunchScreen.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = "<group>"; };
A10D4E921B07948500A72D29 /* DatapointsTableView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatapointsTableView.swift; sourceTree = "<group>"; };
A10DC2DE207BFCBA00FB7B3A /* RemoveHKMetricViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RemoveHKMetricViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -253,7 +248,6 @@
A196CB181AE4142E00B90A3E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
A196CB191AE4142E00B90A3E /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
A196CB1E1AE4142F00B90A3E /* GalleryViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GalleryViewController.swift; sourceTree = "<group>"; };
A196CB211AE4142F00B90A3E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
A196CB231AE4142F00B90A3E /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
A196CB2C1AE4142F00B90A3E /* BeeSwiftTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = BeeSwiftTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
A196CB311AE4142F00B90A3E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
Expand All @@ -275,6 +269,7 @@
A1E618FF1E86980900D8ED93 /* HealthKitConfig.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HealthKitConfig.swift; sourceTree = "<group>"; };
A1EA154C1B01E6EC0052A6E6 /* DatapointTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatapointTableViewCell.swift; sourceTree = "<group>"; };
A1F9D1E9211B9B7600E2BC93 /* EditDatapointViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditDatapointViewController.swift; sourceTree = "<group>"; };
E4015D9E2D10DC4D00F58D94 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
E4040D732A7B5F0E008E7D0E /* WorkoutMinutesHealthKitMetric.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WorkoutMinutesHealthKitMetric.swift; sourceTree = "<group>"; };
E41286ED2A62DF330093D598 /* BeeminderModel.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = BeeminderModel.xcdatamodel; sourceTree = "<group>"; };
E412DADE2B869E1E0099E483 /* BeeLemniscateView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BeeLemniscateView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -483,6 +478,7 @@
A196CB161AE4142E00B90A3E /* BeeSwift */ = {
isa = PBXGroup;
children = (
9B65F2312CFA6418009674A7 /* DeeplinkGenerator.swift */,
A1E618E51E79E01900D8ED93 /* Cells */,
E46071002B43DA7100305DB4 /* Gallery */,
E46070FF2B43DA3D00305DB4 /* GoalView */,
Expand All @@ -497,8 +493,8 @@
A196CB231AE4142F00B90A3E /* Images.xcassets */,
9B8CA57C24B120CA009C86C2 /* LaunchScreen.storyboard */,
E43BEA832A036A9C00FC3A38 /* LogReader.swift */,
A196CB201AE4142F00B90A3E /* Main.storyboard */,
A1453B3E1AEDFCC8006F48DA /* SignInViewController.swift */,
E4015D9E2D10DC4D00F58D94 /* SceneDelegate.swift */,
);
path = BeeSwift;
sourceTree = "<group>";
Expand Down Expand Up @@ -732,7 +728,6 @@
);
dependencies = (
E5F7C4A9260FC5300095684F /* PBXTargetDependency */,
E57BE6F42655EBE000BA540B /* PBXTargetDependency */,
E57BE7132655F00200BA540B /* PBXTargetDependency */,
);
name = BeeSwift;
Expand Down Expand Up @@ -967,7 +962,6 @@
buildActionMask = 2147483647;
files = (
E5DF493724DC69A200260560 /* Config.swift.sample in Resources */,
A196CB221AE4142F00B90A3E /* Main.storyboard in Resources */,
9B8CA57D24B120CA009C86C2 /* LaunchScreen.storyboard in Resources */,
A196CB241AE4142F00B90A3E /* Images.xcassets in Resources */,
);
Expand Down Expand Up @@ -1022,9 +1016,11 @@
A1E618E41E7934C700D8ED93 /* HealthKitConfigTableViewCell.swift in Sources */,
E4B083392932F90400A71564 /* ConfigureHKMetricViewController.swift in Sources */,
E43BEA842A036A9C00FC3A38 /* LogReader.swift in Sources */,
9B65F2322CFA6427009674A7 /* DeeplinkGenerator.swift in Sources */,
A196CB1F1AE4142F00B90A3E /* GalleryViewController.swift in Sources */,
A1BE73AA1E8B45BF00DEC4DB /* ChooseHKMetricViewController.swift in Sources */,
A149147B1BE79FD50060600A /* EditNotificationsViewController.swift in Sources */,
E4015D9F2D10DC4D00F58D94 /* SceneDelegate.swift in Sources */,
A1BE73AC1E8B47E700DEC4DB /* HealthKitMetricTableViewCell.swift in Sources */,
E43833942AC1473E0098A38F /* InlineDatePicker.swift in Sources */,
E55760F526549D310076B95A /* AddDataIntentHandler.swift in Sources */,
Expand Down Expand Up @@ -1168,11 +1164,6 @@
target = A196CB131AE4142E00B90A3E /* BeeSwift */;
targetProxy = E57BE6EC2655EBE000BA540B /* PBXContainerItemProxy */;
};
E57BE6F42655EBE000BA540B /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = E57BE6DF2655EBD900BA540B /* BeeKit */;
targetProxy = E57BE6F32655EBE000BA540B /* PBXContainerItemProxy */;
};
E57BE7132655F00200BA540B /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = E57BE6DF2655EBD900BA540B /* BeeKit */;
Expand All @@ -1190,17 +1181,6 @@
};
/* End PBXTargetDependency section */

/* Begin PBXVariantGroup section */
A196CB201AE4142F00B90A3E /* Main.storyboard */ = {
isa = PBXVariantGroup;
children = (
A196CB211AE4142F00B90A3E /* Base */,
);
name = Main.storyboard;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */

/* Begin XCBuildConfiguration section */
A196CB341AE4142F00B90A3E /* Debug */ = {
isa = XCBuildConfiguration;
Expand Down Expand Up @@ -1235,7 +1215,7 @@
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 53;
CURRENT_PROJECT_VERSION = 55;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
Expand Down Expand Up @@ -1300,7 +1280,7 @@
CODE_SIGN_IDENTITY = "iPhone Distribution";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 53;
CURRENT_PROJECT_VERSION = 55;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
Expand Down Expand Up @@ -1467,7 +1447,7 @@
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = 8TW9V9HVES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 53;
DYLIB_CURRENT_VERSION = 55;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_MODULE_VERIFIER = YES;
EXCLUDED_ARCHS = "";
Expand Down Expand Up @@ -1514,7 +1494,7 @@
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = 8TW9V9HVES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 53;
DYLIB_CURRENT_VERSION = 55;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_MODULE_VERIFIER = YES;
EXCLUDED_ARCHS = "";
Expand Down
20 changes: 13 additions & 7 deletions BeeSwift/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
let logger = Logger(subsystem: "com.beeminder.beeminder", category: "AppDelegate")
let backgroundUpdates = BackgroundUpdates()

var window: UIWindow?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
logger.notice("application:didFinishLaunchingWithOptions")

Expand All @@ -43,8 +41,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD

NetworkActivityIndicatorManager.shared.isEnabled = true

NotificationCenter.default.addObserver(self, selector: #selector(self.updateBadgeCount), name: NSNotification.Name(rawValue: GoalManager.goalsUpdatedNotificationName), object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(self.updateBadgeCount), name: NSNotification.Name(rawValue: CurrentUserManager.signedOutNotificationName), object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(self.handleGoalsUpdated), name: NSNotification.Name(rawValue: GoalManager.goalsUpdatedNotificationName), object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(self.handleUserSignedOut), name: NSNotification.Name(rawValue: CurrentUserManager.signedOutNotificationName), object: nil)

backgroundUpdates.startUpdatingRegularlyInBackground()

Expand Down Expand Up @@ -128,9 +126,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
logger.notice("application:didFailToRegisterForRemoteNotificationsWithError")
}
@objc func updateBadgeCount() {
assert(Thread.isMainThread, "updateBadgeCount must be run on the main thread")

@objc private func handleGoalsUpdated() {
assert(Thread.isMainThread, "\(#function) must be run on the main thread")

let context = ServiceLocator.persistentContainer.viewContext
guard let goals = ServiceLocator.goalManager.staleGoals(context: context) else { return }
Expand All @@ -139,6 +137,14 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD

UNUserNotificationCenter.current().setBadgeCount(beemergencyCount)
}

@objc private func handleUserSignedOut() {
assert(Thread.isMainThread, "\(#function) must be run on the main thread")

logger.notice("User signed out; updating Beemergency badge count to 0")

UNUserNotificationCenter.current().setBadgeCount(0)
}

private func refreshGoalsAndLogErrors() {
Task { @MainActor in
Expand Down
53 changes: 0 additions & 53 deletions BeeSwift/Base.lproj/Main.storyboard

This file was deleted.

42 changes: 42 additions & 0 deletions BeeSwift/DeeplinkGenerator.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//
// DeeplinkGenerator.swift
// BeeSwift
//
// Created by krugerk on 2024-11-29.
//


struct DeeplinkGenerator {
public static func generateDeepLinkToGoalCommitment(username: String, goalName: String) -> URL {
URL(string: "https://www.beeminder.com/\(username)/\(goalName)#commitment")!
}

public static func generateDeepLinkToGoalStop(username: String, goalName: String) -> URL {
URL(string: "https://www.beeminder.com/\(username)/\(goalName)#stop")!
}

public static func generateDeepLinkToGoalData(username: String, goalName: String) -> URL {
URL(string: "https://www.beeminder.com/\(username)/\(goalName)#data")!
}

public static func generateDeepLinkToGoalStatistics(username: String, goalName: String) -> URL {
URL(string: "https://www.beeminder.com/\(username)/\(goalName)#statistics")!
}

public static func generateDeepLinkToGoalSettings(username: String, goalName: String) -> URL {
URL(string: "https://www.beeminder.com/\(username)/\(goalName)#settings")!
}

public static func generateDeepLinkToUrl(accessToken: String, username: String, url: URL) -> URL {
let baseUrlString = "https://www.beeminder.com/api/v1/users/\(username).json"

var components = URLComponents(string: baseUrlString)!

components.queryItems = [
URLQueryItem(name: "access_token", value: accessToken),
URLQueryItem(name: "redirect_to_url", value: url.absoluteString)
]

return components.url!
}
}
Loading

0 comments on commit a757ef6

Please sign in to comment.