summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrettyWhite <geekman3454@protonmail.com>2019-04-29 10:20:47 -0400
committerBrettyWhite <geekman3454@protonmail.com>2019-04-29 10:20:47 -0400
commit389c485c380f39340b46c8fc3d2ab517164693d4 (patch)
tree8a70b2291a5c1c6434f919079a000657b57951af
parent7b1de23e01b77b067cc1cb8c6946a2e76950c426 (diff)
downloadsdl_android-389c485c380f39340b46c8fc3d2ab517164693d4.tar.gz
checkpoint - in middle of code
-rw-r--r--base/src/main/java/com/smartdevicelink/managers/screen/menu/BaseMenuManager.java71
-rw-r--r--base/src/main/java/com/smartdevicelink/managers/screen/menu/cells/MenuCell.java6
2 files changed, 68 insertions, 9 deletions
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 935a77d4b..3150d6b5b 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
@@ -41,13 +41,22 @@ import com.smartdevicelink.managers.screen.menu.cells.MenuCell;
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCMessage;
import com.smartdevicelink.proxy.RPCNotification;
+import com.smartdevicelink.proxy.SystemCapabilityManager;
import com.smartdevicelink.proxy.interfaces.ISdl;
+import com.smartdevicelink.proxy.interfaces.OnSystemCapabilityListener;
+import com.smartdevicelink.proxy.rpc.AddCommand;
+import com.smartdevicelink.proxy.rpc.AddSubMenu;
import com.smartdevicelink.proxy.rpc.DisplayCapabilities;
+import com.smartdevicelink.proxy.rpc.Image;
+import com.smartdevicelink.proxy.rpc.MenuParams;
import com.smartdevicelink.proxy.rpc.OnCommand;
import com.smartdevicelink.proxy.rpc.OnHMIStatus;
+import com.smartdevicelink.proxy.rpc.RegisterAppInterfaceResponse;
import com.smartdevicelink.proxy.rpc.enums.HMILevel;
+import com.smartdevicelink.proxy.rpc.enums.SystemCapabilityType;
import com.smartdevicelink.proxy.rpc.enums.SystemContext;
import com.smartdevicelink.proxy.rpc.listeners.OnRPCNotificationListener;
+import com.smartdevicelink.util.DebugTool;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
@@ -68,6 +77,7 @@ abstract class BaseMenuManager extends BaseSubManager {
private OnRPCNotificationListener hmiListener;
private OnRPCNotificationListener commandListener;
+ private DisplayCapabilities displayCapabilities;
private static final int parentIdNotFound = Integer.MAX_VALUE;
private static final int menuCellIdMin = 1;
@@ -75,8 +85,6 @@ abstract class BaseMenuManager extends BaseSubManager {
private SystemContext currentSystemContext;
- private DisplayCapabilities displayCapabilities;
-
public BaseMenuManager(@NonNull ISdl internalInterface, @NonNull FileManager fileManager) {
super(internalInterface);
@@ -119,20 +127,70 @@ abstract class BaseMenuManager extends BaseSubManager {
super.dispose();
}
+ private AddCommand commandForMenuCell(MenuCell cell, boolean shouldHaveArtwork, int position){
+
+ MenuParams params = new MenuParams(cell.getTitle());
+ params.setParentID(cell.getCellId() != Integer.MAX_VALUE ? cell.getParentCellId() : null);
+ params.setPosition(position);
+
+ AddCommand command = new AddCommand(cell.getCellId());
+ command.setMenuParams(params);
+ command.setVrCommands(cell.getVoiceCommands());
+ command.setCmdIcon((cell.getIcon() != null && shouldHaveArtwork) ? cell.getIcon().getImageRPC() : null);
+
+ return command;
+ }
+
+ private AddSubMenu subMenuCommandForMenuCell(MenuCell cell, boolean shouldHaveArtwork, int position){
+ AddSubMenu subMenu = new AddSubMenu(cell.getCellId(), cell.getTitle());
+ subMenu.setPosition(position);
+ subMenu.setMenuIcon((shouldHaveArtwork && (cell.getIcon().getName() != null)) ? cell.getIcon().getImageRPC() : null);
+ return subMenu;
+ }
+
+ // CELL COMMAND HANDLING
+
+ private boolean callListenerForCells(List<MenuCell> cells, OnCommand command){
+ for (MenuCell cell : cells){
+ if (cell.getCellId() == command.getCmdID() && cell.getMenuSelectionListener() != null){
+ cell.getMenuSelectionListener().onTriggered(command.getTriggerSource());
+ return true;
+ }
+
+ if (cell.getSubCells().size() > 0){
+ // for each cell, if it has sub cells, recursively loop through those as well
+ if (callListenerForCells(cell.getSubCells(), command)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
// LISTENERS
private void addListeners(){
+ // DISPLAY CAPABILITIES - via SCM
+ internalInterface.getCapability(SystemCapabilityType.DISPLAY, new OnSystemCapabilityListener() {
+ @Override
+ public void onCapabilityRetrieved(Object capability) {
+ displayCapabilities = (DisplayCapabilities) capability;
+ }
+
+ @Override
+ public void onError(String info) {
+ DebugTool.logError("Unable to retrieve display capabilities: "+ info);
+ }
+ });
+
// HMI UPDATES
hmiListener = new OnRPCNotificationListener() {
@Override
public void onNotified(RPCNotification notification) {
HMILevel oldHMILevel = currentHMILevel;
currentHMILevel = ((OnHMIStatus) notification).getHmiLevel();
- // Auto-send an update if we were in NONE and now we are not
- if (oldHMILevel.equals(HMILevel.HMI_NONE) && !currentHMILevel.equals(HMILevel.HMI_NONE)){
-
- }
+ // TODO
}
};
internalInterface.addOnRPCNotificationListener(FunctionID.ON_HMI_STATUS, hmiListener);
@@ -142,6 +200,7 @@ abstract class BaseMenuManager extends BaseSubManager {
@Override
public void onNotified(RPCNotification notification) {
OnCommand onCommand = (OnCommand) notification;
+ callListenerForCells(menuCells, onCommand);
}
};
internalInterface.addOnRPCNotificationListener(FunctionID.ON_COMMAND, commandListener);
diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/menu/cells/MenuCell.java b/base/src/main/java/com/smartdevicelink/managers/screen/menu/cells/MenuCell.java
index 333168c85..a22a3ae9b 100644
--- a/base/src/main/java/com/smartdevicelink/managers/screen/menu/cells/MenuCell.java
+++ b/base/src/main/java/com/smartdevicelink/managers/screen/menu/cells/MenuCell.java
@@ -206,7 +206,7 @@ public class MenuCell {
* Get the cellId
* @return the cellId for this menuCell
*/
- private int getCellId() {
+ public int getCellId() {
return cellId;
}
@@ -214,7 +214,7 @@ public class MenuCell {
* Sets the ParentCellId
* @param parentCellId the parent cell's Id
*/
- private void setParentCellId(int parentCellId) {
+ public void setParentCellId(int parentCellId) {
this.parentCellId = parentCellId;
}
@@ -222,7 +222,7 @@ public class MenuCell {
* Get the parent cell's Id
* @return the parent cell's Id
*/
- private int getParentCellId() {
+ public int getParentCellId() {
return parentCellId;
}