diff options
author | NicoleYarroch <nicole@livio.io> | 2017-10-26 09:39:07 -0400 |
---|---|---|
committer | NicoleYarroch <nicole@livio.io> | 2017-10-26 09:39:07 -0400 |
commit | 6cfa6c9135a1642cb844cfca8b1b89d224cb7b49 (patch) | |
tree | 71e25f3b1d175717d5c0f02ec11237f8c81bf1cf | |
parent | ef63547847d24d421915e734ec12c59abaf26ae5 (diff) | |
download | sdl_ios-example_app/expanded_example_app_5.0.0.tar.gz |
Added more stuff for testingexample_app/expanded_example_app_5.0.0
- Added custom lock screen
- Added get system capabilities requests
11 files changed, 165 insertions, 10 deletions
diff --git a/SmartDeviceLink-iOS.xcodeproj/project.pbxproj b/SmartDeviceLink-iOS.xcodeproj/project.pbxproj index 666d636c3..eb86292e5 100644 --- a/SmartDeviceLink-iOS.xcodeproj/project.pbxproj +++ b/SmartDeviceLink-iOS.xcodeproj/project.pbxproj @@ -1026,6 +1026,7 @@ 88B848C31F45E1A600DED768 /* TestResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = 88B848C21F45E1A600DED768 /* TestResponse.m */; }; 88B848C91F462E3600DED768 /* TestProgressResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = 88B848C81F462E3600DED768 /* TestProgressResponse.m */; }; 88D2AAE41F682BB20078D5B2 /* SDLLogConstantsSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 88D2AAE31F682BB20078D5B2 /* SDLLogConstantsSpec.m */; }; + 88EEB6EE1F9FEBF40052FC4A /* CustomLockScreenViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 88EEB6ED1F9FEBF40052FC4A /* CustomLockScreenViewController.m */; }; 88EED8381F33AE1700E6C42E /* SDLHapticRect.h in Headers */ = {isa = PBXBuildFile; fileRef = 88EED8361F33AE1700E6C42E /* SDLHapticRect.h */; settings = {ATTRIBUTES = (Public, ); }; }; 88EED8391F33AE1700E6C42E /* SDLHapticRect.m in Sources */ = {isa = PBXBuildFile; fileRef = 88EED8371F33AE1700E6C42E /* SDLHapticRect.m */; }; 88EED83B1F33BECB00E6C42E /* SDLHapticRectSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 88EED83A1F33BECB00E6C42E /* SDLHapticRectSpec.m */; }; @@ -2261,6 +2262,8 @@ 88B848C71F462E3600DED768 /* TestProgressResponse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestProgressResponse.h; sourceTree = "<group>"; }; 88B848C81F462E3600DED768 /* TestProgressResponse.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TestProgressResponse.m; sourceTree = "<group>"; }; 88D2AAE31F682BB20078D5B2 /* SDLLogConstantsSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLLogConstantsSpec.m; sourceTree = "<group>"; }; + 88EEB6EC1F9FEBF40052FC4A /* CustomLockScreenViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CustomLockScreenViewController.h; sourceTree = "<group>"; }; + 88EEB6ED1F9FEBF40052FC4A /* CustomLockScreenViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CustomLockScreenViewController.m; sourceTree = "<group>"; }; 88EED8361F33AE1700E6C42E /* SDLHapticRect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDLHapticRect.h; sourceTree = "<group>"; }; 88EED8371F33AE1700E6C42E /* SDLHapticRect.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLHapticRect.m; sourceTree = "<group>"; }; 88EED83A1F33BECB00E6C42E /* SDLHapticRectSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLHapticRectSpec.m; sourceTree = "<group>"; }; @@ -2804,6 +2807,8 @@ isa = PBXGroup; children = ( 5D0218EC1A8E796100D1BF62 /* Connection */, + 88EEB6EC1F9FEBF40052FC4A /* CustomLockScreenViewController.h */, + 88EEB6ED1F9FEBF40052FC4A /* CustomLockScreenViewController.m */, ); name = UI; sourceTree = "<group>"; @@ -5051,7 +5056,6 @@ TargetAttributes = { 5D4019AE1A76EC350006B0C2 = { CreatedOnToolsVersion = 6.1.1; - DevelopmentTeam = NCVC2MHU7M; SystemCapabilities = { com.apple.BackgroundModes = { enabled = 1; @@ -5154,6 +5158,7 @@ 5D4832A51A94F90D00252386 /* ConnectionTransitionContext.m in Sources */, 882255911F8BB0A600C13EED /* ShowManager.m in Sources */, 5D0218FC1A8E7E1700D1BF62 /* ConnectionContainerViewController.m in Sources */, + 88EEB6EE1F9FEBF40052FC4A /* CustomLockScreenViewController.m in Sources */, 882255841F8BABE700C13EED /* SoftButtonManager.m in Sources */, 5D0218FF1A8E9E0D00D1BF62 /* ConnectionIAPTableViewController.m in Sources */, 882255811F8BAB0F00C13EED /* TemplateManager.m in Sources */, diff --git a/SmartDeviceLink/SDLStreamingMediaLifecycleManager.m b/SmartDeviceLink/SDLStreamingMediaLifecycleManager.m index 9e37dd472..dd496896d 100644 --- a/SmartDeviceLink/SDLStreamingMediaLifecycleManager.m +++ b/SmartDeviceLink/SDLStreamingMediaLifecycleManager.m @@ -262,7 +262,9 @@ typedef void(^SDLVideoCapabilityResponseHandler)(SDLVideoStreamingCapability *_N [self sdl_sendBackgroundFrames]; [self.touchManager cancelPendingTouches]; + self.restartVideoStream = YES; + [self sdl_startVideoSession]; } // Per Apple's guidelines: https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/StrategiesforHandlingAppStateTransitions/StrategiesforHandlingAppStateTransitions.html diff --git a/SmartDeviceLink_Example/Classes/ProxyManager.m b/SmartDeviceLink_Example/Classes/ProxyManager.m index fc7fb0b3a..3386fd30a 100644 --- a/SmartDeviceLink_Example/Classes/ProxyManager.m +++ b/SmartDeviceLink_Example/Classes/ProxyManager.m @@ -3,6 +3,7 @@ // SmartDeviceLink-iOS #import "ProxyManager.h" +#import "CustomLockScreenViewController.h" #import "ImageManager.h" #import "Preferences.h" #import "ProxyMenuManager.h" @@ -147,11 +148,20 @@ NS_ASSUME_NONNULL_BEGIN SDLStreamingMediaConfiguration *streamingMediaConfig = [SDLStreamingMediaConfiguration insecureConfiguration]; streamingMediaConfig.window = [UIApplication sharedApplication].windows.firstObject; - return [SDLConfiguration configurationWithLifecycle:lifecycleConfig lockScreen:[SDLLockScreenConfiguration enabledConfiguration] logging:[self.class sdlex_logConfiguration]]; + return [SDLConfiguration configurationWithLifecycle:lifecycleConfig lockScreen:[self.class sdlex_lockScreenConfiguration] logging:[self.class sdlex_logConfiguration]]; // return [SDLConfiguration configurationWithLifecycle:lifecycleConfig lockScreen:[SDLLockScreenConfiguration enabledConfiguration] logging:[self.class sdlex_logConfiguration] streamingMedia:streamingMediaConfig]; } ++ (SDLLockScreenConfiguration *)sdlex_lockScreenConfiguration { +// SDLLockScreenConfiguration *lockScreenConfig = [SDLLockScreenConfiguration enabledConfigurationWithAppIcon:[ImageManager mainGraphic] backgroundColor:[UIColor redColor]]; + + CustomLockScreenViewController *customLockScreenController = [[CustomLockScreenViewController alloc] init]; + SDLLockScreenConfiguration *lockScreenConfig = [SDLLockScreenConfiguration enabledConfigurationWithViewController:customLockScreenController]; + + return lockScreenConfig; +} + + (SDLLogConfiguration *)sdlex_logConfiguration { SDLLogConfiguration *logConfig = [SDLLogConfiguration defaultConfiguration]; SDLLogFileModule *sdlExampleModule = [SDLLogFileModule moduleWithName:@"SDL Example" files:[NSSet setWithArray:@[@"ProxyManager"]]]; diff --git a/SmartDeviceLink_Example/CustomLockScreenViewController.h b/SmartDeviceLink_Example/CustomLockScreenViewController.h new file mode 100644 index 000000000..82e7cf0dd --- /dev/null +++ b/SmartDeviceLink_Example/CustomLockScreenViewController.h @@ -0,0 +1,13 @@ +// +// CustomLockScreenViewController.h +// SmartDeviceLink-Example +// +// Created by Nicole on 10/24/17. +// Copyright © 2017 smartdevicelink. All rights reserved. +// + +#import <UIKit/UIKit.h> + +@interface CustomLockScreenViewController : UIViewController + +@end diff --git a/SmartDeviceLink_Example/CustomLockScreenViewController.m b/SmartDeviceLink_Example/CustomLockScreenViewController.m new file mode 100644 index 000000000..098b6c718 --- /dev/null +++ b/SmartDeviceLink_Example/CustomLockScreenViewController.m @@ -0,0 +1,38 @@ +// +// CustomLockScreenViewController.m +// SmartDeviceLink-Example +// +// Created by Nicole on 10/24/17. +// Copyright © 2017 smartdevicelink. All rights reserved. +// + +#import "CustomLockScreenViewController.h" + +@interface CustomLockScreenViewController () + +@end + +@implementation CustomLockScreenViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + // Do any additional setup after loading the view. + self.view.backgroundColor = [UIColor greenColor]; +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +/* +#pragma mark - Navigation + +// In a storyboard-based application, you will often want to do a little preparation before navigation +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { + // Get the new view controller using [segue destinationViewController]. + // Pass the selected object to the new view controller. +} +*/ + +@end diff --git a/SmartDeviceLink_Example/Managers/ImageManager.h b/SmartDeviceLink_Example/Managers/ImageManager.h index 6969daa2c..e63a42dfc 100644 --- a/SmartDeviceLink_Example/Managers/ImageManager.h +++ b/SmartDeviceLink_Example/Managers/ImageManager.h @@ -26,4 +26,6 @@ + (NSString *)mainGraphicImageName; + (NSString *)mainGraphicBlankImageName; ++ (UIImage *)mainGraphic; + @end diff --git a/SmartDeviceLink_Example/Managers/ImageManager.m b/SmartDeviceLink_Example/Managers/ImageManager.m index a3995805a..9539ec6f0 100644 --- a/SmartDeviceLink_Example/Managers/ImageManager.m +++ b/SmartDeviceLink_Example/Managers/ImageManager.m @@ -107,5 +107,9 @@ return mainGraphicBlank; } +#pragma mark - UIImage ++ (UIImage *)mainGraphic { + return [UIImage imageNamed:@"sdl_logo_green"]; +} @end diff --git a/SmartDeviceLink_Example/Managers/SoftButtonManager.m b/SmartDeviceLink_Example/Managers/SoftButtonManager.m index 3271b3d36..2fd522b15 100644 --- a/SmartDeviceLink_Example/Managers/SoftButtonManager.m +++ b/SmartDeviceLink_Example/Managers/SoftButtonManager.m @@ -207,7 +207,8 @@ static Boolean isAddCommandVisible = false; #pragma mark Home Soft Buttons + (NSArray<SDLSoftButton *> *)homeSoftButtonsWithManager:(SDLManager *)manager { - return @[[self.class sdlex_softButton1WithManager:manager], [self.class sdlex_softButton2WithManager:manager], [self.class sdlex_softButton3WithManager:manager], [self.class sdlex_softButton4WithManager:manager]]; +// return @[[self.class sdlex_softButton4WithManager:manager], [self.class sdlex_softButton3WithManager:manager]]; // Manticore + return @[[self.class sdlex_softButton1WithManager:manager], [self.class sdlex_softButton2WithManager:manager], [self.class sdlex_softButton3WithManager:manager], [self.class sdlex_softButton4WithManager:manager]]; } + (SDLSoftButton *)sdlex_softButton1WithManager:(SDLManager *)manager { @@ -251,7 +252,9 @@ static Boolean isAddCommandVisible = false; [ShowManager showHomeTextAndImagesWithManager:manager]; }; - SDLSoftButton *softButton = [self createSoftButtonWithText:HomeSoftButtonsToggleStateManager.sharedManager.isTextOn ? @"➖Text" : @"➕Text" softButtonId:softButtonId manager:manager handler:softButtonHandler]; + SDLSoftButton *softButton = [self createSoftButtonWithImageName:HomeSoftButtonsToggleStateManager.sharedManager.areImagesVisible ? [ImageManager mainGraphicImageName] : [ImageManager mainGraphicBlankImageName] softButtonId:softButtonId manager:manager handler:softButtonHandler]; + +// SDLSoftButton *softButton = [self createSoftButtonWithText:HomeSoftButtonsToggleStateManager.sharedManager.isTextOn ? @"➖Text" : @"➕Text" softButtonId:softButtonId manager:manager handler:softButtonHandler]; return softButton; } @@ -281,11 +284,29 @@ static Boolean isAddCommandVisible = false; [AlertManager alertCommand_showText:@"Error uploading some images" softButtons:nil duration:3 withManager:manager]; } }]; + +// [manager.fileManager uploadFiles:[ImageManager allImages] progressHandler:^BOOL(SDLFileName * _Nonnull fileName, float uploadPercentage, NSError * _Nullable error) { +// SDLLogD(@"Image %@ uploaded successfully", fileName); +// return YES; +// } completionHandler:^(NSError * _Nullable error) { +// if (error == nil) { +// SDLLogD(@"All images uploaded successfully"); +// HomeSoftButtonsToggleStateManager.sharedManager.imagesVisible = !HomeSoftButtonsToggleStateManager.sharedManager.imagesVisible; +// [ShowManager showHomeTextAndImagesWithManager:manager]; +// } else { +// SDLLogW(@"Some or all images were not uploaded successfully (%@)", error); +// [AlertManager alertCommand_showText:@"Error uploading some images" softButtons:nil duration:3 withManager:manager]; +// } +// }]; } }; - // FIXME: add "loading..." to main text field? - SDLSoftButton *softButton = [self createSoftButtonWithText:HomeSoftButtonsToggleStateManager.sharedManager.areImagesVisible ? @"➖Icons" : @"➕Icons" softButtonId:softButtonId manager:manager handler:softButtonHandler]; + SDLSoftButton *softButton = [self createSoftButtonWithImageName:HomeSoftButtonsToggleStateManager.sharedManager.areImagesVisible ? [ImageManager hexagonOnImageName] : [ImageManager mainGraphicBlankImageName] softButtonId:softButtonId manager:manager handler:softButtonHandler]; + + // [self createSoftButtonWithText:HomeSoftButtonsToggleStateManager.sharedManager.areImagesVisible ? @"➖Icons" : @"➕Icons" softButtonId:softButtonId manager:manager handler:softButtonHandler]; + + // TODO: add "loading..." to main text field? +// SDLSoftButton *softButton = [self createSoftButtonWithText:HomeSoftButtonsToggleStateManager.sharedManager.areImagesVisible ? @"➖Icons" : @"➕Icons" softButtonId:softButtonId manager:manager handler:softButtonHandler]; return softButton; } diff --git a/SmartDeviceLink_Example/Managers/SubscribeButtonManager.h b/SmartDeviceLink_Example/Managers/SubscribeButtonManager.h index c9c9cd86a..4de30aa00 100644 --- a/SmartDeviceLink_Example/Managers/SubscribeButtonManager.h +++ b/SmartDeviceLink_Example/Managers/SubscribeButtonManager.h @@ -19,6 +19,8 @@ NS_ASSUME_NONNULL_BEGIN + (NSArray<SDLSubscribeButton *> *)mediaTemplateSubscribeButtonsWithManager:(SDLManager *)manager; + (NSArray<SDLUnsubscribeButton *> *)mediaTemplateUnSubscribeButtons; + (NSArray<SDLSubscribeButton *> *)presetSubscribeButtonsWithManager:(SDLManager *)manager; ++ (NSArray<SDLSubscribeButton *> *)radioSubscribeButtonsWithManager:(SDLManager *)manager; ++ (NSArray<SDLSubscribeButton *> *)climateSubscribeButtonsWithManager:(SDLManager *)manager; @end diff --git a/SmartDeviceLink_Example/Managers/SubscribeButtonManager.m b/SmartDeviceLink_Example/Managers/SubscribeButtonManager.m index 8b5c0aee8..f4f4d7681 100644 --- a/SmartDeviceLink_Example/Managers/SubscribeButtonManager.m +++ b/SmartDeviceLink_Example/Managers/SubscribeButtonManager.m @@ -60,6 +60,24 @@ NS_ASSUME_NONNULL_BEGIN return subscribeButtons; } ++ (NSArray<SDLSubscribeButton *> *)radioSubscribeButtonsWithManager:(SDLManager *)manager { + NSMutableArray *subscribeButtons = [NSMutableArray array]; + NSArray<SDLButtonName> *allTemplateSubscribeButtons = [[NSArray alloc] initWithObjects:SDLButtonNameTuneUp, SDLButtonNameTuneDown, SDLButtonNameVolumeUp, SDLButtonNameVolumeDown, SDLButtonNameEject, SDLButtonNameSource, SDLButtonNameShuffle, SDLButtonNameRepeat, nil]; + for(SDLButtonName buttonName in allTemplateSubscribeButtons) { + [subscribeButtons addObject:[self.class createSubscribeButtonWithName:buttonName withManager:manager]]; + } + return subscribeButtons; +} + ++ (NSArray<SDLSubscribeButton *> *)climateSubscribeButtonsWithManager:(SDLManager *)manager { + NSMutableArray *subscribeButtons = [NSMutableArray array]; + NSArray<SDLButtonName> *allTemplateSubscribeButtons = [[NSArray alloc] initWithObjects:SDLButtonNameACMax, SDLButtonNameAC, SDLButtonNameRecirculate, SDLButtonNameFanUp, SDLButtonNameFanDown, SDLButtonNameTempUp, SDLButtonNameTempDown, SDLButtonNameDefrostMax, SDLButtonNameDefrost, SDLButtonNameDefrostRear, SDLButtonNameUpperVent, SDLButtonNameLowerVent, nil]; + for(SDLButtonName buttonName in allTemplateSubscribeButtons) { + [subscribeButtons addObject:[self.class createSubscribeButtonWithName:buttonName withManager:manager]]; + } + return subscribeButtons; +} + @end NS_ASSUME_NONNULL_END diff --git a/SmartDeviceLink_Example/ProxyMenuManager.m b/SmartDeviceLink_Example/ProxyMenuManager.m index 3b5d2ce10..29bc8b0da 100644 --- a/SmartDeviceLink_Example/ProxyMenuManager.m +++ b/SmartDeviceLink_Example/ProxyMenuManager.m @@ -242,6 +242,27 @@ NS_ASSUME_NONNULL_BEGIN [manager sendRequest:[AddCommandManager addCommandWithManager:manager commandId:(commandId++) menuName:@"Remove PICS" handler:^{ [self.class sdlex_deleteInteractionChoiceSetWithManager:manager]; }]]; + + // Capabilities + [manager sendRequest:[AddCommandManager addCommandWithManager:manager commandId:(commandId++) menuName:@"Remote Control Capabilities" handler:^{ + SDLGetSystemCapability *remoteControl = [[SDLGetSystemCapability alloc] initWithType:SDLSystemCapabilityTypeRemoteControl]; + [manager sendRequest:remoteControl]; + }]]; + + [manager sendRequest:[AddCommandManager addCommandWithManager:manager commandId:(commandId++) menuName:@"Video Capabilities" handler:^{ + SDLGetSystemCapability *videoControl = [[SDLGetSystemCapability alloc] initWithType:SDLSystemCapabilityTypeVideoStreaming]; + [manager sendRequest:videoControl]; + }]]; + + [manager sendRequest:[AddCommandManager addCommandWithManager:manager commandId:(commandId++) menuName:@"Phone Capabilities" handler:^{ + SDLGetSystemCapability *phoneControl = [[SDLGetSystemCapability alloc] initWithType:SDLSystemCapabilityTypePhoneCall]; + [manager sendRequest:phoneControl]; + }]]; + + [manager sendRequest:[AddCommandManager addCommandWithManager:manager commandId:(commandId++) menuName:@"Navigation Capabilities" handler:^{ + SDLGetSystemCapability *phoneControl = [[SDLGetSystemCapability alloc] initWithType:SDLSystemCapabilityTypeNavigation]; + [manager sendRequest:phoneControl]; + }]]; } #pragma mark - Templates menu and submenu @@ -659,6 +680,16 @@ static const int choiceId = 10005; }]; } +#pragma mark - Capabilities + ++ (void)sdlex_sendCapability:(SDLSystemCapability *)capability manager:(SDLManager *)manager { + SDLGetSystemCapability *capabilityRequest = [[SDLGetSystemCapability alloc] initWithType:capability]; + + [manager sendRequest:capabilityRequest withResponseHandler:^(__kindof SDLRPCRequest * _Nullable request, __kindof SDLRPCResponse * _Nullable response, NSError * _Nullable error) { + SDLLogV(@"Send Capability %@ response: %@", capability, response.resultCode); + }]; +} + #pragma mark - Timer + (void)sdlex_showMediaClockTimerWithManager:(SDLManager *)manager { @@ -849,13 +880,22 @@ static const int choiceId = 10005; + (void)sdlex_createButtonPressWithManager:(SDLManager *)manager { SDLButtonPress* buttonPress = [[SDLButtonPress alloc] init]; - buttonPress.moduleType = SDLModuleTypeClimate; - buttonPress.buttonName = SDLButtonNameFanUp; + buttonPress.moduleType = SDLModuleTypeRadio; + buttonPress.buttonName = SDLButtonNameEject; buttonPress.buttonPressMode = SDLButtonPressModeShort; - [manager sendRequest:buttonPress withResponseHandler:^(__kindof SDLRPCRequest * _Nullable request, __kindof SDLRPCResponse * _Nullable response, NSError * _Nullable error) { - [AlertManager alertCommand_showText:@"Button Press RPC sent" text2:[NSString stringWithFormat:@"Response %@", response] softButtons:nil duration:3 withManager:manager]; + SDLGetInteriorVehicleData *interiorVehicleData = [[SDLGetInteriorVehicleData alloc] initAndSubscribeToModuleType:SDLModuleTypeRadio]; + + [manager sendRequest:interiorVehicleData withResponseHandler:^(__kindof SDLRPCRequest * _Nullable request, __kindof SDLRPCResponse * _Nullable response, NSError * _Nullable error) { + SDLLogD(@"subscribed to interior vehicle data"); + [manager sendRequest:buttonPress withResponseHandler:^(__kindof SDLRPCRequest * _Nullable request, __kindof SDLRPCResponse * _Nullable response, NSError * _Nullable error) { + SDLLogD(@"button press eject radio: %@", response.resultCode); + }]; }]; + +// [manager sendRequest:buttonPress withResponseHandler:^(__kindof SDLRPCRequest * _Nullable request, __kindof SDLRPCResponse * _Nullable response, NSError * _Nullable error) { +// [AlertManager alertCommand_showText:@"Button Press RPC sent" text2:[NSString stringWithFormat:@"Response %@", response] softButtons:nil duration:3 withManager:manager]; +// }]; } @end |