Add enabled and activated state to CarUiContentListItem

Fixes: 148970085
Test: Manual

Change-Id: I24611c39b1e934bb878955418e865292bdae6e6f
diff --git a/car-ui-lib/src/com/android/car/ui/recyclerview/CarUiContentListItem.java b/car-ui-lib/src/com/android/car/ui/recyclerview/CarUiContentListItem.java
index ee4e490..cd7c212 100644
--- a/car-ui-lib/src/com/android/car/ui/recyclerview/CarUiContentListItem.java
+++ b/car-ui-lib/src/com/android/car/ui/recyclerview/CarUiContentListItem.java
@@ -105,6 +105,8 @@
     private IconType mPrimaryIconType;
     private boolean mIsActionDividerVisible;
     private boolean mIsChecked;
+    private boolean mIsEnabled = true;
+    private boolean mIsActivated;
     private OnClickListener mOnClickListener;
     private OnCheckedChangedListener mOnCheckedChangedListener;
     private View.OnClickListener mSupplementalIconOnClickListener;
@@ -182,6 +184,38 @@
     }
 
     /**
+     * Returns {@code true} if the item is activated.
+     */
+    public boolean isActivated() {
+        return mIsActivated;
+    }
+
+    /**
+     * Sets the activated state of the item.
+     *
+     * @param activated the activated state for the item.
+     */
+    public void setActivated(boolean activated) {
+        mIsActivated = activated;
+    }
+
+    /**
+     * Returns {@code true} if the item is enabled.
+     */
+    public boolean isEnabled() {
+        return mIsEnabled;
+    }
+
+    /**
+     * Sets the enabled state of the item.
+     *
+     * @param enabled the enabled state for the item.
+     */
+    public void setEnabled(boolean enabled) {
+        mIsEnabled = enabled;
+    }
+
+    /**
      * Returns {@code true} if the item is checked. Will always return {@code false} when the action
      * type for the item is {@code Action.NONE}.
      */
diff --git a/car-ui-lib/src/com/android/car/ui/recyclerview/CarUiListItemAdapter.java b/car-ui-lib/src/com/android/car/ui/recyclerview/CarUiListItemAdapter.java
index 765d21d..671ad58 100644
--- a/car-ui-lib/src/com/android/car/ui/recyclerview/CarUiListItemAdapter.java
+++ b/car-ui-lib/src/com/android/car/ui/recyclerview/CarUiListItemAdapter.java
@@ -383,6 +383,20 @@
                 default:
                     throw new IllegalStateException("Unknown secondary action type.");
             }
+
+            itemView.setActivated(item.isActivated());
+            setEnabled(itemView, item.isEnabled());
+        }
+
+        void setEnabled(View view, boolean enabled) {
+            view.setEnabled(enabled);
+            if (view instanceof ViewGroup) {
+                ViewGroup group = (ViewGroup) view;
+
+                for (int i = 0; i < group.getChildCount(); i++) {
+                    setEnabled(group.getChildAt(i), enabled);
+                }
+            }
         }
     }
 
diff --git a/car-ui-lib/tests/paintbooth/src/com/android/car/ui/paintbooth/caruirecyclerview/CarUiListItemActivity.java b/car-ui-lib/tests/paintbooth/src/com/android/car/ui/paintbooth/caruirecyclerview/CarUiListItemActivity.java
index 10aef44..148e44c 100644
--- a/car-ui-lib/tests/paintbooth/src/com/android/car/ui/paintbooth/caruirecyclerview/CarUiListItemActivity.java
+++ b/car-ui-lib/tests/paintbooth/src/com/android/car/ui/paintbooth/caruirecyclerview/CarUiListItemActivity.java
@@ -116,6 +116,17 @@
 
         item = new CarUiContentListItem();
         item.setIcon(getDrawable(R.drawable.ic_launcher));
+        item.setEnabled(false);
+        item.setTitle("Title -- Checkbox that is disabled");
+        item.setBody("Clicks should not have any affect");
+        item.setOnCheckedChangedListener(
+                (listItem, isChecked) -> Toast.makeText(context,
+                        "Item checked state is: " + isChecked, Toast.LENGTH_SHORT).show());
+        item.setAction(CarUiContentListItem.Action.CHECK_BOX);
+        mData.add(item);
+
+        item = new CarUiContentListItem();
+        item.setIcon(getDrawable(R.drawable.ic_launcher));
         item.setBody("Body -- Item with switch  -- with click listener");
         item.setAction(CarUiContentListItem.Action.SWITCH);
         item.setOnItemClickedListener(item1 -> {