Marino Faggiana 6 years ago
parent
commit
12358d164c

+ 7 - 17
iOSClient/Library/OCCommunicationLib/OCCommunication.m

@@ -1924,30 +1924,20 @@
                 
                 if ([quota count] > 0) {
                     
-                    if ([quota valueForKey:@"free"] && ![[quota valueForKey:@"free"] isKindOfClass:[NSNull class]]) {
+                    if ([quota valueForKey:@"free"] && ![[quota valueForKey:@"free"] isKindOfClass:[NSNull class]])
                         userProfile.quotaFree = [[quota valueForKey:@"free"] doubleValue];
-                        if (userProfile.quotaFree < 0) userProfile.quotaFree = 0;
-                    }
                     
-                    if ([quota valueForKey:@"quota"] && ![[quota valueForKey:@"quota"] isKindOfClass:[NSNull class]]) {
+                    if ([quota valueForKey:@"quota"] && ![[quota valueForKey:@"quota"] isKindOfClass:[NSNull class]])
                         userProfile.quota = [[quota valueForKey:@"quota"] doubleValue];
-                        if (userProfile.quota < 0) userProfile.quota = 0;
-                    }
                     
-                    if ([quota valueForKey:@"relative"] && ![[quota valueForKey:@"relative"] isKindOfClass:[NSNull class]]) {
+                    if ([quota valueForKey:@"relative"] && ![[quota valueForKey:@"relative"] isKindOfClass:[NSNull class]])
                         userProfile.quotaRelative = [[quota valueForKey:@"relative"] doubleValue];
-                        if (userProfile.quotaRelative < 0) userProfile.quotaRelative = 0;
-                    }
-                    
-                    if ([quota valueForKey:@"total"] && ![[quota valueForKey:@"total"] isKindOfClass:[NSNull class]]) {
+                        
+                    if ([quota valueForKey:@"total"] && ![[quota valueForKey:@"total"] isKindOfClass:[NSNull class]])
                         userProfile.quotaTotal = [[quota valueForKey:@"total"] doubleValue];
-                        if (userProfile.quotaTotal < 0) userProfile.quotaTotal = 0;
-                    }
-                    
-                    if ([quota valueForKey:@"used"] && ![[quota valueForKey:@"used"] isKindOfClass:[NSNull class]]) {
+                        
+                    if ([quota valueForKey:@"used"] && ![[quota valueForKey:@"used"] isKindOfClass:[NSNull class]])
                         userProfile.quotaUsed = [[quota valueForKey:@"used"] doubleValue];
-                        if (userProfile.quotaUsed < 0) userProfile.quotaUsed = 0;
-                    }
                 }
                 
                 successRequest(response, userProfile, request.redirectedServer);

+ 4 - 0
iOSClient/Library/OCCommunicationLib/OCFrameworkConstants.h

@@ -110,6 +110,10 @@
 //Name of the container to configure NSURLSessions
 #define k_shared_container_identifier @"group.com.owncloud.iOSmobileapp";
 
+// Quota return value
+#define k_quota_space_not_computed  -1
+#define k_quota_space_unknown       -2
+#define k_quota_space_unlimited     -3
 
 
 

+ 14 - 3
iOSClient/Main/CCMore.swift

@@ -197,7 +197,8 @@ class CCMore: UIViewController, UITableViewDelegate, UITableViewDataSource, CCLo
     @objc func changeUserProfile() {
      
         let fileNamePath = CCUtility.getDirectoryUserData() + "/" + CCUtility.getStringUser(appDelegate.activeUser, activeUrl: appDelegate.activeUrl) + "-avatar.png"
-
+        var quota: String = ""
+        
         if let themingAvatarFile = UIImage.init(contentsOfFile: fileNamePath) {
             themingAvatar.image = themingAvatarFile
         } else {
@@ -232,8 +233,18 @@ class CCMore: UIViewController, UITableViewDelegate, UITableViewDataSource, CCLo
         }
 
         progressQuota.progressTintColor = NCBrandColor.sharedInstance.brandElement
-                
-        let quota : String = CCUtility.transformedSize(Double(tabAccount.quotaTotal))
+        
+        switch Double(tabAccount.quotaTotal) {
+        case Double(k_quota_space_not_computed):
+            quota = "0"
+        case Double(k_quota_space_unknown):
+            quota = NSLocalizedString("_quota_space_unknown_", comment: "")
+        case Double(k_quota_space_unlimited):
+            quota = NSLocalizedString("_quota_space_unlimited_", comment: "")
+        default:
+            quota = CCUtility.transformedSize(Double(tabAccount.quotaTotal))
+        }
+        
         let quotaUsed : String = CCUtility.transformedSize(Double(tabAccount.quotaUsed))
                 
         labelQuota.text = String.localizedStringWithFormat(NSLocalizedString("_quota_using_", comment: ""), quotaUsed, quota)

+ 3 - 1
iOSClient/Supporting Files/en.lproj/Localizable.strings

@@ -106,6 +106,9 @@
 "_more_"                        = "More";
 "_notifications_"               = "Notifications";
 "_logout_"                      = "Log out";
+"_quota_space_unlimited_"       = "Unlimited";
+"_quota_space_unknown_"         = "Unknown";
+"_quota_using_"                 = "You are using %@ of %@";
 
 // Settings
 
@@ -169,7 +172,6 @@
 "_user_email_"                  = "Email";
 "_user_web_"                    = "Website";
 "_user_twitter_"                = "Twitter";
-"_quota_using_"                 = "You are using %@ of %@";
 "_favorite_offline_"            = "Favorites available offline";
 "_favorite_offline_footer_"     = "Making all favorites available offline may take a while and use a lot of memory while doing it.";
 "_advanced_"                    = "Advanced";