Commit 32d8351b authored by Felix Paul Kühne's avatar Felix Paul Kühne

playback: fix fatal runtime exception on iOS 6

The sleep timer requires iOS 7 or later
parent ebd0b86c
...@@ -245,6 +245,8 @@ typedef NS_ENUM(NSInteger, VLCPanType) { ...@@ -245,6 +245,8 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
_sleepTimerButton.accessibilityLabel = NSLocalizedString(@"BUTTON_SLEEP_TIMER", nil); _sleepTimerButton.accessibilityLabel = NSLocalizedString(@"BUTTON_SLEEP_TIMER", nil);
_sleepTimerButton.isAccessibilityElement = YES; _sleepTimerButton.isAccessibilityElement = YES;
[_sleepTimerButton setTitle:NSLocalizedString(@"BUTTON_SLEEP_TIMER", nil) forState:UIControlStateNormal]; [_sleepTimerButton setTitle:NSLocalizedString(@"BUTTON_SLEEP_TIMER", nil) forState:UIControlStateNormal];
if (!SYSTEM_RUNS_IOS7_OR_LATER)
_sleepTimerButton.hidden = YES;
_multiSelectionView = [[VLCMultiSelectionMenuView alloc] init]; _multiSelectionView = [[VLCMultiSelectionMenuView alloc] init];
_multiSelectionView.delegate = self; _multiSelectionView.delegate = self;
...@@ -442,45 +444,47 @@ typedef NS_ENUM(NSInteger, VLCPanType) { ...@@ -442,45 +444,47 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
_equalizerView.hidden = YES; _equalizerView.hidden = YES;
[self.view addSubview:_equalizerView]; [self.view addSubview:_equalizerView];
/* add sleep timer UI */ /* add sleep timer UI, requires iOS 7 or later */
_sleepTimerContainer = [[VLCFrostedGlasView alloc] initWithFrame:CGRectMake(0., 0., 300., 162.)]; if (SYSTEM_RUNS_IOS7_OR_LATER) {
_sleepTimerContainer.center = self.view.center; _sleepTimerContainer = [[VLCFrostedGlasView alloc] initWithFrame:CGRectMake(0., 0., 300., 162.)];
_sleepTimerContainer.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleTopMargin; _sleepTimerContainer.center = self.view.center;
_sleepTimerContainer.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleTopMargin;
_sleepTimeDatePicker = [[UIDatePicker alloc] init];
if ([[UIDevice currentDevice] speedCategory] >= 3) { _sleepTimeDatePicker = [[UIDatePicker alloc] init];
_sleepTimeDatePicker.opaque = NO; if ([[UIDevice currentDevice] speedCategory] >= 3) {
_sleepTimeDatePicker.backgroundColor = [UIColor clearColor]; _sleepTimeDatePicker.opaque = NO;
} else _sleepTimeDatePicker.backgroundColor = [UIColor clearColor];
_sleepTimeDatePicker.backgroundColor = [UIColor blackColor]; } else
_sleepTimeDatePicker.tintColor = [UIColor VLCLightTextColor]; _sleepTimeDatePicker.backgroundColor = [UIColor blackColor];
_sleepTimeDatePicker.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleTopMargin; _sleepTimeDatePicker.tintColor = [UIColor VLCLightTextColor];
[_sleepTimerContainer addSubview:_sleepTimeDatePicker]; _sleepTimeDatePicker.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleTopMargin;
[_sleepTimerContainer addSubview:_sleepTimeDatePicker];
/* adapt the date picker style to suit our needs */
[_sleepTimeDatePicker setValue:[UIColor whiteColor] forKeyPath:@"textColor"]; /* adapt the date picker style to suit our needs */
SEL selector = NSSelectorFromString(@"setHighlightsToday:"); [_sleepTimeDatePicker setValue:[UIColor whiteColor] forKeyPath:@"textColor"];
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIDatePicker instanceMethodSignatureForSelector:selector]]; SEL selector = NSSelectorFromString(@"setHighlightsToday:");
BOOL no = NO; NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIDatePicker instanceMethodSignatureForSelector:selector]];
[invocation setSelector:selector]; BOOL no = NO;
[invocation setArgument:&no atIndex:2]; [invocation setSelector:selector];
[invocation invokeWithTarget:_sleepTimeDatePicker]; [invocation setArgument:&no atIndex:2];
[invocation invokeWithTarget:_sleepTimeDatePicker];
if (_sleepTimerContainer.subviews.count > 0) {
NSArray *subviewsOfSubview = [_sleepTimeDatePicker.subviews[0] subviews]; if (_sleepTimerContainer.subviews.count > 0) {
NSUInteger subviewCount = subviewsOfSubview.count; NSArray *subviewsOfSubview = [_sleepTimeDatePicker.subviews[0] subviews];
for (NSUInteger x = 0; x < subviewCount; x++) { NSUInteger subviewCount = subviewsOfSubview.count;
if ([subviewsOfSubview[x] isKindOfClass:[UILabel class]]) for (NSUInteger x = 0; x < subviewCount; x++) {
[subviewsOfSubview[x] setTextColor:[UIColor VLCLightTextColor]]; if ([subviewsOfSubview[x] isKindOfClass:[UILabel class]])
[subviewsOfSubview[x] setTextColor:[UIColor VLCLightTextColor]];
}
} }
} _sleepTimeDatePicker.datePickerMode = UIDatePickerModeCountDownTimer;
_sleepTimeDatePicker.datePickerMode = UIDatePickerModeCountDownTimer; _sleepTimeDatePicker.minuteInterval = 5;
_sleepTimeDatePicker.minuteInterval = 5; _sleepTimeDatePicker.minimumDate = [NSDate date];
_sleepTimeDatePicker.minimumDate = [NSDate date]; _sleepTimeDatePicker.countDownDuration = 1200.;
_sleepTimeDatePicker.countDownDuration = 1200.; [_sleepTimeDatePicker addTarget:self action:@selector(sleepTimerAction:) forControlEvents:UIControlEventValueChanged];
[_sleepTimeDatePicker addTarget:self action:@selector(sleepTimerAction:) forControlEvents:UIControlEventValueChanged];
[self.view addSubview:_sleepTimerContainer]; [self.view addSubview:_sleepTimerContainer];
}
} }
- (BOOL)_blobCheck - (BOOL)_blobCheck
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment