Skip to content
This repository has been archived by the owner on Feb 27, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into fix-get-sessions
Browse files Browse the repository at this point in the history
  • Loading branch information
syoung-smallwisdom authored Jul 8, 2021
2 parents 145562d + 9b12ad1 commit e474a83
Show file tree
Hide file tree
Showing 24 changed files with 3,028 additions and 514 deletions.
35 changes: 31 additions & 4 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"repositoryURL": "https://github.com/Sage-Bionetworks/BridgeArchiver-Swift.git",
"state": {
"branch": null,
"revision": "5dc7b0d00d568fbdb4a32993bc18bd55c82a9de4",
"version": "0.1.0"
"revision": "f1f0c4a9f177b13315bae618db186c12ecbc5bdb",
"version": "0.3.0"
}
},
{
Expand All @@ -19,13 +19,40 @@
"version": "1.2.0"
}
},
{
"package": "JsonModel",
"repositoryURL": "https://github.com/Sage-Bionetworks/JsonModel-Swift.git",
"state": {
"branch": null,
"revision": "531fbb91179d9272d4fbb389a5c6516ead9d8fd7",
"version": "1.2.2"
}
},
{
"package": "MobilePassiveData",
"repositoryURL": "https://github.com/Sage-Bionetworks/MobilePassiveData-SDK.git",
"state": {
"branch": null,
"revision": "57ba7124b3e27db895410f237b1ced4d51e71a10",
"version": "1.1.1"
}
},
{
"package": "SageResearch",
"repositoryURL": "https://github.com/Sage-Bionetworks/SageResearch.git",
"state": {
"branch": null,
"revision": "877baa4d304bb8400bfc60fb05068ef830d266aa",
"version": "4.1.5"
}
},
{
"package": "SharedMobileUI",
"repositoryURL": "https://github.com/Sage-Bionetworks/SharedMobileUI-AppleOS.git",
"state": {
"branch": null,
"revision": "0fefce5ae5237be1718f4b00f7257df847584b2a",
"version": "0.1.0"
"revision": "ceecf49b32f3d1f33eb4f17aef66ffc2ea987201",
"version": "0.5.0"
}
},
{
Expand Down
16 changes: 12 additions & 4 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import PackageDescription
let package = Package(
name: "BridgeClient",
platforms: [
.iOS(.v13)
.iOS(.v14)
],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
Expand All @@ -22,13 +22,18 @@ let package = Package(
// .package(url: /* package url */, from: "1.0.0"),
.package(name: "SharedMobileUI",
url: "https://github.com/Sage-Bionetworks/SharedMobileUI-AppleOS.git",
from: "0.1.0"),
from: "0.5.0"),
.package(name: "BridgeArchiver",
url: "https://github.com/Sage-Bionetworks/BridgeArchiver-Swift.git",
from: "0.1.0"),
from: "0.3.0"),
.package(name: "SageResearch",
url: "https://github.com/Sage-Bionetworks/SageResearch.git",
from: "4.1.5"),
.package(name: "JsonModel",
url: "https://github.com/Sage-Bionetworks/JsonModel-Swift.git",
from: "1.2.0"),
// TODO: syoung 04/13/2021 Add AssessmentModel-KotlinNative once that repo is set up
// to build the xcframework when the version is updated.
// TODO: syoung 06/08/2021 Add SageResearch once MobileToolbox is set up to use SwiftPM
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
Expand All @@ -40,6 +45,9 @@ let package = Package(
"BridgeClient",
"SharedMobileUI",
"BridgeArchiver",
"JsonModel",
.product(name: "Research", package: "SageResearch"),
.product(name: "ResearchUI", package: "SageResearch"),
],
path: "SwiftPackage/Sources/BridgeClientUI")
]
Expand Down
16 changes: 10 additions & 6 deletions SwiftPackage/Binaries/BridgeClient.xcframework/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,34 @@
<key>AvailableLibraries</key>
<array>
<dict>
<key>DebugSymbolsPath</key>
<string>dSYMs</string>
<key>LibraryIdentifier</key>
<string>ios-arm64</string>
<string>ios-x86_64-simulator</string>
<key>LibraryPath</key>
<string>BridgeClient.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
<dict>
<key>DebugSymbolsPath</key>
<string>dSYMs</string>
<key>LibraryIdentifier</key>
<string>ios-x86_64-simulator</string>
<string>ios-arm64</string>
<key>LibraryPath</key>
<string>BridgeClient.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>x86_64</string>
<string>arm64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
</array>
<key>CFBundlePackageType</key>
Expand Down
Binary file not shown.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleIdentifier</key>
<string>com.apple.xcode.dsym.org.sagebionetworks.bridge.BridgeClient</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>dSYM</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
Binary file not shown.
Binary file not shown.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleIdentifier</key>
<string>com.apple.xcode.dsym.org.sagebionetworks.bridge.BridgeClient</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>dSYM</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
Binary file not shown.
23 changes: 19 additions & 4 deletions SwiftPackage/Sources/BridgeClientUI/BridgeClientAppManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,25 @@ public final class BridgeClientAppManager : ObservableObject {
}

public func encryptAndUpload(_ archives: [DataArchive]) {
DispatchQueue.main.async {
self.isUploadingResults = true
// TODO: syoung 06/17/2021 Figure out what needs to happen to allow uploading files to S3.
// Note: This will have to dispatch to the main queue before accessing the Kotlin framework.
DispatchQueue.global().async {

// Encrypt the files.
if let path = Bundle.main.path(forResource: self.platformConfig.appId, ofType: "pem"),
let pemFile = try? String(contentsOfFile: path, encoding: .utf8) {
archives.forEach { archive in
do {
try archive.encryptArchive(using: pemFile)
} catch let err {
print("Failed to encrypt archive. \(err)")
}
}
}

DispatchQueue.main.async {
self.isUploadingResults = true
// TODO: syoung 06/17/2021 Figure out what needs to happen to allow uploading files to S3.
// Note: This will have to dispatch to the main queue before accessing the Kotlin framework.
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ open class DataArchive : NSObject {

public final internal(set) var isCompleted: Bool = false

public final private(set) var encryptedURL: URL?

public var files: [FileEntry] {
archiver.files
}
Expand All @@ -66,8 +68,10 @@ open class DataArchive : NSObject {
try archiver.addFile(data: data, filepath: filepath, createdOn: createdOn, contentType: contentType)
}

@discardableResult
public final func encryptArchive(using pemFile: String) throws -> URL {
try archiver.encryptArchive(using: pemFile)
self.encryptedURL = try archiver.encryptArchive(using: pemFile)
return self.encryptedURL!
}

#if DEBUG
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ open class SageResearchResultArchive : AbstractResultArchive, RSDDataArchive {
true
}

open func archivableData(for result: RSDResult, sectionIdentifier: String?, stepPath: String?) -> RSDArchivable? {
open func archivableData(for result: ResultData, sectionIdentifier: String?, stepPath: String?) -> RSDArchivable? {
result as? RSDArchivable
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
//

import Foundation
import BridgeClient

extension Date {

Expand All @@ -49,13 +50,7 @@ extension Date {

public func localizeDate(hasTimeOfDay: Bool) -> String {
if !hasTimeOfDay {
if self.isTomorrow {
return NSLocalizedString("tomorrow", comment: "")
}
else {
return String.localizedStringWithFormat(NSLocalizedString("on %@", comment: ""),
DateFormatter.localizedString(from: self, dateStyle: .medium, timeStyle: .none))
}
return DateFormatter.localizedString(from: self, dateStyle: .medium, timeStyle: .none)
}
else if self.isToday {
return String.localizedStringWithFormat(NSLocalizedString("today at %@", comment: ""),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ public final class TimelineSession : ObservableObject, Identifiable {
}

public func updateState(_ now: Date = Date()) {
let availableNow = window.availableNow()
let isExpired = window.isExpired()
let availableNow = window.availableNow(now)
let isExpired = window.isExpired(now)
let performInOrder = window.performInOrder
var found = false
var finishedOn: Date?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ open class TodayTimelineViewModel : NSObject, ObservableObject {
/// task view controller delegate and the SwiftUI requirement that views and view builders are structs.
///
public var selectedAssessment: AssessmentScheduleInfo?

internal func now() -> Date { Date() }


private var schedules: [NativeScheduledSessionWindow] = [] {
didSet {
let newSessions: [TimelineSession] = schedules.map { schedule in
Expand Down Expand Up @@ -92,7 +90,12 @@ open class TodayTimelineViewModel : NSObject, ObservableObject {
public override init() {
super.init()
NotificationCenter.default.addObserver(forName: UIApplication.willEnterForegroundNotification, object: nil, queue: .main) { _ in
self.refreshSchedules()
let now = Date()
self.sessions.forEach { $0.updateState(now) }
if !self.today.isToday {
self.today = now
self.refreshSchedules()
}
}
}

Expand All @@ -112,13 +115,14 @@ open class TodayTimelineViewModel : NSObject, ObservableObject {
self.bridgeManager = bridgeManager
self.studyId = bridgeManager.studyId ?? "preview"
if !bridgeManager.isPreview {
self.timelineManager = NativeTimelineManager(studyId: studyId!) { schedules in
self.timelineManager = NativeTimelineManager(studyId: studyId!, includeAllNotifications: true, alwaysIncludeNextDay: true) { timelineSlice in
DispatchQueue.main.async {
self.schedules = schedules
self.today = timelineSlice.instantInDay
self.schedules = timelineSlice.scheduledSessionWindows
// TODO: syoung 06/28/2021 Set up notifications
}
}
self.timelineManager.observeTodaySchedule()
// TODO: syoung 06/11/2021 Setup background process to trigger at start of "tomorrow" (and figure out when "tomorrow" starts)
}
else {
self.schedules = previewSchedules
Expand Down Expand Up @@ -252,4 +256,3 @@ extension TodayTimelineViewModel : RSDTaskViewControllerDelegate {
}
}
}

Loading

0 comments on commit e474a83

Please sign in to comment.