Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions Nextcloud.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@
AFCE353527E4ED5900FEA6C2 /* DateFormatter+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFCE353427E4ED5900FEA6C2 /* DateFormatter+Extension.swift */; };
AFCE353727E4ED7B00FEA6C2 /* NCShareCells.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFCE353627E4ED7B00FEA6C2 /* NCShareCells.swift */; };
AFCE353927E5DE0500FEA6C2 /* Shareable.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFCE353827E5DE0400FEA6C2 /* Shareable.swift */; };
AFCE353927E5DE0500FEA6C2 /* NCShare+Helper.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFCE353827E5DE0400FEA6C2 /* NCShare+Helper.swift */; };
B5D45E5F2DA50C8500773929 /* TealiumHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5D45E5D2DA50C8500773929 /* TealiumHelper.swift */; };
B5D45E602DA50C8500773929 /* AdjustHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = B5D45E5C2DA50C8500773929 /* AdjustHelper.m */; };
B5D45E632DA50D6A00773929 /* CCManageAutoUpload.m in Sources */ = {isa = PBXBuildFile; fileRef = B5D45E622DA50D6A00773929 /* CCManageAutoUpload.m */; };
B5D45E642DA50D6A00773929 /* CCAdvanced.m in Sources */ = {isa = PBXBuildFile; fileRef = B5D45E612DA50D6A00773929 /* CCAdvanced.m */; };
C04E2F232A17BB4D001BAD85 /* FilesIntegrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C04E2F222A17BB4D001BAD85 /* FilesIntegrationTests.swift */; };
D575039F27146F93008DC9DC /* String+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7A0D1342591FBC5008F8A13 /* String+Extension.swift */; };
D5B6AA7827200C7200D49C24 /* NCActivityTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5B6AA7727200C7200D49C24 /* NCActivityTableViewCell.swift */; };
F310B1EF2BA862F1001C42F5 /* NCViewerMedia+VisionKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = F310B1EE2BA862F1001C42F5 /* NCViewerMedia+VisionKit.swift */; };
Expand Down Expand Up @@ -1329,6 +1335,12 @@
AFCE353427E4ED5900FEA6C2 /* DateFormatter+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DateFormatter+Extension.swift"; sourceTree = "<group>"; };
AFCE353627E4ED7B00FEA6C2 /* NCShareCells.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCShareCells.swift; sourceTree = "<group>"; };
AFCE353827E5DE0400FEA6C2 /* Shareable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Shareable.swift; sourceTree = "<group>"; };
AFCE353827E5DE0400FEA6C2 /* NCShare+Helper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NCShare+Helper.swift"; sourceTree = "<group>"; };
B5D45E5B2DA50C8500773929 /* AdjustHelper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AdjustHelper.h; sourceTree = "<group>"; };
B5D45E5C2DA50C8500773929 /* AdjustHelper.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AdjustHelper.m; sourceTree = "<group>"; };
B5D45E5D2DA50C8500773929 /* TealiumHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TealiumHelper.swift; sourceTree = "<group>"; };
B5D45E612DA50D6A00773929 /* CCAdvanced.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CCAdvanced.m; sourceTree = "<group>"; };
B5D45E622DA50D6A00773929 /* CCManageAutoUpload.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CCManageAutoUpload.m; sourceTree = "<group>"; };
C0046CDA2A17B98400D87C9D /* NextcloudUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = NextcloudUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
C04E2F202A17BB4D001BAD85 /* NextcloudIntegrationTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = NextcloudIntegrationTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
D5B6AA7727200C7200D49C24 /* NCActivityTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCActivityTableViewCell.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2155,6 +2167,16 @@
path = Advanced;
sourceTree = "<group>";
};
B5D45E5E2DA50C8500773929 /* Helper */ = {
isa = PBXGroup;
children = (
B5D45E5B2DA50C8500773929 /* AdjustHelper.h */,
B5D45E5C2DA50C8500773929 /* AdjustHelper.m */,
B5D45E5D2DA50C8500773929 /* TealiumHelper.swift */,
);
path = Helper;
sourceTree = "<group>";
};
C0046CDB2A17B98400D87C9D /* NextcloudUITests */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -2590,6 +2612,8 @@
F76882042C0DD1E7001CF441 /* Settings */ = {
isa = PBXGroup;
children = (
B5D45E612DA50D6A00773929 /* CCAdvanced.m */,
B5D45E622DA50D6A00773929 /* CCManageAutoUpload.m */,
F768820B2C0DD1E7001CF441 /* Settings */,
F76882162C0DD1E7001CF441 /* AutoUpload */,
F389C9F32CEE381E00049762 /* SelectAlbum */,
Expand Down Expand Up @@ -3300,6 +3324,7 @@
isa = PBXGroup;
children = (
AA517BB42D66149900F8D37C /* .tx */,
B5D45E5E2DA50C8500773929 /* Helper */,
F702F2CC25EE5B4F008F8E80 /* AppDelegate.swift */,
F794E13E2BBC0F70003693D7 /* SceneDelegate.swift */,
F77DD6A72C5CC093009448FB /* NCSession.swift */,
Expand Down Expand Up @@ -4709,6 +4734,8 @@
F75DD765290ABB25002EB562 /* Intent.intentdefinition in Sources */,
F7D4BF012CA1831900A5E746 /* NCCollectionViewCommonPinchGesture.swift in Sources */,
F74B6D952A7E239A00F03C5F /* NCManageDatabase+Chunk.swift in Sources */,
B5D45E632DA50D6A00773929 /* CCManageAutoUpload.m in Sources */,
B5D45E642DA50D6A00773929 /* CCAdvanced.m in Sources */,
F7A8FD522C5E2557006C9CF8 /* NCAccount.swift in Sources */,
F310B1EF2BA862F1001C42F5 /* NCViewerMedia+VisionKit.swift in Sources */,
F702F2F725EE5CED008F8E80 /* NCLogin.swift in Sources */,
Expand All @@ -4725,6 +4752,8 @@
3781B9B023DB2B7E006B4B1D /* AppDelegate+Menu.swift in Sources */,
F710D1F52405770F00A6033D /* NCViewerPDF.swift in Sources */,
F389C9F52CEE383300049762 /* SelectAlbumView.swift in Sources */,
B5D45E5F2DA50C8500773929 /* TealiumHelper.swift in Sources */,
B5D45E602DA50C8500773929 /* AdjustHelper.m in Sources */,
F7B6B70427C4E7FA00A7F6EB /* NCScan+CollectionView.swift in Sources */,
F7816EF22C2C3E1F00A52517 /* NCPushNotification.swift in Sources */,
F76882342C0DD1E7001CF441 /* NCDisplayView.swift in Sources */,
Expand Down
236 changes: 234 additions & 2 deletions iOSClient/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ import SwiftUI
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate {
var backgroundSessionCompletionHandler: (() -> Void)?
var activeLogin: NCLogin?
var activeLoginWeb: NCLoginWeb?
var taskAutoUploadDate: Date = Date()
var orientationLock = UIInterfaceOrientationMask.all
@objc let adjust = AdjustHelper()
var isUiTestingEnabled: Bool {
return ProcessInfo.processInfo.arguments.contains("UI_TESTING")
}
Expand All @@ -47,7 +52,16 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
/// Init
let global = NCGlobal.shared
let database = NCManageDatabase.shared

var window: UIWindow?
@objc var sceneIdentifier: String = ""
@objc var activeViewController: UIViewController?
@objc var account: String = ""
@objc var urlBase: String = ""
@objc var user: String = ""
@objc var userId: String = ""
@objc var password: String = ""
var timerErrorNetworking: Timer?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
if isUiTestingEnabled {
NCAccount().deleteAllAccounts()
Expand All @@ -70,6 +84,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
utilityFileSystem.clearCacheDirectory("com.limit-point.LivePhoto")

NCBrandColor.shared.createUserColors()
NCImageCache.shared.createImagesCache()

NextcloudKit.shared.setup(groupIdentifier: NCBrandOptions.shared.capabilitiesGroup,
delegate: NCNetworking.shared)
Expand Down Expand Up @@ -120,6 +135,26 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
NCTransferProgress.shared.setup()
NCActionCenter.shared.setup()

// if account.isEmpty {
// if NCBrandOptions.shared.disable_intro {
// openLogin(viewController: nil, selector: NCGlobal.shared.introLogin, openLoginWeb: false)
// } else {
// if let viewController = UIStoryboard(name: "NCIntro", bundle: nil).instantiateInitialViewController() {
// let navigationController = NCLoginNavigationController(rootViewController: viewController)
// window?.rootViewController = navigationController
// window?.makeKeyAndVisible()
// }
// }
// } else {
// NCPasscode.shared.presentPasscode(delegate: self) {
// NCPasscode.shared.enableTouchFaceID()
// }
// }
adjust.configAdjust()
adjust.subsessionStart()
TealiumHelper.shared.start()
FirebaseApp.configure()

return true
}

Expand Down Expand Up @@ -335,6 +370,175 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
}
}

// MARK: - Login

func openLogin(selector: Int, window: UIWindow? = nil) {
UIApplication.shared.allSceneSessionDestructionExceptFirst()

// func showLoginViewController(_ viewController: UIViewController?) {
// guard let viewController else { return }
// let navigationController = NCLoginNavigationController(rootViewController: viewController)
//
// navigationController.modalPresentationStyle = .fullScreen
// navigationController.navigationBar.barStyle = .black
// navigationController.navigationBar.tintColor = NCBrandColor.shared.customerText
// navigationController.navigationBar.barTintColor = NCBrandColor.shared.customer
// navigationController.navigationBar.isTranslucent = false
//
// if let controller = UIApplication.shared.firstWindow?.rootViewController {
// if let presentedVC = controller.presentedViewController, !(presentedVC is NCLoginNavigationController) {
// presentedVC.dismiss(animated: false) {
// controller.present(navigationController, animated: true)
// }
// } else {
// controller.present(navigationController, animated: true)
// }
// } else {
// window?.rootViewController = navigationController
// window?.makeKeyAndVisible()
// }
// }

// Nextcloud standard login
if selector == NCGlobal.shared.introSignup {
if activeLogin?.view.window == nil {
if selector == NCGlobal.shared.introSignup {
let web = UIStoryboard(name: "NCLogin", bundle: nil).instantiateViewController(withIdentifier: "NCLoginProvider") as? NCLoginProvider
web?.urlBase = NCBrandOptions.shared.linkloginPreferredProviders
showLoginViewController(web)
} else {
activeLogin = UIStoryboard(name: "NCLogin", bundle: nil).instantiateViewController(withIdentifier: "NCLogin") as? NCLogin
if let controller = UIApplication.shared.firstWindow?.rootViewController as? NCMainTabBarController, !controller.account.isEmpty {
let session = NCSession.shared.getSession(account: controller.account)
activeLogin?.urlBase = session.urlBase
}
showLoginViewController(activeLogin)
}
}
} else {
if activeLogin?.view.window == nil {
activeLogin = UIStoryboard(name: "NCLogin", bundle: nil).instantiateViewController(withIdentifier: "NCLogin") as? NCLogin
activeLogin?.urlBase = NCBrandOptions.shared.disable_request_login_url ? NCBrandOptions.shared.loginBaseUrl : ""
showLoginViewController(activeLogin)
}
}
}

@objc func openLogin(viewController: UIViewController?, selector: Int, openLoginWeb: Bool) {
// openLogin(selector: NCGlobal.shared.introLogin)
// [WEBPersonalized] [AppConfig]
if NCBrandOptions.shared.use_login_web_personalized || NCBrandOptions.shared.use_AppConfig {

if activeLoginWeb?.view.window == nil {
activeLoginWeb = UIStoryboard(name: "NCLogin", bundle: nil).instantiateViewController(withIdentifier: "NCLoginWeb") as? NCLoginWeb
activeLoginWeb?.urlBase = NCBrandOptions.shared.loginBaseUrl
showLoginViewController(activeLoginWeb, contextViewController: viewController)
}
return
}

// Nextcloud standard login
if selector == NCGlobal.shared.introSignup {

if activeLoginWeb?.view.window == nil {
activeLoginWeb = UIStoryboard(name: "NCLogin", bundle: nil).instantiateViewController(withIdentifier: "NCLoginWeb") as? NCLoginWeb
if selector == NCGlobal.shared.introSignup {
activeLoginWeb?.urlBase = NCBrandOptions.shared.linkloginPreferredProviders
} else {
activeLoginWeb?.urlBase = self.urlBase
}
showLoginViewController(activeLoginWeb, contextViewController: viewController)
}

} else if NCBrandOptions.shared.disable_intro && NCBrandOptions.shared.disable_request_login_url {

if activeLoginWeb?.view.window == nil {
activeLoginWeb = UIStoryboard(name: "NCLogin", bundle: nil).instantiateViewController(withIdentifier: "NCLoginWeb") as? NCLoginWeb
activeLoginWeb?.urlBase = NCBrandOptions.shared.loginBaseUrl
showLoginViewController(activeLoginWeb, contextViewController: viewController)
}

} else if openLoginWeb {

// Used also for reinsert the account (change passwd)
if activeLoginWeb?.view.window == nil {
activeLoginWeb = UIStoryboard(name: "NCLogin", bundle: nil).instantiateViewController(withIdentifier: "NCLoginWeb") as? NCLoginWeb
activeLoginWeb?.urlBase = urlBase
activeLoginWeb?.user = user
showLoginViewController(activeLoginWeb, contextViewController: viewController)
}

} else {

if activeLogin?.view.window == nil {
activeLogin = UIStoryboard(name: "NCLogin", bundle: nil).instantiateViewController(withIdentifier: "NCLogin") as? NCLogin
showLoginViewController(activeLogin, contextViewController: viewController)
}
}
}

func showLoginViewController(_ viewController: UIViewController?) {
guard let viewController else { return }
let navigationController = NCLoginNavigationController(rootViewController: viewController)

navigationController.modalPresentationStyle = .fullScreen
navigationController.navigationBar.barStyle = .black
navigationController.navigationBar.tintColor = NCBrandColor.shared.customerText
navigationController.navigationBar.barTintColor = NCBrandColor.shared.customer
navigationController.navigationBar.isTranslucent = false

if let controller = UIApplication.shared.firstWindow?.rootViewController {
if let presentedVC = controller.presentedViewController, !(presentedVC is NCLoginNavigationController) {
presentedVC.dismiss(animated: false) {
controller.present(navigationController, animated: true)
}
} else {
controller.present(navigationController, animated: true)
}
} else {
window?.rootViewController = navigationController
window?.makeKeyAndVisible()
}
}

func showLoginViewController(_ viewController: UIViewController?, contextViewController: UIViewController?) {

if contextViewController == nil {
if let viewController = viewController {
let navigationController = NCLoginNavigationController(rootViewController: viewController)
navigationController.navigationBar.barStyle = .black
navigationController.navigationBar.tintColor = NCBrandColor.shared.customerText
navigationController.navigationBar.barTintColor = NCBrandColor.shared.customer
navigationController.navigationBar.isTranslucent = false
window?.rootViewController = navigationController
window?.makeKeyAndVisible()
}
} else if contextViewController is UINavigationController {
if let contextViewController = contextViewController, let viewController = viewController {
(contextViewController as? UINavigationController)?.pushViewController(viewController, animated: true)
}
} else {
if let viewController = viewController, let contextViewController = contextViewController {
let navigationController = NCLoginNavigationController(rootViewController: viewController)
navigationController.modalPresentationStyle = .fullScreen
navigationController.navigationBar.barStyle = .black
navigationController.navigationBar.tintColor = NCBrandColor.shared.customerText
navigationController.navigationBar.barTintColor = NCBrandColor.shared.customer
navigationController.navigationBar.isTranslucent = false
contextViewController.present(navigationController, animated: true) { }
}
}
}

@objc func startTimerErrorNetworking() {
timerErrorNetworking = Timer.scheduledTimer(timeInterval: 3, target: self, selector: #selector(checkErrorNetworking), userInfo: nil, repeats: true)
}

@objc private func checkErrorNetworking() {
guard !account.isEmpty, NCKeychain().getPassword(account: account).isEmpty else { return }
openLogin(viewController: window?.rootViewController, selector: NCGlobal.shared.introLogin, openLoginWeb: true)
}

// MARK: -

func trustCertificateError(host: String) {
Expand Down Expand Up @@ -370,10 +574,31 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD

UIApplication.shared.firstWindow?.rootViewController?.present(alertController, animated: true)
}

// MARK: - Account

@objc func changeAccount(_ account: String, userProfile: NKUserProfile?) {
// NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterChangeUser)
}

@objc func deleteAccount(_ account: String, wipe: Bool) {
NCAccount().deleteAccount(account, wipe: wipe)
}

func deleteAllAccounts() {
let accounts = NCManageDatabase.shared.getAccounts()
accounts?.forEach({ account in
deleteAccount(account, wipe: true)
})
}

func updateShareAccounts() -> Error? {
return NCAccount().updateAppsShareAccounts()
}

// MARK: - Reset Application

func resetApplication() {
@objc func resetApplication() {
let utilityFileSystem = NCUtilityFileSystem()

NCNetworking.shared.cancelAllTask()
Expand Down Expand Up @@ -412,3 +637,10 @@ extension AppDelegate: NCCreateFormUploadConflictDelegate {
NCNetworkingProcess.shared.createProcessUploads(metadatas: metadatas)
}
}

//MARK: NMC Customisation
extension AppDelegate {
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
return self.orientationLock
}
}
Loading