summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Fischer <joeljfischer@gmail.com>2021-11-08 13:20:54 -0500
committerJoel Fischer <joeljfischer@gmail.com>2021-11-08 13:20:54 -0500
commita2ab09d3d99e829616f25533cfd6072c55f8f5fc (patch)
tree4f8c6f3772a60fe0be66573c00e059c7efab61b2
parent983dabca17485c784545bef84c7ba720388d06ca (diff)
downloadsdl_ios-a2ab09d3d99e829616f25533cfd6072c55f8f5fc.tar.gz
Fix incorrect comparison for menu cellprimary image
-rw-r--r--SmartDeviceLink/private/SDLMenuReplaceOperation.m23
-rw-r--r--SmartDeviceLink/private/SDLMenuReplaceUtilities.h10
-rw-r--r--SmartDeviceLink/private/SDLMenuReplaceUtilities.m10
3 files changed, 22 insertions, 21 deletions
diff --git a/SmartDeviceLink/private/SDLMenuReplaceOperation.m b/SmartDeviceLink/private/SDLMenuReplaceOperation.m
index d99febe0e..93d92cc75 100644
--- a/SmartDeviceLink/private/SDLMenuReplaceOperation.m
+++ b/SmartDeviceLink/private/SDLMenuReplaceOperation.m
@@ -341,37 +341,28 @@ NS_ASSUME_NONNULL_BEGIN
// Strip away fields that cannot be used to determine uniqueness visually including fields not supported by the HMI
cell.voiceCommands = nil;
+ if (![SDLMenuReplaceUtilities windowCapabilitySupportsPrimaryImage:windowCapability forCell:cell]) {
+ cell.icon = nil;
+ }
+ if (![SDLMenuReplaceUtilities windowCapabilitySupportsSecondaryImage:windowCapability forCell:cell]) {
+ cell.secondaryArtwork = nil;
+ }
+
if (cell.subCells != nil) {
- // If we're >= 5.0 && < 7.0, but don't have command icon image, no icon. If we're < 5.0 || >= 7.0 and don't have submenu icon, no icon.
- if (![windowCapability hasImageFieldOfName:SDLImageFieldNameSubMenuIcon]
- || ([[SDLGlobals sharedGlobals].rpcVersion isGreaterThanOrEqualToVersion:[SDLVersion versionWithMajor:5 minor:0 patch:0]]
- && [[SDLGlobals sharedGlobals].rpcVersion isLessThanVersion:[SDLVersion versionWithMajor:7 minor:0 patch:0]]
- && ![windowCapability hasImageFieldOfName:SDLImageFieldNameCommandIcon])) {
- cell.icon = nil;
- }
if (![windowCapability hasTextFieldOfName:SDLTextFieldNameMenuSubMenuSecondaryText]) {
cell.secondaryText = nil;
}
if (![windowCapability hasTextFieldOfName:SDLTextFieldNameMenuSubMenuTertiaryText]) {
cell.tertiaryText = nil;
}
- if (![windowCapability hasImageFieldOfName:SDLImageFieldNameMenuSubMenuSecondaryImage]) {
- cell.secondaryArtwork = nil;
- }
cell.subCells = [self sdl_cellsWithRemovedPropertiesFromCells:cell.subCells basedOnWindowCapability:windowCapability];
} else {
- if (![windowCapability hasImageFieldOfName:SDLImageFieldNameCommandIcon]) {
- cell.icon = nil;
- }
if (![windowCapability hasTextFieldOfName:SDLTextFieldNameMenuCommandSecondaryText]) {
cell.secondaryText = nil;
}
if (![windowCapability hasTextFieldOfName:SDLTextFieldNameMenuCommandTertiaryText]) {
cell.tertiaryText = nil;
}
- if (![windowCapability hasImageFieldOfName:SDLImageFieldNameMenuCommandSecondaryImage]) {
- cell.secondaryArtwork = nil;
- }
}
}
diff --git a/SmartDeviceLink/private/SDLMenuReplaceUtilities.h b/SmartDeviceLink/private/SDLMenuReplaceUtilities.h
index 4488d0d4b..42216eb42 100644
--- a/SmartDeviceLink/private/SDLMenuReplaceUtilities.h
+++ b/SmartDeviceLink/private/SDLMenuReplaceUtilities.h
@@ -37,6 +37,16 @@ NS_ASSUME_NONNULL_BEGIN
/// @param windowCapability The window capability to check available image fields
+ (NSArray<SDLArtwork *> *)findAllArtworksToBeUploadedFromCells:(NSArray<SDLMenuCell *> *)cells fileManager:(SDLFileManager *)fileManager windowCapability:(SDLWindowCapability *)windowCapability;
+/// Whether or not a given window capability supports the primary image for a given cell
+/// @param windowCapability The window capability to use for the comparison
+/// @param cell The cell to use for the comparison
++ (BOOL)windowCapabilitySupportsPrimaryImage:(SDLWindowCapability *)windowCapability forCell:(SDLMenuCell *)cell;
+
+/// Whether or not a given window capability supports the secondary image for a given cell
+/// @param windowCapability The window capability to use for the comparison
+/// @param cell The cell to use for the comparison
++ (BOOL)windowCapabilitySupportsSecondaryImage:(SDLWindowCapability *)windowCapability forCell:(SDLMenuCell *)cell;
+
#pragma mark - RPC Commands
/// Finds and returns the command id for a given RPC request, assuming that request is an SDLDeleteSubMenu, SDLDeleteCommand, SDLAddSubMenu, or SDLAddCommand
diff --git a/SmartDeviceLink/private/SDLMenuReplaceUtilities.m b/SmartDeviceLink/private/SDLMenuReplaceUtilities.m
index 30d107813..33616495b 100644
--- a/SmartDeviceLink/private/SDLMenuReplaceUtilities.m
+++ b/SmartDeviceLink/private/SDLMenuReplaceUtilities.m
@@ -99,13 +99,13 @@ static UInt32 _menuId = 0;
NSMutableSet<SDLArtwork *> *mutableArtworks = [NSMutableSet set];
for (SDLMenuCell *cell in cells) {
if ((cell.icon != nil)
- && [self sdl_windowCapabilitySupportsPrimaryImage:windowCapability forCell:cell]
+ && [self windowCapabilitySupportsPrimaryImage:windowCapability forCell:cell]
&& [fileManager fileNeedsUpload:cell.icon]) {
[mutableArtworks addObject:cell.icon];
}
if ((cell.secondaryArtwork != nil)
- && [self sdl_windowCapabilitySupportsSecondaryImage:windowCapability forCell:cell]
+ && [self windowCapabilitySupportsSecondaryImage:windowCapability forCell:cell]
&& [fileManager fileNeedsUpload:cell.secondaryArtwork]) {
[mutableArtworks addObject:cell.secondaryArtwork];
}
@@ -118,7 +118,7 @@ static UInt32 _menuId = 0;
return [mutableArtworks allObjects];
}
-+ (BOOL)sdl_windowCapabilitySupportsPrimaryImage:(SDLWindowCapability *)windowCapability forCell:(SDLMenuCell *)cell {
++ (BOOL)windowCapabilitySupportsPrimaryImage:(SDLWindowCapability *)windowCapability forCell:(SDLMenuCell *)cell {
BOOL supportsImage = NO;
if (cell.subCells != nil) {
if ([[SDLGlobals sharedGlobals].rpcVersion isGreaterThanOrEqualToVersion:[SDLVersion versionWithMajor:5 minor:0 patch:0]]
@@ -135,13 +135,13 @@ static UInt32 _menuId = 0;
return supportsImage;
}
-+ (BOOL)sdl_windowCapabilitySupportsSecondaryImage:(SDLWindowCapability *)windowCapability forCell:(SDLMenuCell *)cell {
++ (BOOL)windowCapabilitySupportsSecondaryImage:(SDLWindowCapability *)windowCapability forCell:(SDLMenuCell *)cell {
return (cell.subCells != nil) ? [windowCapability hasImageFieldOfName:SDLImageFieldNameMenuSubMenuSecondaryImage] : [windowCapability hasImageFieldOfName:SDLImageFieldNameMenuCommandSecondaryImage];
}
/// If there is an icon and the icon has been uploaded, or if the icon is a static icon, it should include the image
+ (BOOL)sdl_shouldCellIncludePrimaryImageFromCell:(SDLMenuCell *)cell fileManager:(SDLFileManager *)fileManager windowCapability:(SDLWindowCapability *)windowCapability {
- return (cell.icon != nil) && [self sdl_windowCapabilitySupportsPrimaryImage:windowCapability forCell:cell] && ([fileManager hasUploadedFile:cell.icon] || cell.icon.isStaticIcon);
+ return (cell.icon != nil) && [self windowCapabilitySupportsPrimaryImage:windowCapability forCell:cell] && ([fileManager hasUploadedFile:cell.icon] || cell.icon.isStaticIcon);
}
/// If there is an icon and the icon has been uploaded, or if the icon is a static icon, it should include the image