Updating alignment of search input

Bug: 30017936
Change-Id: I2f68711762872bc100b41b2b4768d33e2c0cd902
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index c8a05b7..f3d0eaa 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -64,6 +64,7 @@
     <dimen name="all_apps_grid_section_y_offset">8dp</dimen>
     <dimen name="all_apps_grid_section_text_size">24sp</dimen>
     <dimen name="all_apps_search_bar_height">60dp</dimen>
+    <dimen name="all_apps_search_bar_margin_top">5dp</dimen>
     <dimen name="all_apps_search_bar_icon_margin_right">4dp</dimen>
     <dimen name="all_apps_search_bar_icon_margin_top">1dp</dimen>
     <dimen name="all_apps_icon_top_bottom_padding">8dp</dimen>
diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java
index 79a15b9..ae9d836 100644
--- a/src/com/android/launcher3/allapps/AllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java
@@ -153,6 +153,7 @@
     private ExtendedEditText mSearchInput;
     private ImageView mSearchIcon;
     private HeaderElevationController mElevationController;
+    private int mSearchContainerOffsetTop;
 
     private SpannableStringBuilder mSearchQueryBuilder = null;
 
@@ -312,6 +313,8 @@
         mSearchContainer = findViewById(R.id.search_container);
         mSearchInput = (ExtendedEditText) findViewById(R.id.search_box_input);
         mSearchIcon = (ImageView) findViewById(R.id.search_icon);
+        mSearchContainerOffsetTop = getResources().getDimensionPixelSize(
+                R.dimen.all_apps_search_bar_margin_top);
 
         final LinearLayout.LayoutParams searchParams =
                 (LinearLayout.LayoutParams) mSearchInput.getLayoutParams();
@@ -419,13 +422,12 @@
                 mAdapter.setNumAppsPerRow(mNumAppsPerRow);
                 mApps.setNumAppsPerRow(mNumAppsPerRow, mNumPredictedAppsPerRow, new FullMergeAlgorithm());
                 if (mNumAppsPerRow > 0) {
-                    int iconSize = availableWidth / mNumAppsPerRow;
-                    int iconSpacing = (iconSize - grid.allAppsIconSizePx) / 2;
+                    int rvPadding = mAppsRecyclerView.getPaddingStart(); // Assumes symmetry
                     final int thumbMaxWidth =
                             getResources().getDimensionPixelSize(
                                     R.dimen.container_fastscroll_thumb_max_width);
-                    mSearchContainer.setPaddingRelative(
-                            iconSpacing + thumbMaxWidth, 0, iconSpacing + thumbMaxWidth, 0);
+                    mSearchContainer.setPaddingRelative(rvPadding + thumbMaxWidth, 0, rvPadding +
+                            thumbMaxWidth, 0);
                 }
             }
             super.onMeasure(widthMeasureSpec, heightMeasureSpec);
@@ -525,7 +527,7 @@
 
                 LinearLayout.LayoutParams llp =
                         (LinearLayout.LayoutParams) mSearchInput.getLayoutParams();
-                llp.topMargin = insets.top;
+                llp.topMargin = insets.top + mSearchContainerOffsetTop;
                 mSearchInput.setLayoutParams(llp);
                 mSearchIcon.setLayoutParams(llp);
 
diff --git a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java
index 6540a23..d0b8abc 100644
--- a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java
+++ b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java
@@ -203,7 +203,6 @@
                             continue;
                         }
 
-
                         // Find the section name bounds
                         PointF sectionBounds = getAndCacheSectionBounds(sectionName);