Move search bar background protection on top of scrollbar.
This way the search bar looks more connected to the keyboard
without the scrollbar showing next to it.
Note: Here the search bar is added on top of all other views
(previously it was inserted above only the header), and the
protection is always added just behind the search bar.
Also adjusts the height of the scrollbar to end above the search
bar when floating search bar is enabled.
Screenshots:
Scrollbar behind search bar: https://drive.google.com/file/d/10ZJ-q5nA9ZBjr7gjoauTDDAbQRUNk7S7/view?usp=share_link&resourcekey=0-pF6eOcuKz2_sCA_eZpa1Sw
New scrollbar height with floating search: https://drive.google.com/file/d/1fVIJjiG7RMme5fBXiSJmxNfOhHJ__Gwj/view?usp=share_link&resourcekey=0-b9RsB7f55U_rIZBu4IhVGQ
Fix: 265478433
Test: With and without floating search and always-on keyboard and
work profile.
Change-Id: I4f7ae0d376dae215c0cbd8deaee3e4a409d21ae4
diff --git a/src/com/android/launcher3/FastScrollRecyclerView.java b/src/com/android/launcher3/FastScrollRecyclerView.java
index 2f927d3..3504b24 100644
--- a/src/com/android/launcher3/FastScrollRecyclerView.java
+++ b/src/com/android/launcher3/FastScrollRecyclerView.java
@@ -77,11 +77,15 @@
return getPaddingTop();
}
+ public int getScrollBarMarginBottom() {
+ return getPaddingBottom();
+ }
+
/**
* Returns the height of the fast scroll bar
*/
public int getScrollbarTrackHeight() {
- return mScrollbar.getHeight() - getScrollBarTop() - getPaddingBottom();
+ return mScrollbar.getHeight() - getScrollBarTop() - getScrollBarMarginBottom();
}
/**
diff --git a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java
index 95e61b8..15be660 100644
--- a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java
@@ -212,9 +212,9 @@
mBottomSheetHandleArea = findViewById(R.id.bottom_sheet_handle_area);
mSearchRecyclerView = findViewById(R.id.search_results_list_view);
- // Add the search box next to the header
+ // Add the search box above everything else.
mSearchContainer = inflateSearchBox();
- addView(mSearchContainer, indexOfChild(mHeader) + 1);
+ addView(mSearchContainer);
mSearchUiManager = (SearchUiManager) mSearchContainer;
}
@@ -466,6 +466,16 @@
}
setupHeader();
+ if (FeatureFlags.ENABLE_FLOATING_SEARCH_BAR.get()) {
+ // Keep the scroller above the search bar.
+ RelativeLayout.LayoutParams scrollerLayoutParams =
+ (LayoutParams) findViewById(R.id.fast_scroller).getLayoutParams();
+ scrollerLayoutParams.addRule(RelativeLayout.ABOVE, R.id.search_container_all_apps);
+ scrollerLayoutParams.removeRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
+ scrollerLayoutParams.bottomMargin = getResources().getDimensionPixelSize(
+ R.dimen.fastscroll_bottom_margin_floating_search);
+ }
+
mAllAppsStore.registerIconContainer(mAH.get(AdapterHolder.MAIN).mRecyclerView);
mAllAppsStore.registerIconContainer(mAH.get(AdapterHolder.WORK).mRecyclerView);
mAllAppsStore.registerIconContainer(mAH.get(AdapterHolder.SEARCH).mRecyclerView);
diff --git a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
index 7789191..6b45fe6 100644
--- a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
@@ -261,12 +261,19 @@
}
}
+ @Override
public int getScrollBarTop() {
return ActivityContext.lookupContext(getContext()).getAppsView().isSearchSupported()
? getResources().getDimensionPixelOffset(R.dimen.all_apps_header_top_padding)
: 0;
}
+ @Override
+ public int getScrollBarMarginBottom() {
+ return getRootWindowInsets() == null ? 0
+ : getRootWindowInsets().getSystemWindowInsetBottom();
+ }
+
public RecyclerViewFastScroller getScrollbar() {
return mScrollbar;
}