Эх сурвалжийг харах

Merge pull request #2162 from nextcloud/fix_ios16

Fix ios16
Marino Faggiana 2 жил өмнө
parent
commit
e0ba5f0e70

+ 1 - 1
Widget/Dashboard/DashboardData.swift

@@ -140,7 +140,7 @@ func getDashboardDataEntry(intent: Applications, isPreview: Bool, displaySize: C
     
     let (tableDashboard, tableButton) = NCManageDatabase.shared.getDashboardWidget(account: account.account, id: id)
     let existsButton = (tableButton?.isEmpty ?? true) ? false : true
-    let options = NKRequestOptions(queue: NKCommon.shared.backgroundQueue)
+    let options = NKRequestOptions(timeout: 15, queue: NKCommon.shared.backgroundQueue)
     let title = tableDashboard?.title ?? id
     var titleImage = UIImage(named: "widget")!
 

+ 8 - 2
Widget/Files/FilesData.swift

@@ -46,7 +46,12 @@ let filesDatasTest: [FilesData] = [
     .init(id: "1", image: UIImage(named: "widget")!, title: "title2", subTitle: "subTitle-description2", url: URL(string: "https://nextcloud.com/")!),
     .init(id: "2", image: UIImage(named: "widget")!, title: "title3", subTitle: "subTitle-description3", url: URL(string: "https://nextcloud.com/")!),
     .init(id: "3", image: UIImage(named: "widget")!, title: "title4", subTitle: "subTitle-description4", url: URL(string: "https://nextcloud.com/")!),
-    .init(id: "4", image: UIImage(named: "widget")!, title: "title4", subTitle: "subTitle-description4", url: URL(string: "https://nextcloud.com/")!)
+    .init(id: "4", image: UIImage(named: "widget")!, title: "title4", subTitle: "subTitle-description4", url: URL(string: "https://nextcloud.com/")!),
+    .init(id: "5", image: UIImage(named: "widget")!, title: "title4", subTitle: "subTitle-description4", url: URL(string: "https://nextcloud.com/")!),
+    .init(id: "6", image: UIImage(named: "widget")!, title: "title4", subTitle: "subTitle-description4", url: URL(string: "https://nextcloud.com/")!),
+    .init(id: "7", image: UIImage(named: "widget")!, title: "title4", subTitle: "subTitle-description4", url: URL(string: "https://nextcloud.com/")!),
+    .init(id: "8", image: UIImage(named: "widget")!, title: "title4", subTitle: "subTitle-description4", url: URL(string: "https://nextcloud.com/")!),
+    .init(id: "9", image: UIImage(named: "widget")!, title: "title4", subTitle: "subTitle-description4", url: URL(string: "https://nextcloud.com/")!)
 ]
 
 func getTitleFilesWidget() -> String {
@@ -194,7 +199,8 @@ func getFilesDataEntry(isPreview: Bool, displaySize: CGSize, completion: @escapi
         NKCommon.shared.writeLog("Start \(NCBrandOptions.shared.brand) widget session with level \(levelLog) " + versionNextcloudiOS)
     }
     
-    NextcloudKit.shared.searchBodyRequest(serverUrl: account.urlBase, requestBody: requestBody, showHiddenFiles: CCUtility.getShowHiddenFiles()) { _, files, data, error in
+    let options = NKRequestOptions(timeout: 15)
+    NextcloudKit.shared.searchBodyRequest(serverUrl: account.urlBase, requestBody: requestBody, showHiddenFiles: CCUtility.getShowHiddenFiles(), options: options) { _, files, data, error in
 
         var datas: [FilesData] = []
         

+ 1 - 1
Widget/Files/FilesWidgetView.swift

@@ -171,7 +171,7 @@ struct FilesWidgetView: View {
 
 struct FilesWidget_Previews: PreviewProvider {
     static var previews: some View {
-        let datas = Array(filesDatasTest[0...5])
+        let datas = Array(filesDatasTest[0...4])
         let entry = FilesDataEntry(date: Date(), datas: datas, isPlaceholder: false, tile: "Good afternoon, Marino Faggiana", footerImage: "checkmark.icloud", footerText: "Nextcloud files")
         FilesWidgetView(entry: entry).previewContext(WidgetPreviewContext(family: .systemLarge))
     }

+ 17 - 9
iOSClient/AppDelegate.swift

@@ -243,7 +243,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         }
         
         // Initialize Auto upload
-        NCAutoUpload.shared.initAutoUpload(viewController: nil) { _ in }
+        NCAutoUpload.shared.initAutoUpload(viewController: nil) { items in
+            NKCommon.shared.writeLog("Initialize Auto upload with \(items) uploads")
+        }
 
         // Required unsubscribing / subscribing
         NCPushNotification.shared().pushNotification()
@@ -300,7 +302,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         }
 
         scheduleAppRefresh()
-        scheduleBackgroundProcessing()
+        scheduleAppProcessing()
 
         // Passcode
         presentPasscode { }
@@ -326,7 +328,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         NCPushNotification.shared().pushNotification()
 
         // Start Auto Upload
-        NCAutoUpload.shared.initAutoUpload(viewController: nil) { _ in }
+        NCAutoUpload.shared.initAutoUpload(viewController: nil) { items in
+            NKCommon.shared.writeLog("Initialize Auto upload with \(items) uploads")
+        }
 
         // Start services
         NCService.shared.startRequestServicesServer()
@@ -359,7 +363,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         }
     }
 
-    func scheduleBackgroundProcessing() {
+    func scheduleAppProcessing() {
 
         let request = BGProcessingTaskRequest(identifier: NCGlobal.shared.processingTask)
         request.earliestBeginDate = Date(timeIntervalSinceNow: 5 * 60) // Refresh after 5 minutes.
@@ -375,6 +379,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
 
     func handleRefreshTask(_ task: BGTask) {
 
+        // Schedule a new task.
+        scheduleAppRefresh()
+        
         if account == "" {
             task.setTaskCompleted(success: true)
             return
@@ -382,16 +389,17 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
 
         NKCommon.shared.writeLog("Start handler refresh task [Auto upload]")
 
-        NCAutoUpload.shared.initAutoUpload(viewController: nil) { _ in
-            DispatchQueue.main.asyncAfter(deadline: .now() + 5) {
-                NKCommon.shared.writeLog("Completition handler refresh task with [Auto upload]")
-                task.setTaskCompleted(success: true)
-            }
+        NCAutoUpload.shared.initAutoUpload(viewController: nil) { items in
+            NKCommon.shared.writeLog("Completition handler refresh task [Auto upload] with \(items) uploads")
+            task.setTaskCompleted(success: true)
         }
     }
 
     func handleProcessingTask(_ task: BGTask) {
 
+        // Schedule a new task.
+        scheduleAppProcessing()
+        
         if account == "" {
             task.setTaskCompleted(success: true)
             return

+ 1 - 1
iOSClient/Utility/NCUtility.swift

@@ -490,7 +490,7 @@ class NCUtility: NSObject {
                 if error != nil { return callCompletion(error: true) }
             }
 
-            PHImageManager.default().requestImageData(for: asset, options: options) { data, dataUI, orientation, info in
+            PHImageManager.default().requestImageDataAndOrientation(for: asset, options: options) { data, dataUI, orientation, info in
                 guard var data = data else { return callCompletion(error: true) }
                 if compatibilityFormat {
                     guard let ciImage = CIImage.init(data: data), let colorSpace = ciImage.colorSpace, let dataJPEG = CIContext().jpegRepresentation(of: ciImage, colorSpace: colorSpace) else { return callCompletion(error: true) }