Skip to content

Commit

Permalink
Merge pull request #404 from DP-3T/release/1.4
Browse files Browse the repository at this point in the history
Version 1.4.0
  • Loading branch information
UBaggeler authored Mar 12, 2021
2 parents e06f642 + 501c5d3 commit 26fdf36
Show file tree
Hide file tree
Showing 108 changed files with 3,227 additions and 761 deletions.
17 changes: 10 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: build

env:
XCODE_VERSION: 'Xcode_12.4'

on:
push:
branches: [ master, develop ]
Expand All @@ -13,21 +16,21 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Switch to Xcode 12.3
run: sudo xcode-select --switch /Applications/Xcode_12.3.app
- name: Switch to Xcode ${{ env.XCODE_VERSION }}
run: sudo xcode-select --switch /Applications/${{ env.XCODE_VERSION }}.app

# Compile project and run tests
- name: Compile and run tests
run: fastlane scan --scheme "Debug"
run: fastlane test

build_release_prod:
runs-on: macOS-latest

steps:
- uses: actions/checkout@v2

- name: Switch to Xcode 12.3
run: sudo xcode-select --switch /Applications/Xcode_12.3.app
- name: Switch to Xcode ${{ env.XCODE_VERSION }}
run: sudo xcode-select --switch /Applications/${{ env.XCODE_VERSION }}.app

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

- name: Switch to Xcode 12.3
run: sudo xcode-select --switch /Applications/Xcode_12.3.app
- name: Switch to Xcode ${{ env.XCODE_VERSION }}
run: sudo xcode-select --switch /Applications/${{ env.XCODE_VERSION }}.app

# Compile "Release-Dev-Calibration" for iOS Simulator (no signing)
- name: Compile and run tests
Expand Down
23 changes: 13 additions & 10 deletions .github/workflows/distribute.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: appstore

env:
XCODE_VERSION: 'Xcode_12.4'

on:
push:
branches: [ master ]
Expand All @@ -14,8 +17,8 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Switch to Xcode 12.3
run: sudo xcode-select --switch /Applications/Xcode_12.3.app
- name: Switch to Xcode ${{ env.XCODE_VERSION }}
run: sudo xcode-select --switch /Applications/${{ env.XCODE_VERSION }}.app

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

- name: Switch to Xcode 12.3
run: sudo xcode-select --switch /Applications/Xcode_12.3.app
- name: Switch to Xcode ${{ env.XCODE_VERSION }}
run: sudo xcode-select --switch /Applications/${{ env.XCODE_VERSION }}.app

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

- name: Switch to Xcode 12.3
run: sudo xcode-select --switch /Applications/Xcode_12.3.app
- name: Switch to Xcode ${{ env.XCODE_VERSION }}
run: sudo xcode-select --switch /Applications/${{ env.XCODE_VERSION }}.app

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

- name: Switch to Xcode 12.3
run: sudo xcode-select --switch /Applications/Xcode_12.3.app
- name: Switch to Xcode ${{ env.XCODE_VERSION }}
run: sudo xcode-select --switch /Applications/${{ env.XCODE_VERSION }}.app

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

- name: Switch to Xcode 12.3
run: sudo xcode-select --switch /Applications/Xcode_12.3.app
- name: Switch to Xcode ${{ env.XCODE_VERSION }}
run: sudo xcode-select --switch /Applications/${{ env.XCODE_VERSION }}.app

- name: Installs librsvg
run: brew install librsvg
Expand Down
98 changes: 96 additions & 2 deletions DP3TApp.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@
"repositoryURL": "https://github.com/Kitura/BlueRSA.git",
"state": {
"branch": null,
"revision": "c885fcdbe1b04718cb46d747387137653c030f6c",
"version": "1.0.200"
"revision": "440f78db26d8bb073f29590f1c7bd31004da09ae",
"version": "1.0.201"
}
},
{
"package": "DP3TSDK",
"repositoryURL": "https://github.com/DP-3T/dp3t-sdk-ios.git",
"state": {
"branch": null,
"revision": "a70c27f7a06dd3eaf3fbf74069645a8a7dbcbfbd",
"revision": "a9b876ef6ba115130cd9df3b8e249bcd6faed4b3",
"version": null
}
},
Expand Down Expand Up @@ -87,17 +87,17 @@
"repositoryURL": "https://github.com/apple/swift-log.git",
"state": {
"branch": null,
"revision": "173f567a2dfec11d74588eea82cecea555bdc0bc",
"version": "1.4.0"
"revision": "5d66f7ba25daf4f94100e7022febf3c75e37a6c7",
"version": "1.4.2"
}
},
{
"package": "ZIPFoundation",
"repositoryURL": "https://github.com/weichsel/ZIPFoundation/",
"state": {
"branch": null,
"revision": "ec32d62d412578542c0ffb7a6ce34d3e64b43b94",
"version": "0.9.11"
"revision": "cf10bbff6ac3b873e97b36b9784c79866a051a8e",
"version": "0.9.12"
}
}
]
Expand Down
23 changes: 23 additions & 0 deletions DP3TApp/Logic/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
return
}

showEndIsolationPopupIfNecessary()

// if app is cold-started or comes from background > 30 minutes,
if coldStart || backgroundTime > 30.0 * 60.0 {
if !jumpToMessageIfRequired(onlyFirst: true) {
Expand Down Expand Up @@ -189,6 +191,27 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}
}

// MARK: - End isolation popup

private func showEndIsolationPopupIfNecessary() {
// If the state is not infected, never show the end isolation popup
guard let infectionStatus = TracingManager.shared.uiStateManager.tracingState?.infectionStatus, infectionStatus == .infected else {
return
}

if let questionDate = ReportingManager.shared.endIsolationQuestionDate, questionDate < Date() {
let alert = UIAlertController(title: "homescreen_isolation_ended_popup_title".ub_localized, message: "homescreen_isolation_ended_popup_text".ub_localized, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "answer_yes".ub_localized, style: .default, handler: { _ in
TracingManager.shared.deletePositiveTest()
}))
alert.addAction(UIAlertAction(title: "answer_no".ub_localized, style: .cancel, handler: { _ in
ReportingManager.shared.endIsolationQuestionDate = Date().addingTimeInterval(60 * 60 * 24) // Ask again in 1 day
}))

tabBarController.currentViewController.present(alert, animated: true, completion: nil)
}
}

// MARK: - Force update

private func startForceUpdateCheck() {
Expand Down
2 changes: 2 additions & 0 deletions DP3TApp/Logic/Config/ConfigResponseBody.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,15 @@ class ConfigResponseBody: UBCodable {
public let whatToDoPositiveTestTexts: LocalizedValue<WhatToDoPositiveTestTexts>?
public let iOSGaenSdkConfig: GAENSDKConfig?
public let testLocations: LocalizedValue<[TestLocation]>?
public let interOpsCountries: [String]

class InfoBox: UBCodable {
let title, msg: String
let url: URL?
let urlTitle: String?
let infoId: String?
let isDismissible: Bool?
let hearingImpairedInfo: String?
}

class GAENSDKConfig: Codable {
Expand Down
64 changes: 63 additions & 1 deletion DP3TApp/Logic/Statistics/StatisticsResponse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,16 @@
import Foundation

class StatisticsResponse: Codable {
let totalActiveUsers: Int?
let lastUpdated: Date

let totalActiveUsers: Int?

let totalCovidcodesEntered: Int?
let covidcodesEntered0to2dPrevWeek: Double? // Percentage, range [0, 1]

let newInfectionsSevenDayAvg: Int?
let newInfectionsSevenDayAvgRelPrevWeek: Double? // Percentage, range [-1, ∞]

let history: [StatisticEntry]

class StatisticEntry: Codable {
Expand All @@ -22,3 +30,57 @@ class StatisticsResponse: Codable {
let covidcodesEntered: Int?
}
}

extension StatisticsResponse {
private static let counterFormatter: NumberFormatter = {
let formatter = NumberFormatter()
formatter.numberStyle = .decimal
formatter.groupingSeparator = " "
return formatter
}()

private static let percentageFormatter: NumberFormatter = {
let formatter = NumberFormatter()
formatter.numberStyle = .percent
return formatter
}()

private static let positiveNegativePercentageFormatter: NumberFormatter = {
let formatter = NumberFormatter()
formatter.numberStyle = .percent
formatter.positivePrefix = "+"
return formatter
}()

var covidCodes: String? {
Self.counterFormatter.string(fromOptional: totalCovidcodesEntered)
}

var covidCodesAfter0to2d: String? {
Self.percentageFormatter.string(fromOptional: covidcodesEntered0to2dPrevWeek)
}

var newInfectionsAverage: String? {
Self.counterFormatter.string(fromOptional: newInfectionsSevenDayAvg)
}

var newInfectionsRelative: String? {
Self.positiveNegativePercentageFormatter.string(fromOptional: newInfectionsSevenDayAvgRelPrevWeek)
}
}

private extension NumberFormatter {
func string(fromOptional number: Int?) -> String? {
if let nr = number {
return string(from: nr as NSNumber)
}
return nil
}

func string(fromOptional number: Double?) -> String? {
if let nr = number {
return string(from: nr as NSNumber)
}
return nil
}
}
6 changes: 6 additions & 0 deletions DP3TApp/Logic/Tracing/Reporting/ReportingManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ class ReportingManager: ReportingManagerProtocol {

let codeValidator = CodeValidator()

@UBOptionalUserDefault(key: "endIsolationQuestionDate")
var endIsolationQuestionDate: Date?

// MARK: - API

func report(covidCode: String, isFakeRequest fake: Bool = false, completion: @escaping (ReportingProblem?) -> Void) {
Expand Down Expand Up @@ -93,6 +96,9 @@ class ReportingManager: ReportingManagerProtocol {
if let error = error {
completion(.failure(error: error))
} else {
if !fake {
self.endIsolationQuestionDate = Date().addingTimeInterval(60 * 60 * 24 * 14) // Ask if user wants to end isolation after 14 days
}
completion(nil)
}
}
Expand Down
9 changes: 8 additions & 1 deletion DP3TApp/Logic/Tracing/TracingManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ class TracingManager: NSObject {

DP3TTracing.initialize(with: descriptor,
urlSession: URLSession.certificatePinned,
backgroundHandler: self)
backgroundHandler: self,
federationGateway: .yes)

// Do not sync because applicationState is still .background
updateStatus(shouldSync: false) { _ in
Expand All @@ -123,6 +124,8 @@ class TracingManager: NSObject {
DP3TTracing.startTracing(completionHandler: { result in
switch result {
case .success:
// reset stored error when starting tracing
UIStateManager.shared.tracingStartError = nil
// When tracing is enabled trigger sync (for example after ENManager is initialized)
DatabaseSyncer.shared.forceSyncDatabase(completionHandler: nil)
case let .failure(error):
Expand Down Expand Up @@ -158,6 +161,10 @@ class TracingManager: NSObject {

func deletePositiveTest() {
guard #available(iOS 12.5, *) else { return }

// reset end isolation question date
ReportingManager.shared.endIsolationQuestionDate = nil

// reset infection status
DP3TTracing.resetInfectionStatus()

Expand Down
5 changes: 4 additions & 1 deletion DP3TApp/Logic/Tracing/UIState/UIStateLogic.swift
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ class UIStateLogic {
#endif
}
}

newState.homescreen.countries = ConfigManager.currentConfig?.interOpsCountries ?? []
}

private func setInfoBoxState(_ newState: inout UIStateModel) {
Expand All @@ -165,7 +167,8 @@ class UIStateLogic {
link: infoBox.urlTitle,
url: infoBox.url,
isDismissible: infoBox.isDismissible,
infoId: infoBox.infoId)
infoId: infoBox.infoId,
hearingImpairedInfo: infoBox.hearingImpairedInfo)
}
}

Expand Down
2 changes: 2 additions & 0 deletions DP3TApp/Logic/Tracing/UIState/UIStateModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,14 @@ struct UIStateModel: Equatable {
var url: URL?
var isDismissible: Bool?
var infoId: String?
var hearingImpairedInfo: String?
}

var header: TracingState = .tracingActive
var encounters: TracingState = .tracingActive
var reports: Reports = Reports()
var infoBox: InfoBox?
var countries: [String] = []
}

struct EncountersDetail: Equatable {
Expand Down
24 changes: 24 additions & 0 deletions DP3TApp/Logic/Travel/CountryHelper.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
/*
* Copyright (c) 2020 Ubique Innovation AG <https://www.ubique.ch>
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* SPDX-License-Identifier: MPL-2.0
*/

import UIKit

final class CountryHelper {
static func flagForCountryCode(_ code: String) -> UIImage? {
let image = UIImage(named: "flag-\(code.lowercased())")
image?.accessibilityLabel = Self.localizedNameForCountryCode(code)
return image
}

static func localizedNameForCountryCode(_ code: String) -> String {
return (NSLocale.current as NSLocale).displayName(forKey: .countryCode, value: code.lowercased()) ?? ""
}
}
Loading

0 comments on commit 26fdf36

Please sign in to comment.