Browse Source

Theming color

Marino Faggiana 8 years ago
parent
commit
673d306873

+ 7 - 0
iOSClient/Activity/CCActivity.m

@@ -57,6 +57,8 @@
     if (self = [super initWithCoder:aDecoder])  {
         
         app.activeActivity = self;
+        
+        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeTheming) name:@"changeTheming" object:nil];
     }
     return self;
 }
@@ -101,6 +103,11 @@
     [self reloadDatasource];
 }
 
+- (void)changeTheming
+{
+    [app aspectNavigationControllerBar:self.navigationController.navigationBar encrypted:NO online:[app.reachability isReachable] hidden:NO];
+}
+
 - (void)didReceiveMemoryWarning {
     
     [super didReceiveMemoryWarning];

+ 3 - 7
iOSClient/Favorites/CCFavorites.m

@@ -50,6 +50,7 @@
     if (self = [super initWithCoder:aDecoder])  {
         
         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(triggerProgressTask:) name:@"NotificationProgressTask" object:nil];
+        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeTheming) name:@"changeTheming" object:nil];
     }
     return self;
 }
@@ -99,14 +100,9 @@
     [self reloadDatasource];
 }
 
-// E' arrivato
-- (void)viewDidAppear:(BOOL)animated
+- (void)changeTheming
 {
-    [super viewDidAppear:animated];
-}
-
-- (void)didReceiveMemoryWarning {
-    [super didReceiveMemoryWarning];
+    [app aspectNavigationControllerBar:self.navigationController.navigationBar encrypted:NO online:[app.reachability isReachable] hidden:NO];
 }
 
 - (void)triggerProgressTask:(NSNotification *)notification

+ 12 - 7
iOSClient/Local storage/CCLocalStorage.m

@@ -38,6 +38,16 @@
 
 @implementation CCLocalStorage
 
+-  (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];
@@ -83,14 +93,9 @@
     [self reloadDatasource];
 }
 
-// E' arrivato
-- (void)viewDidAppear:(BOOL)animated
+- (void)changeTheming
 {
-    [super viewDidAppear:animated];        
-}
-
-- (void)didReceiveMemoryWarning {
-    [super didReceiveMemoryWarning];
+    [app aspectNavigationControllerBar:self.navigationController.navigationBar encrypted:NO online:[app.reachability isReachable] hidden:NO];
 }
 
 #pragma --------------------------------------------------------------------------------------------

+ 17 - 1
iOSClient/Main/CCDetail.m

@@ -60,8 +60,8 @@
     if (self = [super initWithCoder:aDecoder])  {
         
         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(insertGeocoderLocation:) name:@"insertGeocoderLocation" object:nil];
-        
         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(triggerProgressTask:) name:@"NotificationProgressTask" object:nil];
+        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeTheming) name:@"changeTheming" object:nil];
 
         self.metadataDetail = [[CCMetadata alloc] init];
         self.photos = [[NSMutableArray alloc] init];
@@ -193,6 +193,22 @@
     [self.view addSubview:_toolbar];
 }
 
+- (void)changeTheming
+{
+    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;
+        }
+    }
+    
+    self.navigationController.navigationBar.barTintColor = [NCBrandColor sharedInstance].navigationBar;
+}
+
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark ===== UIDocumentInteractionControllerDelegate =====
 #pragma --------------------------------------------------------------------------------------------

+ 6 - 3
iOSClient/Main/CCMain.m

@@ -1189,13 +1189,16 @@
 }
 
 - (void)getCapabilitiesOfServerSuccess:(OCCapabilities *)capabilities
-{    
+{
+    TableCapabilities *oldCapabilities = [CCCoreData getCapabilitesForAccount:app.activeAccount];
     [CCCoreData addCapabilities:capabilities account:app.activeAccount];
     
-    // Change Theming
-    if (k_option_use_themingColor == YES) {
+    // Change Theming color
+    if (k_option_use_themingColor == YES && ![oldCapabilities.themingColor isEqualToString:capabilities.themingColor]) {
         
         [[NSNotificationCenter defaultCenter] postNotificationName:@"changeTheming" object:nil];
+        
+        self.navigationController.navigationBar.barTintColor = [NCBrandColor sharedInstance].navigationBar;
     }
     
     // Search bar if change version

+ 8 - 0
iOSClient/Main/CCMore.swift

@@ -63,6 +63,9 @@ class CCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
         let tapImageLogo = UITapGestureRecognizer(target: self, action: #selector(tapImageLogoManageAccount))
         imageLogo.isUserInteractionEnabled = true
         imageLogo.addGestureRecognizer(tapImageLogo)
+        
+        // Notification theming
+        NotificationCenter.default.addObserver(self, selector: #selector(self.changeTheming), name: NSNotification.Name(rawValue: "changeTheming"), object: nil)
     }
     
     override func viewWillAppear(_ animated: Bool) {
@@ -194,6 +197,11 @@ class CCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
         self.navigationController?.setNavigationBarHidden(false, animated: animated)
     }
     
+    func changeTheming() {
+        
+        appDelegate.aspectNavigationControllerBar(self.navigationController?.navigationBar, encrypted: false, online: appDelegate.reachability.isReachable(), hidden: false)
+    }
+    
     func numberOfSections(in tableView: UITableView) -> Int {
         
         return 2

+ 3 - 6
iOSClient/PhotosCameraUpload/CCPhotosCameraUpload.m

@@ -57,10 +57,9 @@
     if (self = [super initWithCoder:aDecoder])  {
         
         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(initStateCameraUpload:) name:@"initStateCameraUpload" object:nil];
-        
         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setupCameraUploadFull) name:@"setupCameraUploadFull" object:nil];
-        
         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(triggerProgressTask:) name:@"NotificationProgressTask" object:nil];
+        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeTheming) name:@"changeTheming" object:nil];
         
         app.activePhotosCameraUpload = self;
     }
@@ -108,11 +107,9 @@
     [self reloadDatasource];
 }
 
-- (void)didReceiveMemoryWarning
+- (void)changeTheming
 {
-    [super didReceiveMemoryWarning];
-    
-    // Dispose of any resources that can be recreated.
+    [app aspectNavigationControllerBar:self.navigationController.navigationBar encrypted:NO online:[app.reachability isReachable] hidden:NO];
 }
 
 #pragma --------------------------------------------------------------------------------------------

+ 7 - 0
iOSClient/Settings/CCAdvanced.m

@@ -43,6 +43,8 @@
     XLFormSectionDescriptor *section;
     XLFormRowDescriptor *row;
     
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeTheming) name:@"changeTheming" object:nil];
+    
     form = [XLFormDescriptor formDescriptorWithTitle:NSLocalizedString(@"_advanced_", nil)];
 
     // Section ACTIVITY -------------------------------------------------
@@ -141,6 +143,11 @@
     [self recalculateSize];
 }
 
+- (void)changeTheming
+{
+    [app aspectNavigationControllerBar:self.navigationController.navigationBar encrypted:NO online:[app.reachability isReachable] hidden:NO];
+}
+
 - (void)formRowDescriptorValueHasChanged:(XLFormRowDescriptor *)rowDescriptor oldValue:(id)oldValue newValue:(id)newValue
 {
     [super formRowDescriptorValueHasChanged:rowDescriptor oldValue:oldValue newValue:newValue];

+ 7 - 0
iOSClient/Settings/CCManageAccount.m

@@ -50,6 +50,8 @@
     XLFormSectionDescriptor *section;
     XLFormRowDescriptor *row;
     
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeTheming) name:@"changeTheming" object:nil];
+    
     NSArray *listAccount = [CCCoreData getAllAccount];
 
     // Section : PICKER ACCOUNT -------------------------------------------
@@ -162,6 +164,11 @@
     [self UpdateForm];
 }
 
+- (void)changeTheming
+{
+    [app aspectNavigationControllerBar:self.navigationController.navigationBar encrypted:NO online:[app.reachability isReachable] hidden:NO];
+}
+
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark === Delegate ===
 #pragma --------------------------------------------------------------------------------------------

+ 7 - 0
iOSClient/Settings/CCManageCameraUpload.m

@@ -65,6 +65,8 @@
     XLFormSectionDescriptor *section;
     XLFormRowDescriptor *row;
 
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeTheming) name:@"changeTheming" object:nil];
+    
     form = [XLFormDescriptor formDescriptorWithTitle:NSLocalizedString(@"_uploading_from_camera_", nil)];
     
     // Camera Upload
@@ -209,6 +211,11 @@
     [self reloadForm];
 }
 
+- (void)changeTheming
+{
+    [app aspectNavigationControllerBar:self.navigationController.navigationBar encrypted:NO online:[app.reachability isReachable] hidden:NO];
+}
+
 -(void)formRowDescriptorValueHasChanged:(XLFormRowDescriptor *)rowDescriptor oldValue:(id)oldValue newValue:(id)newValue
 {
     [super formRowDescriptorValueHasChanged:rowDescriptor oldValue:oldValue newValue:newValue];

+ 7 - 0
iOSClient/Settings/CCManageCryptoCloud.m

@@ -38,6 +38,8 @@
     XLFormSectionDescriptor *section;
     XLFormRowDescriptor *row;
     
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeTheming) name:@"changeTheming" object:nil];
+    
     form = [XLFormDescriptor formDescriptorWithTitle:NSLocalizedString(@"_crypto_cloud_system_", nil)];
     
     section = [XLFormSectionDescriptor formSection];
@@ -84,6 +86,11 @@
     [self reloadForm];
 }
 
+- (void)changeTheming
+{
+    [app aspectNavigationControllerBar:self.navigationController.navigationBar encrypted:NO online:[app.reachability isReachable] hidden:NO];
+}
+
 - (void)activateCryptoCloud:(XLFormRowDescriptor *)sender
 {
     [self deselectFormRow:sender];

+ 7 - 0
iOSClient/Settings/CCManageCryptoCloudSecurity.m

@@ -51,6 +51,8 @@
         XLFormSectionDescriptor *section;
         XLFormRowDescriptor *row;
         
+        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeTheming) name:@"changeTheming" object:nil];
+        
         form = [XLFormDescriptor formDescriptorWithTitle:NSLocalizedString(@"_title_form_security_init_", nil)];
         
         // form mail
@@ -111,6 +113,11 @@
     [app aspectTabBar:self.tabBarController.tabBar hidden:NO];
 }
 
+- (void)changeTheming
+{
+    [app aspectNavigationControllerBar:self.navigationController.navigationBar encrypted:NO online:[app.reachability isReachable] hidden:NO];
+}
+
 -(void)formRowDescriptorValueHasChanged:(XLFormRowDescriptor *)rowDescriptor oldValue:(id)oldValue newValue:(id)newValue
 {
     [super formRowDescriptorValueHasChanged:rowDescriptor oldValue:oldValue newValue:newValue];

+ 7 - 0
iOSClient/Settings/CCSettings.m

@@ -49,6 +49,8 @@
         
         [self initializeForm];
         
+        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeTheming) name:@"changeTheming" object:nil];
+        
         app.activeSettings = self;
     }
     
@@ -181,6 +183,11 @@
     [self reloadForm];
 }
 
+- (void)changeTheming
+{
+    [app aspectNavigationControllerBar:self.navigationController.navigationBar encrypted:NO online:[app.reachability isReachable] hidden:NO];
+}
+
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark === Chiamate dal Form ===
 #pragma --------------------------------------------------------------------------------------------

+ 8 - 1
iOSClient/Templates/CCAccountWeb.m

@@ -46,7 +46,9 @@
 {
     self = [super init];
     
-    if (self){
+    if (self) {
+        
+        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeTheming) name:@"changeTheming" object:nil];
         
         self.delegate = delegate;
         self.fileName = fileName;
@@ -142,6 +144,11 @@
     if (self.fileName && !field) [self performSelector:@selector(cancelPressed:) withObject:nil afterDelay:0.5];
 }
 
+- (void)changeTheming
+{
+    [app aspectNavigationControllerBar:self.navigationController.navigationBar encrypted:NO online:[app.reachability isReachable] hidden:NO];
+}
+
 - (void)didSelectFormRow:(XLFormRowDescriptor *)formRow
 {
     [super didSelectFormRow:formRow];

+ 8 - 1
iOSClient/Templates/CCBancomat.m

@@ -47,7 +47,7 @@
 {
     self = [super init];
     
-    if (self){
+    if (self) {
         
         self.delegate = delegate;
         self.fileName = fileName;
@@ -56,6 +56,8 @@
         self.uuid = uuid;
         self.serverUrl = serverUrl;
         
+        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeTheming) name:@"changeTheming" object:nil];
+        
         // if fileName read Crypto File
         if (fileName)
             field = [[CCCrypto sharedManager] getDictionaryEncrypted:fileName uuid:uuid isLocal:isLocal directoryUser:app.directoryUser];
@@ -149,6 +151,11 @@
     if (self.fileName && !field) [self performSelector:@selector(cancelPressed:) withObject:nil afterDelay:0.5];
 }
 
+- (void)changeTheming
+{
+    [app aspectNavigationControllerBar:self.navigationController.navigationBar encrypted:NO online:[app.reachability isReachable] hidden:NO];
+}
+
 - (void)didSelectFormRow:(XLFormRowDescriptor *)formRow
 {
     [super didSelectFormRow:formRow];

+ 7 - 0
iOSClient/Templates/CCCartaDiCredito.m

@@ -56,6 +56,8 @@
         self.uuid = uuid;
         self.serverUrl = serverUrl;
         
+        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeTheming) name:@"changeTheming" object:nil];
+        
         // if fileName read Crypto File
         if (fileName)
             field = [[CCCrypto sharedManager] getDictionaryEncrypted:fileName uuid:uuid isLocal:isLocal directoryUser:app.directoryUser];
@@ -167,6 +169,11 @@
     if (self.fileName && !field) [self performSelector:@selector(cancelPressed:) withObject:nil afterDelay:0.5];
 }
 
+- (void)changeTheming
+{
+    [app aspectNavigationControllerBar:self.navigationController.navigationBar encrypted:NO online:[app.reachability isReachable] hidden:NO];
+}
+
 - (void)didSelectFormRow:(XLFormRowDescriptor *)formRow
 {
     [super didSelectFormRow:formRow];

+ 8 - 1
iOSClient/Templates/CCCartaIdentita.m

@@ -46,7 +46,7 @@
 {
     self = [super init];
     
-    if (self){
+    if (self) {
         
         self.delegate = delegate;
         self.fileName = fileName;
@@ -55,6 +55,8 @@
         self.uuid = uuid;
         self.serverUrl = serverUrl;
         
+        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeTheming) name:@"changeTheming" object:nil];
+        
         // if fileName read Crypto File
         if (fileName)
             field = [[CCCrypto sharedManager] getDictionaryEncrypted:fileName uuid:uuid isLocal:isLocal directoryUser:app.directoryUser];
@@ -165,6 +167,11 @@
     if (self.fileName && !field) [self performSelector:@selector(cancelPressed:) withObject:nil afterDelay:0.5];
 }
 
+- (void)changeTheming
+{
+    [app aspectNavigationControllerBar:self.navigationController.navigationBar encrypted:NO online:[app.reachability isReachable] hidden:NO];
+}
+
 - (void)didSelectFormRow:(XLFormRowDescriptor *)formRow
 {
     [super didSelectFormRow:formRow];

+ 8 - 1
iOSClient/Templates/CCContoCorrente.m

@@ -46,7 +46,7 @@
 {
     self = [super init];
     
-    if (self){
+    if (self) {
         
         self.delegate = delegate;
         self.fileName = fileName;
@@ -55,6 +55,8 @@
         self.uuid = uuid;
         self.serverUrl = serverUrl;
         
+        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeTheming) name:@"changeTheming" object:nil];
+        
         // if fileName read Crypto File
         if (fileName)
             field = [[CCCrypto sharedManager] getDictionaryEncrypted:fileName uuid:uuid isLocal:isLocal directoryUser:app.directoryUser];
@@ -165,6 +167,11 @@
     if (self.fileName && !field) [self performSelector:@selector(cancelPressed:) withObject:nil afterDelay:0.5];
 }
 
+- (void)changeTheming
+{
+    [app aspectNavigationControllerBar:self.navigationController.navigationBar encrypted:NO online:[app.reachability isReachable] hidden:NO];
+}
+
 - (void)didSelectFormRow:(XLFormRowDescriptor *)formRow
 {
     [super didSelectFormRow:formRow];

+ 8 - 1
iOSClient/Templates/CCNote.m

@@ -46,7 +46,7 @@
 {
     self = [super init];
     
-    if (self){
+    if (self) {
         
         self.delegate = delegate;
         self.fileName = fileName;
@@ -55,6 +55,8 @@
         self.uuid = uuid;
         self.serverUrl = serverUrl;
         
+        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeTheming) name:@"changeTheming" object:nil];
+        
         // if fileName read Crypto File
         if (fileName)
             field = [[CCCrypto sharedManager] getDictionaryEncrypted:fileName uuid:uuid isLocal:isLocal directoryUser:app.directoryUser];
@@ -98,6 +100,11 @@
     self.view.backgroundColor = [UIColor whiteColor];
 }
 
+- (void)changeTheming
+{
+    [app aspectNavigationControllerBar:self.navigationController.navigationBar encrypted:NO online:[app.reachability isReachable] hidden:NO];
+}
+
 - (void)viewDidAppear:(BOOL)animated
 {
     [super viewDidAppear:animated];

+ 8 - 1
iOSClient/Templates/CCPassaporto.m

@@ -46,7 +46,7 @@
 {
     self = [super init];
     
-    if (self){
+    if (self) {
         
         self.delegate = delegate;
         self.fileName = fileName;
@@ -55,6 +55,8 @@
         self.uuid = uuid;
         self.serverUrl = serverUrl;
         
+        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeTheming) name:@"changeTheming" object:nil];
+        
         // if fileName read Crypto File
         if (fileName)
             field = [[CCCrypto sharedManager] getDictionaryEncrypted:fileName uuid:uuid isLocal:isLocal directoryUser:app.directoryUser];
@@ -165,6 +167,11 @@
     if (self.fileName && !field) [self performSelector:@selector(cancelPressed:) withObject:nil afterDelay:0.5];
 }
 
+- (void)changeTheming
+{
+    [app aspectNavigationControllerBar:self.navigationController.navigationBar encrypted:NO online:[app.reachability isReachable] hidden:NO];
+}
+
 - (void)didSelectFormRow:(XLFormRowDescriptor *)formRow
 {
     [super didSelectFormRow:formRow];

+ 7 - 0
iOSClient/Templates/CCPatenteGuida.m

@@ -57,6 +57,8 @@
         self.uuid = uuid;
         self.serverUrl = serverUrl;
         
+        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeTheming) name:@"changeTheming" object:nil];
+        
         // if fileName read Crypto File
         if (fileName)
             field = [[CCCrypto sharedManager] getDictionaryEncrypted:fileName uuid:uuid isLocal:isLocal directoryUser:app.directoryUser];
@@ -159,6 +161,11 @@
     if (self.fileName && !field) [self performSelector:@selector(cancelPressed:) withObject:nil afterDelay:0.5];
 }
 
+- (void)changeTheming
+{
+    [app aspectNavigationControllerBar:self.navigationController.navigationBar encrypted:NO online:[app.reachability isReachable] hidden:NO];
+}
+
 - (void)didSelectFormRow:(XLFormRowDescriptor *)formRow
 {
     [super didSelectFormRow:formRow];

+ 4 - 3
iOSClient/Transfers/CCTransfers.m

@@ -58,6 +58,7 @@
     if (self = [super initWithCoder:aDecoder])  {
         
         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(triggerProgressTask:) name:@"NotificationProgressTask" object:nil];
+        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeTheming) name:@"changeTheming" object:nil];
         
         app.activeTransfers = self;
     }
@@ -102,9 +103,9 @@
     [self reloadDatasource];
 }
 
-- (void)didReceiveMemoryWarning {
-    
-    [super didReceiveMemoryWarning];
+- (void)changeTheming
+{
+    [app aspectNavigationControllerBar:self.navigationController.navigationBar encrypted:NO online:[app.reachability isReachable] hidden:NO];
 }
 
 #pragma --------------------------------------------------------------------------------------------