Commit 00f03b65 authored by Olev Abel's avatar Olev Abel
Browse files

Merge branch 'feature/COVAPP-525-crash-on-SDK-reset' into develop

parents 73a27106 5ace32ab
......@@ -15,4 +15,21 @@ extension UIStackView {
func removeAllArrangedSubviews() {
arrangedSubviews.forEach { $0.removeFromSuperview() }
}
func setStackBackground(color: UIColor) {
if #available(iOS 14.0, *) {
self.backgroundColor = color
return
}
guard let backgroundView = subviews.first(where: { $0.tag == 200 }) else {
UIView().adjust {
$0.tag = 200
$0.backgroundColor = color
$0.fill(view: self)
sendSubviewToBack($0)
}
return
}
backgroundView.backgroundColor = color
}
}
......@@ -43,8 +43,8 @@ private extension HomeView {
func setupHeaderViews() {
let vStack = UIStackView().adjust {
$0.axis = .vertical
$0.backgroundColor = Asset.estonianBlue.color
headerStack = $0
$0.setStackBackground(color: Asset.estonianBlue.color)
}
HeaderView().adjust {
......@@ -178,7 +178,7 @@ extension HomeView {
}
contentView.update(fill: header.backgroundColor)
headerStack.backgroundColor = header.backgroundColor
headerStack.setStackBackground(color: header.backgroundColor)
if !animated {
headerView.setup(icon: header.icon, title: header.title)
......
......@@ -28,7 +28,7 @@ final class ConfirmInfectionDeviceView: CustomView {
override func style() {
super.style()
backgroundColor = Asset.pahkla.color
stackView.backgroundColor = .white
stackView.setStackBackground(color: .white)
}
}
......
......@@ -19,22 +19,9 @@ class TracingManager: NSObject {
static let shared = TracingManager()
let uiStateManager = UIStateManager()
var isSDKInitialized = false
private var isSDKInitialized = false
let databaseSyncer = DatabaseSyncer()
@UBUserDefault(key: "tracingIsActivated", defaultValue: true)
public var isActivated: Bool {
didSet {
if isActivated {
beginUpdates()
startTracingFromSettingsToggle()
} else {
endTracing()
}
UIStateManager.shared.changedTracingActivated()
}
}
private override init() {}
func initialize() {
......@@ -123,6 +110,20 @@ class TracingManager: NSObject {
)
}
func isCloseContactAPIActived() -> Bool {
DP3TTracing.status.trackingState == .active
}
func setTracingState(isActive: Bool) {
if isActive {
beginUpdates()
startTracingFromSettingsToggle()
} else {
endTracing()
}
UIStateManager.shared.onTracingStateChange()
}
private func startTracingFromSettingsToggle() {
startTracing()
}
......@@ -153,12 +154,12 @@ class TracingManager: NSObject {
DP3TTracing.stopTracing()
}
func resetSDK() {
func resetSDKData() {
// completely reset SDK
DP3TTracing.reset()
isSDKInitialized = false
DP3TTracing.resetExposureDays()
DP3TTracing.resetInfectionStatus()
endTracing()
// reset debugi fake data to test UI reset
#if DEBUG || ENABLE_TESTING
UIStateManager.shared.overwrittenInfectionState = nil
#endif
......
......@@ -28,7 +28,7 @@ class UIStateLogic {
setErrorStates(&newState, tracing: &tracing)
// Set tracing active
newState.begegnungenDetail.tracingEnabled = TracingManager.shared.isActivated
newState.begegnungenDetail.tracingEnabled = TracingManager.shared.isCloseContactAPIActived()
newState.begegnungenDetail.tracing = tracing
// Get state of SDK tracing
......
......@@ -195,10 +195,10 @@ class UIStateManager: NSObject {
#endif
var tracingIsActivated: Bool {
TracingManager.shared.isActivated
TracingManager.shared.isCloseContactAPIActived()
}
func changedTracingActivated() {
func onTracingStateChange() {
refresh()
}
......
......@@ -33,7 +33,6 @@ final class MyDataView: CustomView {
override func style() {
super.style()
backgroundColor = Asset.pahkla.color
stackView.backgroundColor = .white
}
}
......@@ -109,6 +108,7 @@ private extension MyDataView {
vertical: LayoutStyle.Margin.large)
$0.setCustomSpacing(StackViewStyle.Spacing.mediumLarge, after: subtitleLabel)
$0.setCustomSpacing(StackViewStyle.Spacing.large, after: privacyPolicyLabel)
$0.setStackBackground(color: .white)
contentView.setBottom(view: $0)
stackView = $0
}
......
......@@ -9,8 +9,7 @@ final class MyDataViewModel {
}
private func eraseData() {
TracingManager.shared.resetSDK()
TracingManager.shared.initialize()
TracingManager.shared.resetSDKData()
TracingManager.shared.beginUpdates()
coordinator.displayMyDataErasedAlert()
}
......
"title" = "Are you using your representatives phone?";
"description1" = "Make sure that you are using your representatives phone and HOIA app you want to mark as infected.";
"description2" = "Otherwise sending anonymous notifications through HOIA app will not work properly.";
"continueInfectionConfirmation" = "Continue infection confirmation";
"continueInfectionConfirmation" = "Continue";
"footer.link" = "What is the right of representation?";
"title" = "Вы пользуетесь телефоном своего представляемого?";
"description1" = "Убедитесь, что вы используете телефон своего представляемого и приложение HOIA, которое хотите отметить как зараженное.";
"description2" = "В противном случае отправка анонимных уведомлений через приложение HOIA не будет работать должным образом.";
"continueInfectionConfirmation" = "Продолжить подтверждение заражения";
"continueInfectionConfirmation" = "Продолжить";
"footer.link" = "Что такое право представительства?";
......@@ -20,7 +20,7 @@ class SettingsViewModel {
init(coordinator: HomeCoordinator, permissionService: PermissionService) {
self.coordinator = coordinator
self.permissionService = permissionService
isTracingOn = TracingManager.shared.isActivated
isTracingOn = TracingManager.shared.isCloseContactAPIActived()
}
func notificationsAction() {
......@@ -36,9 +36,7 @@ class SettingsViewModel {
}
func tracingAction(isOn: Bool) {
if TracingManager.shared.isActivated != isOn {
TracingManager.shared.isActivated = isOn
}
TracingManager.shared.setTracingState(isActive: isOn)
}
func notificationAuthStatusChanged(status: UNAuthorizationStatus) {
......
......@@ -53,7 +53,7 @@ private extension UpdateOSView {
func setupHeaderView() {
let vStack = UIStackView().adjust {
$0.axis = .vertical
$0.backgroundColor = Asset.pink.color
$0.setStackBackground(color: Asset.pink.color)
}
HeaderView().adjust {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment