diff options
author | Julian Kast <julian@livio.com> | 2020-03-27 10:58:30 -0400 |
---|---|---|
committer | Julian Kast <julian@livio.com> | 2020-03-27 10:58:30 -0400 |
commit | 59570247015a05d9b50bb40aa1b023ab22636798 (patch) | |
tree | 7fd3d602eb33aa94f1efea96832324e92be50f80 | |
parent | 09fcf0f743b7dca4075aeefd548e9b3c4b9b76c7 (diff) | |
download | sdl_android-59570247015a05d9b50bb40aa1b023ab22636798.tar.gz |
Added ManagerUtility to extend capabilities of WindowCapability, Removed added methods from WindowCapability and added them to ManagerUtility.WindowCapabilityUtility
3 files changed, 73 insertions, 63 deletions
diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java b/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java index 7c4a5e45d..14a719b2e 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java @@ -46,6 +46,7 @@ import com.smartdevicelink.proxy.SystemCapabilityManager; import com.smartdevicelink.proxy.interfaces.ISdl; import com.smartdevicelink.proxy.interfaces.OnSystemCapabilityListener; import com.smartdevicelink.proxy.rpc.DisplayCapability; +import com.smartdevicelink.proxy.rpc.ManagerUtility; import com.smartdevicelink.proxy.rpc.MetadataTags; import com.smartdevicelink.proxy.rpc.OnHMIStatus; import com.smartdevicelink.proxy.rpc.Show; @@ -410,7 +411,7 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { return show; } - int numberOfLines = (defaultMainWindowCapability != null && defaultMainWindowCapability.getTextFields() != null) ? defaultMainWindowCapability.getMaxNumberOfMainFieldLines() : 4; + int numberOfLines = (defaultMainWindowCapability != null && defaultMainWindowCapability.getTextFields() != null) ? ManagerUtility.WindowCapabilityUtility.getMaxNumberOfMainFieldLines(defaultMainWindowCapability) : 4; switch (numberOfLines) { case 1: show = assembleOneLineShowText(show, nonNullFields); @@ -747,7 +748,7 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { * @return true if primaryGraphic should be updated, false if not */ private boolean shouldUpdatePrimaryImage() { - boolean templateSupportsPrimaryArtwork = (defaultMainWindowCapability != null) ? defaultMainWindowCapability.hasImageFieldOfName(ImageFieldName.graphic) : true; + boolean templateSupportsPrimaryArtwork = (defaultMainWindowCapability != null) ? ManagerUtility.WindowCapabilityUtility.hasImageFieldOfName(ImageFieldName.graphic, defaultMainWindowCapability) : true; if (currentScreenData.getGraphic() == null) { return templateSupportsPrimaryArtwork && primaryGraphic != null; @@ -763,7 +764,7 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { * @return true if secondaryGraphic should be updated, false if not */ private boolean shouldUpdateSecondaryImage() { - boolean templateSupportsSecondaryArtwork = (defaultMainWindowCapability != null) ? defaultMainWindowCapability.hasImageFieldOfName(ImageFieldName.secondaryGraphic) : true; + boolean templateSupportsSecondaryArtwork = (defaultMainWindowCapability != null) ? ManagerUtility.WindowCapabilityUtility.hasImageFieldOfName(ImageFieldName.secondaryGraphic, defaultMainWindowCapability) : true; if (currentScreenData.getSecondaryGraphic() == null) { return templateSupportsSecondaryArtwork && secondaryGraphic != null; @@ -779,7 +780,7 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { * @return true if mediaTrackTextField should be updated, false if not */ private boolean shouldUpdateMediaTrackField(){ - return (defaultMainWindowCapability != null) ? defaultMainWindowCapability.hasTextFieldOfName(TextFieldName.mediaTrack) : true; + return (defaultMainWindowCapability != null) ? ManagerUtility.WindowCapabilityUtility.hasTextFieldOfName(TextFieldName.mediaTrack, defaultMainWindowCapability) : true; } /** @@ -787,7 +788,7 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { * @return true if title textField should be updated, false if not */ private boolean shouldUpdateTitleField(){ - return (defaultMainWindowCapability != null) ? defaultMainWindowCapability.hasTextFieldOfName(TextFieldName.templateTitle) : true; + return (defaultMainWindowCapability != null) ? ManagerUtility.WindowCapabilityUtility.hasTextFieldOfName(TextFieldName.templateTitle, defaultMainWindowCapability) : true; } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/ManagerUtility.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/ManagerUtility.java new file mode 100644 index 000000000..884ecd410 --- /dev/null +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/ManagerUtility.java @@ -0,0 +1,67 @@ +package com.smartdevicelink.proxy.rpc; + +import com.smartdevicelink.proxy.rpc.enums.ImageFieldName; +import com.smartdevicelink.proxy.rpc.enums.TextFieldName; + +import java.util.List; + +public class ManagerUtility { + + public static class WindowCapabilityUtility { + + /** + * Check to see if WindowCapability has an ImageFieldName of a given name. + * @param name ImageFieldName representing a name of a given Image field that would be stored in WindowCapability + * @return true if name exist in WindowCapability else false + */ + public static boolean hasImageFieldOfName(ImageFieldName name, WindowCapability windowCapability) { + if (windowCapability.getImageFields() != null) { + for (ImageField field : windowCapability.getImageFields()) { + if (field != null && field.getName() != null && field.getName().equals(name)) { + return true; + } + } + } + return false; + } + + /** + * Check to see if WindowCapability has a textField of a given name. + * @param name - TextFieldName representing a name of a given text field that would be stored in WindowCapability + * @return true if name exist in WindowCapability else false + */ + public static boolean hasTextFieldOfName(TextFieldName name, WindowCapability windowCapability) { + if (windowCapability.getTextFields() != null) { + for (TextField field : windowCapability.getTextFields()) { + if (field != null && field.getName() != null && field.getName().equals(name)) { + return true; + } + } + } + return false; + } + + /** + * Method to get number of textFields allowed to be set according to WindowCapability + * @return linesFound - Number of textFields found in WindowCapability + */ + public static int getMaxNumberOfMainFieldLines(WindowCapability windowCapability) { + int linesFound = 0; + + List<TextField> textFields = windowCapability.getTextFields(); + TextFieldName name; + if (textFields != null && !textFields.isEmpty()) { + for (TextField field : textFields) { + if (field.getName() != null) { + name = field.getName(); + if (name == TextFieldName.mainField1 || name == TextFieldName.mainField2 || name == TextFieldName.mainField3 || name == TextFieldName.mainField4) { + linesFound += 1; + } + } + } + } + return linesFound; + } + } + +} diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/WindowCapability.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/WindowCapability.java index c4b1e1a56..bfebbb885 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/WindowCapability.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/WindowCapability.java @@ -207,62 +207,4 @@ public class WindowCapability extends RPCStruct { public List<MenuLayout> getMenuLayoutsAvailable() { return (List<MenuLayout>) getObject(MenuLayout.class, KEY_MENU_LAYOUTS_AVAILABLE); } - - /** - * Check to see if WindowCapability has an ImageFieldName of a given name. - * @param name ImageFieldName representing a name of a given Image field that would be stored in WindowCapability - * @return true if name exist in WindowCapability else false - */ - public boolean hasImageFieldOfName(ImageFieldName name) { - if (this.getImageTypeSupported() == null || this.getImageTypeSupported().isEmpty()) { - return false; - } - if (this.getImageFields() != null) { - for (ImageField field : this.getImageFields()) { - if (field != null && field.getName() != null && field.getName().equals(name)) { - return true; - } - } - } - return false; - } - - /** - * Check to see if WindowCapability has a textField of a given name. - * @param name - TextFieldName representing a name of a given text field that would be stored in WindowCapability - * @return true if name exist in WindowCapability else false - */ - public boolean hasTextFieldOfName(TextFieldName name) { - if (this.getTextFields() != null) { - for (TextField field : this.getTextFields()) { - if (field != null && field.getName() != null && field.getName().equals(name)) { - return true; - } - } - } - return false; - } - - /** - * Method to get number of textFields allowed to be set according to WindowCapability - * @return linesFound - Number of textFields found in WindowCapability - */ - public int getMaxNumberOfMainFieldLines() { - int linesFound = 0; - - List<TextField> textFields = this.getTextFields(); - TextFieldName name; - if (textFields != null && !textFields.isEmpty()) { - for (TextField field : textFields) { - if (field.getName() != null) { - name = field.getName(); - if (name == TextFieldName.mainField1 || name == TextFieldName.mainField2 || name == TextFieldName.mainField3 || name == TextFieldName.mainField4) { - linesFound += 1; - } - } - } - } - - return linesFound; - } } |