diff --git a/res/drawable/ic_allapps_search.xml b/res/drawable/ic_allapps_search.xml index c0e20f1bb8..dbed824358 100644 --- a/res/drawable/ic_allapps_search.xml +++ b/res/drawable/ic_allapps_search.xml @@ -17,7 +17,8 @@ android:width="24dp" android:height="24dp" android:viewportHeight="24.0" - android:viewportWidth="24.0"> + android:viewportWidth="24.0" + android:autoMirrored="true"> diff --git a/res/layout/widgets_search_bar.xml b/res/layout/widgets_search_bar.xml index e3836df108..c3dd19e0bb 100644 --- a/res/layout/widgets_search_bar.xml +++ b/res/layout/widgets_search_bar.xml @@ -13,7 +13,9 @@ android:id="@+id/widgets_search_bar_edit_text" android:layout_width="match_parent" android:layout_height="wrap_content" - android:padding="12dp" + android:paddingVertical="12dp" + android:paddingStart="12dp" + android:paddingEnd="0dp" android:drawablePadding="8dp" android:drawableStart="@drawable/ic_allapps_search" android:background="@null" @@ -21,6 +23,7 @@ android:maxLines="1" android:layout_weight="1" android:inputType="text" + android:imeOptions="actionSearch" android:textColor="?android:attr/textColorSecondary" android:textColorHint="?android:attr/textColorTertiary"/> @@ -28,7 +31,9 @@ android:id="@+id/widgets_search_cancel_button" android:layout_height="wrap_content" android:layout_width="wrap_content" - android:padding="8dp" + android:paddingVertical="12dp" + android:paddingStart="8dp" + android:paddingEnd="12dp" android:src="@drawable/ic_gm_close_24" android:background="?android:selectableItemBackground" android:layout_gravity="center" diff --git a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java index a4257a208e..f6ff87b504 100644 --- a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java +++ b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java @@ -392,6 +392,7 @@ public class WidgetsFullSheet extends BaseWidgetSheet mAdapters.get(AdapterHolder.SEARCH).mWidgetsListAdapter.setWidgetsOnSearch(entries); updateNoSearchResultsView( mAdapters.get(AdapterHolder.SEARCH).mWidgetsListAdapter.getItemCount() == 0); + mAdapters.get(AdapterHolder.SEARCH).mWidgetsRecyclerView.scrollToTop(); } private void setViewVisibilityBasedOnSearch(boolean isInSearchMode) { diff --git a/src/com/android/launcher3/widget/picker/WidgetsRecyclerView.java b/src/com/android/launcher3/widget/picker/WidgetsRecyclerView.java index b016b4f32c..69672f233f 100644 --- a/src/com/android/launcher3/widget/picker/WidgetsRecyclerView.java +++ b/src/com/android/launcher3/widget/picker/WidgetsRecyclerView.java @@ -243,4 +243,19 @@ public class WidgetsRecyclerView extends BaseRecyclerView implements OnItemTouch */ int getHeaderViewHeight(); } + + @Override + public void scrollToTop() { + if (mScrollbar != null) { + mScrollbar.reattachThumbToScroll(); + } + + if (getLayoutManager() instanceof LinearLayoutManager) { + if (getCurrentScrollY() == 0) { + // We are at the top, so don't scrollToPosition (would cause unnecessary relayout). + return; + } + } + scrollToPosition(0); + } } diff --git a/src/com/android/launcher3/widget/picker/search/WidgetsSearchBarController.java b/src/com/android/launcher3/widget/picker/search/WidgetsSearchBarController.java index d35a75b80a..a8294c0426 100644 --- a/src/com/android/launcher3/widget/picker/search/WidgetsSearchBarController.java +++ b/src/com/android/launcher3/widget/picker/search/WidgetsSearchBarController.java @@ -102,7 +102,7 @@ public class WidgetsSearchBarController implements TextWatcher, @Override public void clearSearchResult() { mSearchAlgorithm.cancel(/* interruptActiveRequests= */ true); - mInput.getText().clear(); + mInput.setText(""); clearFocus(); mSearchModeListener.exitSearchMode(); }