diff options
author | Muller, Alexander (A.) <amulle19@ford.com> | 2017-03-13 11:27:46 -0700 |
---|---|---|
committer | Muller, Alexander (A.) <amulle19@ford.com> | 2017-03-13 11:27:46 -0700 |
commit | 23e539c6fd29128075312885ab1c400532c89250 (patch) | |
tree | d12d4c5893eded93da42edea3c0bbbb0a23e8113 /SmartDeviceLink | |
parent | 68a32ce6ba99ed77e55485039b5543e16b1624e1 (diff) | |
download | sdl_ios-feature/issue_577_enum_equality.tar.gz |
Added convenience isEqualToEnum function.feature/issue_577_enum_equality
Diffstat (limited to 'SmartDeviceLink')
-rw-r--r-- | SmartDeviceLink/SDLEnum.h | 12 | ||||
-rw-r--r-- | SmartDeviceLink/SDLEnum.m | 21 | ||||
-rw-r--r-- | SmartDeviceLink/SDLLifecycleConfiguration.m | 2 | ||||
-rw-r--r-- | SmartDeviceLink/SDLLifecycleManager.m | 8 | ||||
-rw-r--r-- | SmartDeviceLink/SDLLockScreenManager.m | 6 | ||||
-rw-r--r-- | SmartDeviceLink/SDLLockScreenStatusManager.m | 10 | ||||
-rw-r--r-- | SmartDeviceLink/SDLProxy.m | 10 | ||||
-rw-r--r-- | SmartDeviceLink/SDLResponseDispatcher.m | 2 | ||||
-rw-r--r-- | SmartDeviceLink/SDLTouchManager.m | 6 |
9 files changed, 54 insertions, 23 deletions
diff --git a/SmartDeviceLink/SDLEnum.h b/SmartDeviceLink/SDLEnum.h index 7723ea2fb..1667fecd6 100644 --- a/SmartDeviceLink/SDLEnum.h +++ b/SmartDeviceLink/SDLEnum.h @@ -5,4 +5,14 @@ #import <Foundation/Foundation.h> #import "SDLMacros.h" -typedef NSString* SDLEnum SDL_SWIFT_ENUM;
\ No newline at end of file +NS_ASSUME_NONNULL_BEGIN + +typedef NSString* SDLEnum SDL_SWIFT_ENUM; + +@interface NSString (Enum) + +- (BOOL)isEqualToEnum:(SDLEnum)enumObj; + +@end + +NS_ASSUME_NONNULL_END diff --git a/SmartDeviceLink/SDLEnum.m b/SmartDeviceLink/SDLEnum.m new file mode 100644 index 000000000..50d1eaeca --- /dev/null +++ b/SmartDeviceLink/SDLEnum.m @@ -0,0 +1,21 @@ +// +// SDLEnum.m +// SmartDeviceLink-iOS +// +// Created by Muller, Alexander (A.) on 3/13/17. +// Copyright © 2017 smartdevicelink. All rights reserved. +// + +#import "SDLEnum.h" + +NS_ASSUME_NONNULL_BEGIN + +@implementation NSString (Enum) + +- (BOOL)isEqualToEnum:(SDLEnum)enumObj { + return [self isEqualToString:enumObj]; +} + +@end + +NS_ASSUME_NONNULL_END diff --git a/SmartDeviceLink/SDLLifecycleConfiguration.m b/SmartDeviceLink/SDLLifecycleConfiguration.m index 8f50e3258..e3f0fc90c 100644 --- a/SmartDeviceLink/SDLLifecycleConfiguration.m +++ b/SmartDeviceLink/SDLLifecycleConfiguration.m @@ -72,7 +72,7 @@ NS_ASSUME_NONNULL_BEGIN #pragma mark Computed Properties - (BOOL)isMedia { - if ([self.appType isEqualToString:SDLAppHMITypeMedia]) { + if ([self.appType isEqualToEnum:SDLAppHMITypeMedia]) { return YES; } diff --git a/SmartDeviceLink/SDLLifecycleManager.m b/SmartDeviceLink/SDLLifecycleManager.m index bff19c66c..78acbec93 100644 --- a/SmartDeviceLink/SDLLifecycleManager.m +++ b/SmartDeviceLink/SDLLifecycleManager.m @@ -283,7 +283,7 @@ SDLLifecycleState *const SDLLifecycleStateReady = @"Ready"; NSError *startError = nil; // If the resultCode isn't success, we got a warning. Errors were handled in `didEnterStateConnected`. - if (![registerResult isEqualToString:SDLResultSuccess]) { + if (![registerResult isEqualToEnum:SDLResultSuccess]) { startError = [NSError sdl_lifecycle_startedWithWarning:registerResult info:registerInfo]; } @@ -454,16 +454,16 @@ SDLLifecycleState *const SDLLifecycleStateReady = @"Ready"; return; } - if (![oldHMILevel isEqualToString:self.hmiLevel]) { + if (![oldHMILevel isEqualToEnum:self.hmiLevel]) { [self.delegate hmiLevel:oldHMILevel didChangeToLevel:self.hmiLevel]; } - if (![oldStreamingState isEqualToString:self.audioStreamingState] + if (![oldStreamingState isEqualToEnum:self.audioStreamingState] && [self.delegate respondsToSelector:@selector(audioStreamingState:didChangeToState:)]) { [self.delegate audioStreamingState:oldStreamingState didChangeToState:self.audioStreamingState]; } - if (![oldSystemContext isEqualToString:self.systemContext] + if (![oldSystemContext isEqualToEnum:self.systemContext] && [self.delegate respondsToSelector:@selector(systemContext:didChangeToContext:)]) { [self.delegate systemContext:oldSystemContext didChangeToContext:self.systemContext]; } diff --git a/SmartDeviceLink/SDLLockScreenManager.m b/SmartDeviceLink/SDLLockScreenManager.m index b582e5996..3089f6b41 100644 --- a/SmartDeviceLink/SDLLockScreenManager.m +++ b/SmartDeviceLink/SDLLockScreenManager.m @@ -128,17 +128,17 @@ NS_ASSUME_NONNULL_BEGIN } // Present the VC depending on the lock screen status - if ([self.lastLockNotification.lockScreenStatus isEqualToString:SDLLockScreenStatusRequired]) { + if ([self.lastLockNotification.lockScreenStatus isEqualToEnum:SDLLockScreenStatusRequired]) { if (!self.presenter.presented && self.canPresent) { [self.presenter present]; } - } else if ([self.lastLockNotification.lockScreenStatus isEqualToString:SDLLockScreenStatusOptional]) { + } else if ([self.lastLockNotification.lockScreenStatus isEqualToEnum:SDLLockScreenStatusOptional]) { if (self.config.showInOptionalState && !self.presenter.presented && self.canPresent) { [self.presenter present]; } else if (self.presenter.presented) { [self.presenter dismiss]; } - } else if ([self.lastLockNotification.lockScreenStatus isEqualToString:SDLLockScreenStatusOff]) { + } else if ([self.lastLockNotification.lockScreenStatus isEqualToEnum:SDLLockScreenStatusOff]) { if (self.presenter.presented) { [self.presenter dismiss]; } diff --git a/SmartDeviceLink/SDLLockScreenStatusManager.m b/SmartDeviceLink/SDLLockScreenStatusManager.m index 6d2deb68e..82724eb6f 100644 --- a/SmartDeviceLink/SDLLockScreenStatusManager.m +++ b/SmartDeviceLink/SDLLockScreenStatusManager.m @@ -45,9 +45,9 @@ NS_ASSUME_NONNULL_BEGIN _hmiLevel = hmiLevel; } - if ([hmiLevel isEqualToString:SDLHMILevelFull] || [hmiLevel isEqualToString:SDLHMILevelLimited]) { + if ([hmiLevel isEqualToEnum:SDLHMILevelFull] || [hmiLevel isEqualToEnum:SDLHMILevelLimited]) { self.userSelected = YES; - } else if ([hmiLevel isEqualToString:SDLHMILevelNone]) { + } else if ([hmiLevel isEqualToEnum:SDLHMILevelNone]) { self.userSelected = NO; } } @@ -66,10 +66,10 @@ NS_ASSUME_NONNULL_BEGIN } - (SDLLockScreenStatus)lockScreenStatus { - if (self.hmiLevel == nil || [self.hmiLevel isEqualToString:SDLHMILevelNone]) { + if (self.hmiLevel == nil || [self.hmiLevel isEqualToEnum:SDLHMILevelNone]) { // App is not active on the car return SDLLockScreenStatusOff; - } else if ([self.hmiLevel isEqualToString:SDLHMILevelBackground]) { + } else if ([self.hmiLevel isEqualToEnum:SDLHMILevelBackground]) { // App is in the background on the car if (self.userSelected) { // It was user selected @@ -83,7 +83,7 @@ NS_ASSUME_NONNULL_BEGIN } else { return SDLLockScreenStatusOff; } - } else if ([self.hmiLevel isEqualToString:SDLHMILevelFull] || [self.hmiLevel isEqualToString:SDLHMILevelLimited]) { + } else if ([self.hmiLevel isEqualToEnum:SDLHMILevelFull] || [self.hmiLevel isEqualToEnum:SDLHMILevelLimited]) { // App is in the foreground on the car in some manner if (self.haveDriverDistractionStatus && !self.driverDistracted) { // We have the distraction status, and the driver is not distracted diff --git a/SmartDeviceLink/SDLProxy.m b/SmartDeviceLink/SDLProxy.m index 463b8bd71..97105539a 100644 --- a/SmartDeviceLink/SDLProxy.m +++ b/SmartDeviceLink/SDLProxy.m @@ -403,13 +403,13 @@ static float DefaultConnectionTimeout = 45.0; SDLRequestType requestType = systemRequest.requestType; // Handle the various OnSystemRequest types - if ([requestType isEqualToString:SDLRequestTypeProprietary]) { + if ([requestType isEqualToEnum:SDLRequestTypeProprietary]) { [self handleSystemRequestProprietary:systemRequest]; - } else if ([requestType isEqualToString:SDLRequestTypeLockScreenIconURL]) { + } else if ([requestType isEqualToEnum:SDLRequestTypeLockScreenIconURL]) { [self handleSystemRequestLockScreenIconURL:systemRequest]; - } else if ([requestType isEqualToString:SDLRequestTypeHTTP]) { + } else if ([requestType isEqualToEnum:SDLRequestTypeHTTP]) { [self sdl_handleSystemRequestHTTP:systemRequest]; - } else if ([requestType isEqualToString:SDLRequestTypeLaunchApp]) { + } else if ([requestType isEqualToEnum:SDLRequestTypeLaunchApp]) { [self sdl_handleSystemRequestLaunchApp:systemRequest]; } } @@ -587,7 +587,7 @@ static float DefaultConnectionTimeout = 45.0; return nil; } - if (![fileType isEqualToString:SDLFileTypeJSON]) { + if (![fileType isEqualToEnum:SDLFileTypeJSON]) { [SDLDebugTool logInfo:@"OnSystemRequest (notification) failure: file type is not JSON" withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; return nil; } diff --git a/SmartDeviceLink/SDLResponseDispatcher.m b/SmartDeviceLink/SDLResponseDispatcher.m index 98df4a731..4cefaf1b0 100644 --- a/SmartDeviceLink/SDLResponseDispatcher.m +++ b/SmartDeviceLink/SDLResponseDispatcher.m @@ -200,7 +200,7 @@ NS_ASSUME_NONNULL_BEGIN customID = ((SDLOnButtonPress *)rpcNotification).customButtonID; } - if ([name isEqualToString:SDLButtonNameCustomButton]) { + if ([name isEqualToEnum:SDLButtonNameCustomButton]) { handler = self.customButtonHandlerMap[customID]; } else { handler = self.buttonHandlerMap[name]; diff --git a/SmartDeviceLink/SDLTouchManager.m b/SmartDeviceLink/SDLTouchManager.m index b661f3563..680dabad7 100644 --- a/SmartDeviceLink/SDLTouchManager.m +++ b/SmartDeviceLink/SDLTouchManager.m @@ -118,11 +118,11 @@ static NSUInteger const MaximumNumberOfTouches = 2; return; } - if ([notification.type isEqualToString:SDLTouchTypeBegin]) { + if ([notification.type isEqualToEnum:SDLTouchTypeBegin]) { [self sdl_handleTouchBegan:touch]; - } else if ([notification.type isEqualToString:SDLTouchTypeMove]) { + } else if ([notification.type isEqualToEnum:SDLTouchTypeMove]) { [self sdl_handleTouchMoved:touch]; - } else if ([notification.type isEqualToString:SDLTouchTypeEnd]) { + } else if ([notification.type isEqualToEnum:SDLTouchTypeEnd]) { [self sdl_handleTouchEnded:touch]; } } |