mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-30 21:26:57 +02:00
merged element 1.8.10
This commit is contained in:
@@ -40,6 +40,7 @@ final class SecureBackupSetupIntroViewController: UIViewController {
|
||||
// MARK: Private
|
||||
|
||||
private var viewModel: SecureBackupSetupIntroViewModelType!
|
||||
private var cancellable: Bool!
|
||||
private var theme: Theme!
|
||||
|
||||
private var activityIndicatorPresenter: ActivityIndicatorPresenter!
|
||||
@@ -51,9 +52,10 @@ final class SecureBackupSetupIntroViewController: UIViewController {
|
||||
|
||||
// MARK: - Setup
|
||||
|
||||
class func instantiate(with viewModel: SecureBackupSetupIntroViewModelType) -> SecureBackupSetupIntroViewController {
|
||||
class func instantiate(with viewModel: SecureBackupSetupIntroViewModelType, cancellable: Bool) -> SecureBackupSetupIntroViewController {
|
||||
let viewController = StoryboardScene.SecureBackupSetupIntroViewController.initialScene.instantiate()
|
||||
viewController.viewModel = viewModel
|
||||
viewController.cancellable = cancellable
|
||||
viewController.theme = ThemeService.shared().theme
|
||||
return viewController
|
||||
}
|
||||
@@ -87,6 +89,16 @@ final class SecureBackupSetupIntroViewController: UIViewController {
|
||||
// MARK: - Private
|
||||
|
||||
private func setupViews() {
|
||||
if self.cancellable {
|
||||
let cancelBarButtonItem = MXKBarButtonItem(title: VectorL10n.cancel, style: .plain) { [weak self] in
|
||||
guard let self = self else {
|
||||
return
|
||||
}
|
||||
self.delegate?.secureBackupSetupIntroViewControllerDidCancel(self, showSkipAlert: true)
|
||||
}
|
||||
self.navigationItem.rightBarButtonItem = cancelBarButtonItem
|
||||
}
|
||||
|
||||
self.title = VectorL10n.secureKeyBackupSetupIntroTitle
|
||||
self.informationLabel.text = VectorL10n.secureKeyBackupSetupIntroInfo
|
||||
|
||||
@@ -126,14 +138,16 @@ final class SecureBackupSetupIntroViewController: UIViewController {
|
||||
|
||||
setupBackupMethods()
|
||||
}
|
||||
|
||||
|
||||
private func setupBackupMethods() {
|
||||
let secureBackupSetupMethods = self.viewModel.homeserverEncryptionConfiguration.secureBackupSetupMethods
|
||||
|
||||
// Hide setup methods that are not listed
|
||||
if !self.viewModel.wellKnown.isBackupMethodKeySupported() {
|
||||
if !secureBackupSetupMethods.contains(.key) {
|
||||
self.secureKeyCell.isHidden = true
|
||||
}
|
||||
|
||||
if !self.viewModel.wellKnown.isBackupMethodPassphraseSupported() {
|
||||
|
||||
if !secureBackupSetupMethods.contains(.passphrase) {
|
||||
self.securePassphraseCell.isHidden = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,13 +24,13 @@ final class SecureBackupSetupIntroViewModel: SecureBackupSetupIntroViewModelType
|
||||
// TODO: Make these properties private
|
||||
let keyBackup: MXKeyBackup?
|
||||
let checkKeyBackup: Bool
|
||||
let wellKnown: MXWellKnown
|
||||
let homeserverEncryptionConfiguration: HomeserverEncryptionConfiguration
|
||||
|
||||
// MARK: - Setup
|
||||
|
||||
init(keyBackup: MXKeyBackup?, checkKeyBackup: Bool, wellKnown: MXWellKnown) {
|
||||
init(keyBackup: MXKeyBackup?, checkKeyBackup: Bool, homeserverEncryptionConfiguration: HomeserverEncryptionConfiguration) {
|
||||
self.keyBackup = keyBackup
|
||||
self.checkKeyBackup = checkKeyBackup
|
||||
self.wellKnown = wellKnown
|
||||
}
|
||||
self.homeserverEncryptionConfiguration = homeserverEncryptionConfiguration
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,5 +23,5 @@ protocol SecureBackupSetupIntroViewModelType {
|
||||
// TODO: Hide these properties from interface and use same behavior as other view models
|
||||
var keyBackup: MXKeyBackup? { get }
|
||||
var checkKeyBackup: Bool { get }
|
||||
var wellKnown: MXWellKnown { get }
|
||||
var homeserverEncryptionConfiguration: HomeserverEncryptionConfiguration { get }
|
||||
}
|
||||
|
||||
@@ -31,14 +31,14 @@ final class SecureBackupSetupCoordinator: SecureBackupSetupCoordinatorType {
|
||||
private let recoveryService: MXRecoveryService
|
||||
private let keyBackup: MXKeyBackup?
|
||||
private let checkKeyBackup: Bool
|
||||
private let homeserverEncryptionConfiguration: HomeserverEncryptionConfiguration
|
||||
private let allowOverwrite: Bool
|
||||
private let cancellable: Bool
|
||||
|
||||
private var isBackupSetupMethodKeySupported: Bool {
|
||||
guard let homeserverWellknown = self.session.homeserverWellknown else {
|
||||
return false
|
||||
}
|
||||
return homeserverWellknown.isBackupMethodKeySupported()
|
||||
let homeserverEncryptionConfiguration = self.session.vc_homeserverConfiguration().encryption
|
||||
return homeserverEncryptionConfiguration.secureBackupSetupMethods.contains(.key)
|
||||
}
|
||||
private let allowOverwrite: Bool
|
||||
|
||||
// MARK: Public
|
||||
|
||||
@@ -54,14 +54,16 @@ final class SecureBackupSetupCoordinator: SecureBackupSetupCoordinatorType {
|
||||
/// - session: The MXSession.
|
||||
/// - checkKeyBackup: Indicate false to ignore existing key backup.
|
||||
/// - navigationRouter: Use existing navigation router to plug this flow or let nil to use new one.
|
||||
init(session: MXSession, checkKeyBackup: Bool = true, allowOverwrite: Bool = false, navigationRouter: NavigationRouterType? = nil) {
|
||||
/// - cancellable: Whether secure backup can be cancelled
|
||||
init(session: MXSession, checkKeyBackup: Bool = true, allowOverwrite: Bool = false, navigationRouter: NavigationRouterType? = nil, cancellable: Bool) {
|
||||
self.session = session
|
||||
self.recoveryService = session.crypto.recoveryService
|
||||
self.keyBackup = session.crypto.backup
|
||||
self.checkKeyBackup = checkKeyBackup
|
||||
|
||||
self.homeserverEncryptionConfiguration = session.vc_homeserverConfiguration().encryption
|
||||
self.allowOverwrite = allowOverwrite
|
||||
|
||||
self.cancellable = cancellable
|
||||
|
||||
if let navigationRouter = navigationRouter {
|
||||
self.navigationRouter = navigationRouter
|
||||
} else {
|
||||
@@ -82,33 +84,25 @@ final class SecureBackupSetupCoordinator: SecureBackupSetupCoordinatorType {
|
||||
}
|
||||
|
||||
func toPresentable() -> UIViewController {
|
||||
let controller = self.navigationRouter.toPresentable()
|
||||
|
||||
// If the flow is not cancellable, run it fullscreen
|
||||
if let session = AppDelegate.theDelegate().mxSessions.first as? MXSession {
|
||||
if session.homeserverWellknown.backupRequired() {
|
||||
if #available(iOS 13.0, *) {
|
||||
controller.modalPresentationStyle = .fullScreen
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return controller
|
||||
return self.navigationRouter
|
||||
.toPresentable()
|
||||
.vc_setModalFullScreen(!self.cancellable)
|
||||
}
|
||||
|
||||
// MARK: - Private methods
|
||||
|
||||
private func createIntro() -> SecureBackupSetupIntroViewController {
|
||||
// TODO: Use a coordinator
|
||||
let viewModel = SecureBackupSetupIntroViewModel(keyBackup: self.keyBackup, checkKeyBackup: self.checkKeyBackup, wellKnown: self.session.homeserverWellknown)
|
||||
let introViewController = SecureBackupSetupIntroViewController.instantiate(with: viewModel)
|
||||
´ let viewModel = SecureBackupSetupIntroViewModel(keyBackup: self.keyBackup,
|
||||
checkKeyBackup: self.checkKeyBackup,
|
||||
homeserverEncryptionConfiguration: self.homeserverEncryptionConfiguration)
|
||||
let introViewController = SecureBackupSetupIntroViewController.instantiate(with: viewModel, cancellable: self.cancellable)
|
||||
introViewController.delegate = self
|
||||
return introViewController
|
||||
}
|
||||
|
||||
private func showSetupKey(passphraseOnly: Bool, passphrase: String? = nil) {
|
||||
|
||||
let coordinator = SecretsSetupRecoveryKeyCoordinator(recoveryService: self.recoveryService, passphrase: passphrase, passphraseOnly: passphraseOnly, allowOverwrite: allowOverwrite)
|
||||
let coordinator = SecretsSetupRecoveryKeyCoordinator(recoveryService: self.recoveryService, passphrase: passphrase, passphraseOnly: passphraseOnly, allowOverwrite: allowOverwrite, cancellable: self.cancellable)
|
||||
coordinator.delegate = self
|
||||
coordinator.start()
|
||||
|
||||
@@ -119,7 +113,7 @@ final class SecureBackupSetupCoordinator: SecureBackupSetupCoordinatorType {
|
||||
}
|
||||
|
||||
private func showSetupPassphrase() {
|
||||
let coordinator = SecretsSetupRecoveryPassphraseCoordinator(passphraseInput: .new)
|
||||
let coordinator = SecretsSetupRecoveryPassphraseCoordinator(passphraseInput: .new, cancellable: self.cancellable)
|
||||
coordinator.delegate = self
|
||||
coordinator.start()
|
||||
|
||||
@@ -130,7 +124,7 @@ final class SecureBackupSetupCoordinator: SecureBackupSetupCoordinatorType {
|
||||
}
|
||||
|
||||
private func showSetupPassphraseConfirmation(with passphrase: String) {
|
||||
let coordinator = SecretsSetupRecoveryPassphraseCoordinator(passphraseInput: .confirm(passphrase))
|
||||
let coordinator = SecretsSetupRecoveryPassphraseCoordinator(passphraseInput: .confirm(passphrase), cancellable: self.cancellable)
|
||||
coordinator.delegate = self
|
||||
coordinator.start()
|
||||
|
||||
|
||||
@@ -37,9 +37,12 @@ final class SecureBackupSetupCoordinatorBridgePresenter: NSObject {
|
||||
private var coordinator: SecureBackupSetupCoordinator?
|
||||
|
||||
// MARK: Public
|
||||
|
||||
weak var delegate: SecureBackupSetupCoordinatorBridgePresenterDelegate?
|
||||
|
||||
|
||||
var isPresenting: Bool {
|
||||
return self.coordinator != nil
|
||||
}
|
||||
|
||||
// MARK: - Setup
|
||||
|
||||
init(session: MXSession, allowOverwrite: Bool) {
|
||||
@@ -54,9 +57,13 @@ final class SecureBackupSetupCoordinatorBridgePresenter: NSObject {
|
||||
// func present(from viewController: UIViewController, animated: Bool) {
|
||||
// self.present(from: viewController, animated: animated)
|
||||
// }
|
||||
|
||||
|
||||
func present(from viewController: UIViewController, animated: Bool) {
|
||||
let secureBackupSetupCoordinator = SecureBackupSetupCoordinator(session: self.session, allowOverwrite: self.allowOverwrite)
|
||||
self.present(from: viewController, animated: animated, cancellable: true)
|
||||
}
|
||||
|
||||
func present(from viewController: UIViewController, animated: Bool, cancellable: Bool) {
|
||||
let secureBackupSetupCoordinator = SecureBackupSetupCoordinator(session: self.session, allowOverwrite: self.allowOverwrite, cancellable: cancellable)
|
||||
secureBackupSetupCoordinator.delegate = self
|
||||
viewController.present(secureBackupSetupCoordinator.toPresentable(), animated: animated, completion: nil)
|
||||
secureBackupSetupCoordinator.start()
|
||||
|
||||
Reference in New Issue
Block a user