Skip to content
Merged
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
35 changes: 19 additions & 16 deletions Balance.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1316,28 +1316,29 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
CODE_SIGN_ENTITLEMENTS = BalanceWatchApp/BalanceWatchApp.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 637867499T;
DEVELOPMENT_TEAM = 58MHXEFYLU;
ENABLE_PREVIEWS = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu17;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_CFBundleDisplayName = BalanceWatchApp;
INFOPLIST_KEY_NSHealthShareUsageDescription = "$(PRODUCT_NAME) would like to capture a snap shot of your heart rate for the purpose of using the data in a clinical research study. Please grant this permission to continue participating.";
INFOPLIST_KEY_NSHealthUpdateUsageDescription = "$(PRODUCT_NAME) would like to update your health usage with heart rate data. Actually we never do anything of the kind but it seems Apple has lost control of X-Code and has few if any answers, so we will ask this permission.";
INFOPLIST_KEY_NSHealthShareUsageDescription = "BalanceWatchApp would like to capture a snap shot of your heart rate for the purpose of using the data in a clinical research study. Please grant this permission to continue participating.";
INFOPLIST_KEY_NSHealthUpdateUsageDescription = "BalanceWatchApp would like to update your health usage with heart rate data. Actually we never do anything of the kind but it seems Apple has lost control of X-Code and has few if any answers, so we will ask this permission.";
INFOPLIST_KEY_UISupportedInterfaceOrientations = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown";
INFOPLIST_KEY_WKCompanionAppBundleIdentifier = edu.stanford.cs342.2023.balance;
INFOPLIST_KEY_WKCompanionAppBundleIdentifier = com.celteeka.cs342.2023.balance;
INFOPLIST_KEY_WKRunsIndependentlyOfCompanionApp = NO;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = edu.stanford.cs342.2023.balance.watchApp;
PRODUCT_BUNDLE_IDENTIFIER = com.celteeka.cs342.2023.balance.watchApp;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SDKROOT = watchos;
SKIP_INSTALL = YES;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)";
Expand Down Expand Up @@ -1367,10 +1368,10 @@
GCC_C_LANGUAGE_STANDARD = gnu17;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_CFBundleDisplayName = BalanceWatchApp;
INFOPLIST_KEY_NSHealthShareUsageDescription = "$(PRODUCT_NAME) would like to capture a snap shot of your heart rate for the purpose of using the data in a clinical research study. Please grant this permission to continue participating.";
INFOPLIST_KEY_NSHealthUpdateUsageDescription = "$(PRODUCT_NAME) would like to update your health usage with heart rate data. Actually we never do anything of the kind but it seems Apple has lost control of X-Code and has few if any answers, so we will ask this permission.";
INFOPLIST_KEY_NSHealthShareUsageDescription = "BalanceWatchApp would like to capture a snap shot of your heart rate for the purpose of using the data in a clinical research study. Please grant this permission to continue participating.";
INFOPLIST_KEY_NSHealthUpdateUsageDescription = "BalanceWatchApp would like to update your health usage with heart rate data. Actually we never do anything of the kind but it seems Apple has lost control of X-Code and has few if any answers, so we will ask this permission.";
INFOPLIST_KEY_UISupportedInterfaceOrientations = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown";
INFOPLIST_KEY_WKCompanionAppBundleIdentifier = edu.stanford.cs342.2023.balance;
INFOPLIST_KEY_WKCompanionAppBundleIdentifier = com.celteeka.cs342.2023.balance;
INFOPLIST_KEY_WKRunsIndependentlyOfCompanionApp = NO;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand Down Expand Up @@ -1516,11 +1517,11 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Balance/BalanceDebug.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = 637867499T;
DEVELOPMENT_TEAM = 58MHXEFYLU;
ENABLE_PREVIEWS = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -1535,9 +1536,10 @@
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = "Balance/Supporting Files/Info.plist";
INFOPLIST_KEY_CFBundleDisplayName = Balance;
INFOPLIST_KEY_ITSAppUsesNonExemptEncryption = NO;
INFOPLIST_KEY_NSCameraUsageDescription = "This message should never appear. Please adjust this when you start using camera information. We have to put this in here as ResearchKit has the possibility to use it and not putting it here returns an error on AppStore Connect.";
INFOPLIST_KEY_NSHealthShareUsageDescription = "The CS342 2023 Balance Team Application uses the step count to demonstrate CardinalKit's integration with HealthKit.";
INFOPLIST_KEY_NSHealthUpdateUsageDescription = "The CS342 2023 Balance Team Application uses the step count to demonstrate CardinalKit's integration with HealthKit.";
INFOPLIST_KEY_NSHealthShareUsageDescription = "$(PRODUCT_NAME) would like to capture a snap shot of your heart rate for the purpose of using the data in a clinical research study. Please grant this permission to continue participating.";
INFOPLIST_KEY_NSHealthUpdateUsageDescription = "$(PRODUCT_NAME) would like to update your health usage with heart rate data. Actually we never do anything of the kind but it seems Apple has lost control of X-Code and has few if any answers, so we will ask this permission.";
INFOPLIST_KEY_NSLocationAlwaysAndWhenInUseUsageDescription = "This message should never appear. Please adjust this when you start using location information. We have to put this in here as ResearchKit has the possibility to use it and not putting it here returns an error on AppStore Connect.";
INFOPLIST_KEY_NSLocationWhenInUseUsageDescription = "This message should never appear. Please adjust this when you start using location information. We have to put this in here as ResearchKit has the possibility to use it and not putting it here returns an error on AppStore Connect.";
INFOPLIST_KEY_NSMicrophoneUsageDescription = "This message should never appear. Please adjust this when you start using microphone information. We have to put this in here as ResearchKit has the possibility to use it and not putting it here returns an error on AppStore Connect.";
Expand All @@ -1558,7 +1560,7 @@
);
MARKETING_VERSION = 1.0;
OTHER_LDFLAGS = "-ObjC";
PRODUCT_BUNDLE_IDENTIFIER = edu.stanford.cs342.2023.balance;
PRODUCT_BUNDLE_IDENTIFIER = com.celteeka.cs342.2023.balance;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
Expand Down Expand Up @@ -1598,9 +1600,10 @@
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = "Balance/Supporting Files/Info.plist";
INFOPLIST_KEY_CFBundleDisplayName = Balance;
INFOPLIST_KEY_ITSAppUsesNonExemptEncryption = NO;
INFOPLIST_KEY_NSCameraUsageDescription = "This message should never appear. Please adjust this when you start using camera information. We have to put this in here as ResearchKit has the possibility to use it and not putting it here returns an error on AppStore Connect.";
INFOPLIST_KEY_NSHealthShareUsageDescription = "The CS342 2023 Balance Team Application uses the step count to demonstrate CardinalKit's integration with HealthKit.";
INFOPLIST_KEY_NSHealthUpdateUsageDescription = "The CS342 2023 Balance Team Application uses the step count to demonstrate CardinalKit's integration with HealthKit.";
INFOPLIST_KEY_NSHealthShareUsageDescription = "$(PRODUCT_NAME) would like to capture a snap shot of your heart rate for the purpose of using the data in a clinical research study. Please grant this permission to continue participating.";
INFOPLIST_KEY_NSHealthUpdateUsageDescription = "$(PRODUCT_NAME) would like to update your health usage with heart rate data. Actually we never do anything of the kind but it seems Apple has lost control of X-Code and has few if any answers, so we will ask this permission.";
INFOPLIST_KEY_NSLocationAlwaysAndWhenInUseUsageDescription = "This message should never appear. Please adjust this when you start using location information. We have to put this in here as ResearchKit has the possibility to use it and not putting it here returns an error on AppStore Connect.";
INFOPLIST_KEY_NSLocationWhenInUseUsageDescription = "This message should never appear. Please adjust this when you start using location information. We have to put this in here as ResearchKit has the possibility to use it and not putting it here returns an error on AppStore Connect.";
INFOPLIST_KEY_NSMicrophoneUsageDescription = "This message should never appear. Please adjust this when you start using microphone information. We have to put this in here as ResearchKit has the possibility to use it and not putting it here returns an error on AppStore Connect.";
Expand Down
54 changes: 30 additions & 24 deletions Balance/ActivityLogging/ActivityLogBaseView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,57 +11,63 @@ import SwiftUI
struct ActivityLogContainer<Content>: View where Content: View {
@EnvironmentObject var activityLogEntry: ActivityLogEntry
private let content: Content

var body: some View {
content.environmentObject(activityLogEntry)
}

public init(@ViewBuilder content: () -> Content) {
self.content = content()
}
}

// This base view implements functionality to log information that will be send to the ActivityStorageManager
struct ActivityLogBaseView<Content>: View where Content: View {
@EnvironmentObject var activityLogEntry: ActivityLogEntry
@EnvironmentObject var logStore: ActivityLogStore
@State private var isVisible = false
private let viewName: String
private let isDirectChildToContainer: Bool
private let content: Content

var body: some View {
content
.onReceive(NotificationCenter.default.publisher(for: Notification.Name.goBackground)) { _ in
activityLogEntry.reset()
.onAppear {
#if DEBUG
print("[ActivityLogBaseView][onAppear] - View: \(viewName)")
#endif
isVisible = true
activityLogEntry.push(viewName: viewName)
}
.onAppear(perform: {
activityLogEntry.addAction(actionDescription: "Opened \(viewName)")
.onDisappear {
#if DEBUG
print("Opened \(viewName)")
print("[ActivityLogBaseView][onDisappear] - View: \(viewName)")
#endif
})
.onDisappear(perform: {
activityLogEntry.endLog(actionDescription: "Closed \(viewName)")

isVisible = false
// On forward nav, push() already finalized this view before onDisappear fires.
// Only finalize if pendingEntry still matches — i.e. this is a back navigation.
if activityLogEntry.pendingEntry?.description == viewName {
activityLogEntry.finalizePending()
}
if isDirectChildToContainer {
#if DEMO
logStore.saveLog(activityLogEntry)
#else
ActivityStorageManager.shared.uploadActivity(activityLogEntry: activityLogEntry)
#endif
// for debugging
let activityLogEntryString = activityLogEntry.toString()
}
}
.onReceive(NotificationCenter.default.publisher(for: UIApplication.didBecomeActiveNotification)) { _ in
#if DEBUG
print("Sending activity log to storage manager: \(activityLogEntryString)")
print("[ActivityLogBaseView][didBecomeActive] - View: \(viewName), isVisible: \(isVisible)")
#endif
guard isVisible else {
return
}

if activityLogEntry.pendingEntry?.description != viewName {
#if DEBUG
print("Closed \(viewName)")
print("[ActivityLogBaseView][didBecomeActive] - Re-pushing view: \(viewName)")
#endif
})
activityLogEntry.push(viewName: viewName)
}
}
}

public init(viewName: String, isDirectChildToContainer: Bool = false, @ViewBuilder content: () -> Content) {
self.viewName = viewName
self.isDirectChildToContainer = isDirectChildToContainer
Expand Down
12 changes: 6 additions & 6 deletions Balance/ActivityLogging/ActivityLogButtonStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ struct ActivityLogButtonStyle: PrimitiveButtonStyle {
configuration.label
.onTapGesture {
configuration.trigger()
activityLogEntry.addActionButton(actionDescription: "Button " + activityDescription)
activityLogEntry.addButtonEvent(description: "Button " + activityDescription)
#if DEMO
logStore.saveLog(activityLogEntry)
ActivityLogStore.save(logs: logStore.logs) { result in
if case .failure(let error) = result {
print(error.localizedDescription)
}
}
// ActivityLogStore.save(logs: logStore.logs) { result in
// if case .failure(let error) = result {
// print(error.localizedDescription)
// }
// }
#else
ActivityStorageManager.shared.uploadActivity(activityLogEntry: activityLogEntry)
#endif
Expand Down
Loading
Loading