marinofaggiana 5 vuotta sitten
vanhempi
commit
4e43a8928e

+ 3 - 3
iOSClient/AppDelegate.m

@@ -174,7 +174,7 @@
     }
 
     // init home
-    [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"initializeMain" object:nil userInfo:nil];
+    [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:k_notificationCenter_initializeMain object:nil userInfo:nil];
     
     return YES;
 }
@@ -452,7 +452,7 @@
             NSString *newAccount = listAccount[0];
             tableAccount *tableAccount = [[NCManageDatabase sharedInstance] setAccountActive:newAccount];
             [self settingActiveAccount:newAccount activeUrl:tableAccount.url activeUser:tableAccount.user activeUserID:tableAccount.userID activePassword:[CCUtility getPassword:tableAccount.account]];
-            [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"initializeMain" object:nil userInfo:nil];
+            [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:k_notificationCenter_initializeMain object:nil userInfo:nil];
         } else {
             [self openLoginView:self.window.rootViewController selector:k_intro_login openLoginWeb:false];
         }
@@ -1522,7 +1522,7 @@
                                 if ([link containsString:accountURL.host] && [user isEqualToString:accountUser]) {
                                     matchedAccount = [[NCManageDatabase sharedInstance] setAccountActive:account.account];
                                     [self settingActiveAccount:matchedAccount.account activeUrl:matchedAccount.url activeUser:matchedAccount.user activeUserID:matchedAccount.userID activePassword:[CCUtility getPassword:matchedAccount.account]];
-                                    [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"initializeMain" object:nil userInfo:nil];
+                                    [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:k_notificationCenter_initializeMain object:nil userInfo:nil];
                                 }
                             }
                         }

+ 1 - 0
iOSClient/CCGlobal.h

@@ -320,6 +320,7 @@
 
 // Notification Center
 
+#define k_notificationCenter_initializeMain             @"initializeMain"
 #define k_notificationCenter_changeTheming              @"changeTheming"
 #define k_notificationCenter_splitViewChangeDisplayMode @"splitViewChangeDisplayMode"
 

+ 3 - 3
iOSClient/Login/CCLogin.m

@@ -365,18 +365,18 @@
         [appDelegate settingActiveAccount:tableAccount.account activeUrl:tableAccount.url activeUser:tableAccount.user activeUserID:tableAccount.userID activePassword:[CCUtility getPassword:tableAccount.account]];
         
         if ([CCUtility getIntro]) {
-            [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"initializeMain" object:nil userInfo:nil];
+            [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:k_notificationCenter_initializeMain object:nil userInfo:nil];
             [self dismissViewControllerAnimated:YES completion:nil];
         } else {
             [CCUtility setIntro:YES];
             if (self.presentingViewController == nil) {
                 UISplitViewController *splitController = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateInitialViewController];
                 splitController.modalPresentationStyle = UIModalPresentationFullScreen;
-                [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"initializeMain" object:nil userInfo:nil];
+                [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:k_notificationCenter_initializeMain object:nil userInfo:nil];
                 appDelegate.window.rootViewController = splitController;
                 [appDelegate.window makeKeyWindow];
             } else {
-                [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"initializeMain" object:nil userInfo:nil];
+                [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:k_notificationCenter_initializeMain object:nil userInfo:nil];
                 [self dismissViewControllerAnimated:YES completion:nil];
             }
         }

+ 1 - 1
iOSClient/Login/NCAppConfigView.swift

@@ -91,7 +91,7 @@ class NCAppConfigView: UIViewController {
                     }
                     
                     self.appDelegate.settingActiveAccount(account, activeUrl: serverUrl, activeUser: username, activeUserID: tableAccount.userID, activePassword: token!)
-                    NotificationCenter.default.post(name: NSNotification.Name(rawValue: "initializeMain"), object: nil, userInfo: nil)
+                    NotificationCenter.default.post(name: NSNotification.Name(rawValue: k_notificationCenter_initializeMain), object: nil, userInfo: nil)
                     
                     self.dismiss(animated: true) {}
                 } else {

+ 3 - 3
iOSClient/Login/NCLoginWeb.swift

@@ -159,7 +159,7 @@ extension NCLoginWeb: WKNavigationDelegate {
                 appDelegate.settingActiveAccount(account, activeUrl: serverUrl, activeUser: username, activeUserID: tableAccount.userID, activePassword: token)
                 
                 if (CCUtility.getIntro()) {
-                    NotificationCenter.default.post(name: NSNotification.Name(rawValue: "initializeMain"), object: nil, userInfo: nil)
+                    NotificationCenter.default.post(name: NSNotification.Name(rawValue: k_notificationCenter_initializeMain), object: nil, userInfo: nil)
                     self.dismiss(animated: true)
                     
                 } else {
@@ -167,7 +167,7 @@ extension NCLoginWeb: WKNavigationDelegate {
                     if (self.presentingViewController == nil) {
                         let splitController = UIStoryboard(name: "Main", bundle: nil).instantiateInitialViewController()
                         splitController?.modalPresentationStyle = .fullScreen
-                        NotificationCenter.default.post(name: NSNotification.Name(rawValue: "initializeMain"), object: nil, userInfo: nil)
+                        NotificationCenter.default.post(name: NSNotification.Name(rawValue: k_notificationCenter_initializeMain), object: nil, userInfo: nil)
                         splitController!.view.alpha = 0
                         appDelegate.window.rootViewController = splitController!
                         appDelegate.window.makeKeyAndVisible()
@@ -175,7 +175,7 @@ extension NCLoginWeb: WKNavigationDelegate {
                             splitController!.view.alpha = 1
                         }
                     } else {
-                        NotificationCenter.default.post(name: NSNotification.Name(rawValue: "initializeMain"), object: nil, userInfo: nil)
+                        NotificationCenter.default.post(name: NSNotification.Name(rawValue: k_notificationCenter_initializeMain), object: nil, userInfo: nil)
                         self.dismiss(animated: true)
                     }
                 }

+ 5 - 4
iOSClient/Main/CCMain.m

@@ -89,6 +89,8 @@
         
         appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
         appDelegate.activeMain = self;
+        
+        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(initializeMain:) name:k_notificationCenter_initializeMain object:nil];
     }
     
     return self;
@@ -123,8 +125,7 @@
     self.searchController.delegate = self;
     self.searchController.searchBar.delegate = self;
     
-    // Notifiation
-    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(initializeMain:) name:@"initializeMain" object:nil];
+    // Notification
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(clearDateReadDataSource:) name:@"clearDateReadDataSource" object:nil];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setTitle) name:@"setTitleMain" object:nil];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(triggerProgressTask:) name:@"NotificationProgressTask" object:nil];
@@ -425,7 +426,7 @@
         } else {
             [FileProviderDomain.sharedInstance removeAllDomain];
         }        
-    }    
+    }
 }
 
 #pragma --------------------------------------------------------------------------------------------
@@ -2158,7 +2159,7 @@
         [appDelegate settingActiveAccount:tableAccount.account activeUrl:tableAccount.url activeUser:tableAccount.user activeUserID:tableAccount.userID activePassword:[CCUtility getPassword:tableAccount.account]];
     
         // go to home sweet home
-        [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"initializeMain" object:nil userInfo:nil];
+        [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:k_notificationCenter_initializeMain object:nil userInfo:nil];
     }
 }
 

+ 4 - 3
iOSClient/Main/NCDetailViewController.swift

@@ -111,10 +111,11 @@ class NCDetailViewController: UIViewController {
                     navigationController.popToRootViewController(animated: true)
                 }
             } else {
-                for view in backgroundView.subviews {
-                    view.removeFromSuperview()
+                if backgroundView != nil {
+                    for view in backgroundView.subviews {
+                        view.removeFromSuperview()
+                    }
                 }
-                
                 self.navigationController?.navigationBar.topItem?.title = ""
             }
         }

+ 1 - 1
iOSClient/Settings/CCAdvanced.m

@@ -242,7 +242,7 @@
     [appDelegate maintenanceMode:NO];
 
     // Inizialized home
-    [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"initializeMain" object:nil userInfo:nil];
+    [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:k_notificationCenter_initializeMain object:nil userInfo:nil];
 }
 
 - (void)clearCacheRequest:(XLFormRowDescriptor *)sender

+ 1 - 1
iOSClient/Settings/CCManageAccount.m

@@ -418,7 +418,7 @@
         [appDelegate settingActiveAccount:tableAccount.account activeUrl:tableAccount.url activeUser:tableAccount.user activeUserID:tableAccount.userID activePassword:[CCUtility getPassword:tableAccount.account]];
  
         // Init home
-        [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"initializeMain" object:nil userInfo:nil];
+        [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:k_notificationCenter_initializeMain object:nil userInfo:nil];
     }
     
     [self initializeForm];