Browse Source

VLCDropboxController: add support for ATV

Felix Paul Kühne 9 years ago
parent
commit
9445e28f94
2 changed files with 29 additions and 0 deletions
  1. 4 0
      Sources/VLCDropboxController.h
  2. 25 0
      Sources/VLCDropboxController.m

+ 4 - 0
Sources/VLCDropboxController.h

@@ -10,7 +10,11 @@
  * Refer to the COPYING file of the official project for license.
  *****************************************************************************/
 
+#if TARGET_OS_IOS
 #import <DropboxSDK/DropboxSDK.h>
+#else
+#import <DropboxTVSDK/DropboxSDK.h>
+#endif
 #import "VLCCloudStorageController.h"
 
 @interface VLCDropboxController : VLCCloudStorageController <DBRestClientDelegate, DBSessionDelegate, DBNetworkRequestDelegate>

+ 25 - 0
Sources/VLCDropboxController.m

@@ -14,8 +14,12 @@
 #import "VLCDropboxController.h"
 #import "NSString+SupportedMedia.h"
 #import "VLCPlaybackController.h"
+#if TARGET_OS_TV
+#import "VLCPlayerDisplayController.h"
+#else
 #import "VLCActivityManager.h"
 #import "VLCMediaFileDiscoverer.h"
+#endif
 
 @interface VLCDropboxController ()
 {
@@ -163,6 +167,7 @@
 
 - (void)restClient:(DBRestClient*)client loadedFile:(NSString*)localPath
 {
+#if TARGET_OS_IOS
     /* update library now that we got a file */
     [[VLCMediaFileDiscoverer sharedInstance] performSelectorOnMainThread:@selector(updateMediaList) withObject:nil waitUntilDone:NO];
 
@@ -171,6 +176,7 @@
     _downloadInProgress = NO;
 
     [self _triggerNextDownload];
+#endif
 }
 
 - (void)restClient:(DBRestClient*)client loadFileFailedWithError:(NSError*)error
@@ -217,21 +223,25 @@
 - (void)networkRequestStarted
 {
     _outstandingNetworkRequests++;
+#if TARGET_OS_IOS
     if (_outstandingNetworkRequests == 1) {
         VLCActivityManager *activityManager = [VLCActivityManager defaultManager];
         [activityManager networkActivityStarted];
         [activityManager disableIdleTimer];
     }
+#endif
 }
 
 - (void)networkRequestStopped
 {
     _outstandingNetworkRequests--;
+#if TARGET_OS_IOS
     if (_outstandingNetworkRequests == 0) {
         VLCActivityManager *activityManager = [VLCActivityManager defaultManager];
         [activityManager networkActivityStopped];
         [activityManager activateIdleTimer];
     }
+#endif
 }
 
 #pragma mark - VLC internal communication and delegate
@@ -270,12 +280,27 @@
 #pragma mark - user feedback
 - (void)_handleError:(NSError *)error
 {
+#if TARGET_OS_IOS
     VLCAlertView *alert = [[VLCAlertView alloc] initWithTitle:[NSString stringWithFormat:NSLocalizedString(@"ERROR_NUMBER", nil), error.code]
                                                       message:error.localizedDescription
                                                      delegate:self
                                             cancelButtonTitle:NSLocalizedString(@"BUTTON_CANCEL", nil)
                                             otherButtonTitles:nil];
     [alert show];
+#else
+    UIAlertController *alert = [UIAlertController alertControllerWithTitle:[NSString stringWithFormat:NSLocalizedString(@"ERROR_NUMBER", nil), error.code]
+                                                                   message:error.localizedDescription
+                                                            preferredStyle:UIAlertControllerStyleAlert];
+
+    UIAlertAction *defaultAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"BUTTON_CANCEL", nil)
+                                                            style:UIAlertActionStyleDestructive
+                                                          handler:^(UIAlertAction *action) {
+                                                          }];
+
+    [alert addAction:defaultAction];
+
+    [[[VLCPlayerDisplayController sharedInstance] childViewController] presentViewController:alert animated:YES completion:nil];
+#endif
 }
 
 @end