Skip to content

Commit 1176a1e

Browse files
authored
Merge pull request #118 from ProteGO-Safe/release/4.5.0
Release/4.5.0
2 parents 7162854 + 1e36987 commit 1176a1e

File tree

334 files changed

+472
-7023
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

334 files changed

+472
-7023
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ safesafe/resources/Stage/GoogleService-Info.plist
4444
safesafe/resources/Dev/Config-dev.plist
4545
safesafe/resources/Stage/Config-stage.plist
4646

47+
safesafe/Resources/pwa
48+
4749
## Xcodegen
4850
*.xcodeproj
4951
*.xcworkspace

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ All notable changes to this project will be documented in this file.
66
The format is based on [Keep a Changelog](http://keepachangelog.com/)
77
and this project adheres to [Semantic Versioning](http://semver.org/).
88

9+
## 4.5.0
10+
- Manage user diagnosis keys share rejection
11+
- Prevents url requests caching
12+
- Added webkit local storage dump for debug panel in stage builds
13+
- Translations update
14+
- Fix for language reset on data erase
15+
- Added PWA to .gitignore file according to download it on CI/CD
16+
917
## 4.4.0
1018
- Added translations for English and Ukrainian languages
1119
- Ability of change language in app runtime

CONTRIBUTORS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,5 @@
3030
| Oleksandr Katrych | [OKatrych](https://github.com/OKatrych) | android |
3131
| Wojciech Brydak | [wbrydak](https://github.com/wbrydak) | specs |
3232
| Damian Klimas | [D4mK](https://github.com/D4mK) | specs, legal |
33+
| Kamil Gałuszka | [galuszkak](https://github.com/galuszkak) | android, web |
34+
| Piotr Konieczny | [piotr-cz](https://github.com/piotr-cz) | web |

Podfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,4 +206,4 @@ SPEC CHECKSUMS:
206206

207207
PODFILE CHECKSUM: 3b4c80f3b7969f193f8dc8c1f1db0378d6243a8c
208208

209-
COCOAPODS: 1.9.1
209+
COCOAPODS: 1.9.3

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,14 @@ To launch it, type `sh rebuild.sh` in your console.
7474

7575
## ChangeLog
7676

77+
**4.5.0**
78+
- Manage user diagnosis keys share rejection
79+
- Prevents url requests caching
80+
- Added webkit local storage dump for debug panel in stage builds
81+
- Translations update
82+
- Fix for language reset on data erase
83+
- Added PWA to .gitignore file according to download it on CI/CD
84+
7785
**4.4.0**
7886
- Added translations for English and Ukrainian languages
7987
- Ability of change language in app runtime

project.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ configs:
1212

1313
settings:
1414
CODE_SIGN_STYLE: Manual
15-
MARKETING_VERSION: "4.4.0"
15+
MARKETING_VERSION: "4.5.0"
1616
CURRENT_PROJECT_VERSION: 650
1717

1818
schemes:

safesafe/Common/Error/InternalError.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,6 @@ enum InternalError: Error {
5454
// Uplod
5555
case uploadValidation
5656

57+
// Get diagnosis keys
58+
case shareKeysUserCanceled
5759
}
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
//
2+
// DebugTextPreviewViewController.swift
3+
// safesafe
4+
//
5+
// Created by Lukasz szyszkowski on 07/10/2020.
6+
//
7+
8+
import UIKit
9+
10+
final class DebugTextPreviewViewController: UIViewController {
11+
12+
private enum Constants {
13+
static let closeButtonInsets = UIEdgeInsets(top: 20.0, left: 20.0, bottom: .zero, right: .zero)
14+
static let closeButtonSize = CGSize(width: 22.0, height: 22.0)
15+
static let titleLabelInsets = UIEdgeInsets(top: 20, left: .zero, bottom: 15.0, right: .zero)
16+
static let titleFont: UIFont = .systemFont(ofSize: 18.0, weight: .bold)
17+
static let textViewFont: UIFont = .systemFont(ofSize: 12)
18+
}
19+
20+
private let closeButton = UIButton()
21+
private let titleLabel = UILabel()
22+
private let textView = UITextView()
23+
private let text: String
24+
25+
required init?(coder: NSCoder) {
26+
fatalError("has not been implemented yet")
27+
}
28+
29+
init(with text: String) {
30+
self.text = text
31+
super.init(nibName: nil, bundle: nil)
32+
}
33+
34+
override func viewDidLoad() {
35+
super.viewDidLoad()
36+
37+
setup()
38+
layout()
39+
}
40+
41+
override func viewWillAppear(_ animated: Bool) {
42+
super.viewWillAppear(animated)
43+
textView.text = text
44+
}
45+
46+
private func setup() {
47+
view.backgroundColor = .white
48+
view.addSubview(textView)
49+
setupCloseButton()
50+
setupTitleLabel()
51+
setupTextView()
52+
}
53+
54+
private func setupCloseButton() {
55+
closeButton.translatesAutoresizingMaskIntoConstraints = false
56+
closeButton.setImage(#imageLiteral(resourceName: "close_icon"), for: .normal)
57+
closeButton.tintColor = .black
58+
closeButton.addTarget(self, action: #selector(closeButtonTap), for: .touchUpInside)
59+
view.addSubview(closeButton)
60+
}
61+
62+
private func setupTitleLabel() {
63+
titleLabel.translatesAutoresizingMaskIntoConstraints = false
64+
titleLabel.textColor = .black
65+
titleLabel.font = Constants.titleFont
66+
titleLabel.textAlignment = .center
67+
titleLabel.text = DebugViewModel.Texts.previewTitle
68+
view.addSubview(titleLabel)
69+
}
70+
71+
private func setupTextView() {
72+
textView.font = Constants.textViewFont
73+
view.addSubview(textView)
74+
}
75+
76+
private func layout() {
77+
closeButton.snp.makeConstraints { maker in
78+
maker.size.equalTo(Constants.closeButtonSize)
79+
maker.left.top.equalToSuperview().inset(Constants.closeButtonInsets)
80+
}
81+
82+
titleLabel.snp.makeConstraints { maker in
83+
maker.centerX.equalToSuperview()
84+
maker.top.equalToSuperview().inset(Constants.titleLabelInsets)
85+
}
86+
87+
textView.snp.makeConstraints { maker in
88+
maker.leading.trailing.bottom.equalToSuperview()
89+
maker.top.equalTo(titleLabel.snp.bottom)
90+
}
91+
}
92+
93+
@objc private func closeButtonTap(sender: UIButton) {
94+
dismiss(animated: true)
95+
}
96+
97+
}

safesafe/Components/Debug/DebugViewController.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ final class DebugViewController: ViewController<DebugViewModel> {
8181
private func setupStackedItems() {
8282
stackButton(DebugViewModel.Texts.shareUploadedPayloadsTitle, action: .uploadedPayloadsShare)
8383
stackButton(DebugViewModel.Texts.shareLogsTitle, action: .logsShare)
84+
stackButton(DebugViewModel.Texts.dumpLocalStorageTitl, action: .dumpLocalstorage)
8485
}
8586

8687
private func stackButton(_ title: String, action: DebugAction) {
@@ -140,4 +141,21 @@ extension DebugViewController: DebugViewModelDelegate {
140141
let activityController = UIActivityViewController(activityItems: [fileURL], applicationActivities: nil)
141142
present(activityController, animated: true)
142143
}
144+
145+
func showTextPreview(text: String) {
146+
let preview = DebugTextPreviewViewController(with: text)
147+
present(preview, animated: true)
148+
}
149+
150+
func showLocalStorageFiles(list: [String]) {
151+
let alertController = UIAlertController(title: "Pick storage", message: nil, preferredStyle: .actionSheet)
152+
for item in list {
153+
let action = UIAlertAction(title: item, style: .default) { [weak self] _ in
154+
self?.viewModel.openLocalStorage(with: item)
155+
}
156+
alertController.addAction(action)
157+
}
158+
159+
present(alertController, animated: true)
160+
}
143161
}

safesafe/Components/Debug/DebugViewModel.swift

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,28 @@ enum DebugAction {
1313
case uploadedPayloadsShare
1414
case uploadedPayloadsPreview
1515
case logsShare
16+
case dumpLocalstorage
1617
}
1718

1819
protocol DebugViewModelDelegate: class {
1920
func sharePayloads(fileURL: URL)
2021
func shareLogs(fileURL: URL)
22+
func showTextPreview(text: String)
23+
func showLocalStorageFiles(list: [String])
2124
}
2225

2326
final class DebugViewModel: ViewModelType {
2427
weak var delegate: DebugViewModelDelegate?
28+
private lazy var sqliteManager = SQLiteManager()
2529

2630
enum Texts {
2731
static let title = "Debug"
32+
static let previewTitle = "Preview"
2833
static let noUploadedPayloadsTitle = "No Uploaded Payloads Yet"
2934
static let shareUploadedPayloadsTitle = "Share Uploaded Payloads"
3035
static let noLogsTitle = "Nothing logged yet"
3136
static let shareLogsTitle = "Share Logs"
37+
static let dumpLocalStorageTitl = "Dump Local Storage"
3238
}
3339

3440
var numberOfPayloads: Int {
@@ -59,8 +65,28 @@ final class DebugViewModel: ViewModelType {
5965
case .logsShare:
6066
guard let url = try? File.logFileURL() else { return }
6167
delegate?.shareLogs(fileURL: url)
68+
case .dumpLocalstorage:
69+
let list = localStorageFiles()
70+
guard !list.isEmpty else { return }
71+
72+
delegate?.showLocalStorageFiles(list: list)
6273
default: ()
6374
}
6475
}
6576

77+
func openLocalStorage(with name: String) {
78+
delegate?.showTextPreview(text: sqliteManager.read(fileName: name))
79+
}
80+
81+
private func localStorageFiles() -> [String] {
82+
do {
83+
let dirURL = try Directory.webkitLocalStorage()
84+
let dirContent = try FileManager.default.contentsOfDirectory(atPath: dirURL.path).filter({ $0.hasSuffix("localstorage")})
85+
86+
return dirContent
87+
88+
} catch { console(error, type: .error) }
89+
90+
return []
91+
}
6692
}

0 commit comments

Comments
 (0)