Set the bounds offset of RecyclerView FocusArea

When FocusAreas overlap, RotaryService may fail to find the correct
nudge target. Setting the bounds offset of the FocusArea can fix
the bug.

Bug: 171843406
Test: manual

Change-Id: I53ab74953a321763847b89c30ef5885b35678b6e
diff --git a/src/com/android/car/media/BrowseViewController.java b/src/com/android/car/media/BrowseViewController.java
index cd67f71..01ddabd 100644
--- a/src/com/android/car/media/BrowseViewController.java
+++ b/src/com/android/car/media/BrowseViewController.java
@@ -120,6 +120,11 @@
     private List<MediaItemMetadata> mTopItems;
 
     /**
+     * The bottom padding of the FocusArea highlight.
+     */
+    private int mFocusAreaHighlightBottomPadding;
+
+    /**
      * Callbacks (implemented by the hosting Activity)
      */
     public interface Callbacks {
@@ -404,7 +409,12 @@
         int rightPadding = mBrowseList.getPaddingRight();
         int bottomPadding = mBrowseList.getPaddingBottom();
         mBrowseList.setPadding(leftPadding, insets.getTop(), rightPadding, bottomPadding);
-        mFocusArea.setHighlightPadding(leftPadding, insets.getTop(), rightPadding, bottomPadding);
+        if (bottomPadding > mFocusAreaHighlightBottomPadding) {
+            mFocusAreaHighlightBottomPadding = bottomPadding;
+        }
+        mFocusArea.setHighlightPadding(
+                leftPadding, insets.getTop(), rightPadding, mFocusAreaHighlightBottomPadding);
+        mFocusArea.setBoundsOffset(leftPadding, insets.getTop(), rightPadding, bottomPadding);
     }
 
     void onPlaybackControlsChanged(boolean visible) {
@@ -416,8 +426,12 @@
                         R.dimen.browse_fragment_bottom_padding)
                 : 0;
         mBrowseList.setPadding(leftPadding, topPadding, rightPadding, bottomPadding);
-        mFocusArea.setHighlightPadding(leftPadding, topPadding, rightPadding,
-                mSetFocusAreaHighlightBottom ? bottomPadding : 0);
+        int highlightBottomPadding = mSetFocusAreaHighlightBottom ? bottomPadding : 0;
+        if (highlightBottomPadding > mFocusAreaHighlightBottomPadding) {
+            mFocusAreaHighlightBottomPadding = highlightBottomPadding;
+        }
+        mFocusArea.setHighlightPadding(
+                leftPadding, topPadding, rightPadding, mFocusAreaHighlightBottomPadding);
         // Set the bottom offset to bottomPadding regardless of mSetFocusAreaHighlightBottom so that
         // RotaryService can find the correct target when the user nudges the rotary controller.
         mFocusArea.setBoundsOffset(leftPadding, topPadding, rightPadding, bottomPadding);