summaryrefslogtreecommitdiff
path: root/SmartDeviceLink/SDLTextAndGraphicManager.m
diff options
context:
space:
mode:
authorSho Amano <samano@xevo.com>2018-08-09 21:01:58 +0900
committerSho Amano <samano@xevo.com>2018-08-09 22:32:13 +0900
commitf0cff660f098eea0a1d48979734516a4965c44c0 (patch)
tree04893006d6f63ec2360ae8e1f2f4ceacff6c3c44 /SmartDeviceLink/SDLTextAndGraphicManager.m
parent114f9c69f68b0255331236585a338e49069dd62e (diff)
parent3cb0f3be950203b8c0737ffe36debb2628d8d707 (diff)
downloadsdl_ios-f0cff660f098eea0a1d48979734516a4965c44c0.tar.gz
Merge branch 'develop' into feature/multiple_transports
Conflicts: SmartDeviceLink-iOS.xcodeproj/project.pbxproj SmartDeviceLink/SDLCarWindow.m SmartDeviceLink/SDLLifecycleManager.m SmartDeviceLink/SDLStreamingAudioLifecycleManager.h SmartDeviceLink/SDLStreamingAudioLifecycleManager.m SmartDeviceLink/SDLStreamingMediaManager.m SmartDeviceLink/SDLStreamingVideoLifecycleManager.h SmartDeviceLink/SDLStreamingVideoLifecycleManager.m SmartDeviceLinkTests/DevAPISpecs/SDLStreamingVideoLifecycleManagerSpec.m SmartDeviceLinkTests/SDLStreamingMediaLifecycleManagerSpec.m SmartDeviceLinkTests/SDLStreamingVideoLifecycleManagerSpec.m
Diffstat (limited to 'SmartDeviceLink/SDLTextAndGraphicManager.m')
-rw-r--r--SmartDeviceLink/SDLTextAndGraphicManager.m96
1 files changed, 51 insertions, 45 deletions
diff --git a/SmartDeviceLink/SDLTextAndGraphicManager.m b/SmartDeviceLink/SDLTextAndGraphicManager.m
index 413aada4d..34bc8d97d 100644
--- a/SmartDeviceLink/SDLTextAndGraphicManager.m
+++ b/SmartDeviceLink/SDLTextAndGraphicManager.m
@@ -54,6 +54,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (strong, nonatomic, nullable) SDLArtwork *blankArtwork;
+@property (assign, nonatomic) BOOL waitingOnHMILevelUpdateToUpdate;
@property (assign, nonatomic) BOOL isDirty;
@end
@@ -72,6 +73,9 @@ NS_ASSUME_NONNULL_BEGIN
_currentScreenData = [[SDLShow alloc] init];
_currentLevel = SDLHMILevelNone;
+ _waitingOnHMILevelUpdateToUpdate = NO;
+ _isDirty = NO;
+
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sdl_registerResponse:) name:SDLDidReceiveRegisterAppInterfaceResponse object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sdl_displayLayoutResponse:) name:SDLDidReceiveSetDisplayLayoutResponse object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sdl_hmiStatusNotification:) name:SDLDidChangeHMIStatusNotification object:nil];
@@ -102,6 +106,7 @@ NS_ASSUME_NONNULL_BEGIN
_displayCapabilities = nil;
_currentLevel = SDLHMILevelNone;
_blankArtwork = nil;
+ _waitingOnHMILevelUpdateToUpdate = NO;
_isDirty = NO;
}
@@ -110,6 +115,14 @@ NS_ASSUME_NONNULL_BEGIN
- (void)updateWithCompletionHandler:(nullable SDLTextAndGraphicUpdateCompletionHandler)handler {
if (self.isBatchingUpdates) { return; }
+ // Don't send if we're in HMI NONE
+ if (self.currentLevel == nil || [self.currentLevel isEqualToString:SDLHMILevelNone]) {
+ self.waitingOnHMILevelUpdateToUpdate = YES;
+ return;
+ } else {
+ self.waitingOnHMILevelUpdateToUpdate = NO;
+ }
+
if (self.isDirty) {
self.isDirty = NO;
[self sdl_updateWithCompletionHandler:handler];
@@ -117,11 +130,6 @@ NS_ASSUME_NONNULL_BEGIN
}
- (void)sdl_updateWithCompletionHandler:(nullable SDLTextAndGraphicUpdateCompletionHandler)handler {
- // Don't send if we're in HMI NONE
- if (self.currentLevel == nil || [self.currentLevel isEqualToString:SDLHMILevelNone]) {
- return;
- }
-
SDLLogD(@"Updating text and graphics");
if (self.inProgressUpdate != nil) {
SDLLogV(@"In progress update exists, queueing update");
@@ -487,6 +495,13 @@ NS_ASSUME_NONNULL_BEGIN
return [array copy];
}
+- (BOOL)sdl_hasData {
+ BOOL hasTextFields = ([self sdl_findNonNilTextFields].count > 0);
+ BOOL hasImageFields = (self.primaryGraphic != nil) || (self.secondaryGraphic != nil);
+
+ return hasTextFields || hasImageFields;
+}
+
#pragma mark - Equality
- (BOOL)sdl_showImages:(SDLShow *)show isEqualToShowImages:(SDLShow *)show2 {
@@ -507,110 +522,98 @@ NS_ASSUME_NONNULL_BEGIN
- (void)setTextField1:(nullable NSString *)textField1 {
_textField1 = textField1;
+ _isDirty = YES;
if (!self.isBatchingUpdates) {
// If we aren't batching, send the update immediately, if we are, set ourselves as dirty (so we know we should send an update after the batch ends)
- [self sdl_updateWithCompletionHandler:nil];
- } else {
- _isDirty = YES;
+ [self updateWithCompletionHandler:nil];
}
}
- (void)setTextField2:(nullable NSString *)textField2 {
_textField2 = textField2;
+ _isDirty = YES;
if (!self.isBatchingUpdates) {
- [self sdl_updateWithCompletionHandler:nil];
- } else {
- _isDirty = YES;
+ [self updateWithCompletionHandler:nil];
}
}
- (void)setTextField3:(nullable NSString *)textField3 {
_textField3 = textField3;
+ _isDirty = YES;
if (!self.isBatchingUpdates) {
- [self sdl_updateWithCompletionHandler:nil];
- } else {
- _isDirty = YES;
+ [self updateWithCompletionHandler:nil];
}
}
- (void)setTextField4:(nullable NSString *)textField4 {
_textField4 = textField4;
+ _isDirty = YES;
if (!self.isBatchingUpdates) {
- [self sdl_updateWithCompletionHandler:nil];
- } else {
- _isDirty = YES;
+ [self updateWithCompletionHandler:nil];
}
}
- (void)setMediaTrackTextField:(nullable NSString *)mediaTrackTextField {
_mediaTrackTextField = mediaTrackTextField;
+ _isDirty = YES;
if (!self.isBatchingUpdates) {
- [self sdl_updateWithCompletionHandler:nil];
- } else {
- _isDirty = YES;
+ [self updateWithCompletionHandler:nil];
}
}
- (void)setPrimaryGraphic:(nullable SDLArtwork *)primaryGraphic {
_primaryGraphic = primaryGraphic;
+ _isDirty = YES;
if (!self.isBatchingUpdates) {
- [self sdl_updateWithCompletionHandler:nil];
- } else {
- _isDirty = YES;
+ [self updateWithCompletionHandler:nil];
}
}
- (void)setSecondaryGraphic:(nullable SDLArtwork *)secondaryGraphic {
_secondaryGraphic = secondaryGraphic;
+ _isDirty = YES;
if (!self.isBatchingUpdates) {
- [self sdl_updateWithCompletionHandler:nil];
- } else {
- _isDirty = YES;
+ [self updateWithCompletionHandler:nil];
}
}
- (void)setAlignment:(nullable SDLTextAlignment)alignment {
_alignment = alignment ? alignment : SDLTextAlignmentCenter;
+ _isDirty = YES;
if (!self.isBatchingUpdates) {
- [self sdl_updateWithCompletionHandler:nil];
- } else {
- _isDirty = YES;
+ [self updateWithCompletionHandler:nil];
}
}
- (void)setTextField1Type:(nullable SDLMetadataType)textField1Type {
_textField1Type = textField1Type;
+ _isDirty = YES;
if (!self.isBatchingUpdates) {
- [self sdl_updateWithCompletionHandler:nil];
- } else {
- _isDirty = YES;
+ [self updateWithCompletionHandler:nil];
}
}
- (void)setTextField2Type:(nullable SDLMetadataType)textField2Type {
_textField2Type = textField2Type;
+ _isDirty = YES;
if (!self.isBatchingUpdates) {
- [self sdl_updateWithCompletionHandler:nil];
- } else {
- _isDirty = YES;
+ [self updateWithCompletionHandler:nil];
}
}
- (void)setTextField3Type:(nullable SDLMetadataType)textField3Type {
_textField3Type = textField3Type;
+ _isDirty = YES;
if (!self.isBatchingUpdates) {
- [self sdl_updateWithCompletionHandler:nil];
- } else {
- _isDirty = YES;
+ [self updateWithCompletionHandler:nil];
}
}
- (void)setTextField4Type:(nullable SDLMetadataType)textField4Type {
_textField4Type = textField4Type;
+ _isDirty = YES;
if (!self.isBatchingUpdates) {
- [self sdl_updateWithCompletionHandler:nil];
- } else {
- _isDirty = YES;
+ [self updateWithCompletionHandler:nil];
}
}
@@ -644,18 +647,21 @@ NS_ASSUME_NONNULL_BEGIN
self.displayCapabilities = response.displayCapabilities;
// Auto-send an updated show
- [self sdl_updateWithCompletionHandler:nil];
+ if ([self sdl_hasData]) {
+ [self sdl_updateWithCompletionHandler:nil];
+ }
}
- (void)sdl_hmiStatusNotification:(SDLRPCNotificationNotification *)notification {
SDLOnHMIStatus *hmiStatus = (SDLOnHMIStatus *)notification.notification;
+ SDLHMILevel oldLevel = self.currentLevel;
+ self.currentLevel = hmiStatus.hmiLevel;
+
// Auto-send an updated show if we were in NONE and now we are not
- if ([self.currentLevel isEqualToString:SDLHMILevelNone] && ![hmiStatus.hmiLevel isEqualToString:SDLHMILevelNone]) {
+ if ([oldLevel isEqualToString:SDLHMILevelNone] && ![self.currentLevel isEqualToString:SDLHMILevelNone] && self.waitingOnHMILevelUpdateToUpdate) {
[self sdl_updateWithCompletionHandler:nil];
}
-
- self.currentLevel = hmiStatus.hmiLevel;
}
@end