Browse Source

Improved widget

Signed-off-by: marinofaggiana <marino.faggiana@nextcloud.com>
marinofaggiana 2 years ago
parent
commit
d51dc7f865

+ 24 - 0
Widget/Nextcloud/NextcloudData.swift

@@ -48,4 +48,28 @@ let nextcloudDatasTest: [NextcloudData] = [
 
 func readNextcloudData(completion: @escaping (_ NextcloudDatas: [NextcloudData], _ isPlaceholder: Bool, _ footerText: String) -> Void) {
 
+    guard let account = NCManageDatabase.shared.getActiveAccount() else {
+        return completion(nextcloudDatasTest, true, NSLocalizedString("_no_active_account_", value: "No account found", comment: ""))
+    }
+
+    // LOG
+    let levelLog = CCUtility.getLogLevel()
+    let isSimulatorOrTestFlight = NCUtility.shared.isSimulatorOrTestFlight()
+    let versionNextcloudiOS = String(format: NCBrandOptions.shared.textCopyrightNextcloudiOS, NCUtility.shared.getVersionApp())
+
+    NKCommon.shared.levelLog = levelLog
+    if let pathDirectoryGroup = CCUtility.getDirectoryGroup()?.path {
+        NKCommon.shared.pathLog = pathDirectoryGroup
+    }
+    if isSimulatorOrTestFlight {
+        NKCommon.shared.writeLog("Start \(NCBrandOptions.shared.brand) widget session with level \(levelLog) " + versionNextcloudiOS + " (Simulator / TestFlight)")
+    } else {
+        NKCommon.shared.writeLog("Start \(NCBrandOptions.shared.brand) widget session with level \(levelLog) " + versionNextcloudiOS)
+    }
+    NKCommon.shared.writeLog("Start \(NCBrandOptions.shared.brand) widget [Auto upload]")
+
+    NCAutoUpload.shared.initAutoUpload(viewController: nil) { items in
+        completion(nextcloudDatasTest, false, "Auto upoload: \(items), \(Date().formatted())")
+        NKCommon.shared.writeLog("Completition \(NCBrandOptions.shared.brand) widget [Auto upload]")
+    }
 }

+ 3 - 3
Widget/Nextcloud/NextcloudWidgetView.swift

@@ -35,13 +35,13 @@ struct NextcloudWidgetView: View {
                     .frame(width: 10, height: 10)
                     .cornerRadius(3)
                 Text(NCBrandOptions.shared.brand + "")
-                    .font(.system(size: 12))
+                    .font(.system(size: 11))
                     .textCase(.uppercase)
             }
             .padding(.leading, 10)
             .padding(.top, 5)
             VStack(alignment: .leading, spacing: 5) {
-                VStack(spacing: 5) {
+                VStack(spacing: 6) {
                     ForEach(entry.nextcloudDatas, id: \.id) { element in
                         Link(destination: element.url) {
                             HStack {
@@ -76,7 +76,7 @@ struct NextcloudWidgetView: View {
 
 struct NextcloudWidget_Previews: PreviewProvider {
     static var previews: some View {
-        let entry = NextcloudDataEntry(date: Date(), nextcloudDatas: nextcloudDatasTest, isPlaceholder: false, footerText: "Nextcloud widget")
+        let entry = NextcloudDataEntry(date: Date(), nextcloudDatas: nextcloudDatasTest, isPlaceholder: false, footerText: NCBrandOptions.shared.brand + " widget")
         NextcloudWidgetView(entry: entry).previewContext(WidgetPreviewContext(family: .systemLarge))
     }
 }

+ 4 - 4
iOSClient/Networking/NCAutoUpload.swift

@@ -86,7 +86,7 @@ class NCAutoUpload: NSObject {
             self.getCameraRollAssets(viewController: viewController, account: account, selector: selector, alignPhotoLibrary: false) { assets in
                 guard let assets = assets, !assets.isEmpty else {
                     #if EXTENSION_WIDGET
-                    NKCommon.shared.writeLog("Automatic upload Dashboard widget, no new assets found [" + log + "]")
+                    NKCommon.shared.writeLog("Automatic upload widget, no new assets found [" + log + "]")
                     #else
                     NCCommunicationCommon.shared.writeLog("Automatic upload, no new assets found [" + log + "]")
                     #endif
@@ -94,7 +94,7 @@ class NCAutoUpload: NSObject {
                     return
                 }
                 #if EXTENSION_WIDGET
-                NKCommon.shared.writeLog("Automatic upload Dashboard widget, new \(assets.count) assets found [" + log + "]")
+                NKCommon.shared.writeLog("Automatic upload widget, new \(assets.count) assets found [" + log + "]")
                 #else
                 NCCommunicationCommon.shared.writeLog("Automatic upload, new \(assets.count) assets found [" + log + "]")
                 #endif
@@ -171,7 +171,7 @@ class NCAutoUpload: NSObject {
                         }
                         if selector == NCGlobal.shared.selectorUploadAutoUpload {
                             #if EXTENSION_WIDGET
-                            NKCommon.shared.writeLog("Automatic upload Dashboard widget added \(metadata.fileNameView) with Identifier \(metadata.assetLocalIdentifier)")
+                            NKCommon.shared.writeLog("Automatic upload widget added \(metadata.fileNameView) with Identifier \(metadata.assetLocalIdentifier)")
                             #else
                             NCCommunicationCommon.shared.writeLog("Automatic upload added \(metadata.fileNameView) with Identifier \(metadata.assetLocalIdentifier)")
                             #endif
@@ -210,7 +210,7 @@ class NCAutoUpload: NSObject {
 
             NCManageDatabase.shared.addPhotoLibrary(assets, account: activeAccount.account)
             #if EXTENSION_WIDGET
-            NKCommon.shared.writeLog("Dashboard widget align Photo Library \(assets.count)")
+            NKCommon.shared.writeLog("Widget align Photo Library \(assets.count)")
             #else
             NCCommunicationCommon.shared.writeLog("Align Photo Library \(assets.count)")
             #endif