Browse Source

coding

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>
Marino Faggiana 2 years ago
parent
commit
feb87339f6

+ 8 - 8
Nextcloud.xcodeproj/project.pbxproj

@@ -460,8 +460,8 @@
 		F7A321AD1E9E6AD50069AD1B /* CCAdvanced.m in Sources */ = {isa = PBXBuildFile; fileRef = F7A321AC1E9E6AD50069AD1B /* CCAdvanced.m */; };
 		F7A48413297022E000BD1B49 /* ViewerQuickLook.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7A48412297022E000BD1B49 /* ViewerQuickLook.swift */; };
 		F7A48415297028FC00BD1B49 /* Nextcloud Hub.png in Resources */ = {isa = PBXBuildFile; fileRef = F7A48414297028FC00BD1B49 /* Nextcloud Hub.png */; };
-		F7A60F86292D215000FCE1F2 /* NCTalkAccounts.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7A60F84292D215000FCE1F2 /* NCTalkAccounts.swift */; };
-		F7A60F87292D215000FCE1F2 /* NCTalkAccounts.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F7A60F85292D215000FCE1F2 /* NCTalkAccounts.storyboard */; };
+		F7A60F86292D215000FCE1F2 /* NCShareAccounts.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7A60F84292D215000FCE1F2 /* NCShareAccounts.swift */; };
+		F7A60F87292D215000FCE1F2 /* NCShareAccounts.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F7A60F85292D215000FCE1F2 /* NCShareAccounts.storyboard */; };
 		F7A76DC8256A71CD00119AB3 /* UIImage+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7B7504A2397D38E004E13EC /* UIImage+Extension.swift */; };
 		F7A76DCD256A71CE00119AB3 /* UIImage+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7B7504A2397D38E004E13EC /* UIImage+Extension.swift */; };
 		F7A7FA6329265CF4000603EF /* NCManageE2EE.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7A7FA6229265CF4000603EF /* NCManageE2EE.swift */; };
@@ -1051,8 +1051,8 @@
 		F7A321AC1E9E6AD50069AD1B /* CCAdvanced.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCAdvanced.m; sourceTree = "<group>"; };
 		F7A48412297022E000BD1B49 /* ViewerQuickLook.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewerQuickLook.swift; sourceTree = "<group>"; };
 		F7A48414297028FC00BD1B49 /* Nextcloud Hub.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Nextcloud Hub.png"; sourceTree = SOURCE_ROOT; };
-		F7A60F84292D215000FCE1F2 /* NCTalkAccounts.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NCTalkAccounts.swift; sourceTree = "<group>"; };
-		F7A60F85292D215000FCE1F2 /* NCTalkAccounts.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = NCTalkAccounts.storyboard; sourceTree = "<group>"; };
+		F7A60F84292D215000FCE1F2 /* NCShareAccounts.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NCShareAccounts.swift; sourceTree = "<group>"; };
+		F7A60F85292D215000FCE1F2 /* NCShareAccounts.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = NCShareAccounts.storyboard; sourceTree = "<group>"; };
 		F7A7FA6229265CF4000603EF /* NCManageE2EE.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCManageE2EE.swift; sourceTree = "<group>"; };
 		F7A8D72228F176B6008BBE1C /* WidgetDashboardIntentHandler-Brinding-header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "WidgetDashboardIntentHandler-Brinding-header.h"; sourceTree = "<group>"; };
 		F7A8D73028F17C44008BBE1C /* WidgetDashboardIntentHandler.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = WidgetDashboardIntentHandler.entitlements; sourceTree = "<group>"; };
@@ -2096,8 +2096,8 @@
 			children = (
 				F7CA212C25F1333200826ABB /* NCAccountRequest.storyboard */,
 				F7CA212B25F1333200826ABB /* NCAccountRequest.swift */,
-				F7A60F85292D215000FCE1F2 /* NCTalkAccounts.storyboard */,
-				F7A60F84292D215000FCE1F2 /* NCTalkAccounts.swift */,
+				F7A60F85292D215000FCE1F2 /* NCShareAccounts.storyboard */,
+				F7A60F84292D215000FCE1F2 /* NCShareAccounts.swift */,
 			);
 			path = "Account Request";
 			sourceTree = "<group>";
@@ -2875,7 +2875,7 @@
 				F7F4F10627ECDBDB008676F9 /* Inconsolata-Medium.ttf in Resources */,
 				F7AC934A296193050002BC0F /* Reasons to use Nextcloud.pdf in Resources */,
 				F749C10D23C4A5340027D966 /* NCIntro.storyboard in Resources */,
-				F7A60F87292D215000FCE1F2 /* NCTalkAccounts.storyboard in Resources */,
+				F7A60F87292D215000FCE1F2 /* NCShareAccounts.storyboard in Resources */,
 				F7239877253D86D300257F49 /* NCEmptyView.xib in Resources */,
 				F747BA1F22354D2000971601 /* NCCreateFormUploadVoiceNote.storyboard in Resources */,
 				F719D9E0288D37A300762E33 /* NCColorPicker.storyboard in Resources */,
@@ -3222,7 +3222,7 @@
 				F769454622E9F1B0000A798A /* NCShareCommon.swift in Sources */,
 				F70753F12542A9A200972D44 /* NCViewerMedia.swift in Sources */,
 				F78A18B823CDE2B300F681F3 /* NCViewerRichWorkspace.swift in Sources */,
-				F7A60F86292D215000FCE1F2 /* NCTalkAccounts.swift in Sources */,
+				F7A60F86292D215000FCE1F2 /* NCShareAccounts.swift in Sources */,
 				F77910AB25DD53C700CEDB9E /* NCSettingsBundleHelper.swift in Sources */,
 				AF4BF61927562A4B0081CEEF /* NCManageDatabase+Metadata.swift in Sources */,
 				F78A18B623CDD07D00F681F3 /* NCViewerRichWorkspaceWebView.swift in Sources */,

+ 2 - 2
iOSClient/Account Request/NCTalkAccounts.storyboard → iOSClient/Account Request/NCShareAccounts.storyboard

@@ -9,10 +9,10 @@
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <scenes>
-        <!--Talk Accounts-->
+        <!--Share Accounts-->
         <scene sceneID="L90-uG-f4z">
             <objects>
-                <viewController id="V0q-CP-xMJ" customClass="NCTalkAccounts" customModule="Nextcloud" customModuleProvider="target" sceneMemberID="viewController">
+                <viewController id="V0q-CP-xMJ" customClass="NCShareAccounts" customModule="Nextcloud" customModuleProvider="target" sceneMemberID="viewController">
                     <layoutGuides>
                         <viewControllerLayoutGuide type="top" id="4vK-ua-S0e"/>
                         <viewControllerLayoutGuide type="bottom" id="hTI-Bw-Fws"/>

+ 7 - 7
iOSClient/Account Request/NCTalkAccounts.swift → iOSClient/Account Request/NCShareAccounts.swift

@@ -1,5 +1,5 @@
 //
-//  NCTalkAccounts.swift
+//  NCShareAccounts.swift
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 22/11/22.
@@ -24,16 +24,16 @@
 import UIKit
 import NextcloudKit
 
-public protocol NCTalkAccountsDelegate: AnyObject {
+public protocol NCShareAccountsDelegate: AnyObject {
     func selected(url: String, user: String)
 }
 
 // optional func
-public extension NCTalkAccountsDelegate {
+public extension NCShareAccountsDelegate {
     func selected(url: String, user: String) {}
 }
 
-class NCTalkAccounts: UIViewController {
+class NCShareAccounts: UIViewController {
 
     @IBOutlet weak var titleLabel: UILabel!
     @IBOutlet weak var tableView: UITableView!
@@ -43,7 +43,7 @@ class NCTalkAccounts: UIViewController {
     public let heightCell: CGFloat = 60
     public var enableTimerProgress: Bool = true
     public var dismissDidEnterBackground: Bool = true
-    public weak var delegate: NCTalkAccountsDelegate?
+    public weak var delegate: NCShareAccountsDelegate?
 
     private var timer: Timer?
     private var time: Float = 0
@@ -128,7 +128,7 @@ class NCTalkAccounts: UIViewController {
     }
 }
 
-extension NCTalkAccounts: UITableViewDelegate {
+extension NCShareAccounts: UITableViewDelegate {
 
     func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
 
@@ -149,7 +149,7 @@ extension NCTalkAccounts: UITableViewDelegate {
     }
 }
 
-extension NCTalkAccounts: UITableViewDataSource {
+extension NCShareAccounts: UITableViewDataSource {
 
     func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
         return accounts.count

+ 6 - 9
iOSClient/AppDelegate.swift

@@ -629,8 +629,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
     func createDataAccountFile() -> Error? {
         guard !account.isEmpty, let dirGroupApps = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: NCBrandOptions.shared.capabilitiesGroupApps) else { return nil }
 
-        try? FileManager.default.createDirectory(at: dirGroupApps.appendingPathComponent(NCGlobal.shared.appDataShareNextcloud), withIntermediateDirectories: true)
-        let url = dirGroupApps.appendingPathComponent(NCGlobal.shared.appDataShareNextcloud + "/" + NCGlobal.shared.fileAccounts)
+        try? FileManager.default.createDirectory(at: dirGroupApps.appendingPathComponent(NCGlobal.shared.directoryNextcloudAccounts), withIntermediateDirectories: true)
+        let url = dirGroupApps.appendingPathComponent(NCGlobal.shared.directoryNextcloudAccounts + "/" + NCGlobal.shared.fileShareAccounts)
         let tableAccount = NCManageDatabase.shared.getAllAccount()
         var accounts = [NKDataAccountFile]()
         for account in tableAccount {
@@ -638,7 +638,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
             let userBaseUrl = account.user + "-" + (URL(string: account.urlBase)?.host ?? "")
             let avatarFileName = userBaseUrl + "-\(account.user).png"
             let atPathAvatar = String(CCUtility.getDirectoryUserData()) + "/" + avatarFileName
-            let toPathAvatar = (dirGroupApps.appendingPathComponent(NCGlobal.shared.appDataShareNextcloud + "/" + avatarFileName)).path
+            let toPathAvatar = (dirGroupApps.appendingPathComponent(NCGlobal.shared.directoryNextcloudAccounts + "/" + avatarFileName)).path
             if FileManager.default.fileExists(atPath: atPathAvatar) {
                 NCUtilityFileSystem.shared.copyFile(atPath: atPathAvatar, toPath: toPathAvatar)
                 accounts.append(NKDataAccountFile(withUrl: account.urlBase, user: account.user, alias: alias, avatar: toPathAvatar))
@@ -646,10 +646,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
                 accounts.append(NKDataAccountFile(withUrl: account.urlBase, user: account.user, alias: alias))
             }
         }
-        let obj = NKAccountFile().putShareAccounts(at: url, app: "nextcloud", items: accounts)
-        return nil
-
-        // return NKCommon.shared.createDataAccountFile(at: url, accounts: accounts)
+        return NKAccountFile().putShareAccounts(at: url, app: NCGlobal.shared.appScheme, items: accounts)
     }
 
     // MARK: - Account Request
@@ -811,7 +808,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
          nextcloud://open-action?action=create-voice-memo&&user=marinofaggiana&url=https://cloud.nextcloud.com
          */
 
-        if !account.isEmpty && scheme == "nextcloud" && action == "open-action" {
+        if !account.isEmpty && scheme == NCGlobal.shared.appScheme && action == "open-action" {
 
             if let urlComponents = URLComponents(url: url, resolvingAgainstBaseURL: false) {
 
@@ -887,7 +884,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
          nextcloud://open-file?path=Talk/IMG_0000123.jpg&user=marinofaggiana&link=https://cloud.nextcloud.com/f/123
          */
 
-        else if !account.isEmpty && scheme == "nextcloud" && action == "open-file" {
+        else if !account.isEmpty && scheme == NCGlobal.shared.appScheme && action == "open-file" {
 
             if let urlComponents = URLComponents(url: url, resolvingAgainstBaseURL: false) {
 

+ 8 - 8
iOSClient/Login/NCLogin.swift

@@ -42,7 +42,7 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
     private var activeTextfieldDiff: CGFloat = 0
     private var activeTextField = UITextField()
 
-    private var talkAccounts: [NKDataAccountFile]?
+    private var shareAccounts: [NKDataAccountFile]?
 
     // MARK: - View Life Cycle
 
@@ -116,7 +116,7 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
         }
 
         if NCBrandOptions.shared.use_GroupApps, let dirGroupApps = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: NCBrandOptions.shared.capabilitiesGroupApps), let url = URL(string: "nextcloudtalk://"), UIApplication.shared.canOpenURL(url) {
-            let url = dirGroupApps.appendingPathComponent(NCGlobal.shared.appDataShareTalk + "/" + NCGlobal.shared.fileAccounts)
+            let url = dirGroupApps.appendingPathComponent(NCGlobal.shared.directoryNextcloudAccounts + "/" + NCGlobal.shared.fileShareAccounts)
             if FileManager.default.fileExists(atPath: url.path), let talkAccounts = NKCommon.shared.readDataAccountFile(at: url) {
                 var accountTemp = [NKDataAccountFile]()
                 for talkAccount in talkAccounts {
@@ -125,7 +125,7 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
                     }
                 }
                 if !accountTemp.isEmpty {
-                    self.talkAccounts = accountTemp
+                    self.shareAccounts = accountTemp
                     let navigationItemTalk = UIBarButtonItem(image: UIImage(named: "talk_bar"), style: .plain, target: self, action: #selector(openTalkAccountsViewController))
                     navigationItemTalk.tintColor = textColor
                     self.navigationItem.rightBarButtonItem = navigationItemTalk
@@ -145,7 +145,7 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
 
         appDelegate.timerErrorNetworking?.invalidate()
 
-        if self.talkAccounts != nil, let image = UIImage(named: "talk"), let backgroundColor =  NCBrandColor.shared.brandElement.lighter(by: 10) {
+        if self.shareAccounts != nil, let image = UIImage(named: "talk"), let backgroundColor =  NCBrandColor.shared.brandElement.lighter(by: 10) {
             NCContentPresenter.shared.alertAction(image: image, backgroundColor: backgroundColor, textColor: textColor, title: "_talk_detect_", description: "_talk_add_account_", textCancelButton: "_cancel_", textOkButton: "_ok_", attributes: EKAttributes.topFloat) { identifier in
                 if identifier == "ok" {
                     self.openTalkAccountsViewController()
@@ -230,15 +230,15 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
 
     @objc func openTalkAccountsViewController() {
 
-        if let talkAccounts = self.talkAccounts, let vc = UIStoryboard(name: "NCTalkAccounts", bundle: nil).instantiateInitialViewController() as? NCTalkAccounts {
+        if let shareAccounts = self.shareAccounts, let vc = UIStoryboard(name: "NCShareAccounts", bundle: nil).instantiateInitialViewController() as? NCShareAccounts {
 
-            vc.accounts = talkAccounts
+            vc.accounts = shareAccounts
             vc.enableTimerProgress = false
             vc.dismissDidEnterBackground = false
             vc.delegate = self
 
             let screenHeighMax = UIScreen.main.bounds.height - (UIScreen.main.bounds.height/5)
-            let numberCell = talkAccounts.count
+            let numberCell = shareAccounts.count
             let height = min(CGFloat(numberCell * Int(vc.heightCell) + 45), screenHeighMax)
 
             let popup = NCPopupViewController(contentController: vc, popupWidth: 300, popupHeight: height+20)
@@ -439,7 +439,7 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
     }
 }
 
-extension NCLogin: NCTalkAccountsDelegate {
+extension NCLogin: NCShareAccountsDelegate {
 
     func selected(url: String, user: String) {
         isUrlValid(url: url, user: user)

+ 4 - 4
iOSClient/NCGlobal.swift

@@ -78,10 +78,9 @@ class NCGlobal: NSObject {
     @objc let appScan                               = "Library/Application Support/Scan"
     @objc let appUserData                           = "Library/Application Support/UserData"
 
-    // Directory on Group data share Nextcloud apps
+    // Directory on Nextcloud Group data share accounts
     //
-    @objc let appDataShareTalk                      = "Library/Application Support/Talk"
-    @objc let appDataShareNextcloud                 = "Library/Application Support/Nextcloud"
+    @objc let directoryNextcloudAccounts            = "Library/Application Support/NextcloudAccounts"
 
     // Service
     //
@@ -94,6 +93,7 @@ class NCGlobal: NSObject {
     //
     @objc let appName                               = "files"
     @objc let talkName                              = "talk-message"
+    @objc let appScheme                             = "nextcloud"
 
     // Nextcloud version
     //
@@ -115,7 +115,7 @@ class NCGlobal: NSObject {
     //
     let databaseDefault                             = "nextcloud.realm"
     let databaseSchemaVersion: UInt64               = 266
-    let fileAccounts: String                        = "accounts.json"
+    let fileShareAccounts: String                   = "accounts.json"
 
     // Intro selector
     //

+ 0 - 1
iOSClient/Settings/CCAdvanced.m

@@ -461,7 +461,6 @@
 
         [CCUtility removeGroupDirectoryProviderStorage];
         [CCUtility removeGroupApplicationSupport];
-        [CCUtility removeGroupDataShareAppsNextcloud];
         
         [CCUtility removeDocumentsDirectory];
         [CCUtility removeTemporaryDirectory];

+ 0 - 1
iOSClient/Utility/CCUtility.h

@@ -227,7 +227,6 @@
 + (void)removeDocumentsDirectory;
 + (void)removeTemporaryDirectory;
 + (void)emptyTemporaryDirectory;
-+ (void)removeGroupDataShareAppsNextcloud;
 
 + (NSString *)getTitleSectionDate:(NSDate *)date;
 

+ 0 - 7
iOSClient/Utility/CCUtility.m

@@ -1208,13 +1208,6 @@
     }
 }
 
-+ (void)removeGroupDataShareAppsNextcloud
-{
-    NSURL *dirGroup = [[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier:[NCBrandOptions shared].capabilitiesGroupApps];
-    NSString *path = [[dirGroup URLByAppendingPathComponent:NCGlobal.shared.appDataShareNextcloud] path];
-    [[NSFileManager defaultManager] removeItemAtPath:path error:nil];
-}
-
 + (NSString *)getTitleSectionDate:(NSDate *)date
 {
     NSString *title;