Browse Source

Improvements

Marino Faggiana 6 years ago
parent
commit
841352e67e
3 changed files with 45 additions and 32 deletions
  1. 22 0
      iOSClient/Favorites/CCFavorites.m
  2. 2 5
      iOSClient/Main/CCMain.m
  3. 21 27
      iOSClient/Main/NCMainCommon.swift

+ 22 - 0
iOSClient/Favorites/CCFavorites.m

@@ -573,6 +573,18 @@
     [actionSheet addButtonWithTitle: metadata.fileNameView image: iconHeader backgroundColor: [NCBrandColor sharedInstance].tabBar height: 50.0 type: AHKActionSheetButtonTypeDisabled handler: nil
      ];
     
+    // Favorite : ONLY root
+    if (_serverUrl == nil) {
+        [actionSheet addButtonWithTitle: NSLocalizedString(@"_remove_favorites_", nil)
+                                  image: [CCGraphics changeThemingColorImage:[UIImage imageNamed:@"favorite"] multiplier:2 color:[NCBrandColor sharedInstance].yellowFavorite]
+                        backgroundColor: [NCBrandColor sharedInstance].backgroundView
+                                 height: 50.0
+                                   type: AHKActionSheetButtonTypeDefault
+                                handler: ^(AHKActionSheet *as) {
+                                    [self settingFavorite:_metadata favorite:NO];
+                                }];
+    }
+    
     // Share
     [actionSheet addButtonWithTitle:NSLocalizedString(@"_share_", nil) image:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"share"] multiplier:2 color:[NCBrandColor sharedInstance].brandElement] backgroundColor:[NCBrandColor sharedInstance].backgroundView height: 50.0 type:AHKActionSheetButtonTypeDefault handler:^(AHKActionSheet *as) {
         
@@ -588,6 +600,16 @@
         }];
     }
     
+    // Delete
+    [actionSheet addButtonWithTitle:NSLocalizedString(@"_delete_", nil)
+                              image:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"delete"] multiplier:2 color:[UIColor redColor]]
+                    backgroundColor:[NCBrandColor sharedInstance].backgroundView
+                             height:50.0
+                               type:AHKActionSheetButtonTypeDestructive
+                            handler:^(AHKActionSheet *as) {
+                                [self actionDelete:indexPath];
+                            }];
+    
     [actionSheet show];
 }
 

+ 2 - 5
iOSClient/Main/CCMain.m

@@ -3573,12 +3573,9 @@
     NSString *titoloLock, *titleFavorite;
     
     if (_metadata.favorite) {
-        
-        titleFavorite = [NSString stringWithFormat:NSLocalizedString(@"_remove_favorites_", nil)];
-        
+        titleFavorite = NSLocalizedString(@"_remove_favorites_", nil);
     } else {
-        
-        titleFavorite = [NSString stringWithFormat:NSLocalizedString(@"_add_favorites_", nil)];
+        titleFavorite = NSLocalizedString(@"_add_favorites_", nil);
     }
     
     if (_metadata.directory) {

+ 21 - 27
iOSClient/Main/NCMainCommon.swift

@@ -66,7 +66,7 @@ class NCMainCommon: NSObject {
             cell.tintColor = NCBrandColor.sharedInstance.brandElement
             
             cell.labelTitle.textColor = UIColor.black
-            cell.labelTitle.text = metadata.fileNameView;
+            cell.labelTitle.text = metadata.fileNameView
             
             // Share
             let sharesLink = appDelegate.sharesLink.object(forKey: serverUrl + metadata.fileName)
@@ -177,13 +177,13 @@ class NCMainCommon: NSObject {
             let cell = tableView.dequeueReusableCell(withIdentifier: "CellMainTransfer", for: indexPath) as! CCCellMainTransfer
             cell.separatorInset = UIEdgeInsetsMake(0, 60, 0, 0)
             cell.accessoryType = UITableViewCellAccessoryType.none
-            cell.file.image = nil;
-            cell.status.image = nil;
+            cell.file.image = nil
+            cell.status.image = nil
             
             cell.backgroundColor = NCBrandColor.sharedInstance.backgroundView
 
             cell.labelTitle.textColor = UIColor.black
-            cell.labelTitle.text = metadata.fileNameView;
+            cell.labelTitle.text = metadata.fileNameView
             
             cell.transferButton.tintColor = NCBrandColor.sharedInstance.icon
             
@@ -385,15 +385,7 @@ class NCMainCommon: NSObject {
                     }
                 }
                 if cancel == false {
-                    DispatchQueue.main.async {
-                        NCManageDatabase.sharedInstance.setMetadataSession("", sessionError: "", sessionSelector: "", sessionTaskIdentifier: Int(k_taskIdentifierDone), status: Int(k_metadataStatusNormal), predicate: NSPredicate(format: "fileID == %@", metadata.fileID))
-                        
-                        self.appDelegate.activeMain.reloadDatasource()
-                        self.appDelegate.activeFavorites.reloadDatasource()
-                        if (self.appDelegate.activeTransfers != nil) {
-                            self.appDelegate.activeTransfers.reloadDatasource()
-                        }
-                    }
+                    NCManageDatabase.sharedInstance.setMetadataSession("", sessionError: "", sessionSelector: "", sessionTaskIdentifier: Int(k_taskIdentifierDone), status: Int(k_metadataStatusNormal), predicate: NSPredicate(format: "fileID == %@", metadata.fileID))
                 }
             }
             
@@ -406,18 +398,20 @@ class NCMainCommon: NSObject {
                     }
                 }
                 if cancel == false {
-                    DispatchQueue.main.async {
-                        do {
-                            try FileManager.default.removeItem(atPath: CCUtility.getDirectoryProviderStorageFileID(metadata.fileID))
-                        }
-                        catch { }
-                        NCManageDatabase.sharedInstance.deleteMetadata(predicate: NSPredicate(format: "fileID == %@", metadata.fileID), clearDateReadDirectoryID: metadata.directoryID)
-                        
-                        self.appDelegate.activeMain.reloadDatasource()
-                        self.appDelegate.activeFavorites.reloadDatasource()
-                        if (self.appDelegate.activeTransfers != nil) {
-                            self.appDelegate.activeTransfers.reloadDatasource()
-                        }
+                    do {
+                        try FileManager.default.removeItem(atPath: CCUtility.getDirectoryProviderStorageFileID(metadata.fileID))
+                    }
+                    catch { }
+                    NCManageDatabase.sharedInstance.deleteMetadata(predicate: NSPredicate(format: "fileID == %@", metadata.fileID), clearDateReadDirectoryID: metadata.directoryID)
+                }
+            }
+            
+            if cancel == false {
+                DispatchQueue.main.async {
+                    self.appDelegate.activeMain.reloadDatasource()
+                    self.appDelegate.activeFavorites.reloadDatasource()
+                    if (self.appDelegate.activeTransfers != nil) {
+                        self.appDelegate.activeTransfers.reloadDatasource()
                     }
                 }
             }
@@ -459,8 +453,8 @@ class NCMainCommon: NSObject {
     
     @objc func getMetadataFromSectionDataSourceIndexPath(_ indexPath: IndexPath, sectionDataSource: CCSectionDataSourceMetadata) -> tableMetadata? {
         
-        let section = indexPath.section + 1;
-        let row = indexPath.row + 1;
+        let section = indexPath.section + 1
+        let row = indexPath.row + 1
         let totSections = sectionDataSource.sections.count
         
         if totSections < section || section > totSections {