Marino Faggiana 6 anni fa
parent
commit
b10e9b506a

+ 3 - 3
iOSClient/Main/CCMain.m

@@ -2872,9 +2872,9 @@
         item.argument = account;
         
         tableAccount *tableAccount = [[NCManageDatabase sharedInstance] getAccountWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ ", account]];
-        NSString *directoryUser = [CCUtility getDirectoryActiveUser:tableAccount.user activeUrl:tableAccount.url];
-
-        UIImage *avatar = [UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/avatar.png", directoryUser]];
+        NSString *fileNamePath = [NSString stringWithFormat:@"%@/%@-avatar.png", [CCUtility getDirectoryUserData], [CCUtility getStringUser:tableAccount.user activeUrl:tableAccount.url]];
+        
+        UIImage *avatar = [UIImage imageWithContentsOfFile:fileNamePath];
         if (avatar) {
             
             avatar = [CCGraphics scaleImage:avatar toSize:CGSizeMake(25, 25) isAspectRation:YES];

+ 6 - 2
iOSClient/Main/CCMore.swift

@@ -183,7 +183,9 @@ class CCMore: UIViewController, UITableViewDelegate, UITableViewDataSource, CCLo
         
         self.view.backgroundColor = NCBrandColor.sharedInstance.brand
         
-        if let theminBackgroundFile = UIImage.init(contentsOfFile: "\(appDelegate.directoryUser!)/themingBackground.png") {
+        let fileNamePath = CCUtility.getDirectoryUserData() + "/" + CCUtility.getStringUser(appDelegate.activeUser, activeUrl: appDelegate.activeUrl) + "-themingBackground.png"
+        
+        if let theminBackgroundFile = UIImage.init(contentsOfFile: fileNamePath) {
             themingBackground.image = theminBackgroundFile
         } else {
             themingBackground.image = #imageLiteral(resourceName: "themingBackground")
@@ -196,7 +198,9 @@ class CCMore: UIViewController, UITableViewDelegate, UITableViewDataSource, CCLo
     
     @objc func changeUserProfile() {
      
-        if let themingAvatarFile = UIImage.init(contentsOfFile: "\(appDelegate.directoryUser!)/avatar.png") {
+        let fileNamePath = CCUtility.getDirectoryUserData() + "/" + CCUtility.getStringUser(appDelegate.activeUser, activeUrl: appDelegate.activeUrl) + "-avatar.png"
+
+        if let themingAvatarFile = UIImage.init(contentsOfFile: fileNamePath) {
             themingAvatar.image = themingAvatarFile
         } else {
             themingAvatar.image = UIImage.init(named: "moreAvatar")

+ 10 - 7
iOSClient/Networking/NCService.swift

@@ -130,7 +130,7 @@ class NCService: NSObject, OCNetworkingDelegate {
                 DispatchQueue.global().async {
                 
                     let address = capabilities!.themingBackground!.addingPercentEncoding(withAllowedCharacters: .urlFragmentAllowed)!
-                    let fileName = "\(self.appDelegate.directoryUser!)/themingBackground.png"
+                    let fileNamePath = CCUtility.getDirectoryUserData() + "/" + CCUtility.getStringUser(self.appDelegate.activeUser, activeUrl: self.appDelegate.activeUrl) + "-themingBackground.png"
 
                     guard let imageData = try? Data(contentsOf: URL(string: address)!) else {
                         DispatchQueue.main.async {
@@ -142,13 +142,13 @@ class NCService: NSObject, OCNetworkingDelegate {
                     DispatchQueue.main.async {
                         
                         guard let image = UIImage(data: imageData) else {
-                            try? FileManager.default.removeItem(atPath: fileName)
+                            try? FileManager.default.removeItem(atPath: fileNamePath)
                             self.appDelegate.settingThemingColorBrand()
                             return
                         }
                     
                         if let data = UIImagePNGRepresentation(image) {
-                            try? data.write(to: URL(fileURLWithPath: fileName))
+                            try? data.write(to: URL(fileURLWithPath: fileNamePath))
                         }
                     
                         self.appDelegate.settingThemingColorBrand()
@@ -235,6 +235,9 @@ class NCService: NSObject, OCNetworkingDelegate {
                 return
             }
             
+            let user = tableAccount.user
+            let url = tableAccount.url
+            
             CCNetworking.shared().settingAccount()
             appDelegate.settingActiveAccount(tableAccount.account, activeUrl: tableAccount.url, activeUser: tableAccount.user, activeUserID: tableAccount.userID, activePassword: tableAccount.password)
             
@@ -245,8 +248,8 @@ class NCService: NSObject, OCNetworkingDelegate {
             DispatchQueue.global(qos: .default).async {
                 
                 let address = "\(self.appDelegate.activeUrl!)/index.php/avatar/\(self.appDelegate.activeUser!)/128".addingPercentEncoding(withAllowedCharacters: .urlFragmentAllowed)!
-                let fileName = "\(self.appDelegate.directoryUser!)/avatar.png"
-
+                let fileNamePath = CCUtility.getDirectoryUserData() + "/" + CCUtility.getStringUser(user, activeUrl: url) + "-avatar.png"
+                
                 guard let imageData = try? Data(contentsOf: URL(string: address)!) else {
                     DispatchQueue.main.async {
                         NotificationCenter.default.post(name: NSNotification.Name(rawValue: "changeUserProfile"), object: nil)
@@ -257,13 +260,13 @@ class NCService: NSObject, OCNetworkingDelegate {
                 DispatchQueue.main.async {
                     
                     guard let image = UIImage(data: imageData) else {
-                        try? FileManager.default.removeItem(atPath: fileName)
+                        try? FileManager.default.removeItem(atPath: fileNamePath)
                         NotificationCenter.default.post(name: NSNotification.Name(rawValue: "changeUserProfile"), object: nil)
                         return
                     }
                 
                     if let data = UIImagePNGRepresentation(image) {
-                        try? data.write(to: URL(fileURLWithPath: fileName))
+                        try? data.write(to: URL(fileURLWithPath: fileNamePath))
                     }
                 
                     NotificationCenter.default.post(name: NSNotification.Name(rawValue: "changeUserProfile"), object: nil)

+ 3 - 2
iOSClient/Settings/CCManageAccount.m

@@ -374,7 +374,9 @@
     pickerAccount.rowDescriptor.selectorOptions = listAccount;
     pickerAccount.rowDescriptor.value = appDelegate.activeAccount;
     
-    UIImage *avatar = [UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/avatar.png", appDelegate.directoryUser]];
+    NSString *fileNamePath = [NSString stringWithFormat:@"%@/%@-avatar.png", [CCUtility getDirectoryUserData], [CCUtility getStringUser:appDelegate.activeUser activeUrl:appDelegate.activeUrl]];
+
+    UIImage *avatar = [UIImage imageWithContentsOfFile:fileNamePath];
     if (avatar) {
     
         avatar = [CCGraphics scaleImage:avatar toSize:CGSizeMake(40, 40) isAspectRation:YES];
@@ -393,7 +395,6 @@
         avatar = [UIImage imageNamed:@"avatarBN"];
     }
     
-    
     [pickerAccount.rowDescriptor.cellConfig setObject:avatar forKey:@"imageView.image"];
 
     // --