Marino Faggiana 8 年 前
コミット
590f06f497

+ 0 - 14
Nextcloud.xcodeproj/project.pbxproj

@@ -1115,10 +1115,6 @@
 		F7D6A0931D82DBFA0045AD1A /* CCControlCenterTransferCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F7D6A08C1D82DBFA0045AD1A /* CCControlCenterTransferCell.m */; };
 		F7D6A0951D82DBFA0045AD1A /* CCControlCenterTransferCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = F7D6A08D1D82DBFA0045AD1A /* CCControlCenterTransferCell.xib */; };
 		F7D6A0971D82DBFA0045AD1A /* CCMenu.m in Sources */ = {isa = PBXBuildFile; fileRef = F7D6A08F1D82DBFA0045AD1A /* CCMenu.m */; };
-		F7D9C2F81E67746300865617 /* CCControlCenterActivityCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F7D9C2F61E67746300865617 /* CCControlCenterActivityCell.m */; };
-		F7D9C2F91E67746300865617 /* CCControlCenterActivityCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F7D9C2F61E67746300865617 /* CCControlCenterActivityCell.m */; };
-		F7D9C2FA1E67746300865617 /* CCControlCenterActivityCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = F7D9C2F71E67746300865617 /* CCControlCenterActivityCell.xib */; };
-		F7D9C2FB1E67746300865617 /* CCControlCenterActivityCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = F7D9C2F71E67746300865617 /* CCControlCenterActivityCell.xib */; };
 		F7DA62AE1E41E666003E1740 /* CCOfflinePageContent.m in Sources */ = {isa = PBXBuildFile; fileRef = F7DA62AD1E41E666003E1740 /* CCOfflinePageContent.m */; };
 		F7DCA1C81D32BD4100E48D39 /* Share Ext Nextcloud.entitlements in Resources */ = {isa = PBXBuildFile; fileRef = F7DCA1B81D32BD4100E48D39 /* Share Ext Nextcloud.entitlements */; };
 		F7EC147B1E5D9C0B0046F351 /* CCSynchronize.m in Sources */ = {isa = PBXBuildFile; fileRef = F7EC147A1E5D9C0B0046F351 /* CCSynchronize.m */; };
@@ -2129,9 +2125,6 @@
 		F7D96F0D1D99498600A587A5 /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/InfoPlist.strings; sourceTree = "<group>"; };
 		F7D96F0E1D99498700A587A5 /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/Intro.strings; sourceTree = "<group>"; };
 		F7D96F0F1D99498700A587A5 /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/Error.strings; sourceTree = "<group>"; };
-		F7D9C2F51E67746300865617 /* CCControlCenterActivityCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCControlCenterActivityCell.h; sourceTree = "<group>"; };
-		F7D9C2F61E67746300865617 /* CCControlCenterActivityCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCControlCenterActivityCell.m; sourceTree = "<group>"; };
-		F7D9C2F71E67746300865617 /* CCControlCenterActivityCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = CCControlCenterActivityCell.xib; sourceTree = "<group>"; };
 		F7DA62AC1E41E666003E1740 /* CCOfflinePageContent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCOfflinePageContent.h; sourceTree = "<group>"; };
 		F7DA62AD1E41E666003E1740 /* CCOfflinePageContent.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCOfflinePageContent.m; sourceTree = "<group>"; };
 		F7DCA1B81D32BD4100E48D39 /* Share Ext Nextcloud.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; name = "Share Ext Nextcloud.entitlements"; path = "Share Ext/Share Ext Nextcloud.entitlements"; sourceTree = SOURCE_ROOT; };
@@ -3714,9 +3707,6 @@
 				F7D6A08D1D82DBFA0045AD1A /* CCControlCenterTransferCell.xib */,
 				F70FD1C51E67552700C0FDA6 /* CCControlCenterTransfer.h */,
 				F70FD1C61E67552700C0FDA6 /* CCControlCenterTransfer.m */,
-				F7D9C2F51E67746300865617 /* CCControlCenterActivityCell.h */,
-				F7D9C2F61E67746300865617 /* CCControlCenterActivityCell.m */,
-				F7D9C2F71E67746300865617 /* CCControlCenterActivityCell.xib */,
 				F70FD1C91E675F1500C0FDA6 /* CCControlCenterActivity.h */,
 				F70FD1CA1E675F1500C0FDA6 /* CCControlCenterActivity.m */,
 				F7D6A08E1D82DBFA0045AD1A /* CCMenu.h */,
@@ -4569,7 +4559,6 @@
 				084215D41E646E0200C8F4F3 /* Reader-Export@2x.png in Resources */,
 				084215D51E646E0200C8F4F3 /* LMMediaPlayerView.bundle in Resources */,
 				084215D61E646E0200C8F4F3 /* CCCellMain.xib in Resources */,
-				F7D9C2FB1E67746300865617 /* CCControlCenterActivityCell.xib in Resources */,
 				084215D71E646E0200C8F4F3 /* CCCellMainTransfer.xib in Resources */,
 				084215D81E646E0200C8F4F3 /* LMMediaPlayerView.xib in Resources */,
 				084215D91E646E0200C8F4F3 /* ZSSunlink@2x.png in Resources */,
@@ -4758,7 +4747,6 @@
 				F77B0F531D118A16002130FE /* ZSSbold.png in Resources */,
 				F7F54CF11E5B14C700E19C62 /* ImageSelectedSmallOn.png in Resources */,
 				F77B0F541D118A16002130FE /* Reader-Button-N.png in Resources */,
-				F7D9C2FA1E67746300865617 /* CCControlCenterActivityCell.xib in Resources */,
 				F77B0F551D118A16002130FE /* Error.strings in Resources */,
 				F77B0F561D118A16002130FE /* ZSStable.png in Resources */,
 				F77B0F571D118A16002130FE /* synchronizedcrypto.gif in Resources */,
@@ -4972,7 +4960,6 @@
 				084214911E646E0200C8F4F3 /* CCDetail.m in Sources */,
 				084214921E646E0200C8F4F3 /* CCCoreData.m in Sources */,
 				084214931E646E0200C8F4F3 /* PSTCollectionViewController.m in Sources */,
-				F7D9C2F91E67746300865617 /* CCControlCenterActivityCell.m in Sources */,
 				084214941E646E0200C8F4F3 /* CCCertificate.m in Sources */,
 				084214951E646E0200C8F4F3 /* UINavigationController+CCProgress.m in Sources */,
 				084214961E646E0200C8F4F3 /* CCManageCameraUpload.m in Sources */,
@@ -5568,7 +5555,6 @@
 				F77B0E4C1D118A16002130FE /* CCDetail.m in Sources */,
 				F77B0E4D1D118A16002130FE /* CCCoreData.m in Sources */,
 				F7659A5E1DC0B760004860C4 /* PSTCollectionViewController.m in Sources */,
-				F7D9C2F81E67746300865617 /* CCControlCenterActivityCell.m in Sources */,
 				F7F801031D98205A007537BC /* CCCertificate.m in Sources */,
 				F7CE28881D1ACFA70025783C /* UINavigationController+CCProgress.m in Sources */,
 				F77B0E4F1D118A16002130FE /* CCManageCameraUpload.m in Sources */,

+ 14 - 0
iOSClient/Main/CCSection.h

@@ -48,3 +48,17 @@
 
 @end
 
+// -----------------------------------
+
+@interface CCSectionDataSourceActivity : NSObject
+
+@property (nonatomic, strong) NSMutableArray *sections;
+@property (nonatomic, strong) NSMutableDictionary *sectionArrayRow;
+
+@end
+
+@interface CCSectionActivity : NSObject
+
++ (CCSectionDataSourceActivity *)creataDataSourseSectionActivity:(NSArray *)records activeAccount:(NSString *)activeAccount;
+
+@end

+ 55 - 0
iOSClient/Main/CCSection.m

@@ -247,3 +247,58 @@
 @end
 
 
+@implementation CCSectionDataSourceActivity
+
+- (id)init {
+    
+    self = [super init];
+    
+    _sections = [NSMutableArray new];
+    _sectionArrayRow = [NSMutableDictionary new];
+
+    return self;
+}
+
+@end
+
+@implementation CCSectionActivity
+
++ (CCSectionDataSourceActivity *)creataDataSourseSectionActivity:(NSArray *)records activeAccount:(NSString *)activeAccount
+{
+    CCSectionDataSourceActivity *sectionDataSource = [CCSectionDataSourceActivity new];
+    NSDate *oldDate = [NSDate date];
+    
+    for (TableActivity *record in records) {
+        
+        NSDateComponents* comps = [[NSCalendar currentCalendar] components:NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay fromDate:record.date];
+        NSDate *date = [[NSCalendar currentCalendar] dateFromComponents:comps];
+        
+        if ([oldDate compare:date] != NSOrderedSame) {
+            
+            [sectionDataSource.sections addObject:date];
+            oldDate = date;
+        }
+        
+        NSMutableArray *activities = [sectionDataSource.sectionArrayRow objectForKey:date];
+        
+        if (activities) {
+            
+            // ROW ++
+            [activities addObject:record];
+            [sectionDataSource.sectionArrayRow setObject:activities forKey:date];
+            
+        } else {
+            
+            // SECTION ++
+            activities = [[NSMutableArray alloc] initWithObjects:record, nil];
+            [sectionDataSource.sectionArrayRow setObject:activities forKey:date];
+        }
+    }
+    
+    return sectionDataSource;
+}
+
+@end
+
+
+

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

@@ -9,12 +9,12 @@
 #import "CCControlCenterActivity.h"
 
 #import "AppDelegate.h"
-#import "CCControlCenterActivityCell.h"
+#import "CCSection.h"
 
 @interface CCControlCenterActivity ()
 {
     // Datasource
-    NSArray *_sectionDataSource;
+    CCSectionDataSourceActivity *_sectionDataSource;
 }
 @end
 
@@ -37,7 +37,7 @@
     
     [super viewDidLoad];
     
-    _sectionDataSource = [NSArray new];
+    _sectionDataSource = [CCSectionDataSourceActivity new];
     
     // empty Data Source
   
@@ -80,9 +80,11 @@
     
     if (app.controlCenter.isOpen) {
         
-        _sectionDataSource  = [CCCoreData getAllTableActivityWithPredicate:[NSPredicate predicateWithFormat:@"(account == %@)", app.activeAccount]];
+        NSArray *records = [CCCoreData getAllTableActivityWithPredicate:[NSPredicate predicateWithFormat:@"(account == %@)", app.activeAccount]];
         
-        if ([_sectionDataSource count] == 0) {
+        _sectionDataSource = [CCSectionActivity creataDataSourseSectionActivity:records activeAccount:app.activeAccount];
+        
+        if ([records count] == 0) {
             
             app.controlCenter.noRecord.text = NSLocalizedString(@"_no_activity_",nil);
             app.controlCenter.noRecord.hidden = NO;
@@ -102,33 +104,23 @@
 #pragma mark - ==== Table ====
 #pragma --------------------------------------------------------------------------------------------
 
-- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
-{
-    return 50;
-}
-
-- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
+- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
 {
-    return 1;
+    return [[_sectionDataSource.sectionArrayRow allKeys] count];
 }
 
-- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
+- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
 {
-    return [_sectionDataSource count];
+    return [[_sectionDataSource.sectionArrayRow objectForKey:[_sectionDataSource.sections objectAtIndex:section]] count];
 }
 
 - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
 {
     UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
 
-    /*
-    cell.backgroundColor = [UIColor clearColor];
-    cell.selectionStyle = UITableViewCellSelectionStyleNone;
-    
-    TableActivity *activity = [_sectionDataSource objectAtIndex:indexPath.row];
-    cell.labelTitle.text = activity.subject;
-    cell.labelInfoFile.text  = [CCUtility dateDiff:activity.date];
-    */
+    NSArray *metadatasForKey = [_sectionDataSource.sectionArrayRow objectForKey:[_sectionDataSource.sections objectAtIndex:indexPath.section]];
+    TableActivity *activity = [metadatasForKey objectAtIndex:indexPath.row];
+
     
     return cell;
 }

+ 0 - 39
iOSClient/MenuAccount+ControlCenter/CCControlCenterActivityCell.h

@@ -1,39 +0,0 @@
-//
-//  CCControlCenterActivityCell.h
-//  Crypto Cloud Technology Nextcloud
-//
-//  Created by Marino Faggiana on 01/03/17.
-//  Copyright (c) 2017 TWS. All rights reserved.
-//
-//  Author Marino Faggiana <m.faggiana@twsweb.it>
-//
-//  This program is free software: you can redistribute it and/or modify
-//  it under the terms of the GNU General Public License as published by
-//  the Free Software Foundation, either version 3 of the License, or
-//  (at your option) any later version.
-//
-//  This program is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//  GNU General Public License for more details.
-//
-//  You should have received a copy of the GNU General Public License
-//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
-//
-
-#import <UIKit/UIKit.h>
-
-@interface CCControlCenterActivityCell : UITableViewCell
-
-@property(nonatomic, weak) IBOutlet UIImageView *fileImageView;
-
-@property(nonatomic, weak) IBOutlet UILabel *labelTitle;
-@property(nonatomic, weak) IBOutlet UILabel *labelInfoFile;
-
-//Last position of the scroll of the swipe
-@property (nonatomic, assign) CGFloat lastContentOffset;
-
-//Index path of the cell swipe gesture ocured
-@property (nonatomic, strong) NSIndexPath *indexPath;
-
-@end

+ 0 - 59
iOSClient/MenuAccount+ControlCenter/CCControlCenterActivityCell.m

@@ -1,59 +0,0 @@
-//
-//  CCControlCenterActivityCell.m
-//  Crypto Cloud Technology Nextcloud
-//
-//  Created by Marino Faggiana on 01/03/17.
-//  Copyright (c) 2017 TWS. All rights reserved.
-//
-//  Author Marino Faggiana <m.faggiana@twsweb.it>
-//
-//  This program is free software: you can redistribute it and/or modify
-//  it under the terms of the GNU General Public License as published by
-//  the Free Software Foundation, either version 3 of the License, or
-//  (at your option) any later version.
-//
-//  This program is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//  GNU General Public License for more details.
-//
-//  You should have received a copy of the GNU General Public License
-//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
-//
-
-#import "CCControlCenterActivityCell.h"
-
-@implementation CCControlCenterActivityCell
-
-- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
-{
-    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
-    if (self) {
-        // Initialization code
-        
-    }
-    return self;
-}
-
-- (void)setSelected:(BOOL)selected animated:(BOOL)animated
-{
-    [super setSelected:selected animated:animated];
-
-    // Configure the view for the selected state
-    self.contentView.preservesSuperviewLayoutMargins = NO;
-}
-
-///-----------------------------------
-/// @name scrollViewWillBeginDecelerating
-///-----------------------------------
-
-/**
- * Method to initialize the position where we make the swipe in order to detect the direction
- *
- * @param UIScrollView -> scrollView
- */
-- (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView {
-    _lastContentOffset = scrollView.contentOffset.x;
-}
-
-@end

+ 0 - 66
iOSClient/MenuAccount+ControlCenter/CCControlCenterActivityCell.xib

@@ -1,66 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="16D32" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES">
-    <device id="retina4_7" orientation="portrait">
-        <adaptation id="fullscreen"/>
-    </device>
-    <dependencies>
-        <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
-        <capability name="Constraints to layout margins" minToolsVersion="6.0"/>
-        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
-    </dependencies>
-    <objects>
-        <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="CustomCellFileAndDirectory"/>
-        <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
-        <tableViewCell contentMode="scaleToFill" selectionStyle="blue" indentationWidth="0.0" reuseIdentifier="ControlCenterActivityCell" rowHeight="167" id="2" userLabel="CCControlCenterActivityCell" customClass="CCControlCenterActivityCell">
-            <rect key="frame" x="0.0" y="0.0" width="600" height="50"/>
-            <autoresizingMask key="autoresizingMask" flexibleMaxY="YES"/>
-            <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" alpha="0.69999999999999996" contentMode="center" tableViewCell="2" id="sQq-jC-UEV">
-                <rect key="frame" x="0.0" y="0.0" width="600" height="49"/>
-                <autoresizingMask key="autoresizingMask"/>
-                <subviews>
-                    <label opaque="NO" userInteractionEnabled="NO" tag="101" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="QNC-8X-DAC">
-                        <rect key="frame" x="56" y="5" width="33" height="16"/>
-                        <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
-                        <fontDescription key="fontDescription" type="system" pointSize="13"/>
-                        <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
-                        <nil key="highlightedColor"/>
-                    </label>
-                    <label opaque="NO" userInteractionEnabled="NO" tag="102" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="p7I-KN-FVZ">
-                        <rect key="frame" x="56" y="33" width="33" height="12"/>
-                        <fontDescription key="fontDescription" type="system" pointSize="10"/>
-                        <color key="textColor" red="0.33333333333333331" green="0.33333333333333331" blue="0.33333333333333331" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
-                        <nil key="highlightedColor"/>
-                    </label>
-                    <imageView userInteractionEnabled="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="5">
-                        <rect key="frame" x="8" y="5" width="40" height="40"/>
-                        <constraints>
-                            <constraint firstAttribute="width" constant="40" id="kM5-Uf-S8Z"/>
-                        </constraints>
-                    </imageView>
-                </subviews>
-                <constraints>
-                    <constraint firstItem="QNC-8X-DAC" firstAttribute="top" secondItem="sQq-jC-UEV" secondAttribute="topMargin" constant="-3" id="Jec-aH-9mf"/>
-                    <constraint firstItem="5" firstAttribute="top" secondItem="sQq-jC-UEV" secondAttribute="topMargin" constant="-3" id="JnQ-te-G7i"/>
-                    <constraint firstItem="5" firstAttribute="bottom" secondItem="p7I-KN-FVZ" secondAttribute="bottom" id="N38-yB-Rf0"/>
-                    <constraint firstItem="5" firstAttribute="bottom" secondItem="sQq-jC-UEV" secondAttribute="bottomMargin" constant="3" id="Qp5-KA-Mwc"/>
-                    <constraint firstItem="QNC-8X-DAC" firstAttribute="leading" secondItem="p7I-KN-FVZ" secondAttribute="leading" id="Vdn-9J-xdb"/>
-                    <constraint firstItem="p7I-KN-FVZ" firstAttribute="leading" secondItem="5" secondAttribute="trailing" constant="8" symbolic="YES" id="Xur-Fo-IO7"/>
-                    <constraint firstItem="5" firstAttribute="leading" secondItem="sQq-jC-UEV" secondAttribute="leadingMargin" id="jRD-Qd-3a9"/>
-                    <constraint firstItem="QNC-8X-DAC" firstAttribute="trailing" secondItem="p7I-KN-FVZ" secondAttribute="trailing" id="oZv-Y4-1iW"/>
-                </constraints>
-            </tableViewCellContentView>
-            <connections>
-                <outlet property="fileImageView" destination="5" id="IKO-eX-pd2"/>
-                <outlet property="labelInfoFile" destination="p7I-KN-FVZ" id="bIH-yL-aSv"/>
-                <outlet property="labelTitle" destination="QNC-8X-DAC" id="coV-Xj-n1Q"/>
-            </connections>
-            <point key="canvasLocation" x="414" y="297.5"/>
-        </tableViewCell>
-    </objects>
-    <simulatedMetricsContainer key="defaultSimulatedMetrics">
-        <simulatedStatusBarMetrics key="statusBar"/>
-        <simulatedOrientationMetrics key="orientation"/>
-        <simulatedScreenMetrics key="destination" type="retina4_7.fullscreen"/>
-    </simulatedMetricsContainer>
-</document>