Skip to content

Commit

Permalink
Merge pull request #363 from DP-3T/release/1.2.1
Browse files Browse the repository at this point in the history
Release 1.2.1
  • Loading branch information
UBaggeler authored Dec 7, 2020
2 parents 3870b55 + 3e9b461 commit f5cbf55
Show file tree
Hide file tree
Showing 57 changed files with 1,107 additions and 309 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Switch to Xcode 11.7
run: sudo xcode-select --switch /Applications/Xcode_11.7.app
- name: Switch to Xcode 12.2
run: sudo xcode-select --switch /Applications/Xcode_12.2.app

# Compile project and run tests
- name: Compile and run tests
Expand All @@ -26,8 +26,8 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Switch to Xcode 11.7
run: sudo xcode-select --switch /Applications/Xcode_11.7.app
- name: Switch to Xcode 12.2
run: sudo xcode-select --switch /Applications/Xcode_12.2.app

# Compile "Release-Prod" for iOS Simulator (no signing)
- name: Compile and run tests
Expand All @@ -39,8 +39,8 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Switch to Xcode 11.7
run: sudo xcode-select --switch /Applications/Xcode_11.7.app
- name: Switch to Xcode 12.2
run: sudo xcode-select --switch /Applications/Xcode_12.2.app

# Compile "Release-Dev-Calibration" for iOS Simulator (no signing)
- name: Compile and run tests
Expand Down
20 changes: 10 additions & 10 deletions .github/workflows/distribute.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Switch to Xcode 11.7
run: sudo xcode-select --switch /Applications/Xcode_11.7.app
- name: Switch to Xcode 12.2
run: sudo xcode-select --switch /Applications/Xcode_12.2.app

- name: Installs librsvg
run: brew install librsvg
Expand Down Expand Up @@ -67,8 +67,8 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Switch to Xcode 11.7
run: sudo xcode-select --switch /Applications/Xcode_11.7.app
- name: Switch to Xcode 12.2
run: sudo xcode-select --switch /Applications/Xcode_12.2.app

- name: Installs librsvg
run: brew install librsvg
Expand Down Expand Up @@ -120,8 +120,8 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Switch to Xcode 11.7
run: sudo xcode-select --switch /Applications/Xcode_11.7.app
- name: Switch to Xcode 12.2
run: sudo xcode-select --switch /Applications/Xcode_12.2.app

- name: Installs librsvg
run: brew install librsvg
Expand Down Expand Up @@ -173,8 +173,8 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Switch to Xcode 11.7
run: sudo xcode-select --switch /Applications/Xcode_11.7.app
- name: Switch to Xcode 12.2
run: sudo xcode-select --switch /Applications/Xcode_12.2.app

- name: Sets up bundler
run: bundle update --bundler
Expand Down Expand Up @@ -221,8 +221,8 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Switch to Xcode 11.7
run: sudo xcode-select --switch /Applications/Xcode_11.7.app
- name: Switch to Xcode 12.2
run: sudo xcode-select --switch /Applications/Xcode_12.2.app

- name: Installs librsvg
run: brew install librsvg
Expand Down
2 changes: 1 addition & 1 deletion DP3TApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3215,7 +3215,7 @@
repositoryURL = "https://github.com/DP-3T/dp3t-sdk-ios.git";
requirement = {
kind = revision;
revision = 522938daf30dfc93b47aba4d3956a01b5561905e;
revision = 2dd6f63092599632d31eaaa35664664243e0b809;
};
};
F870A5B52492C6D500C34FFA /* XCRemoteSwiftPackageReference "SQLite" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"repositoryURL": "https://github.com/DP-3T/dp3t-sdk-ios.git",
"state": {
"branch": null,
"revision": "522938daf30dfc93b47aba4d3956a01b5561905e",
"revision": "2dd6f63092599632d31eaaa35664664243e0b809",
"version": null
}
},
Expand Down
2 changes: 1 addition & 1 deletion DP3TApp/Logic/Config/ConfigManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class ConfigManager: NSObject {
dataTask = session.dataTask(with: request, completionHandler: { data, response, error in

guard let httpResponse = response as? HTTPURLResponse,
let data = data else {
let data = data else {
Logger.log("Failed to load config, error: \(error?.localizedDescription ?? "?")")
DispatchQueue.main.async { completion(nil) }
return
Expand Down
4 changes: 2 additions & 2 deletions DP3TApp/Logic/Helpers/Bundle+BuildInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ extension Bundle {
static var buildDate: Date? {
let bundleName = Bundle.main.infoDictionary!["CFBundleName"] as? String ?? "Info.plist"
if let infoPath = Bundle.main.path(forResource: bundleName, ofType: nil),
let infoAttr = try? FileManager.default.attributesOfItem(atPath: infoPath),
let infoDate = infoAttr[FileAttributeKey.creationDate] as? Date
let infoAttr = try? FileManager.default.attributesOfItem(atPath: infoPath),
let infoDate = infoAttr[FileAttributeKey.creationDate] as? Date
{ return infoDate }
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion DP3TApp/Logic/Helpers/UIImage+localizedImage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ extension UIImage {

for preferredLanguage in preferredLanguages {
if let code = preferredLanguage.components(separatedBy: "-").first,
let image = UIImage(named: prefix + code) {
let image = UIImage(named: prefix + code) {
return image
}
}
Expand Down
6 changes: 3 additions & 3 deletions DP3TApp/Logic/Networking/Base/URLSession+pinning.swift
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class CertificateEvaluator: NSObject, URLSessionDelegate {
let host = challenge.protectionSpace.host

guard challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust,
let trust = challenge.protectionSpace.serverTrust else {
let trust = challenge.protectionSpace.serverTrust else {
return (.cancelAuthenticationChallenge, nil, nil)
}

Expand All @@ -156,8 +156,8 @@ class CertificateEvaluator: NSObject, URLSessionDelegate {
extension Bundle {
func getCertificate(with name: String, fileExtension: String = "der") -> SecCertificate? {
if let certificateURL = url(forResource: name, withExtension: fileExtension),
let certificateData = try? Data(contentsOf: certificateURL),
let certificate = SecCertificateCreateWithData(nil, certificateData as CFData) {
let certificateData = try? Data(contentsOf: certificateURL),
let certificate = SecCertificateCreateWithData(nil, certificateData as CFData) {
return certificate
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion DP3TApp/Logic/Statistics/StatisticsLoader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class StatisticsLoader {
}

guard let httpResponse = response as? HTTPURLResponse,
let data = data else {
let data = data else {
Logger.log("Failed to load statistics, error: \(error?.localizedDescription ?? "?")")
DispatchQueue.main.async { completionHandler(.failure(.networkError)) }
return
Expand Down
2 changes: 1 addition & 1 deletion DP3TApp/Logic/Tracing/DatabaseSyncer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class DatabaseSyncer {

func syncDatabaseIfNeeded(completionHandler: ((UIBackgroundFetchResult) -> Void)? = nil) {
guard !databaseIsSyncing,
UserStorage.shared.hasCompletedOnboarding else {
UserStorage.shared.hasCompletedOnboarding else {
completionHandler?(.noData)
return
}
Expand Down
2 changes: 1 addition & 1 deletion DP3TApp/Logic/Tracing/Reporting/FakePublishManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ private class FakePublishOperation: Operation {
var numberOfFakeRequestsDone = 0

while isCancelled == false,
now >= manager.nextScheduledFakeRequestDate {
now >= manager.nextScheduledFakeRequestDate {
let isFirstReport = numberOfFakeRequestsDone == 0

// only do request if it was planned to do in the last 48h
Expand Down
6 changes: 4 additions & 2 deletions DP3TApp/Logic/Tracing/TracingLocalPush.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ class TracingLocalPush: NSObject, LocalPushProtocol {
scheduleNotification(identifier: exposure.identifier)
// and update the latestExpsoureDate
lastestExposureDate = exposure.date
// and reset the didOpenLeitfaden flag
UserStorage.shared.didOpenLeitfaden = false

break
}
Expand Down Expand Up @@ -256,8 +258,8 @@ class TracingLocalPush: NSObject, LocalPushProtocol {
let calendar = Calendar.current
let components = calendar.dateComponents([.hour], from: now)
guard let hour = components.hour,
hour > 7,
hour < 23 else {
hour > 7,
hour < 23 else {
return
}

Expand Down
27 changes: 13 additions & 14 deletions DP3TApp/Logic/Tracing/UIState/UIStateLogic.swift
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ class UIStateLogic {
}

if let first = manager.firstSyncErrorTime,
let last = manager.lastSyncErrorTime,
last.timeIntervalSince(first) > manager.syncProblemInterval {
let last = manager.lastSyncErrorTime,
last.timeIntervalSince(first) > manager.syncProblemInterval {
newState.homescreen.reports.syncProblemNetworkingError = true
if let codedError = UIStateManager.shared.syncError {
newState.homescreen.reports.errorTitle = codedError.errorTitle
Expand All @@ -159,7 +159,7 @@ class UIStateLogic {

private func setInfoBoxState(_ newState: inout UIStateModel) {
if let infoBox = ConfigManager.currentConfig?.infoBox?.value,
infoBox.infoId == nil || !NSInfoBoxVisibilityManager.shared.dismissedInfoBoxIds.contains(infoBox.infoId!) {
infoBox.infoId == nil || !NSInfoBoxVisibilityManager.shared.dismissedInfoBoxIds.contains(infoBox.infoId!) {
newState.homescreen.infoBox = UIStateModel.Homescreen.InfoBox(title: infoBox.title,
text: infoBox.msg,
link: infoBox.urlTitle,
Expand Down Expand Up @@ -190,15 +190,11 @@ class UIStateLogic {

private func setLastReportState(_ newState: inout UIStateModel) {
if let report = newState.reportsDetail.reports.first {
newState.shouldStartAtReportsDetail = UserStorage.shared.lastPhoneCall(for: report.identifier) == nil
newState.shouldStartAtReportsDetail = !UserStorage.shared.didOpenLeitfaden
newState.homescreen.reports.lastReport = report.timestamp
newState.reportsDetail.showReportWithAnimation = !UserStorage.shared.hasSeenMessage(for: report.identifier)

if UserStorage.shared.lastPhoneCall(for: report.identifier) != nil {
newState.reportsDetail.phoneCallState = .calledAfterLastExposure
} else {
newState.reportsDetail.phoneCallState = .notCalled
}
newState.reportsDetail.didOpenLeitfaden = UserStorage.shared.didOpenLeitfaden
}
}

Expand Down Expand Up @@ -227,10 +223,13 @@ class UIStateLogic {
}
}

static let randIdentifier1 = UUID()
static let randIdentifier2 = UUID()
static let randDate1 = Date(timeIntervalSinceNow: -10000)
static let randDate2 = Date(timeIntervalSinceNow: -100_000)
static var identifiers: [UUID] = {
var identifiers = [UUID]()
for _ in 0 ... 20 {
identifiers.append(.init())
}
return identifiers
}()

private func setDebugReports(_ newState: inout UIStateModel) {
// in case the infection state is overwritten, we need to
Expand All @@ -253,7 +252,7 @@ class UIStateLogic {
newState.reportsDetail.reports = []

for i in 0 ..< count {
newState.reportsDetail.reports.append(UIStateModel.ReportsDetail.NSReportModel(identifier: UUID(), timestamp: Date(timeIntervalSinceNow: Double(i * 60 * 60 * 24 * -1))))
newState.reportsDetail.reports.append(UIStateModel.ReportsDetail.NSReportModel(identifier: Self.identifiers[i], timestamp: Date(timeIntervalSinceNow: Double(i * 60 * 60 * 24 * -1))))
}

newState.shouldStartAtReportsDetail = true
Expand Down
2 changes: 1 addition & 1 deletion DP3TApp/Logic/Tracing/UIState/UIStateModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ struct UIStateModel: Equatable {
struct ReportsDetail: Equatable {
var report: ReportState = .noReport
var reports: [NSReportModel] = []
var phoneCallState: PhoneCallState = .notCalled
var didOpenLeitfaden: Bool = false
var showReportWithAnimation: Bool = false

struct NSReportModel: Equatable {
Expand Down
31 changes: 3 additions & 28 deletions DP3TApp/Logic/User/UserStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,47 +20,22 @@ class UserStorage {
}
}

func registerPhoneCall(identifier: UUID) {
var lastPhoneCalls = self.lastPhoneCalls
// we only want the last
lastPhoneCalls.removeAll()
lastPhoneCalls["\(identifier.uuidString)"] = Date()

self.lastPhoneCalls = lastPhoneCalls

UIStateManager.shared.userCalledInfoLine()
}

func registerSeenMessages(identifier: UUID) {
seenMessages.append("\(identifier.uuidString)")
}

var lastPhoneCallDate: Date? {
let allDates = lastPhoneCalls.values

return allDates.sorted().last
}

func lastPhoneCall(for identifier: UUID) -> Date? {
if lastPhoneCalls.keys.contains("\(identifier.uuidString)") {
return lastPhoneCalls["\(identifier)"]
}

return nil
}

func hasSeenMessage(for identifier: UUID) -> Bool {
return seenMessages.contains("\(identifier.uuidString)")
}

@KeychainPersisted(key: "lastPhoneCalls", defaultValue: [:])
private var lastPhoneCalls: [String: Date]
@KeychainPersisted(key: "didOpenLeitfaden", defaultValue: false)
var didOpenLeitfaden: Bool

@KeychainPersisted(key: "seenMessages", defaultValue: [])
private var seenMessages: [String]
}

class KeychainMigration {
enum KeychainMigration {
@KeychainPersisted(key: "didMigrateToKeychain", defaultValue: false)
static var didMigrateToKeychain: Bool

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "ic-infoline.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class NSDebugDatabaseUploadHelper {
let fileUrl = documentsDirectory.appendingPathComponent("DP3T_tracing_db").appendingPathExtension("sqlite")

guard let databaseData = try? Data(contentsOf: fileUrl),
let url = URL(string: "https://dp3tdemoupload.azurewebsites.net/upload") else {
let url = URL(string: "https://dp3tdemoupload.azurewebsites.net/upload") else {
completion?(.failure(UploadError(message: "Couldn't read file")))
return
}
Expand Down
2 changes: 2 additions & 0 deletions DP3TApp/Screens/Debugscreen/NSDebugScreenMockView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@
private func select(_ checkBox: NSCheckBoxView) {
let stateManager = UIStateManager.shared

UserStorage.shared.didOpenLeitfaden = false

if let index = checkboxes.firstIndex(of: checkBox) {
switch index {
case 1:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ class NSHomescreenViewController: NSTitleViewScrollViewController {
infoBoxView.uiState = state.homescreen.infoBox

if let infoId = state.homescreen.infoBox?.infoId,
state.homescreen.infoBox?.isDismissible == true {
state.homescreen.infoBox?.isDismissible == true {
infoBoxView.closeButtonTouched = { [weak infoBoxView] in
NSInfoBoxVisibilityManager.shared.dismissedInfoBoxIds.append(infoId)
UIView.animate(withDuration: 0.3) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class NSReportsModuleView: NSModuleBaseView {

private let noPushView = NSTracingErrorView(model: NSTracingErrorView.NSTracingErrorViewModel(icon: UIImage(named: "ic-push-disabled")!, title: "push_deactivated_title".ub_localized, text: "push_deactivated_text".ub_localized, buttonTitle: "push_open_settings_button".ub_localized, action: { _ in
guard let settingsUrl = URL(string: UIApplication.openSettingsURLString),
UIApplication.shared.canOpenURL(settingsUrl) else { return }
UIApplication.shared.canOpenURL(settingsUrl) else { return }

UIApplication.shared.open(settingsUrl)
}))
Expand Down Expand Up @@ -140,7 +140,7 @@ class NSReportsModuleView: NSModuleBaseView {
}
case .exposed:
views.append(exposedView)
views.append(NSMoreInfoView(line1: "exposed_info_contact_hotline".ub_localized, line2: "exposed_info_contact_hotline_name".ub_localized))
views.append(NSMoreInfoView(line1: "exposed_info_answer_questions_in_leitfaden".ub_localized, line2: "exposed_info_swisscovid_leitfaden".ub_localized))
if let lastReport = reportsState.lastReport {
let container = UIView()
let dateLabel = NSLabel(.date, textColor: .ns_blue)
Expand Down
Loading

0 comments on commit f5cbf55

Please sign in to comment.