From 04ead8f26713a3ff954c3fb9c945eeaba4a55af2 Mon Sep 17 00:00:00 2001 From: Julian Kast Date: Tue, 1 Sep 2020 10:34:49 -0400 Subject: Fixed Error with shouldUpdateSecondaryImage and made change to shouldUpdatePrimaryImage to be consistent --- .../managers/screen/TextAndGraphicUpdateOperation.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java b/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java index f7a2c7b89..5f29e0cf9 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperation.java @@ -556,11 +556,12 @@ class TextAndGraphicUpdateOperation extends Task { */ private boolean shouldUpdatePrimaryImage() { boolean templateSupportsPrimaryArtwork = templateSupportsImageField(ImageFieldName.graphic); - String currentScreenDataPrimaryGraphicName = (currentScreenData != null && currentScreenData.getGraphic() != null) ? currentScreenData.getGraphic().getValue() : null; String primaryGraphicName = updatedState.getPrimaryGraphic() != null ? updatedState.getPrimaryGraphic().getName() : null; - return templateSupportsPrimaryArtwork - && !CompareUtils.areStringsEqual(currentScreenDataPrimaryGraphicName, primaryGraphicName, true, true); + + boolean graphicMatchesExisting = CompareUtils.areStringsEqual(currentScreenDataPrimaryGraphicName, primaryGraphicName, true, true); + + return templateSupportsPrimaryArtwork && !graphicMatchesExisting; } /** @@ -570,14 +571,16 @@ class TextAndGraphicUpdateOperation extends Task { */ private boolean shouldUpdateSecondaryImage() { boolean templateSupportsSecondaryArtwork = templateSupportsImageField(ImageFieldName.secondaryGraphic); - String currentScreenDataSecondaryGraphicName = (currentScreenData != null && currentScreenData.getSecondaryGraphic() != null) ? currentScreenData.getSecondaryGraphic().getValue() : null; String secondaryGraphicName = updatedState.getSecondaryGraphic() != null ? updatedState.getSecondaryGraphic().getName() : null; + + boolean graphicMatchesExisting = CompareUtils.areStringsEqual(currentScreenDataSecondaryGraphicName, secondaryGraphicName, true, true); + // Cannot detect if there is a secondary image below v5.0, so we'll just try to detect if the primary image is allowed and allow the secondary image if it is. if (internalInterface.get().getSdlMsgVersion().getMajorVersion() >= 5) { - return templateSupportsSecondaryArtwork && !CompareUtils.areStringsEqual(currentScreenDataSecondaryGraphicName, secondaryGraphicName, true, true); + return templateSupportsSecondaryArtwork && !graphicMatchesExisting; } else { - return templateSupportsImageField(ImageFieldName.graphic); + return templateSupportsImageField(ImageFieldName.graphic) && !graphicMatchesExisting; } } -- cgit v1.2.1