diff options
author | Bilal Alsharifi <599206+bilal-alsharifi@users.noreply.github.com> | 2021-11-22 09:42:06 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-22 09:42:06 -0500 |
commit | b1bf82245e14f983b8d39493976150c2ea284b9d (patch) | |
tree | 6aa66830c6d8803ac43eb49d21412b119070ddb2 | |
parent | 93280da174fd5fddab071cd1179a2276d32b97bb (diff) | |
parent | a627e9e8cfa4e5b4bb758693d9e560ca5878ac22 (diff) | |
download | sdl_android-b1bf82245e14f983b8d39493976150c2ea284b9d.tar.gz |
Merge pull request #1759 from smartdevicelink/bugfix/issue_1756
Menu Manager won't send submenu cell images on RPC versions >= 5.0 && < 7.0
4 files changed, 155 insertions, 40 deletions
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/menu/MenuManagerTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/menu/MenuManagerTests.java index 6f8bff69d..84ef09b7c 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/menu/MenuManagerTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/menu/MenuManagerTests.java @@ -261,12 +261,15 @@ public class MenuManagerTests { @Test public void testUpdatingOldWay() { + ISdl internalInterface = mock(ISdl.class); + when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(new Version(8, 0, 0))); + // Force Menu Manager to use the old way of deleting / sending all menuManager.setDynamicUpdatesMode(DynamicMenuUpdatesMode.FORCE_OFF); assertEquals(menuManager.dynamicMenuUpdatesMode, DynamicMenuUpdatesMode.FORCE_OFF); // when we only send one command to update, we should only be returned one add command List<MenuCell> newArray = Arrays.asList(mainCell1, mainCell4); - assertEquals(MenuReplaceUtilities.allCommandsForCells(newArray, menuManager.fileManager.get(), menuManager.windowCapability, MenuLayout.LIST).size(), 4); // 1 root cells, 1 sub menu root cell, 2 sub menu cells + assertEquals(MenuReplaceUtilities.allCommandsForCells(internalInterface, newArray, menuManager.fileManager.get(), menuManager.windowCapability, MenuLayout.LIST).size(), 4); // 1 root cells, 1 sub menu root cell, 2 sub menu cells menuManager.currentHMILevel = HMILevel.HMI_FULL; menuManager.setMenuCells(newArray); diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/menu/MenuReplaceUtilitiesTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/menu/MenuReplaceUtilitiesTests.java index 61587dbdc..c2153c745 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/menu/MenuReplaceUtilitiesTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/menu/MenuReplaceUtilitiesTests.java @@ -34,13 +34,16 @@ package com.smartdevicelink.managers.screen.menu; import androidx.test.ext.junit.runners.AndroidJUnit4; +import com.smartdevicelink.managers.ISdl; import com.smartdevicelink.managers.file.FileManager; import com.smartdevicelink.managers.file.filetypes.SdlArtwork; import com.smartdevicelink.proxy.rpc.ImageField; +import com.smartdevicelink.proxy.rpc.SdlMsgVersion; import com.smartdevicelink.proxy.rpc.WindowCapability; import com.smartdevicelink.proxy.rpc.enums.ImageFieldName; import com.smartdevicelink.proxy.rpc.enums.MenuLayout; import com.smartdevicelink.test.TestValues; +import com.smartdevicelink.util.Version; import org.junit.Before; import org.junit.Test; @@ -210,7 +213,88 @@ public class MenuReplaceUtilitiesTests { } @Test + public void testWindowCapabilitySupportsPrimaryImage() { + WindowCapability windowCapability; + ISdl internalInterface = mock(ISdl.class); + MenuCell menuCell = mock(MenuCell.class); + + // Test case 0 + windowCapability = createWindowCapability(false, true); + when(menuCell.isSubMenuCell()).thenReturn(true); + when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(new Version(4, 9, 0))); + assertTrue(MenuReplaceUtilities.windowCapabilitySupportsPrimaryImage(internalInterface, windowCapability, menuCell)); + + // Test case 1 + windowCapability = createWindowCapability(false, false); + when(menuCell.isSubMenuCell()).thenReturn(true); + when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(new Version(4, 9, 0))); + assertFalse(MenuReplaceUtilities.windowCapabilitySupportsPrimaryImage(internalInterface, windowCapability, menuCell)); + + // Test case 2 + windowCapability = createWindowCapability(false, false); + when(menuCell.isSubMenuCell()).thenReturn(true); + when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(new Version(5, 0, 0))); + assertFalse(MenuReplaceUtilities.windowCapabilitySupportsPrimaryImage(internalInterface, windowCapability, menuCell)); + + // Test case 3 + windowCapability = createWindowCapability(true, false); + when(menuCell.isSubMenuCell()).thenReturn(true); + when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(new Version(5, 0, 0))); + assertTrue(MenuReplaceUtilities.windowCapabilitySupportsPrimaryImage(internalInterface, windowCapability, menuCell)); + + // Test case 4 + windowCapability = createWindowCapability(false, false); + when(menuCell.isSubMenuCell()).thenReturn(true); + when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(new Version(6, 0, 0))); + assertFalse(MenuReplaceUtilities.windowCapabilitySupportsPrimaryImage(internalInterface, windowCapability, menuCell)); + + // Test case 5 + windowCapability = createWindowCapability(true, false); + when(menuCell.isSubMenuCell()).thenReturn(true); + when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(new Version(6, 0, 0))); + assertTrue(MenuReplaceUtilities.windowCapabilitySupportsPrimaryImage(internalInterface, windowCapability, menuCell)); + + // Test case 6 + windowCapability = createWindowCapability(false, false); + when(menuCell.isSubMenuCell()).thenReturn(true); + when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(new Version(7, 0, 0))); + assertFalse(MenuReplaceUtilities.windowCapabilitySupportsPrimaryImage(internalInterface, windowCapability, menuCell)); + + // Test case 7 + windowCapability = createWindowCapability(false, false); + when(menuCell.isSubMenuCell()).thenReturn(true); + when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(new Version(7, 1, 0))); + assertFalse(MenuReplaceUtilities.windowCapabilitySupportsPrimaryImage(internalInterface, windowCapability, menuCell)); + + // Test case 8 + windowCapability = createWindowCapability(false, false); + when(menuCell.isSubMenuCell()).thenReturn(true); + when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(new Version(8, 0, 0))); + assertFalse(MenuReplaceUtilities.windowCapabilitySupportsPrimaryImage(internalInterface, windowCapability, menuCell)); + + // Test case 9 + windowCapability = createWindowCapability(false, true); + when(menuCell.isSubMenuCell()).thenReturn(true); + when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(new Version(8, 0, 0))); + assertTrue(MenuReplaceUtilities.windowCapabilitySupportsPrimaryImage(internalInterface, windowCapability, menuCell)); + + // Test case 10 + windowCapability = createWindowCapability(false, false); + when(menuCell.isSubMenuCell()).thenReturn(false); + when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(new Version(8, 0, 0))); + assertFalse(MenuReplaceUtilities.windowCapabilitySupportsPrimaryImage(internalInterface, windowCapability, menuCell)); + + // Test case 11 + windowCapability = createWindowCapability(true, false); + when(menuCell.isSubMenuCell()).thenReturn(false); + when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(new Version(8, 0, 0))); + assertTrue(MenuReplaceUtilities.windowCapabilitySupportsPrimaryImage(internalInterface, windowCapability, menuCell)); + } + + @Test public void testShouldCellIncludeImage() { + ISdl internalInterface = mock(ISdl.class); + when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(new Version(8, 0, 0))); MenuCell menuCell; WindowCapability windowCapability; FileManager fileManager; @@ -220,31 +304,31 @@ public class MenuReplaceUtilitiesTests { menuCell = new MenuCell(TestValues.GENERAL_STRING, TestValues.GENERAL_ARTWORK, voiceCommands, null); windowCapability = createWindowCapability(true, true); fileManager = createMockFileManager(true); - assertTrue(MenuReplaceUtilities.shouldCellIncludePrimaryImageFromCell(menuCell, fileManager, windowCapability)); + assertTrue(MenuReplaceUtilities.shouldCellIncludePrimaryImageFromCell(internalInterface, menuCell, fileManager, windowCapability)); // Case 2 - Image are not supported menuCell = new MenuCell(TestValues.GENERAL_STRING, TestValues.GENERAL_ARTWORK, voiceCommands, null); windowCapability = createWindowCapability(false, false); fileManager = createMockFileManager(true); - assertFalse(MenuReplaceUtilities.shouldCellIncludePrimaryImageFromCell(menuCell, fileManager, windowCapability)); + assertFalse(MenuReplaceUtilities.shouldCellIncludePrimaryImageFromCell(internalInterface, menuCell, fileManager, windowCapability)); // Case 3 - Artwork is null menuCell = new MenuCell(TestValues.GENERAL_STRING, null, voiceCommands, null); windowCapability = createWindowCapability(true, true); fileManager = createMockFileManager(true); - assertFalse(MenuReplaceUtilities.shouldCellIncludePrimaryImageFromCell(menuCell, fileManager, windowCapability)); + assertFalse(MenuReplaceUtilities.shouldCellIncludePrimaryImageFromCell(internalInterface, menuCell, fileManager, windowCapability)); // Case 4 - Artwork has not been uploaded menuCell = new MenuCell(TestValues.GENERAL_STRING, TestValues.GENERAL_ARTWORK, voiceCommands, null); windowCapability = createWindowCapability(true, true); fileManager = createMockFileManager(false); - assertFalse(MenuReplaceUtilities.shouldCellIncludePrimaryImageFromCell(menuCell, fileManager, windowCapability)); + assertFalse(MenuReplaceUtilities.shouldCellIncludePrimaryImageFromCell(internalInterface, menuCell, fileManager, windowCapability)); // Case 5 - Artwork is static icon menuCell = new MenuCell(TestValues.GENERAL_STRING, TestValues.GENERAL_ARTWORK_STATIC, voiceCommands, null); windowCapability = createWindowCapability(true, true); fileManager = createMockFileManager(false); - assertTrue(MenuReplaceUtilities.shouldCellIncludePrimaryImageFromCell(menuCell, fileManager, windowCapability)); + assertTrue(MenuReplaceUtilities.shouldCellIncludePrimaryImageFromCell(internalInterface, menuCell, fileManager, windowCapability)); } private WindowCapability createWindowCapability (boolean supportsCmdIcon, boolean supportsSubMenuIcon) { diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/menu/MenuReplaceOperation.java b/base/src/main/java/com/smartdevicelink/managers/screen/menu/MenuReplaceOperation.java index 7db1a85b9..994c14ad8 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/menu/MenuReplaceOperation.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/menu/MenuReplaceOperation.java @@ -48,6 +48,8 @@ import static com.smartdevicelink.managers.screen.menu.MenuReplaceUtilities.send import static com.smartdevicelink.managers.screen.menu.MenuReplaceUtilities.subMenuCommandsForCells; import static com.smartdevicelink.managers.screen.menu.MenuReplaceUtilities.transferCellIDsFromCells; import static com.smartdevicelink.managers.screen.menu.MenuReplaceUtilities.transferCellListenersFromCells; +import static com.smartdevicelink.managers.screen.menu.MenuReplaceUtilities.windowCapabilitySupportsPrimaryImage; +import static com.smartdevicelink.managers.screen.menu.MenuReplaceUtilities.windowCapabilitySupportsSecondaryImage; import com.livio.taskmaster.Task; import com.smartdevicelink.managers.CompletionListener; @@ -198,7 +200,7 @@ class MenuReplaceOperation extends Task { } private void uploadMenuArtworks(final CompletionListener listener) { - List<SdlArtwork> artworksToBeUploaded = new ArrayList<>(findAllArtworksToBeUploadedFromCells(updatedMenu, fileManager.get(), windowCapability)); + List<SdlArtwork> artworksToBeUploaded = new ArrayList<>(findAllArtworksToBeUploadedFromCells(internalInterface.get(), updatedMenu, fileManager.get(), windowCapability)); if (artworksToBeUploaded.isEmpty()) { listener.onComplete(true); return; @@ -373,10 +375,10 @@ class MenuReplaceOperation extends Task { MenuLayout defaultSubmenuLayout = menuConfiguration != null ? menuConfiguration.getSubMenuLayout() : null; // RPCs for cells on the main menu level. They could be AddCommands or AddSubMenus depending on whether the cell has child cells or not. - final List<RPCRequest> mainMenuCommands = mainMenuCommandsForCells(addMenuCells, fileManager.get(), fullMenu, windowCapability, defaultSubmenuLayout); + final List<RPCRequest> mainMenuCommands = mainMenuCommandsForCells(internalInterface.get(), addMenuCells, fileManager.get(), fullMenu, windowCapability, defaultSubmenuLayout); // RPCs for cells on the second menu level (one level deep). They could be AddCommands or AddSubMenus. - final List<RPCRequest> subMenuCommands = subMenuCommandsForCells(addMenuCells, fileManager.get(), windowCapability, defaultSubmenuLayout); + final List<RPCRequest> subMenuCommands = subMenuCommandsForCells(internalInterface.get(), addMenuCells, fileManager.get(), windowCapability, defaultSubmenuLayout); sendRPCs(mainMenuCommands, internalInterface.get(), new SendingRPCsCompletionListener() { @Override @@ -465,12 +467,14 @@ class MenuReplaceOperation extends Task { // Strip away fields that cannot be used to determine uniqueness visually including fields not supported by the HMI cell.setVoiceCommands(null); - // Don't check ImageFieldName.subMenuIcon because it was added in 7.0 when the feature was added in 5.0. - // Just assume that if cmdIcon is not available, the submenu icon is not either. - if (!hasImageFieldOfName(windowCapability, ImageFieldName.cmdIcon)) { + if (!windowCapabilitySupportsPrimaryImage(internalInterface.get(), windowCapability, cell)) { cell.setIcon(null); } + if (!windowCapabilitySupportsSecondaryImage(windowCapability, cell)) { + cell.setSecondaryArtwork(null); + } + // Check for subMenu fields supported if (cell.isSubMenuCell()) { if (!hasTextFieldOfName(windowCapability, TextFieldName.menuSubMenuSecondaryText)) { @@ -479,9 +483,6 @@ class MenuReplaceOperation extends Task { if (!hasTextFieldOfName(windowCapability, TextFieldName.menuSubMenuTertiaryText)) { cell.setTertiaryText(null); } - if (!hasImageFieldOfName(windowCapability, ImageFieldName.menuSubMenuSecondaryImage)) { - cell.setSecondaryArtwork(null); - } cell.setSubCells(cellsWithRemovedPropertiesFromCells(cell.getSubCells(), windowCapability)); } else { if (!hasTextFieldOfName(windowCapability, TextFieldName.menuCommandSecondaryText)) { @@ -490,9 +491,6 @@ class MenuReplaceOperation extends Task { if (!hasTextFieldOfName(windowCapability, TextFieldName.menuCommandTertiaryText)) { cell.setTertiaryText(null); } - if (!hasImageFieldOfName(windowCapability, ImageFieldName.menuCommandSecondaryImage)) { - cell.setSecondaryArtwork(null); - } } } return removePropertiesClone; diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/menu/MenuReplaceUtilities.java b/base/src/main/java/com/smartdevicelink/managers/screen/menu/MenuReplaceUtilities.java index 210b24ba9..2e9711dda 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/menu/MenuReplaceUtilities.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/menu/MenuReplaceUtilities.java @@ -53,6 +53,7 @@ import com.smartdevicelink.proxy.rpc.enums.MenuLayout; import com.smartdevicelink.proxy.rpc.enums.TextFieldName; import com.smartdevicelink.proxy.rpc.listeners.OnMultipleRequestListener; import com.smartdevicelink.util.DebugTool; +import com.smartdevicelink.util.Version; import java.util.ArrayList; import java.util.HashMap; @@ -119,7 +120,7 @@ class MenuReplaceUtilities { } } - static Set<SdlArtwork> findAllArtworksToBeUploadedFromCells(List<MenuCell> cells, FileManager fileManager, WindowCapability windowCapability) { + static Set<SdlArtwork> findAllArtworksToBeUploadedFromCells(ISdl internalInterface, List<MenuCell> cells, FileManager fileManager, WindowCapability windowCapability) { // Make sure we can use images in the menus if (!hasImageFieldOfName(windowCapability, ImageFieldName.cmdIcon)) { return new HashSet<>(); @@ -128,30 +129,59 @@ class MenuReplaceUtilities { Set<SdlArtwork> artworks = new HashSet<>(); for (MenuCell cell : cells) { if (fileManager != null) { - if (fileManager.fileNeedsUpload(cell.getIcon())) { + if (windowCapabilitySupportsPrimaryImage(internalInterface, windowCapability, cell) && fileManager.fileNeedsUpload(cell.getIcon())) { artworks.add(cell.getIcon()); } - if (hasImageFieldOfName(windowCapability, ImageFieldName.menuCommandSecondaryImage) && fileManager.fileNeedsUpload(cell.getSecondaryArtwork())) { + if (windowCapabilitySupportsSecondaryImage(windowCapability, cell) && fileManager.fileNeedsUpload(cell.getSecondaryArtwork())) { artworks.add(cell.getSecondaryArtwork()); } } if (cell.isSubMenuCell() && !cell.getSubCells().isEmpty()) { - artworks.addAll(findAllArtworksToBeUploadedFromCells(cell.getSubCells(), fileManager, windowCapability)); + artworks.addAll(findAllArtworksToBeUploadedFromCells(internalInterface, cell.getSubCells(), fileManager, windowCapability)); } } return artworks; } - // If there is an icon and the icon has been uploaded, or if the icon is a static icon, it should include the image - static boolean shouldCellIncludePrimaryImageFromCell(MenuCell cell, FileManager fileManager, WindowCapability windowCapability) { - boolean supportsImage = cell.isSubMenuCell() ? hasImageFieldOfName(windowCapability, ImageFieldName.subMenuIcon) : hasImageFieldOfName(windowCapability, ImageFieldName.cmdIcon); + static boolean windowCapabilitySupportsPrimaryImage(ISdl internalInterface, WindowCapability windowCapability, MenuCell cell) { + boolean supportsImage; + if (cell.isSubMenuCell()) { + if (isRPCVersionBetween5And7(internalInterface) && hasImageFieldOfName(windowCapability, ImageFieldName.cmdIcon)) { + supportsImage = true; + } else { + supportsImage = hasImageFieldOfName(windowCapability, ImageFieldName.subMenuIcon); + } + } else { + supportsImage = hasImageFieldOfName(windowCapability, ImageFieldName.cmdIcon); + } + return supportsImage; + } + + static boolean isRPCVersionBetween5And7(ISdl internalInterface) { + if (internalInterface != null && internalInterface.getSdlMsgVersion() != null) { + Version headUnitRPCVersion = new Version(internalInterface.getSdlMsgVersion()); + Version minRPCVersion = new Version(5, 0, 0); + Version maxRPCVersion = new Version(7, 0, 0); + // If RPC version is >= 5.0 && < 7.0 + return (headUnitRPCVersion.isNewerThan(minRPCVersion) == 0 || headUnitRPCVersion.isBetween(minRPCVersion, maxRPCVersion) == 1); + } + return false; + } + + static boolean windowCapabilitySupportsSecondaryImage(WindowCapability windowCapability, MenuCell cell) { + return cell.isSubMenuCell() ? hasImageFieldOfName(windowCapability, ImageFieldName.menuSubMenuSecondaryImage) : hasImageFieldOfName(windowCapability, ImageFieldName.menuCommandSecondaryImage); + } + + // If there is an icon and the icon has been uploaded, or if the icon is a static icon, it should include the image + static boolean shouldCellIncludePrimaryImageFromCell(ISdl internalInterface, MenuCell cell, FileManager fileManager, WindowCapability windowCapability) { + boolean supportsImage = windowCapabilitySupportsPrimaryImage(internalInterface, windowCapability, cell); return cell.getIcon() != null && supportsImage && (fileManager.hasUploadedFile(cell.getIcon()) || cell.getIcon().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 static boolean shouldCellIncludeSecondaryImageFromCell(MenuCell cell, FileManager fileManager, WindowCapability windowCapability) { - boolean supportsImage = cell.isSubMenuCell() ? hasImageFieldOfName(windowCapability, ImageFieldName.menuSubMenuSecondaryImage) : hasImageFieldOfName(windowCapability, ImageFieldName.menuCommandSecondaryImage); + boolean supportsImage = windowCapabilitySupportsSecondaryImage(windowCapability, cell); return cell.getSecondaryArtwork() != null && supportsImage && (fileManager.hasUploadedFile(cell.getSecondaryArtwork()) || cell.getSecondaryArtwork().isStaticIcon()); } @@ -193,7 +223,7 @@ class MenuReplaceUtilities { return deletes; } - static List<RPCRequest> mainMenuCommandsForCells(List<MenuCell> cells, FileManager fileManager, List<MenuCell> menu, WindowCapability windowCapability, MenuLayout defaultSubmenuLayout) { + static List<RPCRequest> mainMenuCommandsForCells(ISdl internalInterface, List<MenuCell> cells, FileManager fileManager, List<MenuCell> menu, WindowCapability windowCapability, MenuLayout defaultSubmenuLayout) { List<RPCRequest> commands = new ArrayList<>(); // We need the index to use it as position so we will use this type of loop @@ -203,9 +233,9 @@ class MenuReplaceUtilities { MenuCell addCell = cells.get(updateCellsIndex); if (mainCell.equals(addCell)) { if (addCell.isSubMenuCell()) { - commands.add(subMenuCommandForMenuCell(addCell, fileManager, windowCapability, menuInteger, defaultSubmenuLayout)); + commands.add(subMenuCommandForMenuCell(internalInterface, addCell, fileManager, windowCapability, menuInteger, defaultSubmenuLayout)); } else { - commands.add(commandForMenuCell(addCell, fileManager, windowCapability, menuInteger)); + commands.add(commandForMenuCell(internalInterface, addCell, fileManager, windowCapability, menuInteger)); } break; } @@ -214,36 +244,36 @@ class MenuReplaceUtilities { return commands; } - static List<RPCRequest> subMenuCommandsForCells(List<MenuCell> cells, FileManager fileManager, WindowCapability windowCapability, MenuLayout defaultSubmenuLayout) { + static List<RPCRequest> subMenuCommandsForCells(ISdl internalInterface, List<MenuCell> cells, FileManager fileManager, WindowCapability windowCapability, MenuLayout defaultSubmenuLayout) { List<RPCRequest> commands = new ArrayList<>(); for (MenuCell cell : cells) { if (cell.isSubMenuCell() && !cell.getSubCells().isEmpty()) { - commands.addAll(allCommandsForCells(cell.getSubCells(), fileManager, windowCapability, defaultSubmenuLayout)); + commands.addAll(allCommandsForCells(internalInterface, cell.getSubCells(), fileManager, windowCapability, defaultSubmenuLayout)); } } return commands; } - static List<RPCRequest> allCommandsForCells(List<MenuCell> cells, FileManager fileManager, WindowCapability windowCapability, MenuLayout defaultSubmenuLayout) { + static List<RPCRequest> allCommandsForCells(ISdl internalInterface, List<MenuCell> cells, FileManager fileManager, WindowCapability windowCapability, MenuLayout defaultSubmenuLayout) { List<RPCRequest> commands = new ArrayList<>(); for (int cellIndex = 0; cellIndex < cells.size(); cellIndex++) { MenuCell cell = cells.get(cellIndex); if (cell.isSubMenuCell()) { - commands.add(subMenuCommandForMenuCell(cell, fileManager, windowCapability, cellIndex, defaultSubmenuLayout)); + commands.add(subMenuCommandForMenuCell(internalInterface, cell, fileManager, windowCapability, cellIndex, defaultSubmenuLayout)); // Recursively grab the commands for all the sub cells if (!cell.getSubCells().isEmpty()) { - commands.addAll(allCommandsForCells(cell.getSubCells(), fileManager, windowCapability, defaultSubmenuLayout)); + commands.addAll(allCommandsForCells(internalInterface, cell.getSubCells(), fileManager, windowCapability, defaultSubmenuLayout)); } } else { - commands.add(commandForMenuCell(cell, fileManager, windowCapability, cellIndex)); + commands.add(commandForMenuCell(internalInterface, cell, fileManager, windowCapability, cellIndex)); } } return commands; } - static AddCommand commandForMenuCell(MenuCell cell, FileManager fileManager, WindowCapability windowCapability, int position) { + static AddCommand commandForMenuCell(ISdl internalInterface, MenuCell cell, FileManager fileManager, WindowCapability windowCapability, int position) { AddCommand command = new AddCommand(cell.getCellId()); MenuParams params = new MenuParams(cell.getUniqueTitle()); @@ -258,7 +288,7 @@ class MenuReplaceUtilities { } else { command.setVrCommands(null); } - boolean shouldCellIncludePrimaryImage = cell.getIcon() != null && shouldCellIncludePrimaryImageFromCell(cell, fileManager, windowCapability); + boolean shouldCellIncludePrimaryImage = cell.getIcon() != null && shouldCellIncludePrimaryImageFromCell(internalInterface, cell, fileManager, windowCapability); command.setCmdIcon(shouldCellIncludePrimaryImage ? cell.getIcon().getImageRPC() : null); boolean shouldCellIncludeSecondaryImage = cell.getSecondaryArtwork() != null && shouldCellIncludeSecondaryImageFromCell(cell, fileManager, windowCapability); @@ -267,8 +297,8 @@ class MenuReplaceUtilities { return command; } - static AddSubMenu subMenuCommandForMenuCell(MenuCell cell, FileManager fileManager, WindowCapability windowCapability, int position, MenuLayout defaultSubmenuLayout) { - boolean shouldCellIncludePrimaryImage = cell.getIcon() != null && cell.getIcon().getImageRPC() != null && shouldCellIncludePrimaryImageFromCell(cell, fileManager, windowCapability); + static AddSubMenu subMenuCommandForMenuCell(ISdl internalInterface, MenuCell cell, FileManager fileManager, WindowCapability windowCapability, int position, MenuLayout defaultSubmenuLayout) { + boolean shouldCellIncludePrimaryImage = cell.getIcon() != null && cell.getIcon().getImageRPC() != null && shouldCellIncludePrimaryImageFromCell(internalInterface, cell, fileManager, windowCapability); Image icon = (shouldCellIncludePrimaryImage ? cell.getIcon().getImageRPC() : null); boolean shouldCellIncludeSecondaryImage = cell.getSecondaryArtwork() != null && cell.getSecondaryArtwork().getImageRPC() != null && shouldCellIncludeSecondaryImageFromCell(cell, fileManager, windowCapability); Image secondaryIcon = (shouldCellIncludeSecondaryImage ? cell.getSecondaryArtwork().getImageRPC() : null); @@ -421,4 +451,4 @@ class MenuReplaceUtilities { } }); } -}
\ No newline at end of file +} |