Skip to content

Commit

Permalink
Merge branch 'release-4.2.0'
Browse files Browse the repository at this point in the history
Signed-off-by: Florentin Bekier <[email protected]>

# Conflicts:
#	kDrive/Resources/de.lproj/Localizable.strings
#	kDrive/Resources/de.lproj/Localizable.stringsdict
#	kDrive/Resources/en.lproj/Localizable.strings
#	kDrive/Resources/en.lproj/Localizable.stringsdict
#	kDrive/Resources/es.lproj/Localizable.strings
#	kDrive/Resources/es.lproj/Localizable.stringsdict
#	kDrive/Resources/fr.lproj/Localizable.strings
#	kDrive/Resources/fr.lproj/Localizable.stringsdict
#	kDrive/Resources/it.lproj/Localizable.strings
#	kDrive/Resources/it.lproj/Localizable.stringsdict
#	kDrive/UI/Controller/Files/FileActionsFloatingPanelViewController.swift
#	kDrive/UI/Controller/Files/SelectFloatingPanelTableViewController.swift
  • Loading branch information
flowbe committed Apr 28, 2022
2 parents 5d26acb + 539d7e1 commit ef39090
Show file tree
Hide file tree
Showing 291 changed files with 10,196 additions and 11,238 deletions.
746 changes: 372 additions & 374 deletions .package.resolved

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ opt_in_rules:
excluded:
- .tuist-bin/*
- Derived/Sources/*
function_parameter_count: 7
6 changes: 4 additions & 2 deletions Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import ProjectDescriptionHelpers
let project = Project(name: "kDrive",
packages: [
.package(url: "https://github.com/Alamofire/Alamofire.git", .upToNextMajor(from: "5.2.2")),
.package(url: "https://github.com/Infomaniak/ios-core.git", .upToNextMajor(from: "1.1.2")),
.package(url: "https://github.com/Infomaniak/ios-core.git", .upToNextMajor(from: "1.1.7")),
.package(url: "https://github.com/Infomaniak/ios-login.git", .upToNextMajor(from: "1.4.0")),
.package(url: "https://github.com/realm/realm-cocoa", .upToNextMajor(from: "10.0.0")),
.package(url: "https://github.com/SCENEE/FloatingPanel", .upToNextMajor(from: "2.0.0")),
Expand All @@ -43,7 +43,8 @@ let project = Project(name: "kDrive",
.package(url: "https://github.com/Cocoanetics/Kvitto", .upToNextMajor(from: "1.0.0")),
.package(url: "https://github.com/raspu/Highlightr", .upToNextMajor(from: "2.1.0")),
.package(url: "https://github.com/bmoliveira/MarkdownKit.git", .upToNextMajor(from: "1.7.0")),
.package(url: "https://github.com/matomo-org/matomo-sdk-ios.git", .upToNextMajor(from: "7.5.1"))
.package(url: "https://github.com/matomo-org/matomo-sdk-ios.git", .upToNextMajor(from: "7.5.1")),
.package(url: "https://github.com/flowbe/SwiftRegex.git", .upToNextMajor(from: "1.0.0"))
],
targets: [
Target(name: "kDrive",
Expand Down Expand Up @@ -78,6 +79,7 @@ let project = Project(name: "kDrive",
.package(product: "Highlightr"),
.package(product: "MarkdownKit"),
.package(product: "MatomoTracker"),
.package(product: "SwiftRegex"),
.sdk(name: "StoreKit.framework", status: .required)
],
settings: .settings(base: Constants.baseSettings)),
Expand Down
4 changes: 2 additions & 2 deletions Tuist/ProjectDescriptionHelpers/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import ProjectDescription
public enum Constants {
public static let baseSettings = SettingsDictionary()
.automaticCodeSigning(devTeam: "864VDCS2QY")
.currentProjectVersion("3")
.marketingVersion("4.1.3")
.currentProjectVersion("9")
.marketingVersion("4.2.0")

public static let deploymentTarget = DeploymentTarget.iOS(targetVersion: "13.0", devices: [.iphone, .ipad])

Expand Down
2 changes: 1 addition & 1 deletion Tuist/ProjectDescriptionHelpers/ExtensionTarget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public extension Target {
"kDrive/UI/Controller/Files/Save File/**",
"kDrive/UI/Controller/Files/Search/**",
"kDrive/UI/Controller/Files/MultipleSelectionViewController.swift",
"kDrive/UI/Controller/Files/FileListViewController.swift",
"kDrive/UI/Controller/Files/File List/**",
"kDrive/UI/Controller/Files/FloatingPanelSortOptionTableViewController.swift",
"kDrive/UI/Controller/Floating Panel Information/**",
"kDrive/UI/Controller/NewFolder/**",
Expand Down
114 changes: 48 additions & 66 deletions kDrive/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,18 @@ class AppDelegate: UIResponder, UIApplicationDelegate, AccountManagerDelegate {
private var accountManager: AccountManager!
private var uploadQueue: UploadQueue!
private var reachabilityListener: ReachabilityListener!
private static let currentStateVersion = 1
private static let currentStateVersion = 2
private static let appStateVersionKey = "appStateVersionKey"

func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
Logging.initLogging()
DDLogInfo("Application starting in foreground ? \(UIApplication.shared.applicationState != .background)")
ImageCache.default.memoryStorage.config.totalCostLimit = 20
ImageCache.default.memoryStorage.config.totalCostLimit = Constants.memoryCacheSizeLimit
InfomaniakLogin.initWith(clientId: DriveApiFetcher.clientId)
accountManager = AccountManager.instance
uploadQueue = UploadQueue.instance
reachabilityListener = ReachabilityListener.instance
ApiEnvironment.current = .prod

// Start audio session
do {
Expand All @@ -60,6 +61,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate, AccountManagerDelegate {

registerBackgroundTasks()

// In some cases the application can show the old Nextcloud import notification badge
UIApplication.shared.applicationIconBadgeNumber = 0
NotificationsHelper.askForPermissions()
NotificationsHelper.registerCategories()
UNUserNotificationCenter.current().delegate = self
Expand Down Expand Up @@ -393,7 +396,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, AccountManagerDelegate {
// Compare modification date
let attributes = try? FileManager.default.attributesOfItem(atPath: fileURL.path)
let modificationDate = attributes?[.modificationDate] as? Date ?? Date(timeIntervalSince1970: 0)
if modificationDate > file.lastModifiedDate {
if modificationDate > file.lastModifiedAt {
// Copy and upload file
let uploadFile = UploadFile(parentDirectoryId: file.parentId,
userId: accountManager.currentUserId,
Expand All @@ -410,10 +413,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate, AccountManagerDelegate {
DDLogError("[OPEN-IN-PLACE UPLOAD] Error while uploading: \(error)")
} else {
// Update file to get the new modification date
driveFileManager.getFile(id: fileId, forceRefresh: true) { file, _, _ in
if let file = file {
driveFileManager.notifyObserversWith(file: file)
}
Task {
let file = try await driveFileManager.file(id: fileId, forceRefresh: true)
driveFileManager.notifyObserversWith(file: file)
}
}
group.leave()
Expand Down Expand Up @@ -442,50 +444,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate, AccountManagerDelegate {
continue
}

let offlineFiles = driveFileManager.getAvailableOfflineFiles()
guard !offlineFiles.isEmpty else { continue }
driveFileManager.getFilesActivities(driveId: drive.id, files: offlineFiles, from: UserDefaults.shared.lastSyncDateOfflineFiles) { result in
switch result {
case .success(let filesActivities):
for (fileId, content) in filesActivities {
guard let file = offlineFiles.first(where: { $0.id == fileId }) else {
continue
}

if let activities = content.activities {
// Apply activities to file
var handledActivities = Set<FileActivityType>()
for activity in activities where !handledActivities.contains(activity.action) {
switch activity.action {
case .fileRename:
// Rename file
driveFileManager.getFile(id: file.id, withExtras: true) { newFile, _, _ in
if let newFile = newFile {
try? driveFileManager.renameCachedFile(updatedFile: newFile, oldFile: file)
}
}
case .fileUpdate:
// Download new version
DownloadQueue.instance.addToQueue(file: file, userId: driveFileManager.drive.userId)
case .fileDelete:
// File has been deleted -- remove it from offline files
driveFileManager.setFileAvailableOffline(file: file, available: false) { _ in }
default:
break
}
handledActivities.insert(activity.action)
}
} else if let error = content.error {
if DriveError(apiError: error) == .objectNotFound {
driveFileManager.setFileAvailableOffline(file: file, available: false) { _ in }
} else {
SentrySDK.capture(error: error)
}
// Silently handle error
DDLogError("Error while fetching [\(file.id) - \(file.name)] in [\(drive.id) - \(drive.name)]: \(error)")
}
}
case .failure(let error):
Task {
do {
try await driveFileManager.updateAvailableOfflineFiles()
} catch {
// Silently handle error
DDLogError("Error while fetching offline files activities in [\(drive.id) - \(drive.name)]: \(error)")
}
Expand All @@ -509,7 +471,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, AccountManagerDelegate {
}

func setRootViewController(_ vc: UIViewController, animated: Bool = true) {
guard animated, let window = self.window else {
guard animated, let window = window else {
self.window?.rootViewController = vc
self.window?.makeKeyAndVisible()
return
Expand All @@ -520,27 +482,33 @@ class AppDelegate: UIResponder, UIApplicationDelegate, AccountManagerDelegate {
UIView.transition(with: window, duration: 0.3, options: .transitionCrossDissolve, animations: nil, completion: nil)
}

func present(file: File, driveFileManager: DriveFileManager) {
func present(file: File, driveFileManager: DriveFileManager, office: Bool = false) {
guard let rootViewController = window?.rootViewController as? MainTabViewController else {
return
}

// Dismiss all view controllers presented
rootViewController.dismiss(animated: false)
// Select Files tab
rootViewController.selectedIndex = 1
rootViewController.dismiss(animated: false) {
// Select Files tab
rootViewController.selectedIndex = 1

guard let navController = rootViewController.selectedViewController as? UINavigationController,
let viewController = navController.topViewController as? FileListViewController else {
return
}
guard let navController = rootViewController.selectedViewController as? UINavigationController,
let viewController = navController.topViewController as? FileListViewController else {
return
}

if !file.isRoot && viewController.currentDirectory?.id != file.id {
// Pop to root
navController.popToRootViewController(animated: false)
// Present file
let filePresenter = FilePresenter(viewController: viewController, floatingPanelViewController: nil)
filePresenter.present(driveFileManager: driveFileManager, file: file, files: [file], normalFolderHierarchy: false)
if !file.isRoot && viewController.viewModel.currentDirectory.id != file.id {
// Pop to root
navController.popToRootViewController(animated: false)
// Present file
guard let fileListViewController = navController.topViewController as? FileListViewController else { return }
if office {
OnlyOfficeViewController.open(driveFileManager: driveFileManager, file: file, viewController: fileListViewController)
} else {
let filePresenter = FilePresenter(viewController: fileListViewController)
filePresenter.present(driveFileManager: driveFileManager, file: file, files: [file], normalFolderHierarchy: false)
}
}
}
}

Expand Down Expand Up @@ -575,6 +543,20 @@ class AppDelegate: UIResponder, UIApplicationDelegate, AccountManagerDelegate {
let encodedVersion = coder.decodeInteger(forKey: AppDelegate.appStateVersionKey)
return AppDelegate.currentStateVersion == encodedVersion && !(UserDefaults.shared.isFirstLaunch || accountManager.accounts.isEmpty)
}

// MARK: - User activity

func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
// Get URL components from the incoming user activity.
guard userActivity.activityType == NSUserActivityTypeBrowsingWeb,
let incomingURL = userActivity.webpageURL,
let components = URLComponents(url: incomingURL, resolvingAgainstBaseURL: true) else {
return false
}

// Check for specific URL components that you need.
return UniversalLinksHelper.handlePath(components.path, appDelegate: self)
}
}

// MARK: - User notification center delegate
Expand Down
1 change: 1 addition & 0 deletions kDrive/IAP/StoreRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import Alamofire
import CocoaLumberjackSwift
import Foundation
import InfomaniakCore
import kDriveCore
import Sentry

Expand Down
21 changes: 21 additions & 0 deletions kDrive/Resources/Assets.xcassets/file-form.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"alignment-insets" : {
"bottom" : 0,
"left" : 0,
"right" : 4,
"top" : 0
},
"filename" : "form.svg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true
}
}
14 changes: 14 additions & 0 deletions kDrive/Resources/Assets.xcassets/file-form.imageset/form.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

This file was deleted.

Loading

0 comments on commit ef39090

Please sign in to comment.