diff options
author | Joel Fischer <joeljfischer@gmail.com> | 2018-03-19 13:57:53 -0400 |
---|---|---|
committer | Joel Fischer <joeljfischer@gmail.com> | 2018-03-19 13:57:53 -0400 |
commit | 92d4745f3ceb03cf6eff2e0cd1edf95cfa57fa41 (patch) | |
tree | a99281e72b43d63ed4a1a390c5d63583eae6d78b | |
parent | 6cb1b26c15191520585e9d65226bb511b7365faa (diff) | |
download | sdl_ios-92d4745f3ceb03cf6eff2e0cd1edf95cfa57fa41.tar.gz |
Minor screen manager extensions
* Fix media track text field not available
* Add soft button transition to next state
-rw-r--r-- | SmartDeviceLink/SDLScreenManager.h | 1 | ||||
-rw-r--r-- | SmartDeviceLink/SDLScreenManager.m | 8 | ||||
-rw-r--r-- | SmartDeviceLink/SDLSoftButtonObject.h | 4 | ||||
-rw-r--r-- | SmartDeviceLink/SDLSoftButtonObject.m | 15 | ||||
-rw-r--r-- | SmartDeviceLink/SDLTextAndGraphicManager.h | 1 | ||||
-rw-r--r-- | SmartDeviceLink/SDLTextAndGraphicManager.m | 16 | ||||
-rw-r--r-- | SmartDeviceLink_Example/Classes/ProxyManager.m | 6 |
7 files changed, 46 insertions, 5 deletions
diff --git a/SmartDeviceLink/SDLScreenManager.h b/SmartDeviceLink/SDLScreenManager.h index bf1499f13..716a0eae9 100644 --- a/SmartDeviceLink/SDLScreenManager.h +++ b/SmartDeviceLink/SDLScreenManager.h @@ -32,6 +32,7 @@ typedef void(^SDLScreenManagerUpdateCompletionHandler)(NSError *__nullable error @property (copy, nonatomic, nullable) NSString *textField2; @property (copy, nonatomic, nullable) NSString *textField3; @property (copy, nonatomic, nullable) NSString *textField4; +@property (copy, nonatomic, nullable) NSString *mediaTrackTextField; @property (strong, nonatomic, nullable) SDLArtwork *primaryGraphic; @property (strong, nonatomic, nullable) SDLArtwork *secondaryGraphic; diff --git a/SmartDeviceLink/SDLScreenManager.m b/SmartDeviceLink/SDLScreenManager.m index 244b0abc0..85c5793e5 100644 --- a/SmartDeviceLink/SDLScreenManager.m +++ b/SmartDeviceLink/SDLScreenManager.m @@ -62,6 +62,10 @@ NS_ASSUME_NONNULL_BEGIN self.textAndGraphicManager.textField4 = textField4; } +- (void)setMediaTrackTextField:(nullable NSString *)mediaTrackTextField { + self.textAndGraphicManager.mediaTrackTextField = mediaTrackTextField; +} + - (void)setPrimaryGraphic:(nullable SDLArtwork *)primaryGraphic { if (primaryGraphic == nil) { self.textAndGraphicManager.primaryGraphic = self.textAndGraphicManager.blankArtwork; @@ -122,6 +126,10 @@ NS_ASSUME_NONNULL_BEGIN return _textAndGraphicManager.textField4; } +- (nullable NSString *)mediaTrackTextField { + return _textAndGraphicManager.mediaTrackTextField; +} + - (nullable SDLArtwork *)primaryGraphic { if ([_textAndGraphicManager.primaryGraphic.name isEqualToString:_textAndGraphicManager.blankArtwork.name]) { return nil; diff --git a/SmartDeviceLink/SDLSoftButtonObject.h b/SmartDeviceLink/SDLSoftButtonObject.h index 6f53d83a6..9b1db450c 100644 --- a/SmartDeviceLink/SDLSoftButtonObject.h +++ b/SmartDeviceLink/SDLSoftButtonObject.h @@ -68,7 +68,9 @@ NS_ASSUME_NONNULL_BEGIN @param stateName The next state. @return YES if a state was found with that name, NO otherwise. */ -- (BOOL)transitionToState:(NSString *)stateName; +- (BOOL)transitionToStateNamed:(NSString *)stateName; + +- (void)transitionToNextState; /** Return a state from the state array with a specific name. diff --git a/SmartDeviceLink/SDLSoftButtonObject.m b/SmartDeviceLink/SDLSoftButtonObject.m index 8468bde19..5e436d041 100644 --- a/SmartDeviceLink/SDLSoftButtonObject.m +++ b/SmartDeviceLink/SDLSoftButtonObject.m @@ -47,7 +47,7 @@ NS_ASSUME_NONNULL_BEGIN return [self initWithName:name states:@[state] initialStateName:state.name handler:eventHandler]; } -- (BOOL)transitionToState:(NSString *)stateName { +- (BOOL)transitionToStateNamed:(NSString *)stateName { if ([self stateWithName:stateName] == nil) { SDLLogE(@"Attempted to transition to state: %@ on soft button: %@ but no state with that name was found", stateName, self.name); return NO; @@ -60,6 +60,19 @@ NS_ASSUME_NONNULL_BEGIN return YES; } +- (void)transitionToNextState { + NSString *nextStateName = nil; + for (NSUInteger i = 0; i < self.states.count; i++) { + if ([self.states[i].name isEqualToString:self.currentStateName]) { + NSUInteger nextStateNumber = (i == self.states.count) ? 0 : i; + nextStateName = self.states[nextStateNumber].name; + break; + } + } + + [self transitionToStateNamed:nextStateName]; +} + - (SDLSoftButtonState *)currentState { SDLSoftButtonState *state = [self stateWithName:self.currentStateName]; diff --git a/SmartDeviceLink/SDLTextAndGraphicManager.h b/SmartDeviceLink/SDLTextAndGraphicManager.h index ef2dfc9c7..4becbd77d 100644 --- a/SmartDeviceLink/SDLTextAndGraphicManager.h +++ b/SmartDeviceLink/SDLTextAndGraphicManager.h @@ -35,6 +35,7 @@ typedef void(^SDLTextAndGraphicUpdateCompletionHandler)(NSError *__nullable erro @property (copy, nonatomic, nullable) NSString *textField2; @property (copy, nonatomic, nullable) NSString *textField3; @property (copy, nonatomic, nullable) NSString *textField4; +@property (copy, nonatomic, nullable) NSString *mediaTrackTextField; @property (strong, nonatomic, nullable) SDLArtwork *primaryGraphic; @property (strong, nonatomic, nullable) SDLArtwork *secondaryGraphic; diff --git a/SmartDeviceLink/SDLTextAndGraphicManager.m b/SmartDeviceLink/SDLTextAndGraphicManager.m index c46da4a7b..f198a5840 100644 --- a/SmartDeviceLink/SDLTextAndGraphicManager.m +++ b/SmartDeviceLink/SDLTextAndGraphicManager.m @@ -210,6 +210,13 @@ NS_ASSUME_NONNULL_BEGIN - (SDLShow *)sdl_assembleShowText:(SDLShow *)show { [self sdl_setBlankTextFieldsWithShow:show]; + + if (self.mediaTrackTextField != nil) { + show.mediaTrack = self.mediaTrackTextField; + } else { + show.mediaTrack = @""; + } + NSArray *nonNilFields = [self sdl_findNonNilTextFields]; if (nonNilFields.count == 0) { return show; } @@ -496,6 +503,15 @@ NS_ASSUME_NONNULL_BEGIN } } +- (void)setMediaTrackTextField:(nullable NSString *)mediaTrackTextField { + _mediaTrackTextField = mediaTrackTextField; + if (!self.isBatchingUpdates) { + [self sdl_updateWithCompletionHandler:nil]; + } else { + _isDirty = YES; + } +} + - (void)setPrimaryGraphic:(nullable SDLArtwork *)primaryGraphic { _primaryGraphic = primaryGraphic; if (!self.isBatchingUpdates) { diff --git a/SmartDeviceLink_Example/Classes/ProxyManager.m b/SmartDeviceLink_Example/Classes/ProxyManager.m index f0f329365..09a74129b 100644 --- a/SmartDeviceLink_Example/Classes/ProxyManager.m +++ b/SmartDeviceLink_Example/Classes/ProxyManager.m @@ -150,7 +150,7 @@ NS_ASSUME_NONNULL_BEGIN _hexagonEnabled = hexagonEnabled; SDLSoftButtonObject *object = [self.sdlManager.screenManager softButtonObjectNamed:@"HexagonButton"]; - [object transitionToState:(hexagonEnabled ? @"onState" : @"offState")]; + [object transitionToStateNamed:(hexagonEnabled ? @"onState" : @"offState")]; } - (void)sdlex_updateScreen { @@ -373,7 +373,7 @@ NS_ASSUME_NONNULL_BEGIN weakself.textEnabled = !weakself.textEnabled; SDLSoftButtonObject *object = [weakself.sdlManager.screenManager softButtonObjectNamed:@"TextButton"]; - [object transitionToState:(weakself.textEnabled ? @"onState" : @"offState")]; + [object transitionToNextState]; SDLLogD(@"Text visibility soft button press fired %d", weakself.textEnabled); }]; @@ -388,7 +388,7 @@ NS_ASSUME_NONNULL_BEGIN weakself.imagesEnabled = !weakself.imagesEnabled; SDLSoftButtonObject *object = [weakself.sdlManager.screenManager softButtonObjectNamed:@"ImagesButton"]; - [object transitionToState:(weakself.imagesEnabled ? @"onState" : @"offState")]; + [object transitionToNextState]; SDLLogD(@"Image visibility soft button press fired %d", weakself.imagesEnabled); }]; |