From 7a36ad396e87819459f3bf0d55b976be5b9ba5ba Mon Sep 17 00:00:00 2001 From: Steven Ng Date: Thu, 27 May 2021 18:41:51 +0100 Subject: [PATCH] Don't dismiss keyboard after clicking X button on the widgets search bar Test: Enter some queries in the widgets search bar. Click X button. The keyboard is still opened after the search queries has been erased. Bug: 189454318 Change-Id: Icb0501cf36cbf1517e2da24044da44101fa86ed9 --- .../picker/search/WidgetsSearchBarControllerTest.java | 9 ++------- .../widget/picker/search/WidgetsSearchBarController.java | 4 +--- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/robolectric_tests/src/com/android/launcher3/widget/picker/search/WidgetsSearchBarControllerTest.java b/robolectric_tests/src/com/android/launcher3/widget/picker/search/WidgetsSearchBarControllerTest.java index a057a84d06..7ac879aa44 100644 --- a/robolectric_tests/src/com/android/launcher3/widget/picker/search/WidgetsSearchBarControllerTest.java +++ b/robolectric_tests/src/com/android/launcher3/widget/picker/search/WidgetsSearchBarControllerTest.java @@ -19,7 +19,6 @@ package com.android.launcher3.widget.picker.search; import static org.junit.Assert.assertEquals; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; @@ -131,18 +130,14 @@ public class WidgetsSearchBarControllerTest { public void cancelSearch_shouldInformSearchModeListenerToClearResultsAndExitSearch() { mCancelButton.performClick(); - // 1 time explicitly from the cancel button on click listener. - // Another from the setText("") the cancel button on click listener causing afterTextChange. - verify(mSearchModeListener, times(2)).exitSearchMode(); + verify(mSearchModeListener).exitSearchMode(); } @Test public void cancelSearch_shouldCancelSearch() { mCancelButton.performClick(); - // 1 time explicitly from the cancel button on click listener. - // Another from the setText("") the cancel button on click listener causing afterTextChange. - verify(mSearchAlgorithm, times(2)).cancel(true); + verify(mSearchAlgorithm).cancel(true); verifyNoMoreInteractions(mSearchAlgorithm); } diff --git a/src/com/android/launcher3/widget/picker/search/WidgetsSearchBarController.java b/src/com/android/launcher3/widget/picker/search/WidgetsSearchBarController.java index a8294c0426..2751a52796 100644 --- a/src/com/android/launcher3/widget/picker/search/WidgetsSearchBarController.java +++ b/src/com/android/launcher3/widget/picker/search/WidgetsSearchBarController.java @@ -101,10 +101,8 @@ public class WidgetsSearchBarController implements TextWatcher, @Override public void clearSearchResult() { - mSearchAlgorithm.cancel(/* interruptActiveRequests= */ true); + // Any existing search session will be cancelled by setting text to empty. mInput.setText(""); - clearFocus(); - mSearchModeListener.exitSearchMode(); } /**