Эх сурвалжийг харах

https://github.com/nextcloud/ios/issues/140

Marino Faggiana 8 жил өмнө
parent
commit
a0c659d655

+ 2 - 0
iOSClient/Main/CCMain.h

@@ -99,5 +99,7 @@
 
 - (void)cancelSearchBar;
 
+- (BOOL)shouldPerformSegue;
+
 @end
 

+ 22 - 14
iOSClient/Main/CCMain.m

@@ -51,7 +51,6 @@
 
 @interface CCMain () <CCActionsDeleteDelegate, CCActionsRenameDelegate, CCActionsSearchDelegate, CCActionsDownloadThumbnailDelegate, CCActionsSettingFavoriteDelegate>
 {
-    CCMetadata *_metadataSegue;
     CCMetadata *_metadata;
         
     BOOL _isRoot;
@@ -126,7 +125,6 @@
     
     // init object
     _metadata = [CCMetadata new];
-    _metadataSegue = [CCMetadata new];
     _hud = [[CCHud alloc] initWithView:[[[UIApplication sharedApplication] delegate] window]];
     _hudDeterminate = [[CCHud alloc] initWithView:[[[UIApplication sharedApplication] delegate] window]];
     _selectedMetadatas = [NSMutableArray new];
@@ -1355,10 +1353,9 @@
            
         } else {
             
-            _metadataSegue = metadata;
-            _metadataSegue.sessionSelector = selector;
+            _metadata = metadata;
     
-            if ([self shouldPerformSegue:serverUrl])
+            if ([self shouldPerformSegue])
                 [self performSegueWithIdentifier:@"segueDetail" sender:self];
         }
     }
@@ -5805,7 +5802,7 @@
 #pragma mark ===== Navigation ====
 #pragma --------------------------------------------------------------------------------------------
 
-- (BOOL)shouldPerformSegue:(NSString *)serverUrl
+- (BOOL)shouldPerformSegue
 {
     // if background return
     if ([[UIApplication sharedApplication] applicationState] == UIApplicationStateBackground) return NO;
@@ -5826,6 +5823,8 @@
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
 {
     id viewController = segue.destinationViewController;
+    NSMutableArray *allRecordsDataSourceImagesVideos = [NSMutableArray new];
+    CCMetadata *metadata;
     
     if ([viewController isKindOfClass:[UINavigationController class]]) {
         
@@ -5837,19 +5836,28 @@
         _detailViewController = segue.destinationViewController;
     }
     
-    NSMutableArray *allRecordsDataSourceImagesVideos = [[NSMutableArray alloc] init];
-    for (NSString *fileID in _sectionDataSource.allFileID) {
-        CCMetadata *metadata = [_sectionDataSource.allRecordsDataSource objectForKey:fileID];
-        if ([metadata.typeFile isEqualToString: k_metadataTypeFile_image] || [metadata.typeFile isEqualToString: k_metadataTypeFile_video])
-            [allRecordsDataSourceImagesVideos addObject:metadata];
+    if ([sender isKindOfClass:[CCMetadata class]]) {
+    
+        metadata = sender;
+        [allRecordsDataSourceImagesVideos addObject:sender];
+        
+    } else {
+        
+        metadata = _metadata;
+        
+        for (NSString *fileID in _sectionDataSource.allFileID) {
+            CCMetadata *metadata = [_sectionDataSource.allRecordsDataSource objectForKey:fileID];
+            if ([metadata.typeFile isEqualToString: k_metadataTypeFile_image] || [metadata.typeFile isEqualToString: k_metadataTypeFile_video])
+                [allRecordsDataSourceImagesVideos addObject:metadata];
+        }
     }
-
+    
+    _detailViewController.metadataDetail = metadata;
     _detailViewController.dataSourceImagesVideos = allRecordsDataSourceImagesVideos;
-    _detailViewController.metadataDetail = _metadataSegue;
     _detailViewController.dateFilterQuery = nil;
     _detailViewController.isCameraUpload = NO;
     
-    [_detailViewController setTitle:_metadata.fileNamePrint];
+    [_detailViewController setTitle:metadata.fileNamePrint];
 }
 
 // can i go to next viewcontroller

+ 2 - 0
iOSClient/MenuAccount+ControlCenter/CCControlCenterActivity.h

@@ -11,6 +11,8 @@
 @interface CCControlCenterActivity : UICollectionViewController <UICollectionViewDataSource, UICollectionViewDelegate>
 
 @property NSUInteger pageIndex;
+
+@property (nonatomic, strong) NSDate *storeDateFirstActivity;
 @property (nonatomic, strong) NSString *pageType;
 
 - (void)reloadDatasource;

+ 22 - 3
iOSClient/MenuAccount+ControlCenter/CCControlCenterActivity.m

@@ -18,9 +18,7 @@
 @interface CCControlCenterActivity ()
 {
     // Datasource
-    NSArray *_sectionDataSource;
-    
-    NSDate *_storeDateFirstActivity;
+    NSArray *_sectionDataSource;    
 }
 @end
 
@@ -252,6 +250,27 @@
     return cell;
 }
 
+- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
+{
+    TableActivity *activity = [_sectionDataSource objectAtIndex:indexPath.section];
+    
+    CCMetadata *metadata = [CCCoreData getMetadataWithPreficate:[NSPredicate predicateWithFormat:@"(account == %@) AND (fileID == %@)", activity.account, activity.fileID] context:nil];
+    
+    if (metadata) {
+        
+        if (!self.splitViewController.isCollapsed && app.activeMain.detailViewController.isViewLoaded && app.activeMain.detailViewController.view.window)
+            [app.activeMain.navigationController popToRootViewControllerAnimated:NO];
+        
+        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
+            [app.activeMain performSegueWithIdentifier:@"segueDetail" sender:metadata];
+        });
+        
+    } else {
+        
+        [app messageNotification:@"_info_" description:@"_activity_file_not_present_" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeInfo];
+    }
+}
+
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark - ==== Utility ====
 #pragma --------------------------------------------------------------------------------------------

+ 3 - 0
iOSClient/Settings/CCManageHelp.m

@@ -128,6 +128,9 @@
         } else {
             [CCUtility setActivityVerboseHigh:false];
         }
+        
+        // Clear Date read Activity for force reload datasource
+        app.controlCenterActivity.storeDateFirstActivity = nil;
     }
 }
 

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

@@ -189,6 +189,7 @@
 "_help_activity_mail_"          = "Send activity by mail";
 "_help_activity_clear_"         = "Clear activity";
 
+
 // Manage Optimizations
 
 "_optimized_photos_"            = "Optimized photos resolution";
@@ -492,6 +493,8 @@
 "_no_activity_"                     = "No activity";
 "_transfers_"                       = "Transfers";
 "_activity_"                        = "Activity";
+"_activity_file_not_present_"       = "File no longer present";
+
 
 // Offline