marinofaggiana 5 years ago
parent
commit
b6c4a4f73a

+ 1 - 1
iOSClient/Brand/File_Provider_Extension.plist

@@ -19,7 +19,7 @@
 	<key>CFBundleShortVersionString</key>
 	<string>2.23.8</string>
 	<key>CFBundleVersion</key>
-	<string>1</string>
+	<string>2</string>
 	<key>NSAppTransportSecurity</key>
 	<dict>
 		<key>NSAllowsArbitraryLoads</key>

+ 1 - 1
iOSClient/Brand/Share.plist

@@ -19,7 +19,7 @@
 	<key>CFBundleShortVersionString</key>
 	<string>2.23.8</string>
 	<key>CFBundleVersion</key>
-	<string>1</string>
+	<string>2</string>
 	<key>NSAppTransportSecurity</key>
 	<dict>
 		<key>NSAllowsArbitraryLoads</key>

+ 1 - 1
iOSClient/Brand/iOSClient.plist

@@ -63,7 +63,7 @@
 		</dict>
 	</array>
 	<key>CFBundleVersion</key>
-	<string>1</string>
+	<string>2</string>
 	<key>FIREBASE_ANALYTICS_COLLECTION_DEACTIVATED</key>
 	<true/>
 	<key>Fabric</key>

+ 35 - 6
iOSClient/Notification/CCNotification.storyboard

@@ -13,16 +13,16 @@
         <scene sceneID="dZP-R1-zZF">
             <objects>
                 <tableViewController id="c26-Us-IIn" customClass="CCNotification" customModule="Nextcloud" customModuleProvider="target" sceneMemberID="viewController">
-                    <tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="145" sectionHeaderHeight="28" sectionFooterHeight="28" id="vzh-aE-2MF">
+                    <tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="187" sectionHeaderHeight="28" sectionFooterHeight="28" id="vzh-aE-2MF">
                         <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
                         <prototypes>
-                            <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="Cell" rowHeight="145" id="R1c-h5-BOp" customClass="CCNotificationCell" customModule="Nextcloud" customModuleProvider="target">
-                                <rect key="frame" x="0.0" y="28" width="375" height="145"/>
+                            <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="Cell" rowHeight="187" id="R1c-h5-BOp" customClass="CCNotificationCell" customModule="Nextcloud" customModuleProvider="target">
+                                <rect key="frame" x="0.0" y="28" width="375" height="187"/>
                                 <autoresizingMask key="autoresizingMask"/>
                                 <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="R1c-h5-BOp" id="9Bv-1W-yVV">
-                                    <rect key="frame" x="0.0" y="0.0" width="375" height="144.5"/>
+                                    <rect key="frame" x="0.0" y="0.0" width="375" height="186.5"/>
                                     <autoresizingMask key="autoresizingMask"/>
                                     <subviews>
                                         <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="pg1-7p-7Rz" userLabel="subject">
@@ -45,7 +45,7 @@
                                             <nil key="highlightedColor"/>
                                         </label>
                                         <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="9fz-sr-8Gv" userLabel="message">
-                                            <rect key="frame" x="51" y="64" width="314" height="60"/>
+                                            <rect key="frame" x="51" y="64" width="314" height="82"/>
                                             <constraints>
                                                 <constraint firstAttribute="height" relation="greaterThanOrEqual" constant="5" id="w3S-Mr-J41"/>
                                             </constraints>
@@ -71,17 +71,43 @@
                                                 <action selector="touchUpInsideRemove:" destination="R1c-h5-BOp" eventType="touchUpInside" id="Wlp-VM-Vf2"/>
                                             </connections>
                                         </button>
+                                        <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="sMh-G7-FLo">
+                                            <rect key="frame" x="265" y="146.5" width="100" height="30"/>
+                                            <constraints>
+                                                <constraint firstAttribute="height" constant="30" id="n50-CF-ODl"/>
+                                                <constraint firstAttribute="width" constant="100" id="tiI-55-Qu5"/>
+                                            </constraints>
+                                            <state key="normal" title="primary"/>
+                                            <connections>
+                                                <action selector="touchUpInsidePrimary:" destination="R1c-h5-BOp" eventType="touchUpInside" id="fi2-DV-cKK"/>
+                                            </connections>
+                                        </button>
+                                        <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="obR-h7-TUC">
+                                            <rect key="frame" x="155" y="146.5" width="100" height="30"/>
+                                            <constraints>
+                                                <constraint firstAttribute="height" constant="30" id="Vko-Ob-nuj"/>
+                                                <constraint firstAttribute="width" constant="100" id="sVc-6c-vO4"/>
+                                            </constraints>
+                                            <state key="normal" title="secondary"/>
+                                            <connections>
+                                                <action selector="touchUpInsideSecondary:" destination="R1c-h5-BOp" eventType="touchUpInside" id="Vy9-uI-sth"/>
+                                            </connections>
+                                        </button>
                                     </subviews>
                                     <constraints>
                                         <constraint firstItem="pg1-7p-7Rz" firstAttribute="top" secondItem="9Bv-1W-yVV" secondAttribute="topMargin" constant="25" id="1w3-ai-rMk"/>
+                                        <constraint firstAttribute="trailing" secondItem="sMh-G7-FLo" secondAttribute="trailing" constant="10" id="4W9-Xm-fxY"/>
                                         <constraint firstItem="9mD-Qe-1wu" firstAttribute="centerY" secondItem="YM1-uH-2Cz" secondAttribute="centerY" id="6VB-EF-GQs"/>
-                                        <constraint firstAttribute="bottomMargin" secondItem="9fz-sr-8Gv" secondAttribute="bottom" constant="10" id="FnM-0E-rXs"/>
+                                        <constraint firstAttribute="bottomMargin" secondItem="9fz-sr-8Gv" secondAttribute="bottom" constant="30" id="FnM-0E-rXs"/>
                                         <constraint firstAttribute="trailing" secondItem="9mD-Qe-1wu" secondAttribute="trailing" constant="10" id="L9w-kA-Ypv"/>
+                                        <constraint firstItem="sMh-G7-FLo" firstAttribute="leading" secondItem="obR-h7-TUC" secondAttribute="trailing" constant="10" id="MZG-Fc-cbL"/>
                                         <constraint firstItem="9fz-sr-8Gv" firstAttribute="leading" secondItem="9Bv-1W-yVV" secondAttribute="leadingMargin" constant="35" id="OV5-dL-Q2H"/>
+                                        <constraint firstAttribute="bottom" secondItem="sMh-G7-FLo" secondAttribute="bottom" constant="10" id="RKX-zp-kja"/>
                                         <constraint firstAttribute="trailing" secondItem="pg1-7p-7Rz" secondAttribute="trailing" constant="10" id="bwL-co-8gM"/>
                                         <constraint firstAttribute="trailing" secondItem="9fz-sr-8Gv" secondAttribute="trailing" constant="10" id="d8l-vA-BmP"/>
                                         <constraint firstItem="9mD-Qe-1wu" firstAttribute="leading" secondItem="YPu-No-c8x" secondAttribute="trailing" constant="12" id="goU-TU-7Jd"/>
                                         <constraint firstItem="9fz-sr-8Gv" firstAttribute="top" secondItem="pg1-7p-7Rz" secondAttribute="bottom" constant="5" id="heM-QX-U30"/>
+                                        <constraint firstAttribute="bottom" secondItem="obR-h7-TUC" secondAttribute="bottom" constant="10" id="keX-xE-b77"/>
                                         <constraint firstItem="YM1-uH-2Cz" firstAttribute="top" secondItem="9Bv-1W-yVV" secondAttribute="top" constant="8" id="vBN-K9-5xe"/>
                                         <constraint firstItem="pg1-7p-7Rz" firstAttribute="leading" secondItem="9Bv-1W-yVV" secondAttribute="leadingMargin" constant="35" id="wM1-G2-xgz"/>
                                         <constraint firstItem="YM1-uH-2Cz" firstAttribute="leading" secondItem="9Bv-1W-yVV" secondAttribute="leading" constant="12" id="xEL-jv-PCm"/>
@@ -93,7 +119,10 @@
                                     <outlet property="date" destination="YPu-No-c8x" id="CfW-Pz-jdL"/>
                                     <outlet property="icon" destination="YM1-uH-2Cz" id="MPX-ZL-wVR"/>
                                     <outlet property="message" destination="9fz-sr-8Gv" id="3Zx-pz-gEK"/>
+                                    <outlet property="messageBottomMargin" destination="FnM-0E-rXs" id="Pf6-Au-H7E"/>
+                                    <outlet property="primary" destination="sMh-G7-FLo" id="oyl-c8-sTP"/>
                                     <outlet property="remove" destination="9mD-Qe-1wu" id="r1h-mr-5U9"/>
+                                    <outlet property="secondary" destination="obR-h7-TUC" id="oeU-ya-VU7"/>
                                     <outlet property="subject" destination="pg1-7p-7Rz" id="FP7-vS-vEk"/>
                                 </connections>
                             </tableViewCell>

+ 103 - 24
iOSClient/Notification/CCNotification.swift

@@ -216,12 +216,46 @@ class CCNotification: UITableViewController, CCNotificationCelllDelegate {
             cell.message.text = notification.message.replacingOccurrences(of: "<br />", with: "\n")
             cell.message.textColor = .gray
             
+            cell.remove.setImage(CCGraphics.changeThemingColorImage(UIImage(named: "exit")!, width: 40, height: 40, color: UIColor.gray), for: .normal)
+            
+            cell.primary.titleLabel?.font = .systemFont(ofSize: 14)
+            cell.primary.setTitleColor(.white, for: .normal)
+            cell.primary.layer.cornerRadius = 15
+            cell.primary.layer.masksToBounds = true
+            cell.primary.layer.backgroundColor = NCBrandColor.sharedInstance.brand.cgColor
+            
+            cell.secondary.titleLabel?.font = .systemFont(ofSize: 14)
+            cell.secondary.setTitleColor(.gray, for: .normal)
+            cell.secondary.layer.cornerRadius = 15
+            cell.secondary.layer.masksToBounds = true
+            cell.secondary.layer.backgroundColor = NCBrandColor.sharedInstance.graySoft.withAlphaComponent(0.1).cgColor
+            cell.secondary.layer.borderWidth = 0.3
+            cell.secondary.layer.borderColor = UIColor.gray.cgColor
+            
             // Action
             if notification.actions.count == 0 {
-                cell.remove.setImage(CCGraphics.changeThemingColorImage(UIImage(named: "exit")!, width: 40, height: 40, color: UIColor.gray), for: .normal)
+                
+                cell.primary.isEnabled = false
+                cell.primary.isHidden = true
+                cell.secondary.isEnabled = false
+                cell.secondary.isHidden = true
+                cell.messageBottomMargin.constant = 10
+                
             } else {
-                cell.remove.isHidden = true
-                cell.remove.isEnabled = false
+                
+                for action in notification.actions {
+                    
+                    let label = (action as! OCNotificationsAction).label
+                    let primary = (action as! OCNotificationsAction).primary
+                    
+                    if primary {
+                        cell.primary.setTitle(label, for: .normal)
+                    } else {
+                        cell.secondary.setTitle(label, for: .normal)
+                    }
+                }
+                
+                cell.messageBottomMargin.constant = 40
             }
         }
         
@@ -266,32 +300,62 @@ class CCNotification: UITableViewController, CCNotificationCelllDelegate {
     // MARK: tap Action
     
     func tapRemove(with notification: OCNotifications?) {
-        if notification != nil {
-            OCNetworking.sharedManager().setNotificationWithAccount(self.appDelegate.activeAccount, serverUrl: "\(self.appDelegate.activeUrl!)/\(k_url_acces_remote_notification_api)/\(notification!.idNotification)", type: "DELETE", completion: { (account, message, errorCode) in
+        
+        OCNetworking.sharedManager().setNotificationWithAccount(self.appDelegate.activeAccount, serverUrl: "\(self.appDelegate.activeUrl!)/\(k_url_acces_remote_notification_api)/\(notification!.idNotification)", type: "DELETE", completion: { (account, message, errorCode) in
+            
+            if errorCode == 0 && account == self.appDelegate.activeAccount {
                 
-                if errorCode == 0 && account == self.appDelegate.activeAccount {
-                    
-                    let listOfNotifications = self.appDelegate.listOfNotifications as NSArray as! [OCNotifications]
-                    
-                    if let index = listOfNotifications.firstIndex(where: {$0.idNotification == notification!.idNotification})  {
-                        self.appDelegate.listOfNotifications.removeObject(at: index)
-                    }
-                    
-                    self.reloadDatasource()
+                let listOfNotifications = self.appDelegate.listOfNotifications as NSArray as! [OCNotifications]
+                
+                if let index = listOfNotifications.firstIndex(where: {$0.idNotification == notification!.idNotification})  {
+                    self.appDelegate.listOfNotifications.removeObject(at: index)
+                }
+                
+                self.reloadDatasource()
+                
+                if self.appDelegate.listOfNotifications.count == 0 {
+                    self.viewClose()
+                }
+                
+            } else if errorCode != 0 {
+                self.appDelegate.messageNotification("_error_", description: message, visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
+            } else {
+                print("[LOG] It has been changed user during networking process, error.")
+            }
+        })
+    }
+
+    func tapAction(with notification: OCNotifications?, label: String) {
+        
+        for action in notification!.actions {
+            
+            if (action as! OCNotificationsAction).label == label {
+                
+                OCNetworking.sharedManager().setNotificationWithAccount(self.appDelegate.activeAccount, serverUrl: (action as! OCNotificationsAction).link, type: (action as! OCNotificationsAction).type, completion: { (account, message, errorCode) in
                     
-                    if self.appDelegate.listOfNotifications.count == 0 {
-                        self.viewClose()
+                    if errorCode == 0 && account == self.appDelegate.activeAccount {
+                        
+                        let listOfNotifications = self.appDelegate.listOfNotifications as NSArray as! [OCNotifications]
+                        
+                        if let index = listOfNotifications.firstIndex(where: {$0.idNotification == notification!.idNotification})  {
+                            self.appDelegate.listOfNotifications.removeObject(at: index)
+                        }
+                        
+                        self.reloadDatasource()
+                        
+                        if self.appDelegate.listOfNotifications.count == 0 {
+                            self.viewClose()
+                        }
+                        
+                    } else if errorCode != 0 {
+                        self.appDelegate.messageNotification("_error_", description: message, visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
+                    } else {
+                        print("[LOG] It has been changed user during networking process, error.")
                     }
-                    
-                } else if errorCode != 0 {
-                    self.appDelegate.messageNotification("_error_", description: message, visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
-                } else {
-                    print("[LOG] It has been changed user during networking process, error.")
-                }
-            })
+                })
+            }
         }
     }
-
 }
 
 // MARK: - Class UITableViewCell
@@ -306,6 +370,10 @@ class CCNotificationCell: UITableViewCell {
     @IBOutlet weak var subject: UILabel!
     @IBOutlet weak var message: UILabel!
     @IBOutlet weak var remove: UIButton!
+    @IBOutlet weak var primary: UIButton!
+    @IBOutlet weak var secondary: UIButton!
+
+    @IBOutlet weak var messageBottomMargin: NSLayoutConstraint!
     
     override func awakeFromNib() {
         super.awakeFromNib()
@@ -314,8 +382,19 @@ class CCNotificationCell: UITableViewCell {
     @IBAction func touchUpInsideRemove(_ sender: Any) {
         delegate?.tapRemove(with: notification)
     }
+    
+    @IBAction func touchUpInsidePrimary(_ sender: Any) {
+        let button = sender as! UIButton
+        delegate?.tapAction(with: notification, label: button.titleLabel!.text!)
+    }
+    
+    @IBAction func touchUpInsideSecondary(_ sender: Any) {
+        let button = sender as! UIButton
+        delegate?.tapAction(with: notification, label: button.titleLabel!.text!)
+    }
 }
 
 protocol CCNotificationCelllDelegate {
     func tapRemove(with notification: OCNotifications?)
+    func tapAction(with notification: OCNotifications?, label: String)
 }