Browse Source

control center page

Marino Faggiana 8 years ago
parent
commit
e94ab3b134

+ 7 - 1
iOSClient/FileSystem/CCCoreData.m

@@ -1846,7 +1846,13 @@
 {
     NSManagedObjectContext *context = [NSManagedObjectContext MR_defaultContext];
     
-    return [TableActivity MR_findAllWithPredicate:predicate inContext:context];
+    NSArray *records = [TableActivity MR_findAllWithPredicate:predicate inContext:context];
+    
+    if ([records count] == 0) return nil;
+    
+    NSSortDescriptor *descriptor = [[NSSortDescriptor alloc] initWithKey:@"date" ascending:NO selector:nil];
+
+    return [records sortedArrayUsingDescriptors:[NSArray arrayWithObjects:descriptor, nil]];
 }
 
 + (NSInteger)getLastIDActivityActiveAccount:(NSString *)activeAccount

+ 49 - 9
iOSClient/MenuAccount+ControlCenter/CCControlCenterActivity.m

@@ -11,6 +11,13 @@
 #import "AppDelegate.h"
 #import "CCControlCenterActivityCell.h"
 
+@interface CCControlCenterActivity ()
+{
+    // Datasource
+    NSArray *_sectionDataSource;
+}
+@end
+
 @implementation CCControlCenterActivity
 
 #pragma --------------------------------------------------------------------------------------------
@@ -30,13 +37,15 @@
     
     [super viewDidLoad];
     
+    _sectionDataSource = [NSArray new];
+    
     // Custom Cell
     [_tableView registerNib:[UINib nibWithNibName:@"CCControlCenterActivityCell" bundle:nil] forCellReuseIdentifier:@"ControlCenterActivityCell"];
     
     _tableView.delegate = self;
     _tableView.dataSource = self;
     _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
-    _tableView.backgroundColor = [UIColor greenColor];
+    _tableView.backgroundColor = [UIColor clearColor];
 }
 
 // Apparirà
@@ -44,7 +53,7 @@
 {
     [super viewWillAppear:animated];
     
-    app.controlCenter.noRecord.hidden = YES;
+    [self reloadDatasource];
 }
 
 // E' arrivato
@@ -58,6 +67,36 @@
     [super didReceiveMemoryWarning];
 }
 
+#pragma --------------------------------------------------------------------------------------------
+#pragma mark - ==== Datasource ====
+#pragma --------------------------------------------------------------------------------------------
+
+- (void)reloadDatasource
+{
+    // test
+    if (app.activeAccount.length == 0)
+        return;
+    
+    if (app.controlCenter.isOpen) {
+        
+        _sectionDataSource  = [CCCoreData getAllTableActivityWithPredicate:[NSPredicate predicateWithFormat:@"(account == %@)", app.activeAccount]];
+        
+        if ([_sectionDataSource count] == 0) {
+            
+            app.controlCenter.noRecord.text = NSLocalizedString(@"_no_recent_",nil);
+            app.controlCenter.noRecord.hidden = NO;
+            
+        } else {
+            
+            app.controlCenter.noRecord.hidden = YES;
+        }
+    }
+    
+    [_tableView reloadData];
+    
+    [app updateApplicationIconBadgeNumber];
+}
+
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark - ==== Table ====
 #pragma --------------------------------------------------------------------------------------------
@@ -69,22 +108,23 @@
 
 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
 {
-    return 0;
+    return 1;
 }
 
 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
 {
-    return 0;
-}
-
-- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
-{
-    return 13.0f;
+    return [_sectionDataSource count];
 }
 
 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
 {
     CCControlCenterActivityCell *cell = (CCControlCenterActivityCell *)[tableView dequeueReusableCellWithIdentifier:@"ControlCenterActivityCell" 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];
     
     return cell;
 }

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

@@ -26,16 +26,10 @@
 @interface CCControlCenterActivityCell : UITableViewCell
 
 @property(nonatomic, weak) IBOutlet UIImageView *fileImageView;
-@property(nonatomic, weak) IBOutlet UIImageView *statusImageView;
 
 @property(nonatomic, weak) IBOutlet UILabel *labelTitle;
 @property(nonatomic, weak) IBOutlet UILabel *labelInfoFile;
 
-@property(nonatomic, weak) IBOutlet UIProgressView *progressView;
-@property(nonatomic, weak) IBOutlet UIButton *cancelTaskButton;
-@property(nonatomic, weak) IBOutlet UIButton *reloadTaskButton;
-@property(nonatomic, weak) IBOutlet UIButton *stopTaskButton;
-
 //Last position of the scroll of the swipe
 @property (nonatomic, assign) CGFloat lastContentOffset;
 

+ 4 - 73
iOSClient/MenuAccount+ControlCenter/CCControlCenterActivityCell.xib

@@ -6,7 +6,6 @@
     <dependencies>
         <deployment identifier="iOS"/>
         <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
-        <capability name="Alignment constraints to the first baseline" minToolsVersion="6.0"/>
         <capability name="Constraints to layout margins" minToolsVersion="6.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
@@ -17,17 +16,18 @@
             <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.5"/>
+                <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="449" height="16"/>
+                        <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="449" height="12"/>
+                        <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"/>
@@ -38,91 +38,22 @@
                             <constraint firstAttribute="width" constant="40" id="kM5-Uf-S8Z"/>
                         </constraints>
                     </imageView>
-                    <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="DQR-yN-JaH">
-                        <rect key="frame" x="35" y="32" width="15" height="15"/>
-                        <constraints>
-                            <constraint firstAttribute="height" constant="15" id="bgo-QS-x7k"/>
-                            <constraint firstAttribute="width" constant="15" id="g4P-aH-jOh"/>
-                        </constraints>
-                    </imageView>
-                    <progressView opaque="NO" tag="40" contentMode="scaleToFill" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Q4M-4B-abs">
-                        <rect key="frame" x="56" y="25" width="438" height="2"/>
-                    </progressView>
-                    <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="eGg-ei-EiX" userLabel="Cancel Task Button">
-                        <rect key="frame" x="502" y="0.0" width="50" height="50"/>
-                        <constraints>
-                            <constraint firstAttribute="width" constant="50" id="IOy-Uo-T2K"/>
-                            <constraint firstAttribute="height" constant="50" id="Zjh-5E-j3e"/>
-                        </constraints>
-                        <state key="normal">
-                            <color key="titleShadowColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
-                        </state>
-                    </button>
-                    <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Kaz-0H-BSt">
-                        <rect key="frame" x="551" y="0.0" width="50" height="50"/>
-                        <constraints>
-                            <constraint firstAttribute="height" constant="50" id="7rT-Yp-IRn"/>
-                            <constraint firstAttribute="width" constant="50" id="Czm-WN-sbo"/>
-                        </constraints>
-                        <state key="normal">
-                            <color key="titleShadowColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
-                        </state>
-                    </button>
-                    <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Dge-D1-XMk" userLabel="Stop Task Button">
-                        <rect key="frame" x="551" y="0.0" width="50" height="50"/>
-                        <constraints>
-                            <constraint firstAttribute="width" constant="50" id="5ET-gL-uPM"/>
-                            <constraint firstAttribute="height" constant="50" id="Exd-l9-KUV"/>
-                        </constraints>
-                        <state key="normal">
-                            <color key="titleShadowColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
-                        </state>
-                    </button>
                 </subviews>
                 <constraints>
-                    <constraint firstAttribute="centerY" secondItem="eGg-ei-EiX" secondAttribute="centerY" id="05v-7z-AMN"/>
-                    <constraint firstAttribute="bottomMargin" secondItem="DQR-yN-JaH" secondAttribute="bottom" constant="-5.5" id="976-fq-ram"/>
-                    <constraint firstItem="DQR-yN-JaH" firstAttribute="top" secondItem="p7I-KN-FVZ" secondAttribute="top" constant="-1" id="Bus-ts-kJv"/>
                     <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="Dge-D1-XMk" firstAttribute="baseline" secondItem="eGg-ei-EiX" secondAttribute="baseline" id="Jwx-Fi-xLe"/>
-                    <constraint firstItem="eGg-ei-EiX" firstAttribute="baseline" secondItem="Kaz-0H-BSt" secondAttribute="baseline" id="KXA-uT-AxN"/>
-                    <constraint firstItem="DQR-yN-JaH" firstAttribute="leading" secondItem="sQq-jC-UEV" secondAttribute="leadingMargin" constant="27" id="Kgr-l9-ZUm"/>
-                    <constraint firstItem="Kaz-0H-BSt" firstAttribute="top" secondItem="eGg-ei-EiX" secondAttribute="top" id="LDS-P0-NC6"/>
-                    <constraint firstItem="Q4M-4B-abs" firstAttribute="top" secondItem="QNC-8X-DAC" secondAttribute="bottom" constant="4" id="M1C-9H-wNb"/>
-                    <constraint firstAttribute="trailingMargin" secondItem="Kaz-0H-BSt" secondAttribute="trailing" constant="-9" id="Mfy-V9-Ezo"/>
                     <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="Dge-D1-XMk" firstAttribute="firstBaseline" secondItem="eGg-ei-EiX" secondAttribute="firstBaseline" id="QuM-2N-1ax"/>
-                    <constraint firstItem="Kaz-0H-BSt" firstAttribute="baseline" secondItem="Dge-D1-XMk" secondAttribute="baseline" id="R1y-g5-Bri"/>
-                    <constraint firstItem="Dge-D1-XMk" firstAttribute="leading" secondItem="QNC-8X-DAC" secondAttribute="trailing" constant="46" id="Tad-UN-Ttn"/>
-                    <constraint firstItem="Dge-D1-XMk" firstAttribute="leading" secondItem="Kaz-0H-BSt" secondAttribute="leading" id="Vc0-qc-qvs"/>
                     <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="Dge-D1-XMk" firstAttribute="baseline" secondItem="eGg-ei-EiX" secondAttribute="baseline" id="YY9-7o-8ag"/>
-                    <constraint firstItem="Dge-D1-XMk" firstAttribute="baseline" secondItem="Kaz-0H-BSt" secondAttribute="baseline" id="aaB-ne-qlb"/>
-                    <constraint firstItem="Dge-D1-XMk" firstAttribute="firstBaseline" secondItem="eGg-ei-EiX" secondAttribute="firstBaseline" id="b1Y-qH-GES"/>
-                    <constraint firstItem="Dge-D1-XMk" firstAttribute="firstBaseline" secondItem="Kaz-0H-BSt" secondAttribute="firstBaseline" id="d1C-pM-Blq"/>
-                    <constraint firstItem="Dge-D1-XMk" firstAttribute="firstBaseline" secondItem="Kaz-0H-BSt" secondAttribute="firstBaseline" id="eFj-cr-a0P"/>
-                    <constraint firstItem="Kaz-0H-BSt" firstAttribute="firstBaseline" secondItem="eGg-ei-EiX" secondAttribute="firstBaseline" id="i7M-qf-7pH"/>
-                    <constraint firstItem="eGg-ei-EiX" firstAttribute="leading" secondItem="Kaz-0H-BSt" secondAttribute="trailing" constant="-99" id="iuz-Vg-6UE"/>
                     <constraint firstItem="5" firstAttribute="leading" secondItem="sQq-jC-UEV" secondAttribute="leadingMargin" id="jRD-Qd-3a9"/>
-                    <constraint firstItem="p7I-KN-FVZ" firstAttribute="leading" secondItem="DQR-yN-JaH" secondAttribute="trailing" constant="6" id="mRY-av-dw7"/>
-                    <constraint firstItem="Q4M-4B-abs" firstAttribute="trailing" secondItem="sQq-jC-UEV" secondAttribute="trailingMargin" constant="-98" id="nQL-7B-qXT"/>
-                    <constraint firstItem="Q4M-4B-abs" firstAttribute="leading" secondItem="sQq-jC-UEV" secondAttribute="leadingMargin" constant="48" id="o1f-09-ZgZ"/>
                     <constraint firstItem="QNC-8X-DAC" firstAttribute="trailing" secondItem="p7I-KN-FVZ" secondAttribute="trailing" id="oZv-Y4-1iW"/>
-                    <constraint firstItem="Dge-D1-XMk" firstAttribute="top" secondItem="Kaz-0H-BSt" secondAttribute="top" id="v44-o1-gG7"/>
                 </constraints>
             </tableViewCellContentView>
             <connections>
-                <outlet property="cancelTaskButton" destination="eGg-ei-EiX" id="08u-FB-UcL"/>
                 <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"/>
-                <outlet property="progressView" destination="Q4M-4B-abs" id="Ouc-sW-VLX"/>
-                <outlet property="reloadTaskButton" destination="Kaz-0H-BSt" id="hOL-f8-R0r"/>
-                <outlet property="statusImageView" destination="DQR-yN-JaH" id="wGV-fc-S5H"/>
-                <outlet property="stopTaskButton" destination="Dge-D1-XMk" id="UZF-RR-oCy"/>
             </connections>
             <point key="canvasLocation" x="414" y="297.5"/>
         </tableViewCell>

+ 2 - 2
iOSClient/MenuAccount+ControlCenter/ControlCenter.storyboard

@@ -39,7 +39,7 @@
                                 </connections>
                             </tableView>
                         </subviews>
-                        <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+                        <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
                     </view>
                     <connections>
                         <outlet property="tableView" destination="cFo-AN-kZv" id="vLq-gh-way"/>
@@ -71,7 +71,7 @@
                                 </connections>
                             </tableView>
                         </subviews>
-                        <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+                        <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
                     </view>
                     <connections>
                         <outlet property="tableView" destination="qY2-Sb-k19" id="1CN-d4-ABG"/>

+ 2 - 0
iOSClient/en.lproj/Localizable.strings

@@ -486,7 +486,9 @@
 // Control Center
 
 "_no_transfer_"                     = "No transfer";
+"_no_recent_"                       = "No recent";
 "_transfers_"                       = "Transfers";
+"_recent_"                          = "Recent";
 
 // Offline