diff options
author | Joey Grover <joeygrover@gmail.com> | 2018-06-29 10:14:06 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-29 10:14:06 -0400 |
commit | 54cb61dbaac9f17d0192f9588c3ce40a9c7cce14 (patch) | |
tree | f0548c18d3174cad11caaceed4c9c00b4f1ce33a | |
parent | 1e936dae62a05b7db05cbf29f7bbc762811cc7ce (diff) | |
parent | 3729eeb6eead7288431b4fa95fca31dcc9dd8ed5 (diff) | |
download | sdl_android-54cb61dbaac9f17d0192f9588c3ce40a9c7cce14.tar.gz |
Merge pull request #799 from smartdevicelink/feature/issue_603
Feature/issue 603 - SubMenu icon
4 files changed, 72 insertions, 10 deletions
diff --git a/sdl_android/src/androidTest/assets/json/AddSubMenu.json b/sdl_android/src/androidTest/assets/json/AddSubMenu.json index 5d86c2615..37cc46adb 100644 --- a/sdl_android/src/androidTest/assets/json/AddSubMenu.json +++ b/sdl_android/src/androidTest/assets/json/AddSubMenu.json @@ -5,7 +5,11 @@ "parameters":{ "menuID":765, "position":2, - "menuName":"Menu Name" + "menuName":"Menu Name", + "menuIcon":{ + "value":"cmdImage1.png", + "imageType":"DYNAMIC" + } } }, "response":{ diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/AddSubmenuTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/AddSubmenuTests.java index e44340216..6e73121f1 100644 --- a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/AddSubmenuTests.java +++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/AddSubmenuTests.java @@ -9,14 +9,16 @@ import com.smartdevicelink.marshal.JsonRPCMarshaller; import com.smartdevicelink.protocol.enums.FunctionID; import com.smartdevicelink.proxy.RPCMessage; import com.smartdevicelink.proxy.rpc.AddSubMenu; +import com.smartdevicelink.proxy.rpc.Image; import com.smartdevicelink.test.BaseRpcTests; import com.smartdevicelink.test.JsonUtils; import com.smartdevicelink.test.Test; +import com.smartdevicelink.test.Validator; import com.smartdevicelink.test.json.rpc.JsonFileReader; /** * This is a unit test class for the SmartDeviceLink library project class : - * {@link com.smartdevicelink.rpc.AddSubmenu} + * {@link com.smartdevicelink.proxy.rpc.AddSubMenu} */ public class AddSubmenuTests extends BaseRpcTests{ @@ -27,6 +29,7 @@ public class AddSubmenuTests extends BaseRpcTests{ msg.setMenuID(Test.GENERAL_INT); msg.setMenuName(Test.GENERAL_STRING); msg.setPosition(Test.GENERAL_INT); + msg.setMenuIcon(Test.GENERAL_IMAGE); return msg; } @@ -49,6 +52,7 @@ public class AddSubmenuTests extends BaseRpcTests{ result.put(AddSubMenu.KEY_MENU_ID, Test.GENERAL_INT); result.put(AddSubMenu.KEY_MENU_NAME, Test.GENERAL_STRING); result.put(AddSubMenu.KEY_POSITION, Test.GENERAL_INT); + result.put(AddSubMenu.KEY_MENU_ICON, Test.JSON_IMAGE); }catch(JSONException e){ fail(Test.JSON_FAIL); } @@ -64,13 +68,16 @@ public class AddSubmenuTests extends BaseRpcTests{ int testMenuId = ( (AddSubMenu) msg ).getMenuID(); int testPosition = ( (AddSubMenu) msg ).getPosition(); String testMenuName = ( (AddSubMenu) msg ).getMenuName(); + Image testMenuIcon = ( (AddSubMenu) msg ).getMenuIcon(); // Valid Tests assertEquals("Menu ID didn't match input menu ID.", Test.GENERAL_INT, testMenuId); assertEquals("Menu name didn't match input menu name.", Test.GENERAL_STRING, testMenuName); assertEquals("Position didn't match input position.", Test.GENERAL_INT, testPosition); - - // Invalid/Null Tests + assertTrue("Menu icon didn't match input icon.", Validator.validateImage(Test.GENERAL_IMAGE, testMenuIcon)); + + + // Invalid/Null Tests AddSubMenu msg = new AddSubMenu(); assertNotNull("Null object creation failed.", msg); testNullBase(msg); @@ -78,6 +85,7 @@ public class AddSubmenuTests extends BaseRpcTests{ assertNull(Test.NULL, msg.getMenuID()); assertNull(Test.NULL, msg.getMenuName()); assertNull(Test.NULL, msg.getPosition()); + assertNull(Test.NULL, msg.getMenuIcon()); } /** @@ -103,6 +111,10 @@ public class AddSubmenuTests extends BaseRpcTests{ assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(parameters, AddSubMenu.KEY_MENU_ID), cmd.getMenuID()); assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(parameters, AddSubMenu.KEY_POSITION), cmd.getPosition()); assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(parameters, AddSubMenu.KEY_MENU_NAME), cmd.getMenuName()); + + JSONObject menuIcon = JsonUtils.readJsonObjectFromJsonObject(parameters, AddSubMenu.KEY_MENU_ICON); + Image referenceMenuIcon = new Image(JsonRPCMarshaller.deserializeJSONObject(menuIcon)); + assertTrue(Test.TRUE, Validator.validateImage(referenceMenuIcon, cmd.getMenuIcon())); } catch (JSONException e) { fail(Test.JSON_FAIL); } diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java index 8c38d5c87..7d25745d9 100644 --- a/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java +++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java @@ -4853,28 +4853,47 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> addCommand(commandID, null, null, null, vrCommands, correlationID);
}
-
-
+
/**
* Sends an AddSubMenu RPCRequest to SDL. Responses are captured through callback on IProxyListener.
- *
+ *
* @param menuID -Unique ID of the sub menu to add.
* @param menuName -Text to show in the menu for this sub menu.
* @param position -Position within the items that are are at top level of the in application menu.
+ * @param menuIcon -Image to be be shown along with the submenu item
* @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
* @throws SdlException if an unrecoverable error is encountered
*/
@SuppressWarnings("SameParameterValue")
public void addSubMenu(@NonNull Integer menuID, @NonNull String menuName,
- Integer position, Integer correlationID)
+ Integer position, Image menuIcon, Integer correlationID)
throws SdlException {
AddSubMenu msg = new AddSubMenu(menuID, menuName);
msg.setCorrelationID(correlationID);
msg.setPosition(position);
-
+ msg.setMenuIcon(menuIcon);
+
sendRPCRequest(msg);
}
+
+ /**
+ * Sends an AddSubMenu RPCRequest to SDL. Responses are captured through callback on IProxyListener.
+ *
+ * @param menuID -Unique ID of the sub menu to add.
+ * @param menuName -Text to show in the menu for this sub menu.
+ * @param position -Position within the items that are are at top level of the in application menu.
+ * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
+ * @throws SdlException if an unrecoverable error is encountered
+ */
+ @Deprecated
+ @SuppressWarnings("SameParameterValue")
+ public void addSubMenu(@NonNull Integer menuID, @NonNull String menuName,
+ Integer position, Integer correlationID)
+ throws SdlException {
+
+ addSubMenu(menuID, menuName, position, null, correlationID);
+ }
/**
* Sends an AddSubMenu RPCRequest to SDL. Responses are captured through callback on IProxyListener.
@@ -4884,11 +4903,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
* @throws SdlException if an unrecoverable error is encountered
*/
+ @Deprecated
@SuppressWarnings("unused")
public void addSubMenu(Integer menuID, String menuName,
Integer correlationID) throws SdlException {
- addSubMenu(menuID, menuName, null, correlationID);
+ addSubMenu(menuID, menuName, null, null, correlationID);
}
/*Begin V1 Enhanced helper*/
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/AddSubMenu.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/AddSubMenu.java index b61a28772..b4bd19473 100644 --- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/AddSubMenu.java +++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/AddSubMenu.java @@ -50,6 +50,14 @@ import java.util.Hashtable; * <td>maxlength:500</td>
* <td>SmartDeviceLink 1.0</td>
* </tr>
+ * <tr>
+ * <td>menuIcon</td>
+ * <td>Image</td>
+ * <td>Image to be be shown along with the submenu item</td>
+ * <td>N</td>
+ * <td></td>
+ * <td>SmartDeviceLink 4.6</td>
+ * </tr>
* </table>
* <b>Response</b>
* <p>Indicates that the corresponding request either failed or succeeded. If the response returns with a SUCCESS result code, this means the SubMenu was added to the Command Menu successfully</p>
@@ -66,6 +74,7 @@ public class AddSubMenu extends RPCRequest { public static final String KEY_POSITION = "position";
public static final String KEY_MENU_NAME = "menuName";
public static final String KEY_MENU_ID = "menuID";
+ public static final String KEY_MENU_ICON = "menuIcon";
/**
* Constructs a new AddSubMenu object
@@ -166,4 +175,21 @@ public class AddSubMenu extends RPCRequest { public void setMenuName( @NonNull String menuName ) {
setParameters(KEY_MENU_NAME, menuName);
}
+ /**
+ * Returns Image to be be shown along with the submenu item
+ *
+ * @return Image - the submenu icon
+ */
+ public Image getMenuIcon() {
+ return (Image) getObject(Image.class, KEY_MENU_ICON);
+ }
+ /**
+ * Sets image to be be shown along with the submenu item
+ *
+ * @param menuIcon
+ * Image to be be shown along with the submenu item
+ */
+ public void setMenuIcon(Image menuIcon) {
+ setParameters(KEY_MENU_ICON, menuIcon);
+ }
}
|