summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrettyWhite <geekman3454@protonmail.com>2019-07-18 16:15:33 -0400
committerBrettyWhite <geekman3454@protonmail.com>2019-07-18 16:15:33 -0400
commitbd0f7234cf9dac840cbb107698a579759968f7e1 (patch)
treee90539277144771744392ec30379c31386a94518
parent0a0a3d6accd0bb9d3b9200cb167870acde6c6946 (diff)
downloadsdl_android-bd0f7234cf9dac840cbb107698a579759968f7e1.tar.gz
edit MenuCell and tests
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/menu/MenuCellTests.java9
-rw-r--r--base/src/main/java/com/smartdevicelink/managers/screen/menu/MenuCell.java44
2 files changed, 53 insertions, 0 deletions
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/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..12131a86b 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{{@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,22 @@ 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 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 +229,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
/**