Skip to content
This repository was archived by the owner on Jan 14, 2019. It is now read-only.

Commit e3e8221

Browse files
authored
Merge pull request owncloud#904 from owncloud/private_link
Add support share private link for file
2 parents 2717d34 + a8aeb2a commit e3e8221

File tree

9 files changed

+137
-76
lines changed

9 files changed

+137
-76
lines changed
Binary file not shown.

Owncloud iOs Client/Tabs/FileTab/Share/Cells/ShareFileCell.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class ShareFileCell: UITableViewCell {
2222
@IBOutlet weak var fileName: UILabel!
2323
@IBOutlet weak var folderName: UILabel!
2424
@IBOutlet weak var fileSize: UILabel!
25+
@IBOutlet var privateLinkButton: UIButton!
2526

2627
override func awakeFromNib() {
2728
super.awakeFromNib()
Lines changed: 22 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="15G1004" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="15G1510" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
33
<device id="retina4_7" orientation="portrait">
44
<adaptation id="fullscreen"/>
55
</device>
66
<dependencies>
77
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
8-
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
98
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
109
</dependencies>
1110
<objects>
@@ -15,95 +14,52 @@
1514
<rect key="frame" x="0.0" y="0.0" width="320" height="120"/>
1615
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
1716
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
18-
<rect key="frame" x="0.0" y="0.0" width="320" height="120"/>
17+
<rect key="frame" x="0.0" y="0.0" width="320" height="119"/>
1918
<autoresizingMask key="autoresizingMask"/>
2019
<subviews>
21-
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="3Ov-PO-1rQ">
20+
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="3Ov-PO-1rQ">
2221
<rect key="frame" x="10" y="15" width="90" height="90"/>
23-
<constraints>
24-
<constraint firstAttribute="width" constant="90" id="Fcu-Ir-Zlh"/>
25-
<constraint firstAttribute="height" constant="90" id="znX-FW-wxm"/>
26-
</constraints>
22+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
2723
</imageView>
28-
<label hidden="YES" opaque="NO" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" text="File Name" lineBreakMode="tailTruncation" numberOfLines="2" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Yje-bh-jmU">
29-
<rect key="frame" x="108" y="25" width="204" height="45"/>
24+
<label hidden="YES" opaque="NO" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" fixedFrame="YES" text="File Name" lineBreakMode="tailTruncation" numberOfLines="2" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Yje-bh-jmU">
25+
<rect key="frame" x="108" y="25" width="163" height="44"/>
26+
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
3027
<fontDescription key="fontDescription" type="system" pointSize="17"/>
3128
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
3229
<nil key="highlightedColor"/>
3330
</label>
34-
<label hidden="YES" opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Folder Name" lineBreakMode="tailTruncation" numberOfLines="4" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Bqj-YB-hKp">
35-
<rect key="frame" x="108" y="16" width="204" height="87"/>
31+
<label hidden="YES" opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Folder Name" lineBreakMode="tailTruncation" numberOfLines="4" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Bqj-YB-hKp">
32+
<rect key="frame" x="108" y="16" width="163" height="87"/>
33+
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
3634
<fontDescription key="fontDescription" type="system" pointSize="17"/>
3735
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
3836
<nil key="highlightedColor"/>
3937
</label>
40-
<label hidden="YES" opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Size" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="5i0-Uz-NhM">
41-
<rect key="frame" x="108" y="74" width="204" height="20"/>
38+
<label hidden="YES" opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Size" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="5i0-Uz-NhM">
39+
<rect key="frame" x="108" y="73" width="204" height="21"/>
40+
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
4241
<fontDescription key="fontDescription" type="system" pointSize="17"/>
4342
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
4443
<nil key="highlightedColor"/>
4544
</label>
45+
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="VOr-hs-YaC">
46+
<rect key="frame" x="282" y="16" width="22" height="22"/>
47+
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
48+
<state key="normal" title="Button" image="CopyLinkShareipad.png"/>
49+
</button>
4650
</subviews>
47-
<constraints>
48-
<constraint firstItem="5i0-Uz-NhM" firstAttribute="top" secondItem="Bqj-YB-hKp" secondAttribute="bottom" constant="4" id="0Sm-LB-UKl"/>
49-
<constraint firstItem="5i0-Uz-NhM" firstAttribute="leading" secondItem="3Ov-PO-1rQ" secondAttribute="trailing" constant="8" id="1GM-dI-4MZ"/>
50-
<constraint firstAttribute="trailing" secondItem="Bqj-YB-hKp" secondAttribute="trailing" constant="8" id="1nJ-fJ-9pI"/>
51-
<constraint firstAttribute="trailing" secondItem="Yje-bh-jmU" secondAttribute="trailing" constant="8" id="23u-Xi-W5h"/>
52-
<constraint firstItem="5i0-Uz-NhM" firstAttribute="top" secondItem="Bqj-YB-hKp" secondAttribute="bottom" constant="3" id="5fr-jO-HzS"/>
53-
<constraint firstItem="Yje-bh-jmU" firstAttribute="leading" secondItem="3Ov-PO-1rQ" secondAttribute="trailing" constant="8" id="6oS-He-mk6"/>
54-
<constraint firstItem="Bqj-YB-hKp" firstAttribute="leading" secondItem="3Ov-PO-1rQ" secondAttribute="trailing" constant="8" id="8EF-vp-LNt"/>
55-
<constraint firstItem="5i0-Uz-NhM" firstAttribute="top" secondItem="Yje-bh-jmU" secondAttribute="bottom" constant="8" id="Gz1-gw-Ygq"/>
56-
<constraint firstItem="Bqj-YB-hKp" firstAttribute="trailing" secondItem="H2p-sc-9uM" secondAttribute="trailingMargin" id="IWO-nq-pdn"/>
57-
<constraint firstItem="Bqj-YB-hKp" firstAttribute="leading" secondItem="3Ov-PO-1rQ" secondAttribute="trailing" constant="8" id="JAX-Zm-Igs"/>
58-
<constraint firstItem="Bqj-YB-hKp" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" constant="16" id="Jwj-zi-cCs"/>
59-
<constraint firstAttribute="bottom" secondItem="5i0-Uz-NhM" secondAttribute="bottom" constant="25" id="KRA-iE-1f1"/>
60-
<constraint firstAttribute="trailing" secondItem="5i0-Uz-NhM" secondAttribute="trailing" constant="8" id="LvY-mk-4Ba"/>
61-
<constraint firstAttribute="bottom" secondItem="Bqj-YB-hKp" secondAttribute="bottom" constant="16" id="NDp-y4-Twd"/>
62-
<constraint firstAttribute="bottomMargin" secondItem="3Ov-PO-1rQ" secondAttribute="bottom" constant="6" id="TMJ-kQ-yF4"/>
63-
<constraint firstItem="3Ov-PO-1rQ" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="topMargin" constant="7" id="UlH-Vg-HKA"/>
64-
<constraint firstAttribute="bottom" secondItem="5i0-Uz-NhM" secondAttribute="bottom" constant="14" id="Uz0-VV-rLr"/>
65-
<constraint firstItem="Bqj-YB-hKp" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" constant="37" id="aIa-wX-HXt"/>
66-
<constraint firstAttribute="bottom" secondItem="Bqj-YB-hKp" secondAttribute="bottom" constant="22" id="fll-od-SRe"/>
67-
<constraint firstItem="Yje-bh-jmU" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" constant="25" id="fyt-jl-Ste"/>
68-
<constraint firstItem="Bqj-YB-hKp" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="topMargin" constant="41" id="gZ8-7D-jWP"/>
69-
<constraint firstAttribute="bottomMargin" secondItem="Bqj-YB-hKp" secondAttribute="bottom" constant="41" id="guG-Bi-Rnq"/>
70-
<constraint firstItem="5i0-Uz-NhM" firstAttribute="top" secondItem="Yje-bh-jmU" secondAttribute="bottom" constant="14" id="iVE-9J-Wep"/>
71-
<constraint firstAttribute="bottom" secondItem="Bqj-YB-hKp" secondAttribute="bottom" constant="37" id="jFc-sD-k9r"/>
72-
<constraint firstItem="5i0-Uz-NhM" firstAttribute="top" secondItem="Yje-bh-jmU" secondAttribute="bottom" constant="4" id="mmh-dk-0BI"/>
73-
<constraint firstItem="Yje-bh-jmU" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" constant="15" id="qgr-0r-HWw"/>
74-
<constraint firstAttribute="bottomMargin" secondItem="5i0-Uz-NhM" secondAttribute="bottom" constant="6" id="tJU-35-gA7"/>
75-
<constraint firstItem="Bqj-YB-hKp" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" constant="22" id="tb6-AT-nGd"/>
76-
<constraint firstItem="3Ov-PO-1rQ" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leadingMargin" constant="2" id="wnk-da-vhU"/>
77-
<constraint firstItem="5i0-Uz-NhM" firstAttribute="top" secondItem="Bqj-YB-hKp" secondAttribute="bottom" constant="3" id="xJ0-v6-Lbc"/>
78-
</constraints>
79-
<variation key="default">
80-
<mask key="constraints">
81-
<exclude reference="IWO-nq-pdn"/>
82-
<exclude reference="JAX-Zm-Igs"/>
83-
<exclude reference="aIa-wX-HXt"/>
84-
<exclude reference="fll-od-SRe"/>
85-
<exclude reference="gZ8-7D-jWP"/>
86-
<exclude reference="guG-Bi-Rnq"/>
87-
<exclude reference="jFc-sD-k9r"/>
88-
<exclude reference="tb6-AT-nGd"/>
89-
<exclude reference="qgr-0r-HWw"/>
90-
<exclude reference="0Sm-LB-UKl"/>
91-
<exclude reference="5fr-jO-HzS"/>
92-
<exclude reference="Gz1-gw-Ygq"/>
93-
<exclude reference="Uz0-VV-rLr"/>
94-
<exclude reference="iVE-9J-Wep"/>
95-
<exclude reference="tJU-35-gA7"/>
96-
<exclude reference="xJ0-v6-Lbc"/>
97-
</mask>
98-
</variation>
9951
</tableViewCellContentView>
10052
<connections>
10153
<outlet property="fileImage" destination="3Ov-PO-1rQ" id="fvV-MB-NAY"/>
10254
<outlet property="fileName" destination="Yje-bh-jmU" id="A8X-J2-agA"/>
10355
<outlet property="fileSize" destination="5i0-Uz-NhM" id="mDs-JE-Xom"/>
10456
<outlet property="folderName" destination="Bqj-YB-hKp" id="vC3-yA-HHn"/>
57+
<outlet property="privateLinkButton" destination="VOr-hs-YaC" id="S5C-6c-b76"/>
10558
</connections>
10659
<point key="canvasLocation" x="419" y="421"/>
10760
</tableViewCell>
10861
</objects>
62+
<resources>
63+
<image name="CopyLinkShareipad.png" width="55" height="55"/>
64+
</resources>
10965
</document>

Owncloud iOs Client/Tabs/FileTab/Share/ShareMainViewController.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@
1919
#import "MBProgressHUD.h"
2020
#import "FileDto.h"
2121
#import "AppsActivityProvider.h"
22+
#import "TSMessage.h"
2223

23-
@interface ShareMainViewController : UIViewController <UITableViewDataSource, UITableViewDelegate, ShareFileOrFolderDelegate, MBProgressHUDDelegate, UIAlertViewDelegate, UIGestureRecognizerDelegate, UIActionSheetDelegate >
24+
@interface ShareMainViewController : UIViewController <UITableViewDataSource, UITableViewDelegate, ShareFileOrFolderDelegate, MBProgressHUDDelegate, UIAlertViewDelegate, UIGestureRecognizerDelegate, UIActionSheetDelegate , TSMessageViewProtocol>
2425

2526
@property (weak, nonatomic) IBOutlet UITableView *shareTableView;
2627

Owncloud iOs Client/Tabs/FileTab/Share/ShareMainViewController.m

Lines changed: 60 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -447,13 +447,16 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
447447

448448
if (!k_warning_sharing_public_link || (k_warning_sharing_public_link && indexPath.row != 0 && [self.sharedPublicLinks count] > 0) ) {
449449

450-
NSInteger indexShareLink = indexShareLink = indexPath.row;
450+
NSInteger indexShareLink = indexPath.row;
451451
if (k_warning_sharing_public_link) {
452452
indexShareLink = indexPath.row-1;
453453
}
454454

455455
NSURL *urlShareLink = [ShareUtils getNormalizedURLOfShareLink:self.sharedPublicLinks[indexShareLink]];
456-
[self presentActivityViewForShareLink:urlShareLink];
456+
457+
UIButton *cellGetPublicLinkButton = [self.shareTableView viewWithTag:indexPath.row];
458+
459+
[self presentActivityViewForShareLink:urlShareLink inView:cellGetPublicLinkButton fromRect:cellGetPublicLinkButton.bounds];
457460
}
458461
}
459462
}
@@ -502,6 +505,21 @@ - (UITableViewCell *) getCellOfFileOrFolderInformationByTableView:(UITableView *
502505
shareFileCell.fileSize.hidden = self.sharedItem.isDirectory;
503506
shareFileCell.folderName.hidden = !self.sharedItem.isDirectory;
504507

508+
//Add long press event
509+
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(didLongPressPrivateLinkButton:)];
510+
// longPress.minimumPressDuration = 3; //seconds
511+
longPress.delegate = self;
512+
[shareFileCell.privateLinkButton addGestureRecognizer:longPress];
513+
514+
//Add tap event
515+
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didTapPrivateLinkButton)];
516+
tapGesture.numberOfTapsRequired = 1;
517+
tapGesture.numberOfTouchesRequired = 1;
518+
[shareFileCell.privateLinkButton addGestureRecognizer:tapGesture];
519+
520+
shareFileCell.privateLinkButton.tag = -1;
521+
522+
505523
if (self.sharedItem.isDirectory) {
506524
shareFileCell.fileImage.image = [UIImage imageNamed:@"folder_icon"];
507525
shareFileCell.folderName.text = @"";
@@ -518,6 +536,7 @@ - (UITableViewCell *) getCellOfFileOrFolderInformationByTableView:(UITableView *
518536

519537
}
520538

539+
521540
- (UITableViewCell *) getCellOfUserOrGroupNameSharedByTableView:(UITableView *) tableView andIndexPath:(NSIndexPath *) indexPath {
522541

523542
ShareUserCell* shareUserCell = (ShareUserCell*)[tableView dequeueReusableCellWithIdentifier:shareUserCellIdentifier];
@@ -595,9 +614,8 @@ - (UITableViewCell *) getCellShareLinkByTableView:(UITableView *)tableView andIn
595614
OCSharedDto *shareLink = [self.sharedPublicLinks objectAtIndex:indexLink];
596615

597616
shareLinkCell.itemName.text = ([shareLink.name length] == 0 || [shareLink.name isEqualToString:@"(null)"] ) ? shareLink.token: shareLink.name;
598-
// shareLinkCell.buttonGetLink.tag = shareLink.idRemoteShared;
599-
// [shareLinkCell.buttonGetLink addTarget:self action:@selector(didSelectGetShareLink:) forControlEvents:UIControlEventTouchDown];
600617
shareLinkCell.accessoryType = UITableViewCellAccessoryDetailButton;
618+
shareLinkCell.buttonGetLink.tag = indexPath.row;
601619
}
602620

603621
shareLinkCell.selectionStyle = UITableViewCellEditingStyleNone;
@@ -626,12 +644,39 @@ - (void) didSelectAddPublicLink {
626644
[self presentViewLinkOptionsOfSharedLink:nil ofFile:self.sharedItem withLinkOptionsViewMode:LinkOptionsViewModeCreate];
627645
}
628646

647+
- (void) didTapPrivateLinkButton {
648+
649+
UIButton *cellPrivateLinkButton = [self.shareTableView viewWithTag:-1];
650+
651+
[self presentActivityViewForShareLink: [NSURL URLWithString:[ShareUtils getPrivateLinkOfFile:self.sharedItem]] inView:cellPrivateLinkButton fromRect:cellPrivateLinkButton.bounds];
652+
}
653+
654+
- (void) didLongPressPrivateLinkButton:(UILongPressGestureRecognizer*)gesture {
655+
656+
if ( gesture.state == UIGestureRecognizerStateEnded ) {
657+
658+
[self showWarningMessageWithText:NSLocalizedString(@"message_private_link", nil)];
659+
}
660+
661+
}
662+
629663
- (void) didSelectCloseView {
630664

631665
[self dismissViewControllerAnimated:true completion:nil];
632666
}
633667

634668

669+
#pragma mark - TSMessages
670+
671+
- (void)showWarningMessageWithText: (NSString *) message {
672+
673+
//Run UI Updates
674+
[TSMessage setDelegate:self];
675+
[TSMessage showNotificationInViewController:self title:message subtitle:nil type:TSMessageNotificationTypeWarning];
676+
677+
}
678+
679+
635680
#pragma mark - present views
636681

637682
-(void) presentViewEditSharedUser:(OCSharedDto *)sharedDto ofFile:(FileDto *)fileShared {
@@ -672,7 +717,7 @@ -(void) presentViewLinkOptionsOfSharedLink:(OCSharedDto *)sharedDto ofFile:(File
672717
}
673718

674719

675-
- (void) presentActivityViewForShareLink:(NSURL *)urlShareLink {
720+
- (void) presentActivityViewForShareLink:(NSURL *)urlShareLink inView:(id)sender fromRect:(CGRect)cgRect {
676721

677722
UIActivityItemProvider *activityProvider = [[UIActivityItemProvider alloc] initWithPlaceholderItem:urlShareLink];
678723
NSArray *items = @[activityProvider,urlShareLink];
@@ -697,7 +742,16 @@ - (void) presentActivityViewForShareLink:(NSURL *)urlShareLink {
697742
UIActivityTypeSaveToCameraRoll,
698743
UIActivityTypePostToWeibo]];
699744

700-
[self presentViewController:activityView animated:YES completion:nil];
745+
if (IS_IPHONE) {
746+
747+
[self presentViewController:activityView animated:YES completion:nil];
748+
749+
} else {
750+
751+
self.activityPopoverController = [[UIPopoverController alloc] initWithContentViewController:activityView];
752+
753+
[self.activityPopoverController presentPopoverFromRect:cgRect inView:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
754+
}
701755

702756
}
703757

0 commit comments

Comments
 (0)