marinofaggiana 5 years ago
parent
commit
63bf4906ae

+ 2 - 1
Share/CCCellShareExt.h

@@ -26,7 +26,8 @@
 @interface CCCellShareExt : UITableViewCell
 
 @property(nonatomic, weak) IBOutlet UIImageView *fileImageView;
-@property(nonatomic, weak) IBOutlet UILabel *labelInformazioni;
+@property(nonatomic, weak) IBOutlet UITextField *fileName;
+@property(nonatomic, weak) IBOutlet UILabel *info;
 
 //Last position of the scroll of the swipe
 @property (nonatomic, assign) CGFloat lastContentOffset;

+ 0 - 14
Share/CCCellShareExt.m

@@ -29,9 +29,6 @@
 {
     self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
     if (self) {
-        // Initialization code
-
-        
     }
     return self;
 }
@@ -39,19 +36,8 @@
 - (void)setSelected:(BOOL)selected animated:(BOOL)animated
 {
     [super setSelected:selected animated:animated];
-
-    // Configure the view for the selected state
 }
 
-///-----------------------------------
-/// @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;
 }

+ 31 - 20
Share/CCCellShareExt.xib

@@ -1,11 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES">
-    <device id="retina6_1" orientation="portrait">
-        <adaptation id="fullscreen"/>
-    </device>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="15702" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES">
+    <device id="retina6_1" orientation="portrait" appearance="light"/>
     <dependencies>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15704"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>
@@ -15,38 +13,51 @@
             <rect key="frame" x="0.0" y="0.0" width="597" height="80"/>
             <autoresizingMask key="autoresizingMask" flexibleMaxY="YES"/>
             <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="2" id="sQq-jC-UEV">
-                <rect key="frame" x="0.0" y="0.0" width="597" height="79.5"/>
+                <rect key="frame" x="0.0" y="0.0" width="597" height="80"/>
                 <autoresizingMask key="autoresizingMask"/>
                 <subviews>
-                    <label opaque="NO" userInteractionEnabled="NO" tag="102" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="wordWrap" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="0.0" translatesAutoresizingMaskIntoConstraints="NO" id="15D-cA-LLO" userLabel="Informazioni">
-                        <rect key="frame" x="103" y="2.5" width="484" height="75"/>
-                        <constraints>
-                            <constraint firstAttribute="height" constant="75" id="vPY-Rf-Mrc" userLabel="height = 70"/>
-                        </constraints>
-                        <fontDescription key="fontDescription" type="system" pointSize="12"/>
-                        <color key="textColor" red="0.3333333432674408" green="0.3333333432674408" blue="0.3333333432674408" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
-                        <nil key="highlightedColor"/>
-                    </label>
-                    <imageView userInteractionEnabled="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="5">
+                    <imageView userInteractionEnabled="NO" contentMode="scaleAspectFill" translatesAutoresizingMaskIntoConstraints="NO" id="5">
                         <rect key="frame" x="10" y="5" width="70" height="70"/>
                         <constraints>
                             <constraint firstAttribute="height" constant="70" id="2Z3-9a-dWb"/>
                             <constraint firstAttribute="width" constant="70" id="fbQ-SN-CAK"/>
                         </constraints>
                     </imageView>
+                    <textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="VsB-d4-Sow">
+                        <rect key="frame" x="90" y="10" width="497" height="20"/>
+                        <constraints>
+                            <constraint firstAttribute="height" constant="20" id="Dk0-na-bfK"/>
+                        </constraints>
+                        <fontDescription key="fontDescription" type="system" pointSize="14"/>
+                        <textInputTraits key="textInputTraits"/>
+                    </textField>
+                    <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="0Ow-Hb-LiN">
+                        <rect key="frame" x="90" y="50" width="497" height="20"/>
+                        <constraints>
+                            <constraint firstAttribute="height" constant="20" id="9pk-f4-eS9"/>
+                        </constraints>
+                        <fontDescription key="fontDescription" type="system" pointSize="14"/>
+                        <nil key="textColor"/>
+                        <nil key="highlightedColor"/>
+                    </label>
                 </subviews>
                 <constraints>
                     <constraint firstItem="5" firstAttribute="centerY" secondItem="sQq-jC-UEV" secondAttribute="centerY" id="3LF-0l-IUQ"/>
-                    <constraint firstItem="15D-cA-LLO" firstAttribute="centerY" secondItem="sQq-jC-UEV" secondAttribute="centerY" id="AAD-cK-soS"/>
-                    <constraint firstAttribute="trailing" secondItem="15D-cA-LLO" secondAttribute="trailing" constant="10" id="ZZf-b6-uAj"/>
-                    <constraint firstItem="15D-cA-LLO" firstAttribute="leading" secondItem="sQq-jC-UEV" secondAttribute="leading" constant="103" id="bSg-xJ-sEw"/>
+                    <constraint firstItem="VsB-d4-Sow" firstAttribute="leading" secondItem="5" secondAttribute="trailing" constant="10" id="CrK-6o-Z32"/>
+                    <constraint firstAttribute="trailing" secondItem="0Ow-Hb-LiN" secondAttribute="trailing" constant="10" id="DiV-IR-cy6"/>
+                    <constraint firstAttribute="bottom" secondItem="0Ow-Hb-LiN" secondAttribute="bottom" constant="10" id="ObO-OF-tvn"/>
+                    <constraint firstItem="0Ow-Hb-LiN" firstAttribute="leading" secondItem="5" secondAttribute="trailing" constant="10" id="PFo-Au-ORj"/>
+                    <constraint firstAttribute="trailing" secondItem="VsB-d4-Sow" secondAttribute="trailing" constant="10" id="Q94-2Q-wue"/>
                     <constraint firstItem="5" firstAttribute="leading" secondItem="sQq-jC-UEV" secondAttribute="leading" constant="10" id="fuA-E4-YoA"/>
+                    <constraint firstItem="VsB-d4-Sow" firstAttribute="top" secondItem="sQq-jC-UEV" secondAttribute="top" constant="10" id="i4S-x6-rac"/>
                 </constraints>
             </tableViewCellContentView>
             <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
             <connections>
+                <outlet property="Info" destination="9pk-f4-eS9" id="vm7-h8-kBz"/>
                 <outlet property="fileImageView" destination="5" id="6"/>
-                <outlet property="labelInformazioni" destination="15D-cA-LLO" id="So0-uY-bRj"/>
+                <outlet property="fileName" destination="VsB-d4-Sow" id="IiA-92-aJd"/>
+                <outlet property="info" destination="0Ow-Hb-LiN" id="Hhb-VE-mwc"/>
             </connections>
             <point key="canvasLocation" x="248.55072463768118" y="278.57142857142856"/>
         </tableViewCell>

+ 10 - 13
Share/MainInterface.storyboard

@@ -1,11 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="yQd-yC-53O">
-    <device id="retina4_7" orientation="portrait">
-        <adaptation id="fullscreen"/>
-    </device>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="15702" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="yQd-yC-53O">
+    <device id="retina4_7" orientation="portrait" appearance="light"/>
     <dependencies>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15704"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <scenes>
@@ -15,7 +13,7 @@
                 <navigationController id="yQd-yC-53O" sceneMemberID="viewController">
                     <nil key="simulatedStatusBarMetrics"/>
                     <navigationBar key="navigationBar" contentMode="scaleToFill" translucent="NO" id="Qr0-yX-mDZ">
-                        <rect key="frame" x="0.0" y="20" width="375" height="44"/>
+                        <rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
                         <autoresizingMask key="autoresizingMask"/>
                     </navigationBar>
                     <connections>
@@ -35,11 +33,11 @@
                         <viewControllerLayoutGuide type="bottom" id="d5i-Ba-RvD"/>
                     </layoutGuides>
                     <view key="view" contentMode="scaleToFill" id="wbc-yd-nQP">
-                        <rect key="frame" x="0.0" y="0.0" width="375" height="603"/>
+                        <rect key="frame" x="0.0" y="0.0" width="375" height="623"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <subviews>
                             <toolbar contentMode="scaleToFill" translucent="NO" translatesAutoresizingMaskIntoConstraints="NO" id="gad-k1-Oh8">
-                                <rect key="frame" x="-8" y="559" width="387" height="44"/>
+                                <rect key="frame" x="-8" y="579" width="387" height="44"/>
                                 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                                 <constraints>
                                     <constraint firstAttribute="height" constant="44" id="rZR-ep-syc"/>
@@ -54,8 +52,8 @@
                                     <barButtonItem style="plain" systemItem="flexibleSpace" id="eZh-WQ-5L1"/>
                                 </items>
                             </toolbar>
-                            <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="none" rowHeight="110" sectionHeaderHeight="40" sectionFooterHeight="22" translatesAutoresizingMaskIntoConstraints="NO" id="6bg-ed-mfL">
-                                <rect key="frame" x="-3" y="0.0" width="381" height="559"/>
+                            <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="none" rowHeight="110" sectionHeaderHeight="1" estimatedSectionHeaderHeight="1" sectionFooterHeight="1" estimatedSectionFooterHeight="1" translatesAutoresizingMaskIntoConstraints="NO" id="6bg-ed-mfL">
+                                <rect key="frame" x="0.0" y="0.0" width="375" height="579"/>
                                 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                                 <connections>
                                     <outlet property="dataSource" destination="j1y-V4-xli" id="cqC-oT-nbV"/>
@@ -66,14 +64,13 @@
                         <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                         <constraints>
                             <constraint firstAttribute="trailingMargin" secondItem="gad-k1-Oh8" secondAttribute="trailing" constant="-20" id="Ogc-Ss-sTA"/>
-                            <constraint firstItem="d5i-Ba-RvD" firstAttribute="top" secondItem="gad-k1-Oh8" secondAttribute="bottom" id="ZbI-py-8av"/>
-                            <constraint firstItem="6bg-ed-mfL" firstAttribute="leading" secondItem="wbc-yd-nQP" secondAttribute="leadingMargin" constant="-19" id="aoW-xE-g2g"/>
-                            <constraint firstAttribute="trailingMargin" secondItem="6bg-ed-mfL" secondAttribute="trailing" constant="-19" id="fyA-0H-E9s"/>
+                            <constraint firstAttribute="trailing" secondItem="6bg-ed-mfL" secondAttribute="trailing" id="dku-zI-tdG"/>
                             <constraint firstItem="d5i-Ba-RvD" firstAttribute="top" secondItem="gad-k1-Oh8" secondAttribute="bottom" id="n1F-h4-Uxd"/>
                             <constraint firstItem="gad-k1-Oh8" firstAttribute="top" secondItem="6bg-ed-mfL" secondAttribute="bottom" id="qEs-cg-DMH"/>
                             <constraint firstItem="gad-k1-Oh8" firstAttribute="leadingMargin" secondItem="wbc-yd-nQP" secondAttribute="leadingMargin" constant="-16" id="qnK-zI-jNY"/>
                             <constraint firstItem="6bg-ed-mfL" firstAttribute="top" secondItem="8bI-gs-bmD" secondAttribute="bottom" id="sKS-dx-tS9"/>
                             <constraint firstItem="gad-k1-Oh8" firstAttribute="top" secondItem="6bg-ed-mfL" secondAttribute="bottom" id="xUM-bt-esX"/>
+                            <constraint firstItem="6bg-ed-mfL" firstAttribute="leading" secondItem="wbc-yd-nQP" secondAttribute="leading" id="xkR-sP-qEX"/>
                         </constraints>
                     </view>
                     <navigationItem key="navigationItem" id="DwO-O2-rAX"/>

+ 1 - 1
Share/ShareViewController.h

@@ -32,7 +32,7 @@
 #import "CCError.h"
 #import "CCHud.h"
 
-@interface ShareViewController : UIViewController <UITableViewDelegate, MBProgressHUDDelegate, BKPasscodeViewControllerDelegate, NCSelectDestinationDelegate>
+@interface ShareViewController : UIViewController <UITableViewDelegate, MBProgressHUDDelegate, BKPasscodeViewControllerDelegate, NCSelectDestinationDelegate, UITextFieldDelegate>
 
 @property (nonatomic, strong) NSString *activeAccount;
 @property (nonatomic, strong) NSString *serverUrl;

+ 31 - 4
Share/ShareViewController.m

@@ -126,6 +126,30 @@
     NSLog(@"[LOG] bye bye, Nextcloud Share Extension!");
 }
 
+- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
+{
+    NSString *currentText = textField.text;
+    NSString *newText = [textField.text stringByReplacingCharactersInRange:range withString:string];
+    
+    if ([string isEqualToString:@"\n"] && ![newText isEqualToString:@""]) {
+        [textField endEditing:true];
+        return false;
+    }
+    
+    NSInteger index = [self.filesName indexOfObject:currentText];
+    if (index != NSNotFound) {
+        self.filesName[index] = newText;
+        if (![newText isEqualToString:@""]) {
+            NSString *fileNameAtPath = [NSTemporaryDirectory() stringByAppendingString:currentText];
+            NSString *fileNameToPath = [NSTemporaryDirectory() stringByAppendingString:newText];
+            [CCUtility moveFileAtPath:fileNameAtPath toPath:fileNameToPath];
+        }
+    }
+    
+    return true;
+}
+
+
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark == Action ==
 #pragma --------------------------------------------------------------------------------------------
@@ -432,13 +456,16 @@
     }
     else image = [UIImage imageNamed:@"file"];
     
-    
     NSUInteger fileSize = (NSInteger)[[[NSFileManager defaultManager] attributesOfItemAtPath:[NSTemporaryDirectory() stringByAppendingString:fileName] error:nil] fileSize];
     
-    cell.labelInformazioni.text = [NSString stringWithFormat:@"%@\r\r%@", fileName, [CCUtility transformedSize:fileSize]];
-    cell.labelInformazioni.textColor = NCBrandColor.sharedInstance.textView;
-
     cell.fileImageView.image = image;
+
+    cell.fileName.text = fileName;
+    cell.fileName.textColor = NCBrandColor.sharedInstance.textView;
+    cell.fileName.delegate = self;
+    
+    cell.info.text = [CCUtility transformedSize:fileSize];
+    cell.info.textColor = NCBrandColor.sharedInstance.textView;
     
     return cell;
 }