/* * Copyright (c) 2017 - 2020, SmartDeviceLink Consortium, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following * disclaimer in the documentation and/or other materials provided with the * distribution. * * Neither the name of the SmartDeviceLink Consortium Inc. nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ package com.smartdevicelink.proxy.rpc; import androidx.annotation.NonNull; import com.smartdevicelink.protocol.enums.FunctionID; import com.smartdevicelink.proxy.RPCRequest; import com.smartdevicelink.proxy.rpc.enums.MenuLayout; import java.util.Hashtable; /** *
Add a SubMenu to the Command Menu
* *A SubMenu can only be added to the Top Level Menu (i.e.a SubMenu cannot be * added to a SubMenu), and may only contain commands as children
* * *HMILevel needs to be FULL, LIMITED or BACKGROUND
* *Parameter List
*Param Name | *Type | *Description | *Req. | *Notes | *Version Available | *
---|---|---|---|---|---|
menuID | *Integer | *Unique ID that identifies this sub menu. This value is used in AddCommand to which SubMenu is the parent of the command being added. | *Y | ** | SmartDeviceLink 1.0 | *
position | *Integer | *Position within the items of the top level Command Menu. 0 will insert at the front, 1 will insert after the first existing element, etc. Position of any submenu will always be located before the return and exit options. | *N | *Min Value: 0 Max Value: 1000 If position is greater or equal than the number of items on top level, the sub menu will be appended by the end. If this parameter is omitted, the entry will be added at the end of the list. |
* SmartDeviceLink 1.0 | *
menuName | *String | *Text which is displayed representing this submenu item | *Y | *maxlength:500 | *SmartDeviceLink 1.0 | *
menuIcon | *Image | *Image to be be shown along with the submenu item | *N | ** | SmartDeviceLink 5.0 | *
menuLayout | *MenuLayout | *Sets the layout of the submenu screen. | *N | ** | SmartDeviceLink 6.0 | *
parentID | *Integer | *unique ID of the sub menu, the command will be added to. If not provided or 0, it will be provided to the top level of the in application menu. | *N | *Min Value: 0 Max Value: 2000000000 |
* SmartDeviceLink 7.0.0 | *
secondaryText | *String | *Optional secondary text to display | *N | *{"string_min_length": 1, "string_max_length": 500} | *SmartDeviceLink 7.1.0 | *
tertiaryText | *String | *Optional tertiary text to display | *N | *{"string_min_length": 1, "string_max_length": 500} | *SmartDeviceLink 7.1.0 | *
secondaryImage | *Image | *Optional secondary image struct for sub-menu cell | *N | ** | SmartDeviceLink 7.1.0 | *
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
* *Non-default Result Codes:
*INVALID_ID
*DUPLICATE NAME
* * @see DeleteSubMenu * @see AddCommand * @see DeleteCommand * @since SmartDeviceLink 1.0 */ 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"; public static final String KEY_MENU_LAYOUT = "menuLayout"; public static final String KEY_PARENT_ID = "parentID"; public static final String KEY_SECONDARY_TEXT = "secondaryText"; public static final String KEY_TERTIARY_TEXT = "tertiaryText"; public static final String KEY_SECONDARY_IMAGE = "secondaryImage"; /** * Constructs a new AddSubMenu object */ public AddSubMenu() { super(FunctionID.ADD_SUB_MENU.toString()); } /** * Constructs a new AddSubMenu object indicated by the Hashtable parameter * * @param hash The Hashtable to use */ public AddSubMenu(HashtableNotes: Min Value: 0; Max Value: 2000000000
* @param menuName String which will be displayed representing this submenu item */ public AddSubMenu(@NonNull Integer menuID, @NonNull String menuName) { this(); setMenuID(menuID); setMenuName(menuName); } /** * Returns an Integer object representing the Menu ID that identifies * a sub menu * * @return Integer -an integer representing the Menu ID that identifies a sub * menu */ public Integer getMenuID() { return getInteger(KEY_MENU_ID); } /** *Sets a Menu ID that identifies a sub menu.
This value is used in * {@linkplain AddCommand} to which SubMenu is the parent of the command * being added
* * @param menuID an integer object representing a Menu ID * *Notes: Min Value: 0; Max Value: 2000000000
*/ public AddSubMenu setMenuID(@NonNull Integer menuID) { setParameters(KEY_MENU_ID, menuID); return this; } /** *Returns an Integer object representing the position of menu
* * @return Integer -the value representing the relative position of menus */ public Integer getPosition() { return getInteger(KEY_POSITION); } /** * Sets a position of menu * * @param positionAn Integer object representing the position within the items * of the top level Command Menu. 0 will insert at the front, 1 * will insert after the first existing element, etc. Position of * any submenu will always be located before the return and exit * options *
* Notes: *