Ver código fonte

VLC Cloud Storage Table View classes: added support for ATV

Felix Paul Kühne 9 anos atrás
pai
commit
367a66995a

+ 5 - 1
Sources/VLCCloudStorageTableViewCell.h

@@ -11,10 +11,12 @@
  * Refer to the COPYING file of the official project for license.
  *****************************************************************************/
 
-#import <DropboxSDK/DropboxSDK.h>
+#import "VLCDropboxController.h"
+#if TARGET_OS_IOS
 #import "GTLDrive.h"
 #import <BoxSDK/BoxSDK.h>
 #import "VLCOneDriveObject.h"
+#endif
 
 @interface VLCCloudStorageTableViewCell : UITableViewCell
 
@@ -27,9 +29,11 @@
 @property (nonatomic, strong) IBOutlet UIButton *downloadButton;
 
 @property (nonatomic, retain) DBMetadata *dropboxFile;
+#if TARGET_OS_IOS
 @property (nonatomic, retain) GTLDriveFile *driveFile;
 @property (nonatomic, retain) BoxItem *boxFile;
 @property (nonatomic, retain) VLCOneDriveObject *oneDriveFile;
+#endif
 
 @property (nonatomic, readwrite) BOOL isDownloadable;
 

+ 10 - 2
Sources/VLCCloudStorageTableViewCell.m

@@ -39,6 +39,7 @@
                            withObject:nil waitUntilDone:NO];
 }
 
+#if TARGET_OS_IOS
 - (void)setDriveFile:(GTLDriveFile *)driveFile
 {
     if (driveFile != _driveFile)
@@ -65,6 +66,7 @@
     [self performSelectorOnMainThread:@selector(_updatedDisplayedInformation)
                            withObject:nil waitUntilDone:NO];
 }
+#endif
 
 - (void)_updatedDisplayedInformation
 {
@@ -94,8 +96,9 @@
             self.thumbnailView.image = [UIImage imageNamed:@"blank"];
             APLog(@"missing icon for type '%@'", self.dropboxFile.icon);
         }
-
-    } else if(_driveFile != nil){
+    }
+#if TARGET_OS_IOS
+    else if(_driveFile != nil){
         BOOL isDirectory = [self.driveFile.mimeType isEqualToString:@"application/vnd.google-apps.folder"];
         if (isDirectory) {
             self.folderTitleLabel.text = self.driveFile.title;
@@ -188,6 +191,7 @@
                 self.thumbnailView.image = [UIImage imageNamed:@"blank"];
         }
     }
+#endif
 
     [self setNeedsDisplay];
 }
@@ -215,10 +219,14 @@
 
 + (CGFloat)heightOfCell
 {
+#if TARGET_OS_IOS
     if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
         return 80.;
 
     return 48.;
+#else
+    return 107.;
+#endif
 }
 
 - (void)setIsDownloadable:(BOOL)isDownloadable

+ 1 - 2
Sources/VLCCloudStorageTableViewController.h

@@ -12,7 +12,6 @@
  * Refer to the COPYING file of the official project for license.
  *****************************************************************************/
 
-#import "VLCCloudStorageTableViewCell.h"
 #import "VLCCloudStorageController.h"
 
 @interface VLCCloudStorageTableViewController : UIViewController <VLCCloudStorageDelegate>
@@ -35,4 +34,4 @@
 - (void)updateViewAfterSessionChange;
 - (void)goBack;
 
-@end
+@end

+ 34 - 13
Sources/VLCCloudStorageTableViewController.m

@@ -13,12 +13,17 @@
  *****************************************************************************/
 
 #import "VLCCloudStorageTableViewController.h"
+#import "VLCCloudStorageTableViewCell.h"
+#if TARGET_OS_IOS
 #import "VLCProgressView.h"
+#endif
 
 @interface VLCCloudStorageTableViewController()
 {
+#if TARGET_OS_IOS
     VLCProgressView *_progressView;
-    
+#endif
+
     UIBarButtonItem *_progressBarButtonItem;
     UIBarButtonItem *_logoutButton;
 }
@@ -33,9 +38,9 @@
 
     _authorizationInProgress = NO;
 
+#if TARGET_OS_IOS
     self.modalPresentationStyle = UIModalPresentationFormSheet;
-    self.navigationItem.titleView.contentMode = UIViewContentModeScaleAspectFit;
-    
+
     UIBarButtonItem *backButton = [UIBarButtonItem themedBackButtonWithTarget:self andSelector:@selector(goBack)];
     self.navigationItem.leftBarButtonItem = backButton;
 
@@ -45,13 +50,14 @@
 
     [self.navigationController.toolbar setBackgroundImage:[UIImage imageNamed:@"sudHeaderBg"] forToolbarPosition:UIToolbarPositionAny barMetrics:UIBarMetricsDefault];
 
-    self.tableView.rowHeight = [VLCCloudStorageTableViewCell heightOfCell];
     self.tableView.separatorColor = [UIColor VLCDarkBackgroundColor];
     self.tableView.backgroundColor = [UIColor VLCDarkBackgroundColor];
     self.view.backgroundColor = [UIColor VLCDarkBackgroundColor];
+#endif
 
-    _progressView = [VLCProgressView new];
-    _progressBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:_progressView];
+    self.navigationItem.titleView.contentMode = UIViewContentModeScaleAspectFit;
+
+    self.tableView.rowHeight = [VLCCloudStorageTableViewCell heightOfCell];
 
     _numberOfFilesBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:[NSString stringWithFormat:NSLocalizedString(@"NUM_OF_FILES", nil), 0] style:UIBarButtonItemStylePlain target:nil action:nil];
     [_numberOfFilesBarButtonItem setTitleTextAttributes:@{ NSFontAttributeName : [UIFont systemFontOfSize:11.] } forState:UIControlStateNormal];
@@ -59,15 +65,21 @@
     _activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
     _activityIndicator.hidesWhenStopped = YES;
     _activityIndicator.translatesAutoresizingMaskIntoConstraints = NO;
-    
+
     [self.view addSubview:_activityIndicator];
 
     [self.view addConstraint:[NSLayoutConstraint constraintWithItem:_activityIndicator attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:0]];
     [self.view addConstraint:[NSLayoutConstraint constraintWithItem:_activityIndicator attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0]];
-    
+
+#if TARGET_OS_IOS
+    _progressView = [VLCProgressView new];
+    _progressBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:_progressView];
+
     [self _showProgressInToolbar:NO];
+#endif
 }
 
+#if TARGET_OS_IOS
 - (void)viewWillAppear:(BOOL)animated
 {
     self.navigationController.toolbarHidden = NO;
@@ -81,6 +93,7 @@
     self.navigationController.toolbarHidden = YES;
     [super viewWillDisappear:animated];
 }
+#endif
 
 - (void)_requestInformationForCurrentPath
 {
@@ -104,6 +117,7 @@
         self.numberOfFilesBarButtonItem.title = NSLocalizedString(@"ONE_FILE", nil);
 }
 
+#if TARGET_OS_IOS
 - (void)_showProgressInToolbar:(BOOL)value
 {
     if (!value)
@@ -114,11 +128,6 @@
     }
 }
 
-- (void)operationWithProgressInformationStarted
-{
-    [self _showProgressInToolbar:YES];
-}
-
 - (void)updateRemainingTime:(NSString *)time
 {
     [_progressView updateTime:time];
@@ -128,10 +137,20 @@
 {
     [_progressView.progressBar setProgress:progress animated:YES];
 }
+#endif
+
+- (void)operationWithProgressInformationStarted
+{
+#if TARGET_OS_IOS
+    [self _showProgressInToolbar:YES];
+#endif
+}
 
 - (void)operationWithProgressInformationStopped
 {
+#if TARGET_OS_IOS
     [self _showProgressInToolbar:NO];
+#endif
 }
 #pragma mark - UITableViewDataSources
 
@@ -142,10 +161,12 @@
 
 #pragma mark - UITableViewDelegate
 
+#if TARGET_OS_IOS
 - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
 {
     cell.backgroundColor = (indexPath.row % 2 == 0)? [UIColor blackColor]: [UIColor VLCDarkBackgroundColor];
 }
+#endif
 
 - (void)goBack
 {

+ 77 - 0
VLC for Apple TV/VLCCloudStorageTableViewCell.xib

@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<document type="com.apple.InterfaceBuilder.AppleTV.XIB" version="3.0" toolsVersion="9059" systemVersion="15B42" targetRuntime="AppleTV" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
+    <dependencies>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9049"/>
+        <capability name="Constraints to layout margins" minToolsVersion="6.0"/>
+    </dependencies>
+    <objects>
+        <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
+        <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
+        <tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" rowHeight="107" id="hXT-df-h3G" customClass="VLCCloudStorageTableViewCell">
+            <rect key="frame" x="0.0" y="0.0" width="800" height="107"/>
+            <autoresizingMask key="autoresizingMask"/>
+            <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="hXT-df-h3G" id="dsG-Yq-ktP">
+                <rect key="frame" x="0.0" y="0.0" width="784" height="107"/>
+                <autoresizingMask key="autoresizingMask"/>
+                <subviews>
+                    <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="XK7-9R-AfJ">
+                        <rect key="frame" x="8" y="8" width="91" height="91"/>
+                        <animations/>
+                        <constraints>
+                            <constraint firstAttribute="width" constant="91" id="Skw-hL-8l1"/>
+                            <constraint firstAttribute="height" constant="91" id="j8j-bJ-vpn"/>
+                        </constraints>
+                    </imageView>
+                    <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="744-48-gFJ">
+                        <rect key="frame" x="107" y="36" width="70" height="35"/>
+                        <animations/>
+                        <fontDescription key="fontDescription" style="UICTFontTextStyleSubhead"/>
+                        <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
+                        <nil key="highlightedColor"/>
+                    </label>
+                    <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="vhO-YQ-1Od">
+                        <rect key="frame" x="107" y="17" width="70" height="35"/>
+                        <animations/>
+                        <fontDescription key="fontDescription" style="UICTFontTextStyleSubhead"/>
+                        <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
+                        <nil key="highlightedColor"/>
+                    </label>
+                    <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="97b-un-sxc">
+                        <rect key="frame" x="107" y="60" width="61" height="30"/>
+                        <animations/>
+                        <fontDescription key="fontDescription" style="UICTFontTextStyleCaption1"/>
+                        <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
+                        <nil key="highlightedColor"/>
+                    </label>
+                </subviews>
+                <animations/>
+                <constraints>
+                    <constraint firstItem="97b-un-sxc" firstAttribute="top" secondItem="vhO-YQ-1Od" secondAttribute="bottom" constant="8" id="1Qb-AX-mTz"/>
+                    <constraint firstAttribute="bottomMargin" secondItem="XK7-9R-AfJ" secondAttribute="bottom" id="3WS-Wk-Fkr"/>
+                    <constraint firstItem="744-48-gFJ" firstAttribute="centerY" secondItem="dsG-Yq-ktP" secondAttribute="centerY" id="5fV-f3-MWT"/>
+                    <constraint firstItem="vhO-YQ-1Od" firstAttribute="leading" secondItem="XK7-9R-AfJ" secondAttribute="trailing" constant="8" id="Syv-4s-y6U"/>
+                    <constraint firstAttribute="leadingMargin" secondItem="XK7-9R-AfJ" secondAttribute="leading" id="agW-hM-PCk"/>
+                    <constraint firstItem="vhO-YQ-1Od" firstAttribute="top" secondItem="dsG-Yq-ktP" secondAttribute="topMargin" constant="7" id="gax-lj-sFq"/>
+                    <constraint firstItem="vhO-YQ-1Od" firstAttribute="top" secondItem="dsG-Yq-ktP" secondAttribute="topMargin" constant="9" id="nov-zM-Ymn"/>
+                    <constraint firstItem="97b-un-sxc" firstAttribute="leading" secondItem="XK7-9R-AfJ" secondAttribute="trailing" constant="8" id="p4k-dk-KAi"/>
+                    <constraint firstItem="744-48-gFJ" firstAttribute="leading" secondItem="XK7-9R-AfJ" secondAttribute="trailing" constant="8" id="uZg-hZ-otd"/>
+                    <constraint firstItem="XK7-9R-AfJ" firstAttribute="centerY" secondItem="dsG-Yq-ktP" secondAttribute="centerY" id="yNp-pn-Htf"/>
+                </constraints>
+                <variation key="default">
+                    <mask key="constraints">
+                        <exclude reference="3WS-Wk-Fkr"/>
+                        <exclude reference="gax-lj-sFq"/>
+                    </mask>
+                </variation>
+            </tableViewCellContentView>
+            <animations/>
+            <connections>
+                <outlet property="folderTitleLabel" destination="744-48-gFJ" id="bnU-2b-StB"/>
+                <outlet property="subtitleLabel" destination="97b-un-sxc" id="1oY-Ma-O6S"/>
+                <outlet property="thumbnailView" destination="XK7-9R-AfJ" id="T6E-Qz-R9R"/>
+                <outlet property="titleLabel" destination="vhO-YQ-1Od" id="DRJ-zk-gfE"/>
+            </connections>
+            <point key="canvasLocation" x="-447" y="402.5"/>
+        </tableViewCell>
+    </objects>
+</document>

+ 41 - 0
VLC for Apple TV/VLCCloudStorageTableViewController.xib

@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<document type="com.apple.InterfaceBuilder.AppleTV.XIB" version="3.0" toolsVersion="9059" systemVersion="15B42" targetRuntime="AppleTV" propertyAccessControl="none" useAutolayout="YES">
+    <dependencies>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9049"/>
+    </dependencies>
+    <objects>
+        <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="VLCCloudStorageTableViewController">
+            <connections>
+                <outlet property="preferredFocusedView" destination="BJu-fh-cvS" id="esr-eG-51l"/>
+                <outlet property="tableView" destination="BJu-fh-cvS" id="Q4L-re-bYO"/>
+                <outlet property="view" destination="iN0-l3-epB" id="StN-hL-tvv"/>
+            </connections>
+        </placeholder>
+        <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
+        <view contentMode="scaleToFill" id="iN0-l3-epB">
+            <rect key="frame" x="0.0" y="0.0" width="1920" height="1080"/>
+            <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+            <subviews>
+                <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="plain" separatorStyle="default" rowHeight="66" sectionHeaderHeight="40" sectionFooterHeight="40" translatesAutoresizingMaskIntoConstraints="NO" id="BJu-fh-cvS">
+                    <rect key="frame" x="68" y="114" width="1784" height="917"/>
+                    <animations/>
+                    <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+                    <constraints>
+                        <constraint firstAttribute="width" constant="1784" id="Fbw-Lq-50b"/>
+                        <constraint firstAttribute="height" constant="917" id="U93-WZ-nro"/>
+                    </constraints>
+                    <connections>
+                        <outlet property="dataSource" destination="-1" id="KMS-Qu-Hei"/>
+                        <outlet property="delegate" destination="-1" id="LBp-MJ-kum"/>
+                    </connections>
+                </tableView>
+            </subviews>
+            <animations/>
+            <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
+            <constraints>
+                <constraint firstItem="BJu-fh-cvS" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" constant="114" id="iWm-Kv-B61"/>
+                <constraint firstItem="BJu-fh-cvS" firstAttribute="centerX" secondItem="iN0-l3-epB" secondAttribute="centerX" id="tgK-kM-gPy"/>
+            </constraints>
+        </view>
+    </objects>
+</document>