From c828bd116c220eaec60add1dca4d6f07ec8c5394 Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Mon, 25 Jul 2016 22:24:32 +0300 Subject: [PATCH] [Quick search] fixes --- OsmAnd/res/layout-land/map_hud_top.xml | 10 ++++++---- OsmAnd/res/layout/map_hud_top.xml | 10 ++++++---- OsmAnd/res/values/strings.xml | 1 + .../plus/search/QuickSearchDialogFragment.java | 9 ++++++--- .../plus/views/mapwidgets/MapInfoWidgetsFactory.java | 12 +++++++++--- 5 files changed, 28 insertions(+), 14 deletions(-) diff --git a/OsmAnd/res/layout-land/map_hud_top.xml b/OsmAnd/res/layout-land/map_hud_top.xml index c5b55c7e0f..605f818ecc 100644 --- a/OsmAnd/res/layout-land/map_hud_top.xml +++ b/OsmAnd/res/layout-land/map_hud_top.xml @@ -367,11 +367,13 @@ android:gravity="center_vertical" android:orientation="horizontal"> - + android:layout_height="48dp" + android:contentDescription="@string/back_to_search" + android:src="@drawable/abc_ic_ab_back_mtrl_am_alpha"/> - + android:layout_height="48dp" + android:contentDescription="@string/back_to_search" + android:src="@drawable/abc_ic_ab_back_mtrl_am_alpha"/> + Back to search Do you want to delete selected history items? Show %1$s on the map diff --git a/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java b/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java index 0084d651f6..b59a9499d5 100644 --- a/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java @@ -484,8 +484,11 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC @Override public void onDismiss(DialogInterface dialog) { - getMapActivity().setQuickSearchTopbarActive(false); - getChildFragmentManager().popBackStack(); + MapActivity mapActivity = getMapActivity(); + if (mapActivity != null) { + getMapActivity().setQuickSearchTopbarActive(false); + getChildFragmentManager().popBackStack(); + } super.onDismiss(dialog); } @@ -570,7 +573,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC break; case MAIN: - if (!Algorithms.isEmpty(searchQuery)) { + if (!Algorithms.isEmpty(searchQuery) && !searchQuery.equals(searchEditText.getText().toString())) { String txt = searchQuery; searchQuery = ""; searchEditText.setText(txt); diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java index fe071ca9a4..8ae1f961fa 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java @@ -165,7 +165,7 @@ public class MapInfoWidgetsFactory { private final MapActivity map; private View searchTopBar; private View searchTopBarLayout; - private ImageView searchIcon; + private ImageButton searchBackButton; private TextView searchTitle; private ImageButton searchCloseButton; @@ -173,7 +173,13 @@ public class MapInfoWidgetsFactory { this.map = map; searchTopBar = map.findViewById(R.id.search_topbar); searchTopBarLayout = map.findViewById(R.id.search_topbar_layout); - searchIcon = (ImageView) map.findViewById(R.id.search_icon); + searchBackButton = (ImageButton) map.findViewById(R.id.search_back_button); + searchBackButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + map.showQuickSearch(); + } + }); searchTitle = (TextView) map.findViewById(R.id.search_title); searchTitle.setOnClickListener(new View.OnClickListener() { @Override @@ -222,7 +228,7 @@ public class MapInfoWidgetsFactory { public void updateTextColor(boolean nightMode, int textColor) { OsmandApplication app = map.getMyApplication(); searchTitle.setTextColor(textColor); - searchIcon.setImageDrawable(app.getIconsCache().getIcon(R.drawable.ic_action_search_dark, !nightMode)); + searchBackButton.setImageDrawable(app.getIconsCache().getIcon(R.drawable.abc_ic_ab_back_mtrl_am_alpha, !nightMode)); searchCloseButton.setImageDrawable(app.getIconsCache().getIcon(R.drawable.ic_action_remove_dark, !nightMode)); }