Browse Source

ATV cloud services: add login checker for Dropbox

Felix Paul Kühne 9 years ago
parent
commit
1d1442e433

+ 2 - 0
VLC for Apple TV/VLCCloudServicesTVViewController.h

@@ -13,4 +13,6 @@
 
 
 @interface VLCCloudServicesTVViewController : UIViewController
 @interface VLCCloudServicesTVViewController : UIViewController
 
 
+- (IBAction)dropbox:(id)sender;
+
 @end
 @end

+ 25 - 0
VLC for Apple TV/VLCCloudServicesTVViewController.m

@@ -10,6 +10,8 @@
  *****************************************************************************/
  *****************************************************************************/
 
 
 #import "VLCCloudServicesTVViewController.h"
 #import "VLCCloudServicesTVViewController.h"
+#import <DropboxTVSDK/DropboxSDK.h>
+#import "VLCDropboxController.h"
 
 
 @interface VLCCloudServicesTVViewController ()
 @interface VLCCloudServicesTVViewController ()
 
 
@@ -27,4 +29,27 @@
     return @"Cloud Services";
     return @"Cloud Services";
 }
 }
 
 
+- (void)dropbox:(id)sender
+{
+    if (![[VLCDropboxController sharedInstance] isAuthorized]) {
+        UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Login failure"
+                                                                       message:@"To use Dropbox, you need to login to iCloud with the same ID to both this Apple TV and an iOS device.\nAfterwards, login to Dropbox using the VLC app on your iOS device and try again."
+                                                                preferredStyle:UIAlertControllerStyleAlert];
+
+        UIAlertAction *defaultAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"BUTTON_OK", nil)
+                                                                style:UIAlertActionStyleDestructive
+                                                              handler:^(UIAlertAction * action) {
+                                                              }];
+
+        UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"BUTTON_RETRY", nil)
+                                                               style:UIAlertActionStyleDefault
+                                                             handler:^(UIAlertAction * action) {
+                                                                 [self dropbox:nil];
+                                                             }];
+        [alert addAction:defaultAction];
+        [alert addAction:cancelAction];
+        [self presentViewController:alert animated:YES completion:nil];
+    }
+}
+
 @end
 @end

+ 9 - 1
VLC for Apple TV/VLCCloudServicesTVViewController.xib

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<document type="com.apple.InterfaceBuilder.AppleTV.XIB" version="3.0" toolsVersion="9058" systemVersion="14F1017" targetRuntime="AppleTV" propertyAccessControl="none" useAutolayout="YES">
+<document type="com.apple.InterfaceBuilder.AppleTV.XIB" version="3.0" toolsVersion="9058" systemVersion="15A284" targetRuntime="AppleTV" propertyAccessControl="none" useAutolayout="YES">
     <dependencies>
     <dependencies>
         <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9048"/>
         <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9048"/>
     </dependencies>
     </dependencies>
@@ -16,27 +16,35 @@
             <subviews>
             <subviews>
                 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Cloud Services" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="B3D-nr-ofx">
                 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Cloud Services" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="B3D-nr-ofx">
                     <rect key="frame" x="714" y="26" width="493" height="91"/>
                     <rect key="frame" x="714" y="26" width="493" height="91"/>
+                    <animations/>
                     <fontDescription key="fontDescription" style="UICTFontTextStyleTitle1"/>
                     <fontDescription key="fontDescription" style="UICTFontTextStyleTitle1"/>
                     <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
                     <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
                     <nil key="highlightedColor"/>
                     <nil key="highlightedColor"/>
                 </label>
                 </label>
                 <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="hdP-Dp-Mn0">
                 <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="hdP-Dp-Mn0">
                     <rect key="frame" x="810" y="329" width="301" height="86"/>
                     <rect key="frame" x="810" y="329" width="301" height="86"/>
+                    <animations/>
                     <inset key="contentEdgeInsets" minX="40" minY="20" maxX="40" maxY="20"/>
                     <inset key="contentEdgeInsets" minX="40" minY="20" maxX="40" maxY="20"/>
                     <state key="normal" title="Dropbox"/>
                     <state key="normal" title="Dropbox"/>
+                    <connections>
+                        <action selector="dropbox:" destination="-1" eventType="primaryActionTriggered" id="CbH-po-vKw"/>
+                    </connections>
                 </button>
                 </button>
                 <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="uaI-5Z-SJq">
                 <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="uaI-5Z-SJq">
                     <rect key="frame" x="810" y="445" width="301" height="86"/>
                     <rect key="frame" x="810" y="445" width="301" height="86"/>
+                    <animations/>
                     <inset key="contentEdgeInsets" minX="40" minY="20" maxX="40" maxY="20"/>
                     <inset key="contentEdgeInsets" minX="40" minY="20" maxX="40" maxY="20"/>
                     <state key="normal" title="Google Drive"/>
                     <state key="normal" title="Google Drive"/>
                 </button>
                 </button>
                 <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="HPy-k8-PTt">
                 <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="HPy-k8-PTt">
                     <rect key="frame" x="810" y="561" width="301" height="86"/>
                     <rect key="frame" x="810" y="561" width="301" height="86"/>
+                    <animations/>
                     <inset key="contentEdgeInsets" minX="40" minY="20" maxX="40" maxY="20"/>
                     <inset key="contentEdgeInsets" minX="40" minY="20" maxX="40" maxY="20"/>
                     <state key="normal" title="Box"/>
                     <state key="normal" title="Box"/>
                 </button>
                 </button>
                 <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="gFm-4V-QFs">
                 <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="gFm-4V-QFs">
                     <rect key="frame" x="810" y="677" width="301" height="86"/>
                     <rect key="frame" x="810" y="677" width="301" height="86"/>
+                    <animations/>
                     <inset key="contentEdgeInsets" minX="40" minY="20" maxX="40" maxY="20"/>
                     <inset key="contentEdgeInsets" minX="40" minY="20" maxX="40" maxY="20"/>
                     <state key="normal" title="OneDrive"/>
                     <state key="normal" title="OneDrive"/>
                 </button>
                 </button>