From c434af7dc6a6102d9040f3b1fde8cb09b02119c4 Mon Sep 17 00:00:00 2001 From: Arnaud Vergnet Date: Fri, 4 Feb 2022 11:42:56 +0100 Subject: [PATCH] [android] Close search wheel when closing search toolbar Signed-off-by: Arnaud Vergnet --- .../src/com/mapswithme/maps/MwmActivity.java | 21 +++++++------------ .../mapswithme/maps/routing/SearchWheel.java | 7 ++----- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/android/src/com/mapswithme/maps/MwmActivity.java b/android/src/com/mapswithme/maps/MwmActivity.java index 7ab2ce9a88..d2ed36d5ab 100644 --- a/android/src/com/mapswithme/maps/MwmActivity.java +++ b/android/src/com/mapswithme/maps/MwmActivity.java @@ -383,7 +383,7 @@ public class MwmActivity extends BaseMwmFragmentActivity args.putBoolean(DownloaderActivity.EXTRA_OPEN_DOWNLOADED, openDownloaded); if (mIsTabletLayout) { - closeSearchToolbar(false); + closeSearchToolbar(false, true); replaceFragment(DownloaderFragment.class, args, null); } else @@ -558,7 +558,7 @@ public class MwmActivity extends BaseMwmFragmentActivity } else { - closeSearchToolbar(true); + closeSearchToolbar(true, true); } } @@ -707,18 +707,14 @@ public class MwmActivity extends BaseMwmFragmentActivity return false; } - private boolean closeSearchToolbar(boolean clearText) - { - return closeSearchToolbar(clearText, true); - } - private boolean closeSearchToolbar(boolean clearText, boolean stopSearch) { - if (UiUtils.isVisible(mSearchController.getToolbar()) || mSearchController.hasQuery()) + if (UiUtils.isVisible(mSearchController.getToolbar()) || !TextUtils.isEmpty(SearchEngine.INSTANCE.getQuery())) { if (stopSearch) { mSearchController.cancelSearchApiAndHide(clearText); + mNavigationController.resetSearchWheel(); } else { @@ -1115,7 +1111,7 @@ public class MwmActivity extends BaseMwmFragmentActivity return; } - if (closeSearchToolbar(true)) + if (closeSearchToolbar(true, true)) { return; } @@ -1627,7 +1623,6 @@ public class MwmActivity extends BaseMwmFragmentActivity } closeAllFloatingPanelsTablet(); - mNavigationController.resetSearchWheel(); if (completionListener != null) completionListener.run(); @@ -1695,7 +1690,7 @@ public class MwmActivity extends BaseMwmFragmentActivity mOnmapDownloader.updateState(false); if (show) { - closeFloatingToolbarsAndPanels(true, false); + closeFloatingToolbarsAndPanels(false, false); if (mFilterController != null) mFilterController.show(false); } @@ -1768,7 +1763,7 @@ public class MwmActivity extends BaseMwmFragmentActivity if (!RoutingController.get().isPlanning()) return; - mNavigationController.resetSearchWheel(); + closeSearchToolbar(true, true); } @Override @@ -1959,7 +1954,7 @@ public class MwmActivity extends BaseMwmFragmentActivity public void onSearchRoutePoint(@RoutePointInfo.RouteMarkType int pointType) { RoutingController.get().waitForPoiPick(pointType); - mNavigationController.resetSearchWheel(); + closeSearchToolbar(true, true); showSearch(""); } diff --git a/android/src/com/mapswithme/maps/routing/SearchWheel.java b/android/src/com/mapswithme/maps/routing/SearchWheel.java index a896e9fea8..5241234b95 100644 --- a/android/src/com/mapswithme/maps/routing/SearchWheel.java +++ b/android/src/com/mapswithme/maps/routing/SearchWheel.java @@ -236,10 +236,7 @@ class SearchWheel implements View.OnClickListener if (mCurrentOption != null || !TextUtils.isEmpty(SearchEngine.INSTANCE.getQuery())) { - SearchEngine.INSTANCE.cancelInteractiveSearch(); - mCurrentOption = null; - mIsExpanded = false; - resetSearchButtonImage(); + reset(); refreshSearchVisibility(); return; } @@ -284,8 +281,8 @@ class SearchWheel implements View.OnClickListener mCurrentOption = searchOption; final String query = mFrame.getContext().getString(searchOption.mQueryId); SearchEngine.INSTANCE.searchInteractive(mFrame.getContext(), query, System.nanoTime(), false /* isMapAndTable */); + SearchEngine.INSTANCE.setQuery(query); refreshSearchButtonImage(); - toggleSearchLayout(); } }