diff options
author | Bilal Alsharifi <599206+bilal-alsharifi@users.noreply.github.com> | 2019-07-23 12:53:15 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-23 12:53:15 -0400 |
commit | c992ba06a61d61882c800707c30c18b2f37c40c5 (patch) | |
tree | 022bfaeb40a4d9da5032e994ec4900274d13fd1d | |
parent | b34a4e1f4fc38c8d2994dc9398dceac86a68683d (diff) | |
parent | 4802626ac319c6b75eb6a5c6e871c70e9d01d2d3 (diff) | |
download | sdl_android-c992ba06a61d61882c800707c30c18b2f37c40c5.tar.gz |
Merge pull request #1117 from smartdevicelink/feature/Implement_sdl_0231_main_menu_tiles
Implement SDL 0231 Main Menu Tiles
19 files changed, 674 insertions, 81 deletions
diff --git a/android/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlService.java b/android/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlService.java index ada04a703..9ad06490a 100755 --- a/android/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlService.java +++ b/android/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlService.java @@ -32,6 +32,7 @@ import com.smartdevicelink.proxy.rpc.enums.AppHMIType; import com.smartdevicelink.proxy.rpc.enums.FileType; import com.smartdevicelink.proxy.rpc.enums.HMILevel; import com.smartdevicelink.proxy.rpc.enums.InteractionMode; +import com.smartdevicelink.proxy.rpc.enums.MenuLayout; import com.smartdevicelink.proxy.rpc.enums.TriggerSource; import com.smartdevicelink.proxy.rpc.listeners.OnRPCNotificationListener; import com.smartdevicelink.transport.BaseTransportConfig; @@ -270,7 +271,7 @@ public class SdlService extends Service { }); // sub menu parent cell - MenuCell mainCell3 = new MenuCell("Test Cell 3 (sub menu)", null, Arrays.asList(subCell1,subCell2)); + MenuCell mainCell3 = new MenuCell("Test Cell 3 (sub menu)", MenuLayout.LIST, null, Arrays.asList(subCell1,subCell2)); MenuCell mainCell4 = new MenuCell("Show Perform Interaction", null, null, new MenuSelectionListener() { @Override diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/ScreenManagerTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/ScreenManagerTests.java index c4e22af6f..3ca13bc0f 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/ScreenManagerTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/ScreenManagerTests.java @@ -25,7 +25,7 @@ public class ScreenManagerTests extends AndroidTestCase2 { private SdlArtwork testArtwork; @Override - public void setUp() throws Exception{ + public void setUp() throws Exception { super.setUp(); ISdl internalInterface = mock(ISdl.class); @@ -60,6 +60,7 @@ public class ScreenManagerTests extends AndroidTestCase2 { assertNull(screenManager.getSoftButtonObjectById(1)); assertEquals(screenManager.getDynamicMenuUpdatesMode(), DynamicMenuUpdatesMode.ON_WITH_COMPAT_MODE); assertEquals(screenManager.getState(), BaseSubManager.READY); + assertNotNull(screenManager.getMenuConfiguration()); } public void testSetTextField() { @@ -120,9 +121,12 @@ public class ScreenManagerTests extends AndroidTestCase2 { public void testSetMenuManagerFields(){ screenManager.setDynamicMenuUpdatesMode(DynamicMenuUpdatesMode.FORCE_ON); screenManager.setMenu(Test.GENERAL_MENUCELL_LIST); + screenManager.setMenuConfiguration(Test.GENERAL_MENU_CONFIGURATION); assertEquals(screenManager.getMenu(), Test.GENERAL_MENUCELL_LIST); assertEquals(screenManager.getDynamicMenuUpdatesMode(), DynamicMenuUpdatesMode.FORCE_ON); + // Should not set because of improper RAI response and improper HMI states + assertNotNull(screenManager.getMenuConfiguration()); } public void testSetVoiceCommands(){ diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/menu/MenuCellTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/menu/MenuCellTests.java index 9699a3899..6aa9b479a 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/menu/MenuCellTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/menu/MenuCellTests.java @@ -33,6 +33,7 @@ package com.smartdevicelink.managers.screen.menu; import com.smartdevicelink.AndroidTestCase2; +import com.smartdevicelink.proxy.rpc.enums.MenuLayout; import com.smartdevicelink.proxy.rpc.enums.TriggerSource; import com.smartdevicelink.test.Test; @@ -63,6 +64,7 @@ public class MenuCellTests extends AndroidTestCase2 { menuCell.setIcon(Test.GENERAL_ARTWORK); menuCell.setVoiceCommands(Test.GENERAL_STRING_LIST); menuCell.setMenuSelectionListener(menuSelectionListener); + menuCell.setSubMenuLayout(Test.GENERAL_MENU_LAYOUT); // use getters and assert equality assertEquals(menuCell.getTitle(), Test.GENERAL_STRING); @@ -71,6 +73,7 @@ public class MenuCellTests extends AndroidTestCase2 { assertEquals(menuCell.getMenuSelectionListener(), menuSelectionListener); assertEquals(menuCell.getCellId(), Test.GENERAL_MENU_MAX_ID); assertEquals(menuCell.getParentCellId(), Test.GENERAL_MENU_MAX_ID); + assertEquals(menuCell.getSubMenuLayout(), Test.GENERAL_MENU_LAYOUT); } public void testConstructors(){ @@ -86,6 +89,12 @@ public class MenuCellTests extends AndroidTestCase2 { MenuCell menuCell4 =new MenuCell(Test.GENERAL_STRING,null, null, menuSelectionListener); assertEquals(menuCell4.getTitle(), Test.GENERAL_STRING); assertEquals(menuCell4.getMenuSelectionListener(), menuSelectionListener); + + MenuCell menuCell5 = new MenuCell(Test.GENERAL_STRING, Test.GENERAL_MENU_LAYOUT, Test.GENERAL_ARTWORK, Test.GENERAL_MENUCELL_LIST); + assertEquals(menuCell5.getTitle(), Test.GENERAL_STRING); + assertEquals(menuCell5.getIcon(), Test.GENERAL_ARTWORK); + assertEquals(menuCell5.getSubMenuLayout(), Test.GENERAL_MENU_LAYOUT); + assertEquals(menuCell5.getSubCells(), Test.GENERAL_MENUCELL_LIST); } public void testEquality(){ diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/menu/MenuConfigurationTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/menu/MenuConfigurationTests.java new file mode 100644 index 000000000..62f6ccb92 --- /dev/null +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/menu/MenuConfigurationTests.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2019 Livio, 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 Livio 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. + * + * Created by brettywhite on 7/18/19 3:36 PM + * + */ + +package com.smartdevicelink.managers.screen.menu; + +import com.smartdevicelink.AndroidTestCase2; +import com.smartdevicelink.test.Test; + +public class MenuConfigurationTests extends AndroidTestCase2 { + + + @Override + public void setUp() throws Exception{ + super.setUp(); + } + + @Override + public void tearDown() throws Exception { + super.tearDown(); + } + + public void testSettersAndGetters(){ + + // set everything - we only use the constructor to set variables in the Menu Manager + MenuConfiguration menuConfiguration = new MenuConfiguration(Test.GENERAL_MENU_LAYOUT, Test.GENERAL_MENU_LAYOUT); + + // use getters and assert equality + assertEquals(menuConfiguration.getMenuLayout(), Test.GENERAL_MENU_LAYOUT); + assertEquals(menuConfiguration.getSubMenuLayout(), Test.GENERAL_MENU_LAYOUT); + } +} 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 73581cab4..d06d96bdc 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 @@ -39,11 +39,16 @@ import com.smartdevicelink.managers.CompletionListener; import com.smartdevicelink.managers.file.FileManager; import com.smartdevicelink.managers.file.filetypes.SdlArtwork; import com.smartdevicelink.protocol.enums.FunctionID; +import com.smartdevicelink.proxy.RPCRequest; +import com.smartdevicelink.proxy.RPCResponse; import com.smartdevicelink.proxy.interfaces.ISdl; import com.smartdevicelink.proxy.rpc.OnCommand; import com.smartdevicelink.proxy.rpc.OnHMIStatus; +import com.smartdevicelink.proxy.rpc.SdlMsgVersion; +import com.smartdevicelink.proxy.rpc.SetGlobalProperties; import com.smartdevicelink.proxy.rpc.enums.FileType; import com.smartdevicelink.proxy.rpc.enums.HMILevel; +import com.smartdevicelink.proxy.rpc.enums.MenuLayout; import com.smartdevicelink.proxy.rpc.enums.SystemContext; import com.smartdevicelink.proxy.rpc.enums.TriggerSource; import com.smartdevicelink.proxy.rpc.listeners.OnRPCNotificationListener; @@ -80,7 +85,7 @@ public class MenuManagerTests extends AndroidTestCase2 { cells = createTestCells(); - ISdl internalInterface = mock(ISdl.class); + final ISdl internalInterface = mock(ISdl.class); FileManager fileManager = mock(FileManager.class); // When internalInterface.addOnRPCNotificationListener(FunctionID.ON_HMI_STATUS, OnRPCNotificationListener) is called @@ -106,6 +111,19 @@ public class MenuManagerTests extends AndroidTestCase2 { }; doAnswer(onCommandAnswer).when(internalInterface).addOnRPCNotificationListener(eq(FunctionID.ON_COMMAND), any(OnRPCNotificationListener.class)); + Answer<Void> answer = new Answer<Void>() { + @Override + public Void answer(InvocationOnMock invocation) { + Object[] args = invocation.getArguments(); + RPCRequest request = (RPCRequest) args[0]; + RPCResponse response = new RPCResponse(FunctionID.SET_GLOBAL_PROPERTIES.toString()); + response.setSuccess(true); + request.getOnRPCResponseListener().onResponse(0, response); + return null; + } + }; + doAnswer(answer).when(internalInterface).sendRPC(any(SetGlobalProperties.class)); + menuManager = new MenuManager(internalInterface, fileManager); // Check some stuff during setup @@ -120,6 +138,7 @@ public class MenuManagerTests extends AndroidTestCase2 { assertNull(menuManager.inProgressUpdate); assertNull(menuManager.keepsNew); assertNull(menuManager.keepsOld); + assertNotNull(menuManager.menuConfiguration); assertNotNull(menuManager.hmiListener); assertNotNull(menuManager.commandListener); assertNotNull(menuManager.displayListener); @@ -142,6 +161,7 @@ public class MenuManagerTests extends AndroidTestCase2 { assertNull(menuManager.waitingUpdateMenuCells); assertNull(menuManager.keepsNew); assertNull(menuManager.keepsOld); + assertNull(menuManager.menuConfiguration); // after everything, make sure we are in the correct state assertEquals(menuManager.getState(), BaseSubManager.SHUTDOWN); @@ -425,6 +445,16 @@ public class MenuManagerTests extends AndroidTestCase2 { assertEquals(menuManager.menuCells.size(), 0); } + public void testSetMenuConfiguration(){ + menuManager.currentHMILevel = HMILevel.HMI_FULL; + menuManager.currentSystemContext = SystemContext.SYSCTXT_MAIN; + menuManager.sdlMsgVersion = new SdlMsgVersion(6,0); + + MenuConfiguration menuConfigurationTest = new MenuConfiguration(MenuLayout.LIST, MenuLayout.LIST); + menuManager.setMenuConfiguration(menuConfigurationTest); + assertEquals(menuManager.menuConfiguration, menuConfigurationTest); + } + // HELPERS // Emulate what happens when Core sends OnHMIStatus notification @@ -459,7 +489,7 @@ public class MenuManagerTests extends AndroidTestCase2 { MenuCell subCell1 = new MenuCell("SubCell 1",null, null, menuSelectionListenerSub1); MenuCell subCell2 = new MenuCell("SubCell 2",null, null, menuSelectionListenerSub2); - mainCell4 = new MenuCell("Test Cell 4", livio, Arrays.asList(subCell1,subCell2)); // sub menu parent cell + mainCell4 = new MenuCell("Test Cell 4", MenuLayout.LIST, livio, Arrays.asList(subCell1,subCell2)); // sub menu parent cell return Arrays.asList(mainCell1, mainCell2, mainCell3, mainCell4); } diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/Test.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/Test.java index e6a005e8c..9669daf83 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/Test.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/Test.java @@ -8,6 +8,7 @@ import com.smartdevicelink.managers.file.filetypes.SdlArtwork; import com.smartdevicelink.managers.lockscreen.LockScreenConfig; import com.smartdevicelink.managers.screen.choiceset.ChoiceCell; import com.smartdevicelink.managers.screen.menu.MenuCell; +import com.smartdevicelink.managers.screen.menu.MenuConfiguration; import com.smartdevicelink.managers.screen.menu.MenuSelectionListener; import com.smartdevicelink.managers.screen.menu.VoiceCommand; import com.smartdevicelink.managers.screen.menu.VoiceCommandSelectionListener; @@ -149,6 +150,7 @@ import com.smartdevicelink.proxy.rpc.enums.MassageMode; import com.smartdevicelink.proxy.rpc.enums.MassageZone; import com.smartdevicelink.proxy.rpc.enums.MediaClockFormat; import com.smartdevicelink.proxy.rpc.enums.MediaType; +import com.smartdevicelink.proxy.rpc.enums.MenuLayout; import com.smartdevicelink.proxy.rpc.enums.MetadataType; import com.smartdevicelink.proxy.rpc.enums.ModuleType; import com.smartdevicelink.proxy.rpc.enums.NavigationAction; @@ -399,6 +401,8 @@ public class Test { public static final LightControlData GENERAL_LIGHTCONTROLDATA = new LightControlData(); public static final HMISettingsControlData GENERAL_HMISETTINGSCONTROLDATA = new HMISettingsControlData(); public static final SdlArtwork GENERAL_ARTWORK = new SdlArtwork("sdl", FileType.GRAPHIC_PNG, R.drawable.ic_sdl, false); + public static final MenuLayout GENERAL_MENU_LAYOUT = MenuLayout.LIST; + public static final MenuConfiguration GENERAL_MENU_CONFIGURATION = new MenuConfiguration(GENERAL_MENU_LAYOUT, GENERAL_MENU_LAYOUT); public static final HMICapabilities GENERAL_HMICAPABILITIES = new HMICapabilities(); @@ -456,6 +460,7 @@ public class Test { public static final List<WeatherAlert> GENERAL_WEATHERALERT_LIST = Arrays.asList(GENERAL_WEATHERALERT); public static final List<NavigationInstruction> GENERAL_NAVIGATION_INSTRUCTION_LIST = Arrays.asList(GENERAL_NAVIGATION_INSTRUCTION); public static final List<Integer> GENERAL_AVAILABLE_HD_CHANNELS_LIST = Arrays.asList(new Integer[]{ 1, 2}); + public static final List<MenuLayout> GENERAL_MENU_LAYOUT_LIST = Arrays.asList(MenuLayout.LIST, MenuLayout.TILES); public static final int GENERAL_MENU_MAX_ID = 2000000000; public static final MenuCell GENERAL_MENUCELL = new MenuCell(GENERAL_STRING,null, null, new MenuSelectionListener() { @Override diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/DisplayCapabilitiesTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/DisplayCapabilitiesTests.java index f7fcb45e3..742c4d03d 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/DisplayCapabilitiesTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/DisplayCapabilitiesTests.java @@ -7,6 +7,7 @@ import com.smartdevicelink.proxy.rpc.ScreenParams; import com.smartdevicelink.proxy.rpc.TextField; import com.smartdevicelink.proxy.rpc.enums.DisplayType; import com.smartdevicelink.proxy.rpc.enums.MediaClockFormat; +import com.smartdevicelink.proxy.rpc.enums.MenuLayout; import com.smartdevicelink.test.JsonUtils; import com.smartdevicelink.test.Test; import com.smartdevicelink.test.Validator; @@ -23,7 +24,7 @@ import java.util.List; /** * This is a unit test class for the SmartDeviceLink library project class : - * {@link com.smartdevicelink.rpc.DisplayCapabilities} + * {@link com.smartdevicelink.proxy.rpc.DisplayCapabilities} */ public class DisplayCapabilitiesTests extends TestCase{ @@ -42,6 +43,7 @@ public class DisplayCapabilitiesTests extends TestCase{ msg.setMediaClockFormats(Test.GENERAL_MEDIACLOCKFORMAT_LIST); msg.setScreenParams(Test.GENERAL_SCREENPARAMS); msg.setTemplatesAvailable(Test.GENERAL_STRING_LIST); + msg.setMenuLayoutsAvailable(Test.GENERAL_MENU_LAYOUT_LIST); } /** @@ -58,6 +60,7 @@ public class DisplayCapabilitiesTests extends TestCase{ List<MediaClockFormat> mediaClock = msg.getMediaClockFormats(); List<TextField> textFields = msg.getTextFields(); List<ImageField> imageFields = msg.getImageFields(); + List<MenuLayout> menuLayouts = msg.getMenuLayoutsAvailable(); // Valid Tests assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, graphicSupported); @@ -69,6 +72,7 @@ public class DisplayCapabilitiesTests extends TestCase{ assertEquals(Test.MATCH, Test.GENERAL_MEDIACLOCKFORMAT_LIST.size(), mediaClock.size()); assertEquals(Test.MATCH, Test.GENERAL_TEXTFIELD_LIST.size(), textFields.size()); assertEquals(Test.MATCH, Test.GENERAL_IMAGEFIELD_LIST.size(), imageFields.size()); + assertEquals(Test.MATCH, Test.GENERAL_MENU_LAYOUT_LIST.size(), menuLayouts.size()); for(int i = 0; i < Test.GENERAL_STRING_LIST.size(); i++){ assertEquals(Test.MATCH, Test.GENERAL_STRING_LIST.get(i), templatesAvailable.get(i)); @@ -85,6 +89,10 @@ public class DisplayCapabilitiesTests extends TestCase{ for(int i = 0; i < Test.GENERAL_IMAGEFIELD_LIST.size(); i++){ assertTrue(Test.TRUE, Validator.validateImageFields(Test.GENERAL_IMAGEFIELD_LIST.get(i), imageFields.get(i))); } + + for(int i = 0; i < Test.GENERAL_MENU_LAYOUT_LIST.size(); i++){ + assertEquals(Test.MATCH, Test.GENERAL_MENU_LAYOUT_LIST.get(i), menuLayouts.get(i)); + } // Invalid/Null Tests DisplayCapabilities msg = new DisplayCapabilities(); @@ -99,6 +107,7 @@ public class DisplayCapabilitiesTests extends TestCase{ assertNull(Test.NULL, msg.getScreenParams()); assertNull(Test.NULL, msg.getTemplatesAvailable()); assertNull(Test.NULL, msg.getTextFields()); + assertNull(Test.NULL, msg.getMenuLayoutsAvailable()); } public void testJson(){ @@ -114,6 +123,7 @@ public class DisplayCapabilitiesTests extends TestCase{ reference.put(DisplayCapabilities.KEY_TEXT_FIELDS, Test.JSON_TEXTFIELDS); reference.put(DisplayCapabilities.KEY_IMAGE_FIELDS, Test.JSON_IMAGEFIELDS); reference.put(DisplayCapabilities.KEY_SCREEN_PARAMS, Test.JSON_SCREENPARAMS); + reference.put(DisplayCapabilities.KEY_MENU_LAYOUTS_AVAILABLE, JsonUtils.createJsonArray(Test.GENERAL_MENU_LAYOUT_LIST)); JSONObject underTest = msg.serializeJSON(); assertEquals(Test.MATCH, reference.length(), underTest.length()); @@ -153,7 +163,7 @@ public class DisplayCapabilitiesTests extends TestCase{ Hashtable<String, Object> hashTest= JsonRPCMarshaller.deserializeJSONObject(underTestArray); assertTrue(Test.TRUE, Validator.validateScreenParams(new ScreenParams(hashReference), new ScreenParams(hashTest))); - } else if(key.equals(DisplayCapabilities.KEY_MEDIA_CLOCK_FORMATS)){ + } else if(key.equals(DisplayCapabilities.KEY_MEDIA_CLOCK_FORMATS) || key.equals(DisplayCapabilities.KEY_MENU_LAYOUTS_AVAILABLE)){ JSONArray referenceArray = JsonUtils.readJsonArrayFromJsonObject(reference, key); JSONArray underTestArray = JsonUtils.readJsonArrayFromJsonObject(underTest, key); assertEquals(Test.MATCH, referenceArray.length(), underTestArray.length()); diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/MenuLayoutTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/MenuLayoutTests.java new file mode 100644 index 000000000..f92de1f94 --- /dev/null +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/MenuLayoutTests.java @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2019 Livio, 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 Livio 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. + * + * Created by brettywhite on 7/17/19 12:04 PM + * + */ + +package com.smartdevicelink.test.rpc.enums; + +import com.smartdevicelink.proxy.rpc.enums.MenuLayout; + +import junit.framework.TestCase; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class MenuLayoutTests extends TestCase { + + /** + * Verifies that the enum values are not null upon valid assignment. + */ + public void testValidEnums() { + String example = "LIST"; + MenuLayout enumList = MenuLayout.valueForString(example); + example = "TILES"; + MenuLayout enumTiles = MenuLayout.valueForString(example); + + assertNotNull("LIST returned null", enumList); + assertNotNull("TILES returned null", enumTiles); + } + + /** + * Verifies that an invalid assignment is null. + */ + public void testInvalidEnum() { + String example = "TooLs"; + try { + MenuLayout temp = MenuLayout.valueForString(example); + assertNull("Result of valueForString should be null.", temp); + } catch (IllegalArgumentException exception) { + fail("Invalid enum throws IllegalArgumentException."); + } + } + + /** + * Verifies that a null assignment is invalid. + */ + public void testNullEnum() { + String example = null; + try { + MenuLayout temp = MenuLayout.valueForString(example); + assertNull("Result of valueForString should be null.", temp); + } catch (NullPointerException exception) { + fail("Null string throws NullPointerException."); + } + } + + /** + * Verifies the possible enum values of MenuLayout. + */ + public void testListEnum() { + List<MenuLayout> enumValueList = Arrays.asList(MenuLayout.values()); + + List<MenuLayout> enumTestList = new ArrayList<>(); + enumTestList.add(MenuLayout.LIST); + enumTestList.add(MenuLayout.TILES); + + assertTrue("Enum value list does not match enum class list", + enumValueList.containsAll(enumTestList) && enumTestList.containsAll(enumValueList)); + } +}
\ No newline at end of file diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/AddSubmenuTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/AddSubmenuTests.java index 4ba991c44..2ea3d2079 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/AddSubmenuTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/AddSubmenuTests.java @@ -5,6 +5,7 @@ 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.proxy.rpc.enums.MenuLayout; import com.smartdevicelink.test.BaseRpcTests; import com.smartdevicelink.test.JsonUtils; import com.smartdevicelink.test.Test; @@ -30,6 +31,7 @@ public class AddSubmenuTests extends BaseRpcTests{ msg.setMenuName(Test.GENERAL_STRING); msg.setPosition(Test.GENERAL_INT); msg.setMenuIcon(Test.GENERAL_IMAGE); + msg.setMenuLayout(Test.GENERAL_MENU_LAYOUT); return msg; } @@ -53,6 +55,7 @@ public class AddSubmenuTests extends BaseRpcTests{ 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); + result.put(AddSubMenu.KEY_MENU_LAYOUT, Test.GENERAL_MENU_LAYOUT); }catch(JSONException e){ fail(Test.JSON_FAIL); } @@ -69,12 +72,14 @@ public class AddSubmenuTests extends BaseRpcTests{ int testPosition = ( (AddSubMenu) msg ).getPosition(); String testMenuName = ( (AddSubMenu) msg ).getMenuName(); Image testMenuIcon = ( (AddSubMenu) msg ).getMenuIcon(); + MenuLayout testMenuLayout = ( (AddSubMenu) msg ).getMenuLayout(); // 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); assertTrue("Menu icon didn't match input icon.", Validator.validateImage(Test.GENERAL_IMAGE, testMenuIcon)); + assertEquals("Menu layout didn't match input menu layout.", Test.GENERAL_MENU_LAYOUT, testMenuLayout); // Invalid/Null Tests @@ -86,6 +91,7 @@ public class AddSubmenuTests extends BaseRpcTests{ assertNull(Test.NULL, msg.getMenuName()); assertNull(Test.NULL, msg.getPosition()); assertNull(Test.NULL, msg.getMenuIcon()); + assertNull(Test.NULL, msg.getMenuLayout()); } /** @@ -111,10 +117,11 @@ 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()); + assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(parameters, AddSubMenu.KEY_MENU_LAYOUT), cmd.getMenuLayout()); - JSONObject menuIcon = JsonUtils.readJsonObjectFromJsonObject(parameters, AddSubMenu.KEY_MENU_ICON); - Image referenceMenuIcon = new Image(JsonRPCMarshaller.deserializeJSONObject(menuIcon)); - assertTrue(Test.TRUE, Validator.validateImage(referenceMenuIcon, cmd.getMenuIcon())); + 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/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SetGlobalPropertiesTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SetGlobalPropertiesTests.java index 969ae9522..1ca333e73 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SetGlobalPropertiesTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SetGlobalPropertiesTests.java @@ -8,6 +8,7 @@ import com.smartdevicelink.proxy.rpc.KeyboardProperties; import com.smartdevicelink.proxy.rpc.SetGlobalProperties; import com.smartdevicelink.proxy.rpc.TTSChunk; import com.smartdevicelink.proxy.rpc.VrHelpItem; +import com.smartdevicelink.proxy.rpc.enums.MenuLayout; import com.smartdevicelink.test.BaseRpcTests; import com.smartdevicelink.test.JsonUtils; import com.smartdevicelink.test.Test; @@ -24,7 +25,7 @@ import java.util.List; /** * This is a unit test class for the SmartDeviceLink library project class : - * {@link com.smartdevicelink.rpc.SetGlobalProperties} + * {@link com.smartdevicelink.proxy.rpc.SetGlobalProperties} */ public class SetGlobalPropertiesTests extends BaseRpcTests { @@ -39,6 +40,7 @@ public class SetGlobalPropertiesTests extends BaseRpcTests { msg.setHelpPrompt(Test.GENERAL_TTSCHUNK_LIST); msg.setTimeoutPrompt(Test.GENERAL_TTSCHUNK_LIST); msg.setKeyboardProperties(Test.GENERAL_KEYBOARDPROPERTIES); + msg.setMenuLayout(Test.GENERAL_MENU_LAYOUT); return msg; } @@ -64,7 +66,8 @@ public class SetGlobalPropertiesTests extends BaseRpcTests { result.put(SetGlobalProperties.KEY_TIMEOUT_PROMPT, Test.JSON_TTSCHUNKS); result.put(SetGlobalProperties.KEY_MENU_TITLE, Test.GENERAL_STRING); result.put(SetGlobalProperties.KEY_VR_HELP_TITLE, Test.GENERAL_STRING); - result.put(SetGlobalProperties.KEY_KEYBOARD_PROPERTIES, Test.JSON_KEYBOARDPROPERTIES); + result.put(SetGlobalProperties.KEY_KEYBOARD_PROPERTIES, Test.JSON_KEYBOARDPROPERTIES); + result.put(SetGlobalProperties.KEY_MENU_LAYOUT, Test.GENERAL_MENU_LAYOUT); } catch (JSONException e) { fail(Test.JSON_FAIL); } @@ -84,6 +87,7 @@ public class SetGlobalPropertiesTests extends BaseRpcTests { List<TTSChunk> testTimeout = ( (SetGlobalProperties) msg ).getTimeoutPrompt(); List<VrHelpItem> testVrHelpItems = ( (SetGlobalProperties) msg ).getVrHelp(); KeyboardProperties testKeyboardProperties = ( (SetGlobalProperties) msg ).getKeyboardProperties(); + MenuLayout testMenuLayout = ( (SetGlobalProperties) msg ).getMenuLayout(); // Valid Tests assertEquals(Test.MATCH, Test.GENERAL_STRING, testMenuTitle); @@ -93,6 +97,7 @@ public class SetGlobalPropertiesTests extends BaseRpcTests { assertTrue(Test.TRUE, Validator.validateTtsChunks(Test.GENERAL_TTSCHUNK_LIST, testHelpPrompt)); assertTrue(Test.TRUE, Validator.validateTtsChunks(Test.GENERAL_TTSCHUNK_LIST, testTimeout)); assertTrue(Test.TRUE, Validator.validateKeyboardProperties(Test.GENERAL_KEYBOARDPROPERTIES, testKeyboardProperties)); + assertEquals(Test.MATCH, Test.GENERAL_MENU_LAYOUT, testMenuLayout); // Invalid/Null Tests SetGlobalProperties msg = new SetGlobalProperties(); @@ -106,6 +111,7 @@ public class SetGlobalPropertiesTests extends BaseRpcTests { assertNull(Test.NULL, msg.getTimeoutPrompt()); assertNull(Test.NULL, msg.getKeyboardProperties()); assertNull(Test.NULL, msg.getVrHelpTitle()); + assertNull(Test.NULL, msg.getMenuLayout()); } /** @@ -129,6 +135,8 @@ public class SetGlobalPropertiesTests extends BaseRpcTests { JSONObject parameters = JsonUtils.readJsonObjectFromJsonObject(body, RPCMessage.KEY_PARAMETERS); assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(parameters, SetGlobalProperties.KEY_VR_HELP_TITLE), cmd.getVrHelpTitle()); assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(parameters, SetGlobalProperties.KEY_MENU_TITLE), cmd.getMenuTitle()); + + assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(parameters, SetGlobalProperties.KEY_MENU_LAYOUT), cmd.getMenuLayout()); JSONObject menuIcon = JsonUtils.readJsonObjectFromJsonObject(parameters, SetGlobalProperties.KEY_MENU_ICON); Image referenceMenuIcon = new Image(JsonRPCMarshaller.deserializeJSONObject(menuIcon)); diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/BaseScreenManager.java b/base/src/main/java/com/smartdevicelink/managers/screen/BaseScreenManager.java index cc33bae86..b6a2effa5 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/BaseScreenManager.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/BaseScreenManager.java @@ -45,6 +45,7 @@ import com.smartdevicelink.managers.screen.choiceset.ChoiceSetManager; import com.smartdevicelink.managers.screen.choiceset.KeyboardListener; import com.smartdevicelink.managers.screen.menu.DynamicMenuUpdatesMode; import com.smartdevicelink.managers.screen.menu.MenuCell; +import com.smartdevicelink.managers.screen.menu.MenuConfiguration; import com.smartdevicelink.managers.screen.menu.MenuManager; import com.smartdevicelink.managers.screen.menu.VoiceCommand; import com.smartdevicelink.managers.screen.menu.VoiceCommandManager; @@ -425,6 +426,22 @@ abstract class BaseScreenManager extends BaseSubManager { return this.menuManager.getDynamicMenuUpdatesMode(); } + /** + * The main menu layout. See available menu layouts on DisplayCapabilities.menuLayoutsAvailable. Defaults to LIST. + * @param menuConfiguration - The default menuConfiguration + */ + public void setMenuConfiguration(@NonNull MenuConfiguration menuConfiguration) { + this.menuManager.setMenuConfiguration(menuConfiguration); + } + + /** + * The main menu layout. See available menu layouts on DisplayCapabilities.menuLayoutsAvailable. Defaults to LIST. + * @return the currently set MenuConfiguration + */ + public MenuConfiguration getMenuConfiguration(){ + return this.menuManager.getMenuConfiguration(); + } + // CHOICE SETS /** diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/menu/BaseMenuManager.java b/base/src/main/java/com/smartdevicelink/managers/screen/menu/BaseMenuManager.java index 140e4cacc..f9be78036 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/menu/BaseMenuManager.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/menu/BaseMenuManager.java @@ -54,14 +54,18 @@ import com.smartdevicelink.proxy.rpc.ImageField; import com.smartdevicelink.proxy.rpc.MenuParams; import com.smartdevicelink.proxy.rpc.OnCommand; import com.smartdevicelink.proxy.rpc.OnHMIStatus; +import com.smartdevicelink.proxy.rpc.SdlMsgVersion; +import com.smartdevicelink.proxy.rpc.SetGlobalProperties; import com.smartdevicelink.proxy.rpc.enums.DisplayType; import com.smartdevicelink.proxy.rpc.enums.HMILevel; import com.smartdevicelink.proxy.rpc.enums.ImageFieldName; +import com.smartdevicelink.proxy.rpc.enums.MenuLayout; import com.smartdevicelink.proxy.rpc.enums.Result; import com.smartdevicelink.proxy.rpc.enums.SystemCapabilityType; import com.smartdevicelink.proxy.rpc.enums.SystemContext; import com.smartdevicelink.proxy.rpc.listeners.OnMultipleRequestListener; import com.smartdevicelink.proxy.rpc.listeners.OnRPCNotificationListener; +import com.smartdevicelink.proxy.rpc.listeners.OnRPCResponseListener; import com.smartdevicelink.util.DebugTool; import org.json.JSONException; @@ -83,6 +87,8 @@ abstract class BaseMenuManager extends BaseSubManager { List<MenuCell> menuCells, waitingUpdateMenuCells, oldMenuCells, keepsNew, keepsOld; List<RPCRequest> inProgressUpdate; DynamicMenuUpdatesMode dynamicMenuUpdatesMode; + MenuConfiguration menuConfiguration; + SdlMsgVersion sdlMsgVersion; private DisplayType displayType; boolean waitingOnHMIUpdate; @@ -110,6 +116,9 @@ abstract class BaseMenuManager extends BaseSubManager { currentHMILevel = HMILevel.HMI_NONE; lastMenuId = menuCellIdMin; dynamicMenuUpdatesMode = DynamicMenuUpdatesMode.ON_WITH_COMPAT_MODE; + sdlMsgVersion = internalInterface.getSdlMsgVersion(); + // default menu configuration + menuConfiguration = new MenuConfiguration(MenuLayout.LIST, MenuLayout.LIST); addListeners(); } @@ -136,6 +145,8 @@ abstract class BaseMenuManager extends BaseSubManager { waitingUpdateMenuCells = null; keepsNew = null; keepsOld = null; + menuConfiguration = null; + sdlMsgVersion = null; // remove listeners internalInterface.removeOnRPCNotificationListener(FunctionID.ON_HMI_STATUS, hmiListener); @@ -245,6 +256,54 @@ abstract class BaseMenuManager extends BaseSubManager { return this.dynamicMenuUpdatesMode; } + /** + * This method is called via the screen manager to set the menuConfiguration. + * This will be used when a menu item with sub-cells has a null value for menuConfiguration + * @param menuConfiguration - The default menuConfiguration + */ + public void setMenuConfiguration(@NonNull final MenuConfiguration menuConfiguration) { + + if (sdlMsgVersion == null) { + DebugTool.logError("SDL Message Version is null. Cannot set Menu Configuration"); + return; + } + + if (sdlMsgVersion.getMajorVersion() < 6){ + DebugTool.logWarning("Menu configurations is only supported on head units with RPC spec version 6.0.0 or later. Currently connected head unit RPC spec version is: "+sdlMsgVersion.getMajorVersion() + "." + sdlMsgVersion.getMinorVersion()+ "." +sdlMsgVersion.getPatchVersion()); + return; + } + + if (currentHMILevel == null || currentHMILevel.equals(HMILevel.HMI_NONE) || currentSystemContext.equals(SystemContext.SYSCTXT_MENU)){ + // We are in NONE or the menu is in use, bail out of here + DebugTool.logError("Could not set main menu configuration, HMI level: "+currentHMILevel+", required: 'Not-NONE', system context: "+currentSystemContext+", required: 'Not MENU'"); + return; + } + + // In the future, when the manager is switched to use queues, the menuConfiguration should be set when SetGlobalProperties response is received + this.menuConfiguration = menuConfiguration; + + SetGlobalProperties setGlobalProperties = new SetGlobalProperties(); + setGlobalProperties.setMenuLayout(menuConfiguration.getMenuLayout()); + setGlobalProperties.setOnRPCResponseListener(new OnRPCResponseListener() { + @Override + public void onResponse(int correlationId, RPCResponse response) { + if (response.getSuccess()){ + DebugTool.logInfo("Menu Configuration successfully set: "+ menuConfiguration.toString()); + } + } + + @Override + public void onError(int correlationId, Result resultCode, String info){ + DebugTool.logError("onError: "+ resultCode+ " | Info: "+ info ); + } + }); + internalInterface.sendRPC(setGlobalProperties); + } + + public MenuConfiguration getMenuConfiguration(){ + return this.menuConfiguration; + } + // UPDATING SYSTEM // ROOT MENU @@ -826,6 +885,7 @@ abstract class BaseMenuManager extends BaseSubManager { private AddSubMenu subMenuCommandForMenuCell(MenuCell cell, boolean shouldHaveArtwork, int position){ AddSubMenu subMenu = new AddSubMenu(cell.getCellId(), cell.getTitle()); subMenu.setPosition(position); + subMenu.setMenuLayout((cell.getSubMenuLayout() != null ? cell.getSubMenuLayout() : menuConfiguration.getSubMenuLayout())); subMenu.setMenuIcon((shouldHaveArtwork && (cell.getIcon()!= null && cell.getIcon().getImageRPC() != null)) ? cell.getIcon().getImageRPC() : null); return subMenu; } diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/menu/MenuCell.java b/base/src/main/java/com/smartdevicelink/managers/screen/menu/MenuCell.java index 3ba0ee0b6..519dcad93 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/menu/MenuCell.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/menu/MenuCell.java @@ -36,6 +36,7 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; import com.smartdevicelink.managers.file.filetypes.SdlArtwork; +import com.smartdevicelink.proxy.rpc.enums.MenuLayout; import java.util.ArrayList; import java.util.List; @@ -78,6 +79,12 @@ public class MenuCell implements Cloneable{ private int cellId; /** + * The submenu's layout that the subCells will be shown in. If `null`, the default submenu + * layout set via the screen manager's `MenuConfiguration` will be used. + */ + private MenuLayout subMenuLayout; + + /** * MAX ID for cells - Cannot use Integer.MAX_INT as the value is too high. */ private static final int MAX_ID = 2000000000; @@ -110,7 +117,10 @@ public class MenuCell implements Cloneable{ * @param title The cell's primary text * @param icon The cell's image * @param subCells The sub-cells for the sub menu that will appear when the cell is selected + * + * @deprecated use {@link #MenuCell(String, MenuLayout, SdlArtwork, List)} */ + @Deprecated public MenuCell(@NonNull String title, @Nullable SdlArtwork icon, @Nullable List<MenuCell> subCells) { setTitle(title); // title is the only required param setIcon(icon); @@ -119,6 +129,24 @@ public class MenuCell implements Cloneable{ setParentCellId(MAX_ID); } + /** + * Creates a new MenuCell Object with multiple parameters set + * <strong>NOTE: because this has sub-cells, there does not need to be a listener</strong> + * @param title The cell's primary text + * @param subMenuLayout The submenu's layout that the subCells will be shown in. If `null`, the + * default submenu layout in the screen manager's `MenuConfiguration` will be used. + * @param icon The cell's image + * @param subCells The sub-cells for the sub menu that will appear when the cell is selected + */ + public MenuCell(@NonNull String title, @Nullable MenuLayout subMenuLayout, @Nullable SdlArtwork icon, @Nullable List<MenuCell> subCells) { + setTitle(title); // title is the only required param + setSubMenuLayout(subMenuLayout); + setIcon(icon); + setSubCells(subCells); + setCellId(MAX_ID); + setParentCellId(MAX_ID); + } + // SETTERS / GETTERS // PUBLIC METHODS @@ -203,6 +231,24 @@ public class MenuCell implements Cloneable{ return menuSelectionListener; } + /** + * The submenu's layout that the subCells will be shown in. If `null`, the default submenu + * layout set via the screen manager's `MenuConfiguration` will be used. + * @param subMenuLayout - the layout used for the sub menu + */ + public void setSubMenuLayout(MenuLayout subMenuLayout) { + this.subMenuLayout = subMenuLayout; + } + + /** + * The submenu's layout that the subCells will be shown in. If `null`, the default submenu + * layout set via the screen manager's `MenuConfiguration` will be used. + * @return - the layout used for the sub menu + */ + public MenuLayout getSubMenuLayout() { + return this.subMenuLayout; + } + // INTERNALLY USED METHODS /** @@ -291,9 +337,7 @@ public class MenuCell implements Cloneable{ clone.voiceCommands = null; if (this.voiceCommands != null){ clone.voiceCommands = new ArrayList<>(); - for (String voiceCommand : this.voiceCommands) { - clone.voiceCommands.add(voiceCommand); - } + clone.voiceCommands.addAll(this.voiceCommands); } clone.subCells = null; if (this.subCells != null) { diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/menu/MenuConfiguration.java b/base/src/main/java/com/smartdevicelink/managers/screen/menu/MenuConfiguration.java new file mode 100644 index 000000000..501c12d62 --- /dev/null +++ b/base/src/main/java/com/smartdevicelink/managers/screen/menu/MenuConfiguration.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2019 Livio, 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 Livio 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. + * + * Created by brettywhite on 7/18/19 3:28 PM + * + */ + +package com.smartdevicelink.managers.screen.menu; + +import android.support.annotation.NonNull; + +import com.smartdevicelink.proxy.rpc.enums.MenuLayout; + +public class MenuConfiguration { + + private MenuLayout mainMenuLayout, defaultSubmenuLayout; + + public MenuConfiguration(@NonNull MenuLayout mainMenuLayout, @NonNull MenuLayout defaultSubmenuLayout){ + setMenuLayout(mainMenuLayout); + setSubMenuLayout(defaultSubmenuLayout); + } + + /** + * Changes the default main menu layout. Defaults to `MenuLayoutList`. + * @param mainMenuLayout - the layout of the main menu + */ + private void setMenuLayout(@NonNull MenuLayout mainMenuLayout){ + this.mainMenuLayout = mainMenuLayout; + } + + /** + * Changes the default main menu layout. Defaults to `MenuLayoutList`. + * @return - the layout of the main menu + */ + public MenuLayout getMenuLayout() { + return this.mainMenuLayout; + } + + /** + * Changes the default submenu layout. To change this for an individual submenu, set the + * `menuLayout` property on the `MenuCell` constructor for creating a cell with sub-cells. + * Defaults to `MenuLayoutList`. + * @param defaultSubmenuLayout - the MenuLayout for this sub menu + */ + private void setSubMenuLayout(@NonNull MenuLayout defaultSubmenuLayout){ + this.defaultSubmenuLayout = defaultSubmenuLayout; + } + + /** + * Changes the default submenu layout. To change this for an individual submenu, set the + * `menuLayout` property on the `MenuCell` constructor for creating a cell with sub-cells. + * Defaults to `MenuLayoutList`. + * @return - the MenuLayout for this sub menu + */ + public MenuLayout getSubMenuLayout() { + return defaultSubmenuLayout; + } + + /** + * @return A string description of the cell, useful for debugging. + */ + @Override @NonNull + public String toString() { + return "MenuConfiguration: MenuLayout = "+ this.mainMenuLayout + " | SubMenuLayout = "+ this.defaultSubmenuLayout; + } + +} diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/AddSubMenu.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/AddSubMenu.java index a75b5899e..e2bd7e675 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/AddSubMenu.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/AddSubMenu.java @@ -1,40 +1,41 @@ -/* - * Copyright (c) 2017 - 2019, 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. - */ +/*
+ * Copyright (c) 2017 - 2019, 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 android.support.annotation.NonNull;
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCRequest;
+import com.smartdevicelink.proxy.rpc.enums.MenuLayout;
import java.util.Hashtable;
@@ -89,6 +90,14 @@ import java.util.Hashtable; * <td></td>
* <td>SmartDeviceLink 5.0</td>
* </tr>
+ * <tr>
+ * <td>menuLayout</td>
+ * <td>MenuLayout</td>
+ * <td>Sets the layout of the submenu screen.</td>
+ * <td></td>
+ * <td></td>
+ * <td>SmartDeviceLink 6.0</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>
@@ -106,6 +115,7 @@ public class AddSubMenu extends RPCRequest { 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";
/**
* Constructs a new AddSubMenu object
@@ -223,4 +233,21 @@ public class AddSubMenu extends RPCRequest { public void setMenuIcon(Image menuIcon) {
setParameters(KEY_MENU_ICON, menuIcon);
}
+
+ /**
+ * Sets the layout of the submenu screen.
+ * @param menuLayout - the menuLayout
+ */
+ public void setMenuLayout(MenuLayout menuLayout) {
+ setParameters(KEY_MENU_LAYOUT, menuLayout);
+ }
+
+ /**
+ * Gets the layout of the submenu screen.
+ * @return the MenuLayout
+ */
+ @SuppressWarnings("unchecked")
+ public MenuLayout getMenuLayout() {
+ return (MenuLayout) getObject(MenuLayout.class, KEY_MENU_LAYOUT);
+ }
}
diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/DisplayCapabilities.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/DisplayCapabilities.java index 32677230b..8f0fc3fb4 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/DisplayCapabilities.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/DisplayCapabilities.java @@ -36,6 +36,7 @@ import android.support.annotation.NonNull; import com.smartdevicelink.proxy.RPCStruct;
import com.smartdevicelink.proxy.rpc.enums.DisplayType;
import com.smartdevicelink.proxy.rpc.enums.MediaClockFormat;
+import com.smartdevicelink.proxy.rpc.enums.MenuLayout;
import com.smartdevicelink.util.Version;
import java.util.Hashtable;
@@ -85,6 +86,12 @@ import java.util.List; * <td>The display's persistent screen supports referencing a static or dynamic image.</td>
* <td>SmartDeviceLink 2.0</td>
* </tr>
+ * <tr>
+ * <td>menuLayoutsAvailable</td>
+ * <td>MenuLayout[]</td>
+ * <td>An array of available menu layouts. If this parameter is not provided, only the `LIST` layout is assumed to be available</td>
+ * <td>SmartDeviceLink 6.0</td>
+ * </tr>
* </table>
* @since SmartDeviceLink 1.0
* @see DisplayType
@@ -103,6 +110,7 @@ public class DisplayCapabilities extends RPCStruct { public static final String KEY_SCREEN_PARAMS = "screenParams";
public static final String KEY_TEMPLATES_AVAILABLE = "templatesAvailable";
public static final String KEY_NUM_CUSTOM_PRESETS_AVAILABLE = "numCustomPresetsAvailable";
+ public static final String KEY_MENU_LAYOUTS_AVAILABLE = "menuLayoutsAvailable";
/**
* Constructs a newly allocated DisplayCapabilities object
*/
@@ -270,5 +278,24 @@ public class DisplayCapabilities extends RPCStruct { @SuppressWarnings("unchecked")
public ScreenParams getScreenParams() {
return (ScreenParams) getObject(ScreenParams.class, KEY_SCREEN_PARAMS);
- }
+ }
+
+ /**
+ * An array of available menu layouts. If this parameter is not provided, only the `LIST` layout
+ * is assumed to be available
+ * @param menuLayout - An array of MenuLayouts
+ */
+ public void setMenuLayoutsAvailable(List<MenuLayout> menuLayout) {
+ setValue(KEY_MENU_LAYOUTS_AVAILABLE, menuLayout);
+ }
+
+ /**
+ * An array of available menu layouts. If this parameter is not provided, only the `LIST` layout
+ * is assumed to be available
+ * @return MenuLayout[]
+ */
+ @SuppressWarnings("unchecked")
+ public List<MenuLayout> getMenuLayoutsAvailable() {
+ return (List<MenuLayout>) getObject(MenuLayout.class, KEY_MENU_LAYOUTS_AVAILABLE);
+ }
}
diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/SetGlobalProperties.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/SetGlobalProperties.java index 62aca4657..d3cf34310 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/SetGlobalProperties.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/SetGlobalProperties.java @@ -1,38 +1,39 @@ -/* - * Copyright (c) 2017 - 2019, 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. - */ +/*
+ * Copyright (c) 2017 - 2019, 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 com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCRequest;
+import com.smartdevicelink.proxy.rpc.enums.MenuLayout;
import java.util.Hashtable;
import java.util.List;
@@ -87,7 +88,7 @@ import java.util.List; * </tr>
* <tr>
* <td>vrHelp</td>
- * <td>VrHelep</td>
+ * <td>VrHelp</td>
* <td>Items listed in the VR help screen used in an interaction started by PTT.</td>
* <td>N</td>
* <td>If omitted on supported displays, the default SDL VR help / What Can I Say? screen will be used<p>If the list of VR Help Items contains nonsequential positions (e.g. [1,2,4]), the RPC will be rejected.</p><p>If omitted and a vrHelpTitle is provided, the request will be rejected.</p>minsize:1; maxsize: 100 </td>
@@ -112,11 +113,19 @@ import java.util.List; * <tr>
* <td>keyboardProperties</td>
* <td>KeyboardProperties</td>
- * <td>On-screen keybaord configuration (if available).</td>
+ * <td>On-screen keyboard configuration (if available).</td>
* <td>N</td>
* <td></td>
* <td>SmartDeviceLink 1.0</td>
* </tr>
+ * <tr>
+ * <td>menuLayout</td>
+ * <td>MenuLayout</td>
+ * <td>Sets the layout of the main menu screen. If this is sent while a menu is already on-screen, the head unit will change the display to the new layout type.</td>
+ * <td></td>
+ * <td></td>
+ * <td>SmartDeviceLink 6.0</td>
+ * </tr>
*
* </table>
*
@@ -144,6 +153,7 @@ public class SetGlobalProperties extends RPCRequest { public static final String KEY_HELP_PROMPT = "helpPrompt";
public static final String KEY_TIMEOUT_PROMPT = "timeoutPrompt";
public static final String KEY_VR_HELP = "vrHelp";
+ public static final String KEY_MENU_LAYOUT = "menuLayout";
/**
* Constructs a new SetGlobalProperties object
*/
@@ -305,6 +315,25 @@ public class SetGlobalProperties extends RPCRequest { @SuppressWarnings("unchecked")
public KeyboardProperties getKeyboardProperties() {
return (KeyboardProperties) getObject(KeyboardProperties.class, KEY_KEYBOARD_PROPERTIES);
- }
+ }
+
+ /**
+ * Sets the layout of the main menu screen. If this is sent while a menu is already on-screen,
+ * the head unit will change the display to the new layout type.
+ * @param menuLayout - the menuLayout
+ */
+ public void setMenuLayout(MenuLayout menuLayout) {
+ setParameters(KEY_MENU_LAYOUT, menuLayout);
+ }
+
+ /**
+ * Sets the layout of the main menu screen. If this is sent while a menu is already on-screen,
+ * the head unit will change the display to the new layout type.
+ * @return the MenuLayout
+ */
+ @SuppressWarnings("unchecked")
+ public MenuLayout getMenuLayout() {
+ return (MenuLayout) getObject(MenuLayout.class, KEY_MENU_LAYOUT);
+ }
}
diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/enums/MenuLayout.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/enums/MenuLayout.java new file mode 100644 index 000000000..fcda7b498 --- /dev/null +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/enums/MenuLayout.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2019 Livio, 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 Livio 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. + * + * Created by brettywhite on 7/17/19 12:00 PM + * + */ + +package com.smartdevicelink.proxy.rpc.enums; + +/** + * How the main menu or submenu is laid out on screen + */ +public enum MenuLayout { + + LIST, + + TILES, + + ; + + public static MenuLayout valueForString(String value) { + try { + return valueOf(value); + } catch (Exception e) { + return null; + } + } + +} diff --git a/hello_sdl_java/src/main/java/com/smartdevicelink/java/SdlService.java b/hello_sdl_java/src/main/java/com/smartdevicelink/java/SdlService.java index 4292c086c..2a658181c 100644 --- a/hello_sdl_java/src/main/java/com/smartdevicelink/java/SdlService.java +++ b/hello_sdl_java/src/main/java/com/smartdevicelink/java/SdlService.java @@ -232,7 +232,7 @@ public class SdlService { }); // sub menu parent cell - MenuCell mainCell3 = new MenuCell("Test Cell 3 (sub menu)", null, Arrays.asList(subCell1,subCell2)); + MenuCell mainCell3 = new MenuCell("Test Cell 3 (sub menu)", MenuLayout.LIST, null, Arrays.asList(subCell1,subCell2)); MenuCell mainCell4 = new MenuCell("Show Perform Interaction", null, null, new MenuSelectionListener() { @Override |