Remove unneeded ime functions from the toolbar

Bug: 162268101
Bug: 170343703
Test: Manually
Change-Id: Iaa08671ee894d8efea826e610a1a5c69b60031fb
Merged-In: Iaa08671ee894d8efea826e610a1a5c69b60031fb
diff --git a/car-ui-lib/.gitignore b/car-ui-lib/.gitignore
index a6be7ed..57df0a4 100644
--- a/car-ui-lib/.gitignore
+++ b/car-ui-lib/.gitignore
@@ -16,3 +16,6 @@
 
 # Android studio's layout inspector captures
 captures/
+
+# A file created when launching android emulators
+read-snapshot.txt
diff --git a/car-ui-lib/build.gradle b/car-ui-lib/build.gradle
index ae26e4c..28633d9 100644
--- a/car-ui-lib/build.gradle
+++ b/car-ui-lib/build.gradle
@@ -23,7 +23,7 @@
 
     }
     dependencies {
-        classpath 'com.android.tools.build:gradle:4.1.0-beta05'
+        classpath 'com.android.tools.build:gradle:4.0.2'
 
         // NOTE: Do not place your application dependencies here; they belong
         // in the individual module build.gradle files
diff --git a/car-ui-lib/car-ui-lib/src/androidTest/java/com/android/car/ui/recyclerview/CarUiListItemTest.java b/car-ui-lib/car-ui-lib/src/androidTest/java/com/android/car/ui/recyclerview/CarUiListItemTest.java
index bd21173..da446e1 100644
--- a/car-ui-lib/car-ui-lib/src/androidTest/java/com/android/car/ui/recyclerview/CarUiListItemTest.java
+++ b/car-ui-lib/car-ui-lib/src/androidTest/java/com/android/car/ui/recyclerview/CarUiListItemTest.java
@@ -29,13 +29,10 @@
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
-import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 
-import android.view.View;
-
 import androidx.test.rule.ActivityTestRule;
 
 import com.android.car.ui.R;
@@ -43,7 +40,6 @@
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
-import org.mockito.ArgumentCaptor;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -242,7 +238,8 @@
 
         CarUiContentListItem.OnClickListener clickListener = mock(
                 CarUiContentListItem.OnClickListener.class);
-        View.OnClickListener supplementalIconClickListener = mock(View.OnClickListener.class);
+        CarUiContentListItem.OnClickListener supplementalIconClickListener = mock(
+                CarUiContentListItem.OnClickListener.class);
 
         CarUiContentListItem item = new CarUiContentListItem(
                 CarUiContentListItem.Action.ICON);
@@ -262,18 +259,14 @@
         // listener.
         onView(withId(R.id.title)).perform(click());
         verify(clickListener, times(1)).onClick(item);
-        verify(supplementalIconClickListener, times(0)).onClick(any());
+        verify(supplementalIconClickListener, times(0)).onClick(item);
 
-        ArgumentCaptor<View> iconCaptor = ArgumentCaptor.forClass(View.class);
         onView(withId(R.id.supplemental_icon)).perform(click());
         // Check that icon is argument for single call to click listener.
-        verify(supplementalIconClickListener, times(1)).onClick(iconCaptor.capture());
+        verify(supplementalIconClickListener, times(1)).onClick(item);
 
         // Verify that the standard click listener wasn't also fired.
         verify(clickListener, times(1)).onClick(item);
-
-        View icon = mCarUiRecyclerView.findViewById(R.id.supplemental_icon);
-        assertEquals(icon, iconCaptor.getValue());
     }
 
     @Test
@@ -282,7 +275,8 @@
 
         CarUiContentListItem.OnClickListener mockedItemOnClickListener = mock(
                 CarUiContentListItem.OnClickListener.class);
-        View.OnClickListener mockedIconListener = mock(View.OnClickListener.class);
+        CarUiContentListItem.OnClickListener mockedIconListener = mock(
+                CarUiContentListItem.OnClickListener.class);
 
         CarUiContentListItem item = new CarUiContentListItem(
                 CarUiContentListItem.Action.ICON);
@@ -306,7 +300,7 @@
         // Clicks anywhere on the icon should invoke both listeners.
         onView(withId(R.id.action_container)).perform(click());
         verify(mockedItemOnClickListener, times(1)).onClick(item);
-        verify(mockedIconListener, times(1)).onClick(any(View.class));
+        verify(mockedIconListener, times(1)).onClick(item);
     }
 
     @Test
diff --git a/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/AlertDialogBuilder.java b/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/AlertDialogBuilder.java
index e56fa6b..48d86c7 100644
--- a/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/AlertDialogBuilder.java
+++ b/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/AlertDialogBuilder.java
@@ -27,6 +27,7 @@
 import android.content.DialogInterface;
 import android.database.Cursor;
 import android.graphics.drawable.Drawable;
+import android.os.Build;
 import android.os.Bundle;
 import android.text.InputFilter;
 import android.text.TextUtils;
@@ -80,6 +81,11 @@
     // passed to the IME to be rendered. If the information is not passed to the IME the content
     // area of the IME will render nothing into the content area.
     private final View.OnApplyWindowInsetsListener mOnApplyWindowInsetsListener = (v, insets) -> {
+        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
+            // WindowInsets.isVisible() is only available on R or above
+            return insets;
+        }
+
         if (insets.isVisible(ime())) {
             Bundle bundle = new Bundle();
             String title = mWideScreenTitle != null ? mWideScreenTitle : mTitle.toString();
diff --git a/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/imewidescreen/CarUiImeSearchListItem.java b/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/imewidescreen/CarUiImeSearchListItem.java
index fd0ba61..e234c23 100644
--- a/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/imewidescreen/CarUiImeSearchListItem.java
+++ b/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/imewidescreen/CarUiImeSearchListItem.java
@@ -16,8 +16,6 @@
 
 package com.android.car.ui.imewidescreen;
 
-import androidx.annotation.Nullable;
-
 import com.android.car.ui.recyclerview.CarUiContentListItem;
 import com.android.car.ui.recyclerview.CarUiListItemAdapter;
 
@@ -31,9 +29,7 @@
  */
 public class CarUiImeSearchListItem extends CarUiContentListItem {
 
-    private CharSequence mItemId;
     private int mIconResId;
-    private CharSequence mSupplementalIconId;
     private int mSupplementalIconResId;
 
     public CarUiImeSearchListItem(Action action) {
@@ -41,23 +37,6 @@
     }
 
     /**
-     * Returns the id of the item.
-     */
-    @Nullable
-    public CharSequence getItemId() {
-        return mItemId;
-    }
-
-    /**
-     * Sets the id of the item.
-     *
-     * @param itemId text to display as title.
-     */
-    public void setItemId(CharSequence itemId) {
-        mItemId = itemId;
-    }
-
-    /**
      * Returns the icons resource of the item.
      */
     public int getIconResId() {
@@ -84,19 +63,4 @@
     public void setSupplementalIconResId(int supplementalIconResId) {
         mSupplementalIconResId = supplementalIconResId;
     }
-
-    /**
-     * Returns the supplemental icon id of the item.
-     */
-    @Nullable
-    public CharSequence getSupplementalIconId() {
-        return mSupplementalIconId;
-    }
-
-    /**
-     * Sets supplemental icon id.
-     */
-    public void setSupplementalIconId(CharSequence supplementalIconId) {
-        mSupplementalIconId = supplementalIconId;
-    }
 }
diff --git a/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/imewidescreen/CarUiImeWideScreenController.java b/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/imewidescreen/CarUiImeWideScreenController.java
index 9856019..bd010e7 100644
--- a/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/imewidescreen/CarUiImeWideScreenController.java
+++ b/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/imewidescreen/CarUiImeWideScreenController.java
@@ -369,10 +369,8 @@
                 searchItem = new CarUiImeSearchListItem(CarUiContentListItem.Action.NONE);
             } else {
                 searchItem = new CarUiImeSearchListItem(CarUiContentListItem.Action.ICON);
-                searchItem.setSupplementalIconId(secondaryImageIdList.get(i));
             }
 
-            searchItem.setItemId(itemIdList.get(i));
             searchItem.setOnItemClickedListener(v -> {
                 Bundle bundle = new Bundle();
                 bundle.putString(SEARCH_RESULT_ITEM_ID, itemIdList.get(index));
diff --git a/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/recyclerview/CarUiContentListItem.java b/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/recyclerview/CarUiContentListItem.java
index 71f5d1a..e6a14d7 100644
--- a/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/recyclerview/CarUiContentListItem.java
+++ b/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/recyclerview/CarUiContentListItem.java
@@ -17,7 +17,6 @@
 package com.android.car.ui.recyclerview;
 
 import android.graphics.drawable.Drawable;
-import android.view.View;
 
 import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
@@ -114,7 +113,7 @@
     private boolean mIsActivated;
     private OnClickListener mOnClickListener;
     private OnCheckedChangeListener mOnCheckedChangeListener;
-    private View.OnClickListener mSupplementalIconOnClickListener;
+    private OnClickListener mSupplementalIconOnClickListener;
 
 
     public CarUiContentListItem(Action action) {
@@ -301,7 +300,7 @@
      * @param listener the callback that is invoked when the icon is clicked.
      */
     public void setSupplementalIcon(@Nullable Drawable icon,
-            @Nullable View.OnClickListener listener) {
+            @Nullable OnClickListener listener) {
         if (mAction != Action.ICON) {
             throw new IllegalStateException(
                     "Cannot set supplemental icon on list item that does not have an action of "
@@ -313,7 +312,7 @@
     }
 
     @Nullable
-    public View.OnClickListener getSupplementalIconOnClickListener() {
+    public OnClickListener getSupplementalIconOnClickListener() {
         return mSupplementalIconOnClickListener;
     }
 
diff --git a/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/recyclerview/CarUiListItemAdapter.java b/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/recyclerview/CarUiListItemAdapter.java
index 8bc39eb..b737e92 100644
--- a/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/recyclerview/CarUiListItemAdapter.java
+++ b/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/recyclerview/CarUiListItemAdapter.java
@@ -309,8 +309,7 @@
                         mActionContainerTouchInterceptor.setOnClickListener(
                                 (container) -> {
                                     if (item.getSupplementalIconOnClickListener() != null) {
-                                        item.getSupplementalIconOnClickListener().onClick(
-                                                mSupplementalIcon);
+                                        item.getSupplementalIconOnClickListener().onClick(item);
                                     }
                                 });
                         mTouchInterceptor.setVisibility(View.GONE);
diff --git a/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/CarUiEditText.java b/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/toolbar/CarUiEditText.java
similarity index 88%
rename from car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/CarUiEditText.java
rename to car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/toolbar/CarUiEditText.java
index f451c1e..faedd7e 100644
--- a/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/CarUiEditText.java
+++ b/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/toolbar/CarUiEditText.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.car.ui;
+package com.android.car.ui.toolbar;
 
 import static com.android.car.ui.imewidescreen.CarUiImeWideScreenController.SEARCH_RESULT_ITEM_ID;
 import static com.android.car.ui.imewidescreen.CarUiImeWideScreenController.SEARCH_RESULT_SECONDARY_IMAGE_ID;
@@ -29,15 +29,15 @@
 import java.util.Set;
 
 /**
- * Edit text supporting the callbacks from the IMS.This will be useful in widescreen IME mode to
- * notify apps of specific action through Interface.
+ * Edit text supporting the callbacks from the IMS. This will be useful in widescreen IME mode to
+ * allow car-ui-lib to receive responses (like onClick events) from the IMS
  */
-public class CarUiEditText extends EditText {
+class CarUiEditText extends EditText {
     /**
      * Interface for {@link CarUiEditText} to support different actions and callbacks from IME
      * when running in wide screen mode.
      */
-    public interface PrivateImeCommandCallback {
+    interface PrivateImeCommandCallback {
         /**
          * Called when user clicks on an item in the search results.
          *
@@ -58,6 +58,9 @@
 
     private final Set<PrivateImeCommandCallback> mPrivateImeCommandCallback = new HashSet<>();
 
+    // These need to be public for the layout inflater to inflate them, but
+    // checkstyle complains about a public constructor on a package-private class
+    //CHECKSTYLE:OFF Generated code
     public CarUiEditText(Context context) {
         super(context);
     }
@@ -74,6 +77,7 @@
             int defStyleRes) {
         super(context, attrs, defStyleAttr, defStyleRes);
     }
+    //CHECKSTYLE:ON Generated code
 
     @Override
     public boolean onPrivateIMECommand(String action, Bundle data) {
diff --git a/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/toolbar/SearchView.java b/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/toolbar/SearchView.java
index 8bf0fee..55a044d 100644
--- a/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/toolbar/SearchView.java
+++ b/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/toolbar/SearchView.java
@@ -28,6 +28,7 @@
 
 import android.content.Context;
 import android.graphics.drawable.Drawable;
+import android.os.Build;
 import android.os.Bundle;
 import android.text.Editable;
 import android.text.TextUtils;
@@ -44,7 +45,6 @@
 import androidx.annotation.NonNull;
 import androidx.constraintlayout.widget.ConstraintLayout;
 
-import com.android.car.ui.CarUiEditText;
 import com.android.car.ui.R;
 import com.android.car.ui.imewidescreen.CarUiImeSearchListItem;
 import com.android.car.ui.recyclerview.CarUiContentListItem;
@@ -52,7 +52,9 @@
 
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 /**
@@ -66,7 +68,9 @@
     private final int mStartPaddingWithoutIcon;
     private final int mStartPadding;
     private final int mEndPadding;
-    private List<CarUiListItem> mWideScreenSearchItemList = new ArrayList<>();
+    private List<? extends CarUiImeSearchListItem> mWideScreenSearchItemList = new ArrayList<>();
+    private final Map<String, CarUiImeSearchListItem> mIdToListItem = new HashMap<>();
+
     private Set<Toolbar.OnSearchListener> mSearchListeners = Collections.emptySet();
     private Set<Toolbar.OnSearchCompletedListener> mSearchCompletedListeners =
             Collections.emptySet();
@@ -145,12 +149,46 @@
             }
             return false;
         });
+
+        if (mSearchText instanceof CarUiEditText) {
+            ((CarUiEditText) mSearchText).registerOnPrivateImeCommandListener(
+                    new CarUiEditText.PrivateImeCommandCallback() {
+                        @Override
+                        public void onItemClicked(String itemId) {
+                            CarUiImeSearchListItem item = mIdToListItem.get(itemId);
+                            if (item != null) {
+                                CarUiContentListItem.OnClickListener listener =
+                                        item.getOnClickListener();
+                                if (listener != null) {
+                                    listener.onClick(item);
+                                }
+                            }
+                        }
+
+                        @Override
+                        public void onSecondaryImageClicked(String secondaryImageId) {
+                            CarUiImeSearchListItem item = mIdToListItem.get(secondaryImageId);
+                            if (item != null) {
+                                CarUiContentListItem.OnClickListener listener =
+                                        item.getSupplementalIconOnClickListener();
+                                if (listener != null) {
+                                    listener.onClick(item);
+                                }
+                            }
+                        }
+                    });
+        }
     }
 
     /**
      * Apply window inset listener to the search container.
      */
     void installWindowInsetsListener(View searchContainer) {
+        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
+            // WindowInsets.isVisible() is only available on R or above
+            return;
+        }
+
         searchContainer.getRootView().setOnApplyWindowInsetsListener((v, insets) -> {
             if (insets.isVisible(ime())) {
                 displaySearchWideScreen();
@@ -193,16 +231,15 @@
     }
 
     /**
-     * Adds a listener for the search text changing.
-     * See also {@link #unregisterOnSearchListener(Toolbar.OnSearchListener)}
+     * Sets a listener for the search text changing.
      */
     public void setSearchListeners(Set<Toolbar.OnSearchListener> listeners) {
         mSearchListeners = listeners;
     }
 
     /**
-     * Removes a search listener.
-     * See also {@link #registerOnSearchListener(Toolbar.OnSearchListener)}
+     * Sets a listener for the user completing their search, for example by clicking the
+     * enter/search button on the keyboard.
      */
     public void setSearchCompletedListeners(Set<Toolbar.OnSearchCompletedListener> listeners) {
         mSearchCompletedListeners = listeners;
@@ -212,12 +249,13 @@
      * Sets list of search item {@link CarUiListItem} to be displayed in the IMS
      * template.
      */
-    public void setSearchItemsForWideScreen(List<CarUiListItem> searchItems) {
-        mWideScreenSearchItemList = searchItems;
+    public void setSearchItemsForWideScreen(List<? extends CarUiImeSearchListItem> searchItems) {
+        mWideScreenSearchItemList = new ArrayList<>(searchItems);
         displaySearchWideScreen();
     }
 
     private void displaySearchWideScreen() {
+        mIdToListItem.clear();
         if (mWideScreenSearchItemList.isEmpty()) {
             return;
         }
@@ -227,17 +265,18 @@
         ArrayList<Integer> primaryImageResId = new ArrayList<>();
         ArrayList<String> secondaryItemId = new ArrayList<>();
         ArrayList<Integer> secondaryImageResId = new ArrayList<>();
-        for (CarUiListItem listItem : mWideScreenSearchItemList) {
-            if (listItem instanceof CarUiContentListItem) {
-                CarUiImeSearchListItem item = (CarUiImeSearchListItem) listItem;
-                itemIdList.add(item.getItemId() != null ? item.getItemId().toString() : null);
-                titleList.add(item.getTitle() != null ? item.getTitle().toString() : null);
-                subTitleList.add(item.getBody() != null ? item.getBody().toString() : null);
-                primaryImageResId.add(item.getIconResId());
-                secondaryItemId.add(item.getSupplementalIconId() != null
-                        ? item.getSupplementalIconId().toString() : null);
-                secondaryImageResId.add(item.getSupplementalIconResId());
-            }
+        int id = 0;
+        for (CarUiImeSearchListItem item : mWideScreenSearchItemList) {
+            String idString = String.valueOf(id);
+            itemIdList.add(idString);
+            titleList.add(item.getTitle() != null ? item.getTitle().toString() : null);
+            subTitleList.add(item.getBody() != null ? item.getBody().toString() : null);
+            primaryImageResId.add(item.getIconResId());
+            secondaryItemId.add(idString);
+            secondaryImageResId.add(item.getSupplementalIconResId());
+
+            mIdToListItem.put(idString, item);
+            id++;
         }
 
         Bundle bundle = new Bundle();
@@ -251,38 +290,6 @@
     }
 
     /**
-     * Registers a new {@link CarUiEditText.PrivateImeCommandCallback} to the list of
-     * listeners.
-     */
-    public void registerOnPrivateImeCommandListener(
-            CarUiEditText.PrivateImeCommandCallback listener) {
-        if (mSearchText instanceof CarUiEditText) {
-            ((CarUiEditText) mSearchText).registerOnPrivateImeCommandListener(listener);
-        }
-    }
-
-    /**
-     * Unregisters an existing {@link CarUiEditText.PrivateImeCommandCallback} from the list
-     * of listeners.
-     */
-    public boolean unregisterOnPrivateImeCommandListener(
-            CarUiEditText.PrivateImeCommandCallback listener) {
-        if (mSearchText instanceof CarUiEditText) {
-            return ((CarUiEditText) mSearchText).unregisterOnPrivateImeCommandListener(listener);
-        }
-        return false;
-    }
-
-    /**
-     * Sets the search hint.
-     *
-     * @param resId A string resource id of the search hint.
-     */
-    public void setHint(int resId) {
-        mSearchText.setHint(resId);
-    }
-
-    /**
      * Sets the search hint
      *
      * @param hint A CharSequence of the search hint.
@@ -291,11 +298,6 @@
         mSearchText.setHint(hint);
     }
 
-    /** Gets the search hint */
-    public CharSequence getHint() {
-        return mSearchText.getHint();
-    }
-
     /**
      * Sets a custom icon to display in the search box.
      */
diff --git a/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/toolbar/Toolbar.java b/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/toolbar/Toolbar.java
index 3278edd..c9a96ce 100644
--- a/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/toolbar/Toolbar.java
+++ b/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/toolbar/Toolbar.java
@@ -30,9 +30,8 @@
 import androidx.annotation.StringRes;
 import androidx.annotation.XmlRes;
 
-import com.android.car.ui.CarUiEditText;
 import com.android.car.ui.R;
-import com.android.car.ui.recyclerview.CarUiListItem;
+import com.android.car.ui.imewidescreen.CarUiImeSearchListItem;
 
 import java.util.List;
 
@@ -654,32 +653,12 @@
     }
 
     /**
-     * Registers a new {@link CarUiEditText.PrivateImeCommandCallback} to the list of
-     * listeners.
-     */
-    @Override
-    public void registerOnPrivateImeCommandListener(
-            CarUiEditText.PrivateImeCommandCallback listener) {
-        mController.registerOnPrivateImeCommandListener(listener);
-    }
-
-    /**
-     * Unregisters an existing {@link CarUiEditText.PrivateImeCommandCallback} from the list
-     * of listeners.
-     */
-    @Override
-    public boolean unregisterOnPrivateImeCommandListener(
-            CarUiEditText.PrivateImeCommandCallback listener) {
-        return mController.unregisterOnPrivateImeCommandListener(listener);
-    }
-
-    /**
      * Sets a list of search items to be displayed in the IME window when running as a wide screen
      * mode. This should be called each time the list is updated. For example, when a user is typing
      * in the input field and the list gets filtered this method should be invoked each time.
      */
     @Override
-    public void setSearchItemsForWideScreen(List<CarUiListItem> searchItems) {
+    public void setSearchItemsForWideScreen(List<? extends CarUiImeSearchListItem> searchItems) {
         mController.setSearchItemsForWideScreen(searchItems);
     }
 
diff --git a/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/toolbar/ToolbarController.java b/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/toolbar/ToolbarController.java
index d88259f..6bed46c 100644
--- a/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/toolbar/ToolbarController.java
+++ b/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/toolbar/ToolbarController.java
@@ -24,7 +24,7 @@
 import androidx.annotation.StringRes;
 import androidx.annotation.XmlRes;
 
-import com.android.car.ui.CarUiEditText;
+import com.android.car.ui.imewidescreen.CarUiImeSearchListItem;
 import com.android.car.ui.recyclerview.CarUiListItem;
 
 import java.util.List;
@@ -277,23 +277,10 @@
     boolean unregisterOnSearchListener(Toolbar.OnSearchListener listener);
 
     /**
-     * Registers a new {@link CarUiEditText.PrivateImeCommandCallback} to the list of
-     * listeners.
-     */
-    void registerOnPrivateImeCommandListener(CarUiEditText.PrivateImeCommandCallback listener);
-
-    /**
-     * Unregisters an existing {@link CarUiEditText.PrivateImeCommandCallback} from the list
-     * of listeners.
-     */
-    boolean unregisterOnPrivateImeCommandListener(
-            CarUiEditText.PrivateImeCommandCallback listener);
-
-    /**
      * Sets list of search item {@link CarUiListItem} to be displayed in the IMS
      * template.
      */
-    void setSearchItemsForWideScreen(List<CarUiListItem> searchItems);
+    void setSearchItemsForWideScreen(List<? extends CarUiImeSearchListItem> searchItems);
 
     /** Registers a new {@link Toolbar.OnSearchCompletedListener} to the list of listeners. */
     void registerOnSearchCompletedListener(Toolbar.OnSearchCompletedListener listener);
diff --git a/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/toolbar/ToolbarControllerImpl.java b/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/toolbar/ToolbarControllerImpl.java
index f89d420..92d57b6 100644
--- a/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/toolbar/ToolbarControllerImpl.java
+++ b/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/toolbar/ToolbarControllerImpl.java
@@ -42,8 +42,8 @@
 import androidx.annotation.XmlRes;
 
 import com.android.car.ui.AlertDialogBuilder;
-import com.android.car.ui.CarUiEditText;
 import com.android.car.ui.R;
+import com.android.car.ui.imewidescreen.CarUiImeSearchListItem;
 import com.android.car.ui.recyclerview.CarUiContentListItem;
 import com.android.car.ui.recyclerview.CarUiListItem;
 import com.android.car.ui.recyclerview.CarUiListItemAdapter;
@@ -113,7 +113,7 @@
     private boolean mNavIconSpaceReserved;
     private boolean mLogoFillsNavIconSpace;
     private boolean mShowLogo;
-    private List<CarUiListItem> mSearchItems;
+    private List<? extends CarUiImeSearchListItem> mSearchItems;
     private final ProgressBarController mProgressBar;
     private final MenuItem.Listener mOverflowItemListener = item -> {
         updateOverflowDialog(item);
@@ -871,33 +871,8 @@
         return mOnSearchListeners.remove(listener);
     }
 
-    /**
-     * Registers a new {@link CarUiEditText.PrivateImeCommandCallback} to the list of
-     * listeners.
-     */
     @Override
-    public void registerOnPrivateImeCommandListener(
-            CarUiEditText.PrivateImeCommandCallback listener) {
-        if (mSearchView != null) {
-            mSearchView.registerOnPrivateImeCommandListener(listener);
-        }
-    }
-
-    /**
-     * Unregisters an existing {@link CarUiEditText.PrivateImeCommandCallback} from the list
-     * of listeners.
-     */
-    @Override
-    public boolean unregisterOnPrivateImeCommandListener(
-            CarUiEditText.PrivateImeCommandCallback listener) {
-        if (mSearchView != null) {
-            return mSearchView.unregisterOnPrivateImeCommandListener(listener);
-        }
-        return false;
-    }
-
-    @Override
-    public void setSearchItemsForWideScreen(List<CarUiListItem> searchItems) {
+    public void setSearchItemsForWideScreen(List<? extends CarUiImeSearchListItem> searchItems) {
         mSearchItems = searchItems;
         if (mSearchView != null) {
             mSearchView.setSearchItemsForWideScreen(searchItems);
diff --git a/car-ui-lib/car-ui-lib/src/main/res/layout/car_ui_alert_dialog_edit_text.xml b/car-ui-lib/car-ui-lib/src/main/res/layout/car_ui_alert_dialog_edit_text.xml
index 378b539..985b7d8 100644
--- a/car-ui-lib/car-ui-lib/src/main/res/layout/car_ui_alert_dialog_edit_text.xml
+++ b/car-ui-lib/car-ui-lib/src/main/res/layout/car_ui_alert_dialog_edit_text.xml
@@ -16,7 +16,7 @@
   -->
 
 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android">
-    <com.android.car.ui.CarUiEditText
+    <com.android.car.ui.toolbar.CarUiEditText
               android:id="@+id/textbox"
               android:layout_width="match_parent"
               android:layout_height="@dimen/car_ui_dialog_edittext_height"
diff --git a/car-ui-lib/car-ui-lib/src/main/res/layout/car_ui_preference_dialog_edittext.xml b/car-ui-lib/car-ui-lib/src/main/res/layout/car_ui_preference_dialog_edittext.xml
index 39b4112..86474a9 100644
--- a/car-ui-lib/car-ui-lib/src/main/res/layout/car_ui_preference_dialog_edittext.xml
+++ b/car-ui-lib/car-ui-lib/src/main/res/layout/car_ui_preference_dialog_edittext.xml
@@ -33,7 +33,7 @@
         android:layout_marginEnd="@dimen/car_ui_preference_edit_text_dialog_message_margin_end"
         android:visibility="gone"/>
 
-    <com.android.car.ui.CarUiEditText
+    <com.android.car.ui.toolbar.CarUiEditText
         android:id="@android:id/edit"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
diff --git a/car-ui-lib/car-ui-lib/src/main/res/layout/car_ui_toolbar_search_view.xml b/car-ui-lib/car-ui-lib/src/main/res/layout/car_ui_toolbar_search_view.xml
index 1c82fff..6a3d9ec 100644
--- a/car-ui-lib/car-ui-lib/src/main/res/layout/car_ui_toolbar_search_view.xml
+++ b/car-ui-lib/car-ui-lib/src/main/res/layout/car_ui_toolbar_search_view.xml
@@ -19,7 +19,7 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:app="http://schemas.android.com/apk/res-auto">
 
-    <com.android.car.ui.CarUiEditText
+    <com.android.car.ui.toolbar.CarUiEditText
         android:id="@+id/car_ui_toolbar_search_bar"
         android:layout_height="match_parent"
         android:layout_width="match_parent"
diff --git a/car-ui-lib/paintbooth/AndroidManifest-gradle.xml b/car-ui-lib/paintbooth/AndroidManifest-gradle.xml
index 3184bd7..36823ec 100644
--- a/car-ui-lib/paintbooth/AndroidManifest-gradle.xml
+++ b/car-ui-lib/paintbooth/AndroidManifest-gradle.xml
@@ -49,18 +49,27 @@
         android:exported="false"
         android:parentActivityName=".MainActivity"/>
     <activity
+        android:name=".widescreenime.WideScreenImeActivity"
+        android:windowSoftInputMode="stateHidden|adjustNothing"
+        android:exported="false"
+        android:parentActivityName=".MainActivity">
+    </activity>
+    <activity
         android:name=".toolbar.ToolbarActivity"
         android:exported="false"
         android:parentActivityName=".MainActivity">
       <meta-data android:name="distractionOptimized" android:value="true"/>
     </activity>
     <activity
+        android:name=".toolbar.NoCarUiToolbarActivity"
+        android:exported="false"
+        android:parentActivityName=".MainActivity"
+        android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>
+    <activity
         android:name=".toolbar.OldToolbarActivity"
         android:exported="false"
         android:parentActivityName=".MainActivity"
-        android:theme="@style/Theme.CarUi">
-      <meta-data android:name="distractionOptimized" android:value="true"/>
-    </activity>
+        android:theme="@style/Theme.CarUi"/>
     <activity
         android:name=".overlays.OverlayActivity"
         android:exported="false"
diff --git a/car-ui-lib/paintbooth/src/main/java/com/android/car/ui/paintbooth/widescreenime/WideScreenImeActivity.java b/car-ui-lib/paintbooth/src/main/java/com/android/car/ui/paintbooth/widescreenime/WideScreenImeActivity.java
index 09fb578..e7bc6f5 100644
--- a/car-ui-lib/paintbooth/src/main/java/com/android/car/ui/paintbooth/widescreenime/WideScreenImeActivity.java
+++ b/car-ui-lib/paintbooth/src/main/java/com/android/car/ui/paintbooth/widescreenime/WideScreenImeActivity.java
@@ -41,19 +41,18 @@
 import android.view.ViewGroup;
 import android.view.inputmethod.InputMethodManager;
 import android.widget.EditText;
+import android.widget.Toast;
 
 import androidx.annotation.NonNull;
 import androidx.appcompat.app.AppCompatActivity;
 import androidx.recyclerview.widget.RecyclerView;
 
-import com.android.car.ui.CarUiEditText;
 import com.android.car.ui.baselayout.Insets;
 import com.android.car.ui.baselayout.InsetsChangedListener;
 import com.android.car.ui.core.CarUi;
 import com.android.car.ui.imewidescreen.CarUiImeSearchListItem;
 import com.android.car.ui.paintbooth.R;
 import com.android.car.ui.recyclerview.CarUiContentListItem;
-import com.android.car.ui.recyclerview.CarUiListItem;
 import com.android.car.ui.recyclerview.CarUiRecyclerView;
 import com.android.car.ui.toolbar.MenuItem;
 import com.android.car.ui.toolbar.Toolbar;
@@ -106,16 +105,22 @@
                     return false;
                 });
 
+        CarUiContentListItem.OnClickListener mainClickListener = i ->
+                Toast.makeText(this, "Item clicked!", Toast.LENGTH_SHORT).show();
+
+        CarUiContentListItem.OnClickListener secondaryClickListener = i ->
+                Toast.makeText(this, "Item's secondary action clicked!", Toast.LENGTH_SHORT).show();
+
         final int[] count = {1};
         CarUiImeSearchListItem item = new CarUiImeSearchListItem(CarUiContentListItem.Action.ICON);
-        item.setItemId("Item Id" + count[0]);
         item.setTitle("Title " + count[0]);
         item.setBody("Sub title " + count[0]);
         item.setIconResId(R.drawable.ic_launcher);
-        item.setSupplementalIconId("Image Id " + count[0]);
         item.setSupplementalIconResId(R.drawable.ic_launcher);
+        item.setSupplementalIcon(getDrawable(R.drawable.ic_launcher), secondaryClickListener);
+        item.setOnItemClickedListener(mainClickListener);
 
-        List<CarUiListItem> searchItems = new ArrayList<>();
+        List<CarUiImeSearchListItem> searchItems = new ArrayList<>();
 
         searchItems.add(item);
 
@@ -126,12 +131,12 @@
             count[0]++;
             CarUiImeSearchListItem item1 = new CarUiImeSearchListItem(
                     CarUiContentListItem.Action.ICON);
-            item1.setItemId("Item Id" + count[0]);
             item1.setTitle("Title " + count[0]);
             item1.setBody("Sub title " + count[0]);
             item1.setIconResId(R.drawable.ic_launcher);
-            item1.setSupplementalIconId("Image Id " + count[0]);
             item1.setSupplementalIconResId(R.drawable.ic_launcher);
+            item1.setSupplementalIcon(getDrawable(R.drawable.ic_launcher), secondaryClickListener);
+            item1.setOnItemClickedListener(mainClickListener);
             searchItems.add(item1);
 
             toolbar.setSearchItemsForWideScreen(searchItems);
@@ -281,22 +286,11 @@
 
     private static class ViewHolder extends RecyclerView.ViewHolder {
 
-        private final CarUiEditText mEditText;
+        private final EditText mEditText;
 
         ViewHolder(View itemView) {
             super(itemView);
             mEditText = itemView.requireViewById(R.id.edit_text);
-            mEditText.registerOnPrivateImeCommandListener(
-                    new CarUiEditText.PrivateImeCommandCallback() {
-
-                        @Override
-                        public void onItemClicked(String itemId) {
-                        }
-
-                        @Override
-                        public void onSecondaryImageClicked(String secondaryImageId) {
-                        }
-                    });
         }
 
         public void bind(CharSequence title, View.OnFocusChangeListener listener) {
diff --git a/car-ui-lib/paintbooth/src/main/res/layout/edit_text_list_item.xml b/car-ui-lib/paintbooth/src/main/res/layout/edit_text_list_item.xml
index 3475b14..a04edd7 100644
--- a/car-ui-lib/paintbooth/src/main/res/layout/edit_text_list_item.xml
+++ b/car-ui-lib/paintbooth/src/main/res/layout/edit_text_list_item.xml
@@ -18,7 +18,7 @@
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content">
 
-    <com.android.car.ui.CarUiEditText
+    <EditText
         android:id="@+id/edit_text"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"