Add missing FocusArea into preference fragments

Fixes: 174766325
Test: manual
Change-Id: Ibfc1ffb268705b0a06cbcb9308d425ece1c338eb
diff --git a/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/preference/ListPreferenceFragment.java b/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/preference/ListPreferenceFragment.java
index 2f63fbf..b9ad789 100644
--- a/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/preference/ListPreferenceFragment.java
+++ b/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/preference/ListPreferenceFragment.java
@@ -30,6 +30,7 @@
 import androidx.preference.ListPreference;
 import androidx.preference.Preference;
 
+import com.android.car.ui.FocusArea;
 import com.android.car.ui.R;
 import com.android.car.ui.baselayout.Insets;
 import com.android.car.ui.baselayout.InsetsChangedListener;
@@ -106,6 +107,12 @@
                     int oldHeight = carUiRecyclerView.getPaddingTop();
                     carUiRecyclerView.setPadding(0, newHeight, 0, 0);
                     carUiRecyclerView.scrollBy(0, oldHeight - newHeight);
+
+                    FocusArea focusArea = view.findViewById(R.id.car_ui_focus_area);
+                    if (focusArea != null) {
+                        focusArea.setHighlightPadding(0, newHeight, 0, 0);
+                        focusArea.setBoundsOffset(0, newHeight, 0, 0);
+                    }
                 });
             }
         }
@@ -221,5 +228,10 @@
         CarUiUtils.requireViewByRefId(view, R.id.list)
                 .setPadding(0, insets.getTop(), 0, insets.getBottom());
         view.setPadding(insets.getLeft(), 0, insets.getRight(), 0);
+        FocusArea focusArea = view.findViewById(R.id.car_ui_focus_area);
+        if (focusArea != null) {
+            focusArea.setHighlightPadding(0, insets.getTop(), 0, insets.getBottom());
+            focusArea.setBoundsOffset(0, insets.getTop(), 0, insets.getBottom());
+        }
     }
 }
diff --git a/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/preference/MultiSelectListPreferenceFragment.java b/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/preference/MultiSelectListPreferenceFragment.java
index b1b8a28..f9cf8a2 100644
--- a/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/preference/MultiSelectListPreferenceFragment.java
+++ b/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/preference/MultiSelectListPreferenceFragment.java
@@ -29,6 +29,7 @@
 import androidx.preference.DialogPreference;
 import androidx.preference.Preference;
 
+import com.android.car.ui.FocusArea;
 import com.android.car.ui.R;
 import com.android.car.ui.baselayout.Insets;
 import com.android.car.ui.baselayout.InsetsChangedListener;
@@ -107,6 +108,12 @@
                     int oldHeight = recyclerView.getPaddingTop();
                     recyclerView.setPadding(0, newHeight, 0, 0);
                     recyclerView.scrollBy(0, oldHeight - newHeight);
+
+                    FocusArea focusArea = view.findViewById(R.id.car_ui_focus_area);
+                    if (focusArea != null) {
+                        focusArea.setHighlightPadding(0, newHeight, 0, 0);
+                        focusArea.setBoundsOffset(0, newHeight, 0, 0);
+                    }
                 });
             }
         }
@@ -221,5 +228,10 @@
         CarUiUtils.requireViewByRefId(view, R.id.list)
                 .setPadding(0, insets.getTop(), 0, insets.getBottom());
         view.setPadding(insets.getLeft(), 0, insets.getRight(), 0);
+        FocusArea focusArea = view.findViewById(R.id.car_ui_focus_area);
+        if (focusArea != null) {
+            focusArea.setHighlightPadding(0, insets.getTop(), 0, insets.getBottom());
+            focusArea.setBoundsOffset(0, insets.getTop(), 0, insets.getBottom());
+        }
     }
 }
diff --git a/car-ui-lib/car-ui-lib/src/main/res/layout/car_ui_list_preference.xml b/car-ui-lib/car-ui-lib/src/main/res/layout/car_ui_list_preference.xml
index 70bf96d..d56fb38 100644
--- a/car-ui-lib/car-ui-lib/src/main/res/layout/car_ui_list_preference.xml
+++ b/car-ui-lib/car-ui-lib/src/main/res/layout/car_ui_list_preference.xml
@@ -22,11 +22,16 @@
     android:layout_height="match_parent"
     android:background="@drawable/car_ui_activity_background">
 
-    <com.android.car.ui.recyclerview.CarUiRecyclerView
-        android:id="@+id/list"
+    <com.android.car.ui.FocusArea
+        android:id="@+id/car_ui_focus_area"
         android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:tag="carUiPreferenceRecyclerView"
-        app:enableDivider="true" />
+        android:layout_height="match_parent">
+        <com.android.car.ui.recyclerview.CarUiRecyclerView
+            android:id="@+id/list"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:tag="carUiPreferenceRecyclerView"
+            app:enableDivider="true" />
+    </com.android.car.ui.FocusArea>
 
 </FrameLayout>
diff --git a/car-ui-lib/car-ui-lib/src/main/res/layout/car_ui_list_preference_with_toolbar.xml b/car-ui-lib/car-ui-lib/src/main/res/layout/car_ui_list_preference_with_toolbar.xml
index f42c9f1..c83528b 100644
--- a/car-ui-lib/car-ui-lib/src/main/res/layout/car_ui_list_preference_with_toolbar.xml
+++ b/car-ui-lib/car-ui-lib/src/main/res/layout/car_ui_list_preference_with_toolbar.xml
@@ -16,23 +16,32 @@
   -->
 
 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
-    android:id="@+id/container"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:background="@drawable/car_ui_activity_background">
+             xmlns:app="http://schemas.android.com/apk/res-auto"
+             android:id="@+id/container"
+             android:layout_width="match_parent"
+             android:layout_height="match_parent"
+             android:background="@drawable/car_ui_activity_background">
 
-    <com.android.car.ui.recyclerview.CarUiRecyclerView
-        android:id="@+id/list"
+    <com.android.car.ui.FocusArea
+        android:id="@+id/car_ui_focus_area"
         android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:tag="carUiPreferenceRecyclerView"
-        app:enableDivider="true" />
+        android:layout_height="match_parent">
+        <com.android.car.ui.recyclerview.CarUiRecyclerView
+            android:id="@+id/list"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:tag="carUiPreferenceRecyclerView"
+            app:enableDivider="true"/>
+    </com.android.car.ui.FocusArea>
 
-    <com.android.car.ui.toolbar.Toolbar
-        android:id="@+id/toolbar"
+    <com.android.car.ui.FocusArea
         android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        app:car_ui_state="subpage" />
+        android:layout_height="match_parent">
+        <com.android.car.ui.toolbar.Toolbar
+            android:id="@+id/toolbar"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            app:car_ui_state="subpage"/>
+    </com.android.car.ui.FocusArea>
 
 </FrameLayout>