Bläddra i källkod

Settings: Hide unlink settings when cloud storage not linked

Signed-off-by: Felix Paul Kühne <fkuehne@videolan.org>
Steven Kabbes 11 år sedan
förälder
incheckning
5d4068bcac

+ 1 - 0
Sources/VLCMenuTableViewController.m

@@ -337,6 +337,7 @@
             self.settingsViewController.showCreditsFooter = NO;
 
             viewController = self.settingsController.viewController;
+            [self.settingsController willShow];
         } else if (itemIndex == 1)
             viewController = [[VLCAboutViewController alloc] init];
     } else {

+ 3 - 0
Sources/VLCSettingsController.h

@@ -16,4 +16,7 @@
 
 @property (nonatomic, retain) IASKAppSettingsViewController *viewController;
 
+// this should be called when the this view controller is about to become in focus
+- (void)willShow;
+
 @end

+ 18 - 0
Sources/VLCSettingsController.m

@@ -45,6 +45,11 @@
     [[NSNotificationCenter defaultCenter] removeObserver:self];
 }
 
+- (void)willShow
+{
+    [self filterCloudStorageCellsWithAnimation:NO];
+}
+
 - (void)settingDidChange:(NSNotification*)notification
 {
     if ([notification.object isEqual:kVLCSettingPasscodeOnKey]) {
@@ -58,6 +63,18 @@
     }
 }
 
+- (void) filterCloudStorageCellsWithAnimation:(BOOL)shouldAnimate
+{
+    NSMutableSet * hideKeys = [[NSMutableSet alloc] init];
+    if (![[DBSession sharedSession] isLinked]) {
+        [hideKeys addObject:@"UnlinkDropbox"];
+    }
+    if (![[VLCGoogleDriveController sharedInstance] isAuthorized]) {
+        [hideKeys addObject:@"UnlinkGoogleDrive"];
+    }
+    [self.viewController setHiddenKeys:hideKeys animated:shouldAnimate];
+}
+
 - (void)settingsViewControllerDidEnd:(IASKAppSettingsViewController*)sender
 {
     [[(VLCAppDelegate*)[UIApplication sharedApplication].delegate revealController] toggleSidebar:![(VLCAppDelegate*)[UIApplication sharedApplication].delegate revealController].sidebarShowing duration:kGHRevealSidebarDefaultAnimationDuration];
@@ -100,6 +117,7 @@
                               cancelButtonTitle:NSLocalizedString(@"BUTTON_DONE", @"")
                               otherButtonTitles:nil];
         [alert show];
+        [self filterCloudStorageCellsWithAnimation:YES];
         _currentUnlinkDialogTitle = nil;
         _currentCloudName = nil;
     }