Fix full widgets picker fast scroller height.
1. Fix the app title to one line.
2. Use the measured height of a header view to estimate the available
fast scroll bar height.
Test: Open full widgets picker. Scroll to the bottom by scroll gesture.
Observe the fast scroll bar indicator is correctly shown.
Scroll back to top and then use the fast scroll bar to scroll to
the end of the page. Observe the last app row is aligned to the
bottom of the page.
Bug: 188914448
Change-Id: I57a2419d1fbfc8f946a932eebfefb67ae0c07eb6
diff --git a/res/layout/widgets_list_row_header.xml b/res/layout/widgets_list_row_header.xml
index a0a0456..22cf942 100644
--- a/res/layout/widgets_list_row_header.xml
+++ b/res/layout/widgets_list_row_header.xml
@@ -49,6 +49,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start|center_vertical"
+ android:ellipsize="end"
+ android:maxLines="1"
android:textColor="?android:attr/textColorPrimary"
android:textSize="16sp"
tools:text="App name" />
diff --git a/src/com/android/launcher3/widget/picker/WidgetsRecyclerView.java b/src/com/android/launcher3/widget/picker/WidgetsRecyclerView.java
index e981906..e30e245 100644
--- a/src/com/android/launcher3/widget/picker/WidgetsRecyclerView.java
+++ b/src/com/android/launcher3/widget/picker/WidgetsRecyclerView.java
@@ -49,10 +49,10 @@
private final int mScrollbarTop;
private final Point mFastScrollerOffset = new Point();
- private final int mEstimatedWidgetListHeaderHeight;
private boolean mTouchDownOnScroller;
private HeaderViewDimensionsProvider mHeaderViewDimensionsProvider;
private int mLastVisibleWidgetContentTableHeight = 0;
+ private int mWidgetHeaderHeight = 0;
@Nullable private OnContentChangeListener mOnContentChangeListener;
public WidgetsRecyclerView(Context context) {
@@ -71,9 +71,6 @@
ActivityContext activity = ActivityContext.lookupContext(getContext());
DeviceProfile grid = activity.getDeviceProfile();
- mEstimatedWidgetListHeaderHeight = grid.iconSizePx
- + 2 * context.getResources().getDimensionPixelSize(
- R.dimen.widget_list_header_view_vertical_padding);
}
@Override
@@ -164,6 +161,14 @@
if (view instanceof TableLayout) {
// This assumes there is ever only one content shown in this recycler view.
mLastVisibleWidgetContentTableHeight = view.getMeasuredHeight();
+ } else if (view instanceof WidgetsListHeader
+ && mLastVisibleWidgetContentTableHeight == 0
+ && view.getMeasuredHeight() > 0) {
+ // This assumes all header views are of the same height.
+ RecyclerView.LayoutParams layoutParams =
+ (RecyclerView.LayoutParams) view.getLayoutParams();
+ mWidgetHeaderHeight = view.getMeasuredHeight() + layoutParams.topMargin
+ + layoutParams.bottomMargin;
}
}
@@ -262,7 +267,7 @@
WidgetsListBaseEntry entry = mAdapter.getItems().get(i);
if (entry instanceof WidgetsListHeaderEntry
|| entry instanceof WidgetsListSearchHeaderEntry) {
- totalItemsHeight += mEstimatedWidgetListHeaderHeight;
+ totalItemsHeight += mWidgetHeaderHeight;
} else if (entry instanceof WidgetsListContentEntry) {
totalItemsHeight += mLastVisibleWidgetContentTableHeight;
} else {