diff options
author | BrettyWhite <geekman3454@protonmail.com> | 2019-07-18 16:56:32 -0400 |
---|---|---|
committer | BrettyWhite <geekman3454@protonmail.com> | 2019-07-18 16:56:32 -0400 |
commit | f771aef7eb3446c6e161b653248ff3422397a6ae (patch) | |
tree | 0839677c76b2614b200e9f8abcc1861c0b6bda51 | |
parent | bd0f7234cf9dac840cbb107698a579759968f7e1 (diff) | |
download | sdl_android-f771aef7eb3446c6e161b653248ff3422397a6ae.tar.gz |
modifications to menumanager
3 files changed, 74 insertions, 1 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/base/src/main/java/com/smartdevicelink/managers/screen/BaseScreenManager.java b/base/src/main/java/com/smartdevicelink/managers/screen/BaseScreenManager.java index cc33bae86..c11b73d41 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(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..d7dd5c94e 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,6 +54,8 @@ 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; @@ -62,6 +64,7 @@ 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,7 +86,9 @@ abstract class BaseMenuManager extends BaseSubManager { List<MenuCell> menuCells, waitingUpdateMenuCells, oldMenuCells, keepsNew, keepsOld; List<RPCRequest> inProgressUpdate; DynamicMenuUpdatesMode dynamicMenuUpdatesMode; + MenuConfiguration menuConfiguration; private DisplayType displayType; + private SdlMsgVersion sdlMsgVersion; boolean waitingOnHMIUpdate; private boolean hasQueuedUpdate; @@ -110,6 +115,7 @@ abstract class BaseMenuManager extends BaseSubManager { currentHMILevel = HMILevel.HMI_NONE; lastMenuId = menuCellIdMin; dynamicMenuUpdatesMode = DynamicMenuUpdatesMode.ON_WITH_COMPAT_MODE; + sdlMsgVersion = internalInterface.getSdlMsgVersion(); addListeners(); } @@ -245,6 +251,55 @@ 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(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; + } + + SetGlobalProperties setGlobalProperties = new SetGlobalProperties(); + setGlobalProperties.setMenuLayout(menuConfiguration.getMenuLayout()); + setGlobalProperties.setOnRPCResponseListener(new OnRPCResponseListener() { + @Override + public void onResponse(int correlationId, RPCResponse response) { + if (response.getSuccess()){ + setMenuConfigPrivate(menuConfiguration); + } + } + + @Override + public void onError(int correlationId, Result resultCode, String info){ + DebugTool.logError("onError: "+ resultCode+ " | Info: "+ info ); + } + }); + internalInterface.sendRPC(setGlobalProperties); + } + + private void setMenuConfigPrivate(MenuConfiguration menuConfigPrivate){ + this.menuConfiguration = menuConfigPrivate; + } + + public MenuConfiguration getMenuConfiguration(){ + return this.menuConfiguration; + } + // UPDATING SYSTEM // ROOT MENU |