Skip to content

Commit

Permalink
Merge branch 'release/2.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
tobihagemann committed Mar 21, 2022
2 parents 8512085 + d6c426e commit 6a50773
Show file tree
Hide file tree
Showing 157 changed files with 3,444 additions and 2,878 deletions.
177 changes: 98 additions & 79 deletions Cryptomator.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@
"version": "1.4.0"
}
},
{
"package": "ASN1Swift",
"repositoryURL": "https://github.com/tikhop/ASN1Swift",
"state": {
"branch": null,
"revision": "b53bee03a942623db25afc5bfb80227b2cb3b425",
"version": "1.2.4"
}
},
{
"package": "Base32",
"repositoryURL": "https://github.com/norio-nomura/Base32.git",
Expand All @@ -24,8 +33,8 @@
"repositoryURL": "https://github.com/cryptomator/cloud-access-swift.git",
"state": {
"branch": null,
"revision": "09453b28d986dc52b038640be763818fecb633cb",
"version": "1.1.6"
"revision": "1db22e4ea17c85eaa98bfabf1fbf699fcf6e94e0",
"version": "1.2.0"
}
},
{
Expand All @@ -51,17 +60,17 @@
"repositoryURL": "https://github.com/phil1995/dropbox-sdk-obj-c.git",
"state": {
"branch": null,
"revision": "f74da6cf58dfe078e1ddafa0673b69fa9d32de1a",
"version": "6.2.0-fork"
"revision": "9d390f1cbae0f77066117f9b97370735914875b0",
"version": "6.2.3-fork"
}
},
{
"package": "GoogleAPIClientForREST",
"repositoryURL": "https://github.com/google/google-api-objectivec-client-for-rest.git",
"state": {
"branch": null,
"revision": "a0a0826501a4075a5dcb7ad59ecd97a1f2422c32",
"version": "1.5.2"
"revision": "3228334d0584cb9174796fecbe628a723be70452",
"version": "1.7.0"
}
},
{
Expand All @@ -78,8 +87,8 @@
"repositoryURL": "https://github.com/google/gtm-session-fetcher.git",
"state": {
"branch": null,
"revision": "91ed3d188eb95705fef3c249453b81f32dc557d1",
"version": "1.5.0"
"revision": "bc6a19702ac76ac4e488b68148710eb815f9bc56",
"version": "1.7.0"
}
},
{
Expand All @@ -105,8 +114,8 @@
"repositoryURL": "https://github.com/AzureAD/microsoft-authentication-library-for-objc.git",
"state": {
"branch": null,
"revision": "14a1750834d13567de1a4afb0fa148a22bd7ddbf",
"version": "1.1.25"
"revision": "2825c3f72bf51f8be43df7177fe1c66370be2d0e",
"version": "1.2.0"
}
},
{
Expand All @@ -127,6 +136,15 @@
"version": "1.3.0-fork"
}
},
{
"package": "PCloudSDKSwift",
"repositoryURL": "https://github.com/pCloud/pcloud-sdk-swift.git",
"state": {
"branch": null,
"revision": "6da4ca6bb4e7068145d9325988e29862d26300ba",
"version": "3.2.0"
}
},
{
"package": "Promises",
"repositoryURL": "https://github.com/google/promises.git",
Expand All @@ -144,6 +162,15 @@
"revision": "5d66f7ba25daf4f94100e7022febf3c75e37a6c7",
"version": "1.4.2"
}
},
{
"package": "TPInAppReceipt",
"repositoryURL": "https://github.com/tikhop/TPInAppReceipt.git",
"state": {
"branch": null,
"revision": "2b9946f8fe2dd74ed87dfcb5dbedc3be06c5ccab",
"version": "3.3.3"
}
}
]
},
Expand Down
32 changes: 8 additions & 24 deletions Cryptomator/AddVault/AddVaultCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,32 +115,16 @@ private class AddVaultPurchaseCoordinator: PurchaseCoordinator, PoppingCloseCoor
popToOldTopViewController()
}

override func getUpgradeCoordinator() -> UpgradeCoordinator {
return AddVaultUpgradeCoordinator(navigationController: navigationController, oldTopViewController: oldTopViewController)
override func getUpgradeCoordinator() -> PurchaseCoordinator {
return self
}
}

private class AddVaultUpgradeCoordinator: UpgradeCoordinator, PoppingCloseCoordinator {
let oldTopViewController: UIViewController?

init(navigationController: UINavigationController, oldTopViewController: UIViewController?) {
self.oldTopViewController = oldTopViewController
super.init(navigationController: navigationController)
}

override func close() {
popToOldTopViewController()
}

override func start() {
let upgradeViewController = UpgradeViewController(viewModel: SettingsUpgradeViewModel())
upgradeViewController.coordinator = self
navigationController.pushViewController(upgradeViewController, animated: true)
}
}

private class CreateNewVaultPurchaseViewModel: SettingsPurchaseViewModel {
override var headerTitle: String {
return LocalizedString.getValue("addVault.createNewVault.purchase")
private class CreateNewVaultPurchaseViewModel: PurchaseViewModel {
override var infoText: NSAttributedString? {
.textWithLeadingSystemImage("info.circle.fill",
text: LocalizedString.getValue("addVault.createNewVault.purchase"),
font: .preferredFont(forTextStyle: .body),
color: .secondaryLabel)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class CreateNewVaultCoordinator: AccountListing, CloudChoosing, Coordinator {
}

func start() {
let viewModel = ChooseCloudViewModel(clouds: [.localFileSystem(type: .iCloudDrive), .dropbox, .googleDrive, .oneDrive, .webDAV(type: .custom), .localFileSystem(type: .custom)], headerTitle: LocalizedString.getValue("addVault.createNewVault.chooseCloud.header"))
let viewModel = ChooseCloudViewModel(clouds: [.localFileSystem(type: .iCloudDrive), .dropbox, .googleDrive, .oneDrive, .pCloud, .webDAV(type: .custom), .localFileSystem(type: .custom)], headerTitle: LocalizedString.getValue("addVault.createNewVault.chooseCloud.header"))
let chooseCloudVC = ChooseCloudViewController(viewModel: viewModel)
chooseCloudVC.title = LocalizedString.getValue("addVault.createNewVault.title")
chooseCloudVC.coordinator = self
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class OpenExistingVaultCoordinator: AccountListing, CloudChoosing, Coordinator {
}

func start() {
let viewModel = ChooseCloudViewModel(clouds: [.localFileSystem(type: .iCloudDrive), .dropbox, .googleDrive, .oneDrive, .webDAV(type: .custom), .localFileSystem(type: .custom)], headerTitle: LocalizedString.getValue("addVault.openExistingVault.chooseCloud.header"))
let viewModel = ChooseCloudViewModel(clouds: [.localFileSystem(type: .iCloudDrive), .dropbox, .googleDrive, .oneDrive, .pCloud, .webDAV(type: .custom), .localFileSystem(type: .custom)], headerTitle: LocalizedString.getValue("addVault.openExistingVault.chooseCloud.header"))
let chooseCloudVC = ChooseCloudViewController(viewModel: viewModel)
chooseCloudVC.title = LocalizedString.getValue("addVault.openExistingVault.title")
chooseCloudVC.coordinator = self
Expand Down
4 changes: 4 additions & 0 deletions Cryptomator/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
return false
}

func applicationDidBecomeActive(_ application: UIApplication) {
PremiumManager.shared.refreshStatus()
}

func applicationWillTerminate(_ application: UIApplication) {
SKPaymentQueue.default().remove(StoreObserver.shared)
}
Expand Down
23 changes: 23 additions & 0 deletions Cryptomator/Common/AutoHidingLabel.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// AutoHidingLabel.swift
// Cryptomator
//
// Created by Philipp Schmid on 07.03.22.
// Copyright © 2022 Skymatic GmbH. All rights reserved.
//

import UIKit

class AutoHidingLabel: UILabel {
override var text: String? {
didSet {
isHidden = text == nil && attributedText == nil
}
}

override var attributedText: NSAttributedString? {
didSet {
isHidden = text == nil && attributedText == nil
}
}
}
28 changes: 28 additions & 0 deletions Cryptomator/Common/CloudAccountList/AccountListViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ class AccountListViewModel: AccountListViewModelProtocol {
}
}

func refreshPCloudItems() -> Promise<Void> {
return all(accountInfos
.compactMap { try? PCloudCredential(userID: $0.accountUID) }
.map { self.createAccountCellContent(for: $0) }
).then { accounts in
self.accounts = accounts
}
}

func createAccountCellContent(from accountInfo: AccountInfo) throws -> AccountCellContent {
switch cloudProviderType {
case .dropbox:
Expand All @@ -66,6 +75,9 @@ class AccountListViewModel: AccountListViewModelProtocol {
case .oneDrive:
let credential = try OneDriveCredential(with: accountInfo.accountUID)
return try createAccountCellContent(for: credential)
case .pCloud:
let credential = try PCloudCredential(userID: accountInfo.accountUID)
return createAccountCellContentPlaceholder(for: credential)
case .webDAV:
guard let credential = WebDAVAuthenticator.getCredentialFromKeychain(with: accountInfo.accountUID) else {
throw CloudProviderAccountError.accountNotFoundError
Expand Down Expand Up @@ -96,6 +108,16 @@ class AccountListViewModel: AccountListViewModelProtocol {
return AccountCellContent(mainLabelText: username, detailLabelText: nil)
}

func createAccountCellContent(for credential: PCloudCredential) -> Promise<AccountCellContent> {
return credential.getUsername().then { username in
AccountCellContent(mainLabelText: username, detailLabelText: nil)
}
}

private func createAccountCellContentPlaceholder(for credential: PCloudCredential) -> AccountCellContent {
return AccountCellContent(mainLabelText: "(…)", detailLabelText: nil)
}

func createAccountCellContent(for credential: WebDAVCredential) -> AccountCellContent {
let detailLabelText: String
let path = credential.baseURL.path
Expand Down Expand Up @@ -153,6 +175,12 @@ class AccountListViewModel: AccountListViewModelProtocol {
}.catch { error in
self.databaseChangedPublisher.send(.failure(error))
}
} else if self.cloudProviderType == .pCloud, !self.removedRow {
self.refreshPCloudItems().then {
self.databaseChangedPublisher.send(.success(self.accounts))
}.catch { error in
self.databaseChangedPublisher.send(.failure(error))
}
}
})
return databaseChangedPublisher.eraseToAnyPublisher()
Expand Down
15 changes: 15 additions & 0 deletions Cryptomator/Common/CloudAuthenticator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ class CloudAuthenticator {
}
}

func authenticatePCloud(from viewController: UIViewController) -> Promise<CloudProviderAccount> {
let authenticator = PCloudAuthenticator(appKey: CloudAccessSecrets.pCloudAppKey)
return authenticator.authenticate(from: viewController).then { credential -> CloudProviderAccount in
try credential.saveToKeychain()
let account = CloudProviderAccount(accountUID: credential.userID, cloudProviderType: .pCloud)
try self.accountManager.saveNewAccount(account)
return account
}
}

func authenticateWebDAV(from viewController: UIViewController) -> Promise<CloudProviderAccount> {
return WebDAVAuthenticator.authenticate(from: viewController).then { credential -> CloudProviderAccount in
let account = CloudProviderAccount(accountUID: credential.identifier, cloudProviderType: .webDAV(type: .custom))
Expand All @@ -64,6 +74,8 @@ class CloudAuthenticator {
return authenticateGoogleDrive(from: viewController)
case .oneDrive:
return authenticateOneDrive(from: viewController)
case .pCloud:
return authenticatePCloud(from: viewController)
case .webDAV:
return authenticateWebDAV(from: viewController)
case .localFileSystem:
Expand All @@ -82,6 +94,9 @@ class CloudAuthenticator {
case .oneDrive:
let credential = try OneDriveCredential(with: account.accountUID)
try credential.deauthenticate()
case .pCloud:
let credential = try PCloudCredential(userID: account.accountUID)
try credential.deauthenticate()
case .webDAV:
try WebDAVAuthenticator.removeCredentialFromKeychain(with: account.accountUID)
case .localFileSystem:
Expand Down
2 changes: 2 additions & 0 deletions Cryptomator/Common/CloudProviderType+Localization.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ extension CloudProviderType {
return "Google Drive"
case .oneDrive:
return "OneDrive"
case .pCloud:
return "pCloud"
case .webDAV:
return "WebDAV"
case let .localFileSystem(localFileSystemType):
Expand Down
26 changes: 26 additions & 0 deletions Cryptomator/Common/NSAttributedString+Extension.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// NSAttributedString+Extension.swift
// Cryptomator
//
// Created by Philipp Schmid on 09.03.22.
// Copyright © 2022 Skymatic GmbH. All rights reserved.
//

import UIKit

extension NSAttributedString {
static func textWithLeadingSystemImage(_ imageName: String, text: String, font: UIFont, color: UIColor) -> NSAttributedString {
let configuration = UIImage.SymbolConfiguration(font: font)
let imageAttachment = NSTextAttachment()
imageAttachment.image = UIImage(systemName: imageName, withConfiguration: configuration)?.withTintColor(color)
let attributedString = NSMutableAttributedString(attachment: imageAttachment)
attributedString.append(NSAttributedString(string: " \(text)"))
attributedString.addAttribute(.foregroundColor,
value: color,
range: NSRange(location: 0, length: attributedString.length))
attributedString.addAttribute(.font,
value: font,
range: NSRange(location: 0, length: attributedString.length))
return attributedString
}
}
2 changes: 0 additions & 2 deletions Cryptomator/Common/Previews/UIView+Preview.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
// Copyright © 2021 Skymatic GmbH. All rights reserved.
//

#if DEBUG
import SwiftUI
import UIKit

Expand All @@ -27,4 +26,3 @@ extension UIView {
Preview(view: self)
}
}
#endif
2 changes: 0 additions & 2 deletions Cryptomator/Common/Previews/UIViewController+Preview.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
// Copyright © 2021 Skymatic GmbH. All rights reserved.
//

#if DEBUG
import SwiftUI
import UIKit

Expand All @@ -27,4 +26,3 @@ extension UIViewController {
Preview(viewController: self)
}
}
#endif
8 changes: 6 additions & 2 deletions Cryptomator/Common/UIImage+CloudProviderType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ extension UIImage {
assetName = "google-drive-vault"
case .oneDrive:
assetName = "onedrive-vault"
case .pCloud:
assetName = "pcloud-vault"
case .webDAV:
assetName = "webdav-vault"
case let .localFileSystem(localFileSystemType):
Expand Down Expand Up @@ -53,10 +55,12 @@ extension UIImage {
assetName = "google-drive"
case .oneDrive:
assetName = "onedrive"
case let .localFileSystem(localFileSystemType):
assetName = UIImage.getStorageIcon(for: localFileSystemType)
case .pCloud:
assetName = "pcloud"
case .webDAV:
assetName = "webdav"
case let .localFileSystem(localFileSystemType):
assetName = UIImage.getStorageIcon(for: localFileSystemType)
}
self.init(named: assetName)
}
Expand Down
2 changes: 1 addition & 1 deletion Cryptomator/MainCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ extension MainCoordinator: RemoveVaultDelegate {
extension MainCoordinator: StoreObserverDelegate {
func purchaseDidSucceed(transaction: PurchaseTransaction) {
switch transaction {
case .fullVersion:
case .fullVersion, .yearlySubscription:
showFullVersionAlert()
case let .freeTrial(expiresOn):
showTrialAlert(expirationDate: expiresOn)
Expand Down
Loading

0 comments on commit 6a50773

Please sign in to comment.