diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index 366bd47340..3c82a549e7 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -1481,10 +1481,8 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven QuickSearchDialogFragment fragment = getQuickSearchDialogFragment(); if (fragment != null) { if (mode == ShowQuickSearchMode.NEW || (mode == ShowQuickSearchMode.NEW_IF_EXPIRED && fragment.isExpired())) { - if (!fragment.onBackPressed()) { - fragment.dismiss(); - QuickSearchDialogFragment.showInstance(this, "", null, showCategories, null); - } + fragment.dismiss(); + QuickSearchDialogFragment.showInstance(this, "", null, showCategories, null); } else { fragment.show(); } diff --git a/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java b/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java index 3ebf851b56..f56cfa89ee 100644 --- a/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java @@ -344,7 +344,9 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC new OnClickListener() { @Override public void onClick(View v) { - dismiss(); + if (!processBackAction()) { + dismiss(); + } } } ); @@ -551,6 +553,19 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC } } + @NonNull + @Override + public Dialog onCreateDialog(Bundle savedInstanceState) { + return new Dialog(getActivity(), getTheme()){ + @Override + public void onBackPressed() { + if (!processBackAction()) { + cancel(); + } + } + }; + } + public void saveCustomFilter() { final OsmandApplication app = getMyApplication(); final PoiUIFilter filter = app.getPoiFilters().getCustomPOIFilter(); @@ -834,7 +849,11 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC super.onDismiss(dialog); } - public boolean onBackPressed() { + private boolean processBackAction() { + if (addressSearch && isSearchViewVisible()) { + searchEditText.setText(""); + return true; + } return false; } @@ -909,6 +928,10 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC } } + private boolean isSearchViewVisible() { + return searchView.getVisibility() == View.VISIBLE; + } + public void setResultCollection(SearchResultCollection resultCollection) { searchHelper.setResultCollection(resultCollection); }