Skip to content

Commit

Permalink
Remove isIOS7OrGreater checks
Browse files Browse the repository at this point in the history
  • Loading branch information
vishalduggal committed Feb 11, 2015
1 parent 8ce11d1 commit 71010d6
Show file tree
Hide file tree
Showing 28 changed files with 269 additions and 532 deletions.
10 changes: 2 additions & 8 deletions iphone/Classes/MediaModule.m
Expand Up @@ -207,18 +207,12 @@ -(NSString*)apiName

-(NSString*)AUDIO_SESSION_PORT_BLUETOOTHLE
{
if ([TiUtils isIOS7OrGreater]) {
return AVAudioSessionPortBluetoothLE;
}
return @"Unavailable";
return AVAudioSessionPortBluetoothLE;
}

-(NSString*)AUDIO_SESSION_PORT_CARAUDIO
{
if ([TiUtils isIOS7OrGreater]) {
return AVAudioSessionPortCarAudio;
}
return @"Unavailable";
return AVAudioSessionPortCarAudio;
}


Expand Down
20 changes: 5 additions & 15 deletions iphone/Classes/TiAppiOSProxy.m
Expand Up @@ -531,13 +531,9 @@ -(void)didRegisterUserNotificationSettingsNotification:(NSNotification*)notifica
-(void)setMinimumBackgroundFetchInterval:(id)value
{
ENSURE_TYPE(value, NSNumber);
if ([TiUtils isIOS7OrGreater]) {
double fetchInterval = [TiUtils doubleValue:value];
fetchInterval = MAX(MIN(fetchInterval, UIApplicationBackgroundFetchIntervalNever),UIApplicationBackgroundFetchIntervalMinimum);
[[UIApplication sharedApplication] setMinimumBackgroundFetchInterval:fetchInterval];
} else {
DebugLog(@"[ERROR] Methond only available on iOS 7 and above.");
}
double fetchInterval = [TiUtils doubleValue:value];
fetchInterval = MAX(MIN(fetchInterval, UIApplicationBackgroundFetchIntervalNever),UIApplicationBackgroundFetchIntervalMinimum);
[[UIApplication sharedApplication] setMinimumBackgroundFetchInterval:fetchInterval];
}

-(void)endBackgroundHandler:(id)arg
Expand All @@ -551,17 +547,11 @@ -(void)endBackgroundHandler:(id)arg
}

-(NSNumber*)BACKGROUNDFETCHINTERVAL_MIN {
if ([TiUtils isIOS7OrGreater]) {
return NUMDOUBLE(UIApplicationBackgroundFetchIntervalMinimum);
}
return nil;
return NUMDOUBLE(UIApplicationBackgroundFetchIntervalMinimum);
}

-(NSNumber*)BACKGROUNDFETCHINTERVAL_NEVER {
if ([TiUtils isIOS7OrGreater]) {
return NUMDOUBLE(UIApplicationBackgroundFetchIntervalNever);
}
return nil;
return NUMDOUBLE(UIApplicationBackgroundFetchIntervalNever);
}

-(NSNumber*)USER_NOTIFICATION_TYPE_NONE
Expand Down
2 changes: 1 addition & 1 deletion iphone/Classes/TiErrorController.m
Expand Up @@ -55,7 +55,7 @@ - (void)loadView
RELEASE_TO_NIL(disclosureLabel)

dismissButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
dismissButton.backgroundColor = [TiUtils isIOS7OrGreater] ? [UIColor whiteColor] : [UIColor clearColor];
dismissButton.backgroundColor = [UIColor whiteColor];
dismissButton.translatesAutoresizingMaskIntoConstraints = NO;
[dismissButton setTitle:@"Dismiss" forState:UIControlStateNormal];

Expand Down
8 changes: 3 additions & 5 deletions iphone/Classes/TiMediaAudioSession.m
Expand Up @@ -64,11 +64,9 @@ -(void)routeChangeCallback:(NSNotification*)note
case AVAudioSessionRouteChangeReasonNoSuitableRouteForCategory:
[event setObject:@"no_route_for_category" forKey:@"reason"];
break;
case 8://AVAudioSessionRouteChangeReasonRouteConfigurationChange:
if ([TiUtils isIOS7OrGreater]) {
[event setObject:@"route_config_change" forKey:@"reason"];
break;
}
case AVAudioSessionRouteChangeReasonRouteConfigurationChange:
[event setObject:@"route_config_change" forKey:@"reason"];
break;
default:
[event setObject:@"silence_change" forKey:@"reason"];
break;
Expand Down
38 changes: 15 additions & 23 deletions iphone/Classes/TiRootViewController.m
Expand Up @@ -1071,30 +1071,22 @@ -(void)adjustFrameForUpSideDownOrientation:(NSNotification*)notification
CGRect appFrame = [[UIScreen mainScreen] applicationFrame];
CGRect viewBounds = [[self view] bounds];

if ([TiUtils isIOS7OrGreater]) {
//Need to do this to force navigation bar to draw correctly on iOS7
[[NSNotificationCenter defaultCenter] postNotificationName:kTiFrameAdjustNotification object:nil];
if (statusBarFrame.size.height > 20) {
if (viewBounds.size.height != (mainScreenBounds.size.height - statusBarFrame.size.height)) {
CGRect newBounds = CGRectMake(0, 0, mainScreenBounds.size.width, mainScreenBounds.size.height - statusBarFrame.size.height);
CGPoint newCenter = CGPointMake(mainScreenBounds.size.width/2, (mainScreenBounds.size.height - statusBarFrame.size.height)/2);
[[self view] setBounds:newBounds];
[[self view] setCenter:newCenter];
[[self view] setNeedsLayout];
}
} else {
if (viewBounds.size.height != mainScreenBounds.size.height) {
CGRect newBounds = CGRectMake(0, 0, mainScreenBounds.size.width, mainScreenBounds.size.height);
CGPoint newCenter = CGPointMake(mainScreenBounds.size.width/2, mainScreenBounds.size.height/2);
[[self view] setBounds:newBounds];
[[self view] setCenter:newCenter];
[[self view] setNeedsLayout];
}
//Need to do this to force navigation bar to draw correctly on iOS7
[[NSNotificationCenter defaultCenter] postNotificationName:kTiFrameAdjustNotification object:nil];
if (statusBarFrame.size.height > 20) {
if (viewBounds.size.height != (mainScreenBounds.size.height - statusBarFrame.size.height)) {
CGRect newBounds = CGRectMake(0, 0, mainScreenBounds.size.width, mainScreenBounds.size.height - statusBarFrame.size.height);
CGPoint newCenter = CGPointMake(mainScreenBounds.size.width/2, (mainScreenBounds.size.height - statusBarFrame.size.height)/2);
[[self view] setBounds:newBounds];
[[self view] setCenter:newCenter];
[[self view] setNeedsLayout];
}

} else {
if (viewBounds.size.height != appFrame.size.height) {
[[self view] setFrame:appFrame];
if (viewBounds.size.height != mainScreenBounds.size.height) {
CGRect newBounds = CGRectMake(0, 0, mainScreenBounds.size.width, mainScreenBounds.size.height);
CGPoint newCenter = CGPointMake(mainScreenBounds.size.width/2, mainScreenBounds.size.height/2);
[[self view] setBounds:newBounds];
[[self view] setCenter:newCenter];
[[self view] setNeedsLayout];
}
}
Expand Down Expand Up @@ -1664,7 +1656,7 @@ -(BOOL) modalPresentationCapturesStatusBarAppearance

- (void) updateStatusBar
{
if ([TiUtils isIOS7OrGreater] && viewControllerControlsStatusBar) {
if (viewControllerControlsStatusBar) {
[self performSelector:@selector(setNeedsStatusBarAppearanceUpdate) withObject:nil];
} else {
[[UIApplication sharedApplication] setStatusBarHidden:[self prefersStatusBarHidden] withAnimation:UIStatusBarAnimationNone];
Expand Down
4 changes: 0 additions & 4 deletions iphone/Classes/TiSelectedCellbackgroundView.m
Expand Up @@ -133,10 +133,6 @@ -(void)drawRect:(CGRect)rect

-(void)setPosition:(TiCellBackgroundViewPosition)inPosition
{
if((position != inPosition) && (![TiUtils isIOS7OrGreater]))
{
position = inPosition;
}
[self setNeedsDisplay];
}

Expand Down
218 changes: 107 additions & 111 deletions iphone/Classes/TiUIAttributedStringProxy.m
Expand Up @@ -70,117 +70,113 @@ -(void)addAttribute:(id)args
id attrValue = nil;
switch ([type integerValue]) {

case AttributeNameFont:
attrName = NSFontAttributeName;
WebFont *strFont = [TiUtils fontValue:value def:[WebFont defaultFont]];
attrValue = [strFont font];
break;

case AttributeNameParagraphStyle:
attrName = NSParagraphStyleAttributeName;
errorMessage = @"ATTRIBUTE_PARAGRAPH_STYLE not yet supported";
break;

case AttributeNameForegroundColor:
attrName = NSForegroundColorAttributeName;
attrValue = [[TiUtils colorValue:value] _color];
break;

case AttributeNameBackgroundColor:
attrName = NSBackgroundColorAttributeName;
attrValue = [[TiUtils colorValue:value] _color];
break;

case AttributeNameLigature:
attrName = NSLigatureAttributeName;
attrValue = [TiUtils numberFromObject:value];
break;

case AttributeNameKern:
attrName = NSKernAttributeName;
attrValue = [TiUtils numberFromObject:value];
break;

case AttributeNameStrikethroughStyle:
attrName = NSStrikethroughStyleAttributeName;
attrValue = [TiUtils numberFromObject:value];
break;

case AttributeNameUnderlineStyle:
attrName = NSUnderlineStyleAttributeName;
attrValue = [TiUtils numberFromObject:value];
break;

case AttributeNameStrokeColor:
attrName = NSStrokeColorAttributeName;
attrValue = [[TiUtils colorValue:value] _color];
break;

case AttributeNameStrokeWidth:
attrName = NSStrokeWidthAttributeName;
attrValue = [TiUtils numberFromObject:value];
break;

case AttributeNameShadow:
attrName = NSShadowAttributeName;
attrValue = [TiUtils shadowValue:value];
break;

case AttributeNameVerticalGlyphForm:
attrName = NSVerticalGlyphFormAttributeName;
attrValue = [TiUtils numberFromObject:value];
break;
}
if (attrName == nil && attrValue == nil && [TiUtils isIOS7OrGreater])
{
switch ([type integerValue]) {
case AttributeNameWritingDirection:
attrName = NSWritingDirectionAttributeName;
NSMutableArray *array = [NSMutableArray array];
[array addObject:[TiUtils numberFromObject: value]];
attrValue = array;
break;

case AttributeNameTextEffect:
attrName = NSTextEffectAttributeName;
attrValue = [TiUtils stringValue:value];
break;

case AttributeNameAttachment:
attrName = NSAttachmentAttributeName;
errorMessage = @"ATTRIBUTE_ATTACHMENT not yet supported";
break;

case AttributeNameLink:
attrName = NSLinkAttributeName;
attrValue = [TiUtils stringValue:value];
break;

case AttributeNameBaselineOffset:
attrName = NSBaselineOffsetAttributeName;
attrValue = [TiUtils numberFromObject:value];
break;

case AttributeNameUnderlineColor:
attrName = NSUnderlineColorAttributeName;
attrValue = [[TiUtils colorValue:value] _color];
break;

case AttributeNameStrikethroughColor:
attrName = NSStrikethroughColorAttributeName;
attrValue = [[TiUtils colorValue:value] _color];
break;

case AttributeNameObliqueness:
attrName = NSObliquenessAttributeName;
attrValue = [TiUtils numberFromObject:value];
break;

case AttributeNameExpansion:
attrName = NSExpansionAttributeName;
attrValue = [TiUtils numberFromObject:value];
break;
}
case AttributeNameFont:
attrName = NSFontAttributeName;
WebFont *strFont = [TiUtils fontValue:value def:[WebFont defaultFont]];
attrValue = [strFont font];
break;

case AttributeNameParagraphStyle:
attrName = NSParagraphStyleAttributeName;
errorMessage = @"ATTRIBUTE_PARAGRAPH_STYLE not yet supported";
break;

case AttributeNameForegroundColor:
attrName = NSForegroundColorAttributeName;
attrValue = [[TiUtils colorValue:value] _color];
break;

case AttributeNameBackgroundColor:
attrName = NSBackgroundColorAttributeName;
attrValue = [[TiUtils colorValue:value] _color];
break;

case AttributeNameLigature:
attrName = NSLigatureAttributeName;
attrValue = [TiUtils numberFromObject:value];
break;

case AttributeNameKern:
attrName = NSKernAttributeName;
attrValue = [TiUtils numberFromObject:value];
break;

case AttributeNameStrikethroughStyle:
attrName = NSStrikethroughStyleAttributeName;
attrValue = [TiUtils numberFromObject:value];
break;

case AttributeNameUnderlineStyle:
attrName = NSUnderlineStyleAttributeName;
attrValue = [TiUtils numberFromObject:value];
break;

case AttributeNameStrokeColor:
attrName = NSStrokeColorAttributeName;
attrValue = [[TiUtils colorValue:value] _color];
break;

case AttributeNameStrokeWidth:
attrName = NSStrokeWidthAttributeName;
attrValue = [TiUtils numberFromObject:value];
break;

case AttributeNameShadow:
attrName = NSShadowAttributeName;
attrValue = [TiUtils shadowValue:value];
break;

case AttributeNameVerticalGlyphForm:
attrName = NSVerticalGlyphFormAttributeName;
attrValue = [TiUtils numberFromObject:value];
break;

case AttributeNameWritingDirection:
attrName = NSWritingDirectionAttributeName;
NSMutableArray *array = [NSMutableArray array];
[array addObject:[TiUtils numberFromObject: value]];
attrValue = array;
break;

case AttributeNameTextEffect:
attrName = NSTextEffectAttributeName;
attrValue = [TiUtils stringValue:value];
break;

case AttributeNameAttachment:
attrName = NSAttachmentAttributeName;
errorMessage = @"ATTRIBUTE_ATTACHMENT not yet supported";
break;

case AttributeNameLink:
attrName = NSLinkAttributeName;
attrValue = [TiUtils stringValue:value];
break;

case AttributeNameBaselineOffset:
attrName = NSBaselineOffsetAttributeName;
attrValue = [TiUtils numberFromObject:value];
break;

case AttributeNameUnderlineColor:
attrName = NSUnderlineColorAttributeName;
attrValue = [[TiUtils colorValue:value] _color];
break;

case AttributeNameStrikethroughColor:
attrName = NSStrikethroughColorAttributeName;
attrValue = [[TiUtils colorValue:value] _color];
break;

case AttributeNameObliqueness:
attrName = NSObliquenessAttributeName;
attrValue = [TiUtils numberFromObject:value];
break;

case AttributeNameExpansion:
attrName = NSExpansionAttributeName;
attrValue = [TiUtils numberFromObject:value];
break;
}
if(errorMessage != nil) {
DebugLog(@"[WARN] Ti.UI.%@", errorMessage);
Expand Down
6 changes: 1 addition & 5 deletions iphone/Classes/TiUIEmailDialogProxy.m
Expand Up @@ -104,11 +104,7 @@ - (void)open:(id)args
[composer setMailComposeDelegate:self];
if (barColor != nil)
{
if([TiUtils isIOS7OrGreater]) {
[[composer navigationBar] performSelector:@selector(setBarTintColor:) withObject:barColor];
} else {
[[composer navigationBar] setTintColor:barColor];
}
[[composer navigationBar] setBarTintColor:barColor];
}

[composer setSubject:subject];
Expand Down
2 changes: 1 addition & 1 deletion iphone/Classes/TiUILabel.m
Expand Up @@ -313,7 +313,7 @@ -(void)recognizedLongPress:(UILongPressGestureRecognizer*)recognizer
nil];
[self.proxy fireEvent:@"longpress" withObject:event];
}
if ([(TiViewProxy*)[self proxy] _hasListeners:@"link" checkParent:NO] && (label != nil) && [TiUtils isIOS7OrGreater]) {
if ([(TiViewProxy*)[self proxy] _hasListeners:@"link" checkParent:NO] && (label != nil)) {
NSMutableAttributedString* optimizedAttributedText = [label.attributedText mutableCopy];
if (optimizedAttributedText != nil) {
// use label's font and lineBreakMode properties in case the attributedText does not contain such attributes
Expand Down

0 comments on commit 71010d6

Please sign in to comment.