Skip to content

Commit

Permalink
Merge pull request #449 from smartdevicelink/feature/issue_419_iOS6_r…
Browse files Browse the repository at this point in the history
…emoval

[SDL-0008] iOS 6 Removal
  • Loading branch information
joeljfischer authored Jan 23, 2017
2 parents 36dc4c2 + 3faad1f commit 74484a8
Show file tree
Hide file tree
Showing 28 changed files with 77 additions and 870 deletions.
2 changes: 1 addition & 1 deletion SmartDeviceLink-iOS.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ s.summary = "Connect your app with cars!"
s.homepage = "https://github.com/smartdevicelink/SmartDeviceLink-iOS"
s.license = { :type => "New BSD", :file => "LICENSE" }
s.author = { "SmartDeviceLink Team" => "developer@smartdevicelink.com" }
s.platform = :ios, "6.0"
s.platform = :ios, "7.0"
s.source = { :git => "https://github.com/smartdevicelink/sdl_ios.git", :tag => s.version.to_s }
s.source_files = "SmartDeviceLink/*.{h,m}"
s.requires_arc = true
Expand Down
84 changes: 0 additions & 84 deletions SmartDeviceLink-iOS.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion SmartDeviceLink/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<string>7.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
Expand Down
51 changes: 26 additions & 25 deletions SmartDeviceLink/SDLLockScreenViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ - (BOOL)shouldAutorotate {
}

- (UIStatusBarStyle)preferredStatusBarStyle {
BOOL useWhiteIcon = [self.class shouldUseWhiteForegroundForBackgroundColor:self.backgroundColor];
BOOL useWhiteIcon = [self.class sdl_shouldUseWhiteForegroundForBackgroundColor:self.backgroundColor];

return useWhiteIcon ? UIStatusBarStyleLightContent : UIStatusBarStyleDefault;
}
Expand Down Expand Up @@ -71,15 +71,18 @@ - (void)setBackgroundColor:(UIColor *_Nullable)backgroundColor {
#pragma mark - Layout

- (void)sdl_layoutViews {
BOOL useWhiteIcon = [self.class shouldUseWhiteForegroundForBackgroundColor:self.backgroundColor];
UIColor *iconColor = [self.class sdl_accentColorBasedOnColor:self.backgroundColor];

UIImage *sdlLogo = [self.class sdl_logoImageWithColor:useWhiteIcon];
self.sdlIconImageView.image = sdlLogo;
self.sdlIconImageView.image = [self.class sdl_imageWithName:@"sdl_logo_black"];
self.sdlIconImageView.tintColor = iconColor;

self.arrowUpImageView.image = [self.class sdl_arrowUpImageWithColor:useWhiteIcon];
self.arrowDownImageView.image = [self.class sdl_arrowDownImageWithColor:useWhiteIcon];

self.lockedLabel.textColor = useWhiteIcon ? [UIColor whiteColor] : [UIColor blackColor];
self.arrowUpImageView.image = [self.class sdl_imageWithName:@"lock_arrow_up_black"];
self.arrowUpImageView.tintColor = iconColor;

self.arrowDownImageView.image = [self.class sdl_imageWithName:@"lock_arrow_down_black"];
self.arrowDownImageView.tintColor = iconColor;

self.lockedLabel.textColor = iconColor;

if (self.vehicleIcon != nil && self.appIcon != nil) {
[self sdl_setVehicleAndAppIconsLayout];
Expand All @@ -106,7 +109,8 @@ - (void)sdl_setVehicleAndAppIconsLayout {
self.primaryVehicleIconImageView.image = self.vehicleIcon;

self.backupImageView.image = nil;

self.backupImageView.tintColor = nil;

self.arrowUpImageView.alpha = 1.0;
self.arrowDownImageView.alpha = 1.0;

Expand All @@ -118,7 +122,8 @@ - (void)sdl_setAppIconOnlyLayout {
self.primaryVehicleIconImageView.image = nil;

self.backupImageView.image = self.appIcon;

self.backupImageView.tintColor = nil;

self.arrowUpImageView.alpha = 0.0;
self.arrowDownImageView.alpha = 0.0;

Expand All @@ -130,7 +135,8 @@ - (void)sdl_setVehicleIconOnlyLayout {
self.primaryVehicleIconImageView.image = nil;

self.backupImageView.image = self.vehicleIcon;

self.backupImageView.tintColor = nil;

self.arrowUpImageView.alpha = 0.0;
self.arrowDownImageView.alpha = 0.0;

Expand All @@ -142,6 +148,7 @@ - (void)sdl_setNoIconsLayout {
self.primaryVehicleIconImageView.image = nil;

self.backupImageView.image = self.sdlIconImageView.image;
self.backupImageView.tintColor = [self.class sdl_accentColorBasedOnColor:self.backgroundColor];

self.arrowUpImageView.alpha = 0.0;
self.arrowDownImageView.alpha = 0.0;
Expand All @@ -152,34 +159,28 @@ - (void)sdl_setNoIconsLayout {

#pragma mark - Private Image

// TODO: (Joel F.)[2016-08-22] When moved to iOS 7+, use `imageWithRenderingMode:`
+ (UIImage *)sdl_logoImageWithColor:(BOOL)white {
return [self sdl_imageWithName:[NSString stringWithFormat:@"sdl_logo_%@", white ? @"white" : @"black"]];
}

+ (UIImage *)sdl_arrowUpImageWithColor:(BOOL)white {
return [self sdl_imageWithName:[NSString stringWithFormat:@"lock_arrow_up_%@", white ? @"white" : @"black"]];
}

+ (UIImage *)sdl_arrowDownImageWithColor:(BOOL)white {
return [self sdl_imageWithName:[NSString stringWithFormat:@"lock_arrow_down_%@", white ? @"white" : @"black"]];
+ (UIColor *)sdl_accentColorBasedOnColor:(UIColor *)backgroundColor {
return [self sdl_shouldUseWhiteForegroundForBackgroundColor:backgroundColor] ? [UIColor whiteColor] : [UIColor blackColor];
}

+ (UIImage *)sdl_imageWithName:(NSString *)name {
UIImage* image = nil;
if (SDL_SYSTEM_VERSION_LESS_THAN(@"8.0")) {
NSString *bundlePath = [[NSBundle sdlBundle] bundlePath];
NSInteger deviceScale = [[UIScreen mainScreen] scale];
// We assume we are only dealing with PNGs.
NSString *fileName = [NSString stringWithFormat:@"%@%li.png", name, (long)deviceScale];
NSString *fullPath = [NSString stringWithFormat:@"%@/%@", bundlePath, fileName];
NSData *imageData = [NSData dataWithContentsOfFile:fullPath];
return [UIImage imageWithData:imageData];
image = [UIImage imageWithData:imageData];
} else {
return [UIImage imageNamed:name inBundle:[NSBundle sdlBundle] compatibleWithTraitCollection:nil];
image = [UIImage imageNamed:name inBundle:[NSBundle sdlBundle] compatibleWithTraitCollection:nil];
}

return [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
}

+ (BOOL)shouldUseWhiteForegroundForBackgroundColor:(UIColor *)backgroundColor {
+ (BOOL)sdl_shouldUseWhiteForegroundForBackgroundColor:(UIColor *)backgroundColor {
CGFloat red, green, blue;

[backgroundColor getRed:&red green:&green blue:&blue alpha:nil];
Expand Down
68 changes: 47 additions & 21 deletions SmartDeviceLink/SDLProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
#import "SDLSystemContext.h"
#import "SDLSystemRequest.h"
#import "SDLTimer.h"
#import "SDLURLSession.h"
#import "SDLVehicleType.h"

NS_ASSUME_NONNULL_BEGIN
Expand All @@ -52,6 +51,7 @@
const float startSessionTime = 10.0;
const float notifyProxyClosedDelay = 0.1;
const int POLICIES_CORRELATION_ID = 65535;
static float DefaultConnectionTimeout = 45.0;

@interface SDLProxy () {
SDLLockScreenStatusManager *_lsm;
Expand All @@ -62,6 +62,7 @@ @interface SDLProxy () {
@property (nullable, nonatomic, strong, readwrite) SDLStreamingMediaManager *streamingMediaManager;
@property (nullable, nonatomic, strong) SDLDisplayCapabilities *displayCapabilities;
@property (nonatomic, strong) NSMutableDictionary<SDLVehicleMake *, Class> *securityManagers;
@property (nonatomic, strong) NSURLSession* urlSession;

@end

Expand All @@ -86,6 +87,14 @@ - (instancetype)initWithTransport:(SDLAbstractTransport *)transport protocol:(SD

[SDLDebugTool logInfo:@"SDLProxy initWithTransport"];
[[EAAccessoryManager sharedAccessoryManager] registerForLocalNotifications];

NSURLSessionConfiguration* configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
configuration.timeoutIntervalForRequest = DefaultConnectionTimeout;
configuration.timeoutIntervalForResource = DefaultConnectionTimeout;
configuration.requestCachePolicy = NSURLRequestUseProtocolCachePolicy;

_urlSession = [NSURLSession sessionWithConfiguration:configuration];

}

return self;
Expand All @@ -98,9 +107,9 @@ - (void)dealloc {

[[NSNotificationCenter defaultCenter] removeObserver:self];
[[EAAccessoryManager sharedAccessoryManager] unregisterForLocalNotifications];
[[SDLURLSession defaultSession] cancelAllTasks];

[_urlSession invalidateAndCancel];

[SDLDebugTool logInfo:@"SDLProxy Dealloc" withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:_debugConsoleGroupName];
}

Expand Down Expand Up @@ -509,17 +518,17 @@ - (void)handleSystemRequestProprietary:(SDLOnSystemRequest *)request {
}

- (void)handleSystemRequestLockScreenIconURL:(SDLOnSystemRequest *)request {
[[SDLURLSession defaultSession] dataFromURL:[NSURL URLWithString:request.url]
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error != nil) {
NSString *logMessage = [NSString stringWithFormat:@"OnSystemRequest failure (HTTP response), download task failed: %@", error.localizedDescription];
[SDLDebugTool logInfo:logMessage withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName];
return;
}

UIImage *icon = [UIImage imageWithData:data];
[self invokeMethodOnDelegates:@selector(onReceivedLockScreenIcon:) withObject:icon];
}];
[self sdl_sendDataTaskWithURL:[NSURL URLWithString:request.url]
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error != nil) {
NSString *logMessage = [NSString stringWithFormat:@"OnSystemRequest failure (HTTP response), download task failed: %@", error.localizedDescription];
[SDLDebugTool logInfo:logMessage withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName];
return;
}
UIImage *icon = [UIImage imageWithData:data];
[self invokeMethodOnDelegates:@selector(onReceivedLockScreenIcon:) withObject:icon];
}];
}

- (void)sdl_handleSystemRequestHTTP:(SDLOnSystemRequest *)request {
Expand Down Expand Up @@ -613,7 +622,7 @@ - (void)sdl_uploadData:(NSData *_Nonnull)data toURLString:(NSString *_Nonnull)ur
[SDLDebugTool logInfo:logMessage withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName];

// Create the upload task
[[SDLURLSession defaultSession] uploadWithURLRequest:request data:data completionHandler:completionHandler];
[self sdl_sendUploadRequest:request withData:data completionHandler:completionHandler];
}

/**
Expand Down Expand Up @@ -649,9 +658,26 @@ - (void)uploadForBodyDataDictionary:(NSDictionary<NSString *, id> *)dictionary U
[SDLDebugTool logInfo:logMessage withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName];

// Create the upload task
[[SDLURLSession defaultSession] uploadWithURLRequest:request data:bodyData completionHandler:completionHandler];
[self sdl_sendUploadRequest:request withData:bodyData completionHandler:completionHandler];
}

- (void)sdl_sendUploadRequest:(NSURLRequest*)request withData:(NSData*)data completionHandler:(URLSessionTaskCompletionHandler)completionHandler {
NSMutableURLRequest* mutableRequest = [request mutableCopy];

if ([mutableRequest.URL.scheme isEqualToString:@"http"]) {
mutableRequest.URL = [NSURL URLWithString:[mutableRequest.URL.absoluteString stringByReplacingCharactersInRange:NSMakeRange(0, 4) withString:@"https"]];
}

[[self.urlSession uploadTaskWithRequest:request fromData:data completionHandler:completionHandler] resume];
}

- (void)sdl_sendDataTaskWithURL:(NSURL*)url completionHandler:(URLSessionTaskCompletionHandler)completionHandler {
if ([url.scheme isEqualToString:@"http"]) {
url = [NSURL URLWithString:[url.absoluteString stringByReplacingCharactersInRange:NSMakeRange(0, 4) withString:@"https"]];
}

[[self.urlSession dataTaskWithURL:url completionHandler:completionHandler] resume];
}

#pragma mark - Delegate management

Expand Down Expand Up @@ -704,11 +730,11 @@ - (void)sendEncodedSyncPData:(NSDictionary<NSString *, id> *)encodedSyncPData to
}

// Send the HTTP Request
[[SDLURLSession defaultSession] uploadWithURLRequest:request
data:data
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
[[self.urlSession uploadTaskWithRequest:request
fromData:data
completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
[self syncPDataNetworkRequestCompleteWithData:data response:response error:error];
}];
}] resume];

[SDLDebugTool logInfo:@"OnEncodedSyncPData (HTTP request)" withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName];
}
Expand Down
46 changes: 0 additions & 46 deletions SmartDeviceLink/SDLURLRequestTask.h

This file was deleted.

Loading

0 comments on commit 74484a8

Please sign in to comment.