Marino Faggiana 7 anni fa
parent
commit
1a72b77824

+ 0 - 1
iOSClient/AppDelegate.h

@@ -67,7 +67,6 @@
 @property BOOL hasServerShareSupport;
 @property BOOL hasServerShareeSupport;
 @property BOOL hasServerCapabilitiesSupport;
-@property OCCapabilities *capabilities;
 @property (nonatomic, strong) NSMutableArray<OCCommunication *> *listOfNotifications;
 @property NSInteger serverVersion;
 

+ 11 - 0
iOSClient/AppDelegate.m

@@ -867,6 +867,17 @@
 
 - (void)aspectNavigationControllerBar:(UINavigationBar *)nav encrypted:(BOOL)encrypted online:(BOOL)online hidden:(BOOL)hidden
 {
+    if (app.activeAccount.length > 0 && k_option_use_themingColor == YES) {
+        
+        TableCapabilities *capabilities = [CCCoreData getCapabilitesForAccount:app.activeAccount];
+        if (capabilities.themingColor.length > 0) {
+            
+            UIColor *themingColor = [CCGraphics colorFromHexString:capabilities.themingColor];
+            NCBrandColor.sharedInstance.navigationBar = themingColor;
+            NCBrandColor.sharedInstance.navigationBarShare = themingColor;
+        }
+    }
+    
     nav.translucent = NO;
     nav.barTintColor = [NCBrandColor sharedInstance].navigationBar;
     nav.tintColor = [NCBrandColor sharedInstance].navigationBarText;

+ 2 - 0
iOSClient/FileSystem/CCCoreData.h

@@ -227,7 +227,9 @@
 + (NSArray *)getAllTableExternalSitesWithPredicate:(NSPredicate *)predicate;
 
 // ===== Capabilities =====
+
 + (void)addCapabilities:(OCCapabilities *)capabilities account:(NSString *)account;
++ (TableCapabilities *)getCapabilitesForAccount:(NSString *)account;
 
 // ===== File System =====
 

+ 7 - 0
iOSClient/FileSystem/CCCoreData.m

@@ -2034,6 +2034,13 @@
     }];
 }
 
++ (TableCapabilities *)getCapabilitesForAccount:(NSString *)account
+{
+    NSManagedObjectContext *context = [NSManagedObjectContext MR_defaultContext];
+    
+    return [TableCapabilities MR_findFirstWithPredicate:[NSPredicate predicateWithFormat:@"(account == %@)", account] inContext:context];
+}
+
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark ===== File System =====
 #pragma --------------------------------------------------------------------------------------------

+ 5 - 7
iOSClient/Main/CCMain.m

@@ -1189,15 +1189,13 @@
 }
 
 - (void)getCapabilitiesOfServerSuccess:(OCCapabilities *)capabilities
-{
-    app.capabilities = capabilities;
+{    
+    [CCCoreData addCapabilities:capabilities account:app.activeAccount];
     
+    // Change Theming
     if (k_option_use_themingColor == YES) {
         
-        UIColor *themingColor = [CCGraphics colorFromHexString:capabilities.themingColor];
-        NCBrandColor.sharedInstance.navigationBar = themingColor;
-        NCBrandColor.sharedInstance.navigationBarShare = themingColor;
-        self.navigationController.navigationBar.barTintColor = [NCBrandColor sharedInstance].navigationBar;
+        [[NSNotificationCenter defaultCenter] postNotificationName:@"changeTheming" object:nil];
     }
     
     // Search bar if change version
@@ -1223,7 +1221,7 @@
         });
     }
     
-    if (app.capabilities.isExternalSitesServerEnabled) {
+    if (capabilities.isExternalSitesServerEnabled) {
         
         CCMetadataNet *metadataNet = [[CCMetadataNet alloc] initWithAccount:app.activeAccount];
 

+ 15 - 0
iOSClient/Settings/Acknowledgements.m

@@ -26,6 +26,16 @@
 
 @implementation Acknowledgements
 
+-  (id)initWithCoder:(NSCoder *)aDecoder
+{
+    if (self = [super initWithCoder:aDecoder])  {
+        
+        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeTheming) name:@"changeTheming" object:nil];
+    }
+    
+    return self;
+}
+
 - (void)viewDidLoad
 {
     [super viewDidLoad];
@@ -61,6 +71,11 @@
     self.txtTermini.hidden = false;
 }
 
+- (void)changeTheming
+{
+    [app aspectNavigationControllerBar:self.navigationController.navigationBar encrypted:NO online:[app.reachability isReachable] hidden:NO];
+}
+
 - (void)cancelPressed
 {
     [self dismissViewControllerAnimated:true completion:nil];