diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml
index bed149248c..b2a8522548 100644
--- a/OsmAnd/res/values/strings.xml
+++ b/OsmAnd/res/values/strings.xml
@@ -9,6 +9,7 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
-->
+ Type address
Type city or town
Type postcode
Nearest cities
diff --git a/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java b/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java
index f56cfa89ee..91e2405fa4 100644
--- a/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java
+++ b/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java
@@ -122,7 +122,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
private QuickSearchMainListFragment mainSearchFragment;
private QuickSearchHistoryListFragment historySearchFragment;
private QuickSearchCategoriesListFragment categoriesSearchFragment;
- private QuickSearchAddressListFragment addrSearchFragment;
+ private QuickSearchAddressListFragment addressSearchFragment;
private QuickSearchToolbarController toolbarController;
private Toolbar toolbarEdit;
@@ -436,7 +436,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
addressSearch = position == 2;
updateClearButtonAndHint();
if (addressSearch) {
- startSearchingCity(true, true);
+ startAddressSearch();
} else {
stopAddressSearch();
}
@@ -466,6 +466,9 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
updateClearButtonVisibility(true);
boolean textEmpty = newQueryText.length() == 0;
updateTabbarVisibility(textEmpty);
+ if (textEmpty && addressSearch) {
+ startAddressSearch();
+ }
if (textEmpty && poiFilterApplied) {
poiFilterApplied = false;
reloadCategories();
@@ -477,15 +480,8 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
if (!searchQuery.equalsIgnoreCase(newQueryText)) {
searchQuery = newQueryText;
if (Algorithms.isEmpty(searchQuery)) {
- if (addressSearch) {
- startSearchingCity(true, true);
- }
searchUICore.resetPhrase();
} else {
- if (addressSearch) {
- updateAddressSearch(searchUICore.getPhrase().getLastSelectedWord() != null
- ? searchUICore.getPhrase().getLastSelectedWord().getResult() : null);
- }
runSearch();
}
} else if (runSearchFirstTime) {
@@ -517,6 +513,9 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
searchUICore.updateSettings(ss);
updateClearButtonAndHint();
updateClearButtonVisibility(true);
+ if (addressSearchFragment != null) {
+ reloadCities();
+ }
startLocationUpdate();
}
updateToolbarButton();
@@ -898,7 +897,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
clearButton.setImageDrawable(app.getIconsCache().getIcon(R.drawable.ic_action_get_my_location, R.color.color_myloc_distance));
} else {
if (addressSearch) {
- searchEditText.setHint(R.string.type_city_town);
+ searchEditText.setHint(R.string.type_address);
} else {
searchEditText.setHint(R.string.search_poi_category_hint);
}
@@ -953,7 +952,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
break;
case ADDRESS:
- addrSearchFragment = (QuickSearchAddressListFragment) searchListFragment;
+ addressSearchFragment = (QuickSearchAddressListFragment) searchListFragment;
reloadCities();
break;
@@ -1002,8 +1001,13 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
private void reloadCategoriesInternal() {
try {
- SearchResultCollection res = searchUICore.shallowSearch(SearchAmenityTypesAPI.class,
- "", null);
+ if (addressSearch) {
+ stopAddressSearch();
+ }
+ SearchResultCollection res = searchUICore.shallowSearch(SearchAmenityTypesAPI.class, "", null);
+ if (addressSearch) {
+ startAddressSearch();
+ }
if (res != null) {
List rows = new ArrayList<>();
for (SearchResult sr : res.getCurrentSearchResults()) {
@@ -1052,11 +1056,10 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
private void reloadCitiesInternal() {
try {
- startSearchingCity(false, false);
- SearchResultCollection res = searchUICore.shallowSearch(SearchAddressByNameAPI.class,
- "", null);
+ startNearestCitySearch();
+ SearchResultCollection res = searchUICore.shallowSearch(SearchAddressByNameAPI.class, "", null);
if (addressSearch) {
- startSearchingCity(true, true);
+ startAddressSearch();
} else {
stopAddressSearch();
}
@@ -1067,7 +1070,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
@Override
public void onClick(View v) {
searchEditText.setHint(R.string.type_city_town);
- startSearchingCity(true, true);
+ startCitySearch();
updateTabbarVisibility(false);
runSearch();
searchEditText.requestFocus();
@@ -1079,7 +1082,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
@Override
public void onClick(View v) {
searchEditText.setHint(R.string.type_postcode);
- startSearchingPostcode(true);
+ startPostcodeSearch();
mainSearchFragment.getAdapter().clear();
updateTabbarVisibility(false);
searchEditText.requestFocus();
@@ -1097,7 +1100,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
limit--;
}
}
- addrSearchFragment.updateListAdapter(rows, false);
+ addressSearchFragment.updateListAdapter(rows, false);
} catch (IOException e) {
e.printStackTrace();
app.showToastMessage(e.getMessage());
@@ -1129,9 +1132,14 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
private void reloadHistoryInternal() {
try {
- SearchResultCollection res = searchUICore.shallowSearch(SearchHistoryAPI.class,
- "", null);
- List rows = new ArrayList<>();
+ if (addressSearch) {
+ stopAddressSearch();
+ }
+ SearchResultCollection res = searchUICore.shallowSearch(SearchHistoryAPI.class, "", null);
+ if (addressSearch) {
+ startAddressSearch();
+ }
+ List rows = new ArrayList<>();
if (res != null) {
for (SearchResult sr : res.getCurrentSearchResults()) {
rows.add(new QuickSearchListItem(app, sr));
@@ -1144,58 +1152,52 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
}
}
- private void startSearchingCity(boolean sortByName, boolean searchVillages) {
+ private void startAddressSearch() {
SearchSettings settings = searchUICore.getSearchSettings()
.setEmptyQueryAllowed(true)
.setAddressSearch(true)
+ .setSortByName(true)
+ .setSearchTypes(ObjectType.CITY, ObjectType.VILLAGE, ObjectType.POSTCODE,
+ ObjectType.HOUSE, ObjectType.STREET_INTERSECTION, ObjectType.STREET,
+ ObjectType.LOCATION, ObjectType.PARTIAL_LOCATION)
.setRadiusLevel(1);
- if (sortByName) {
- settings = settings.setSortByName(true);
- }
- if (searchVillages) {
- settings = settings.setSearchTypes(ObjectType.CITY, ObjectType.VILLAGE);
- } else {
- settings = settings.setSearchTypes(ObjectType.CITY);
- }
searchUICore.updateSettings(settings);
}
- private void startSearchingPostcode(boolean sortByName) {
+ private void startCitySearch() {
+ SearchSettings settings = searchUICore.getSearchSettings()
+ .setEmptyQueryAllowed(true)
+ .setAddressSearch(true)
+ .setSortByName(true)
+ .setSearchTypes(ObjectType.CITY, ObjectType.VILLAGE)
+ .setRadiusLevel(1);
+
+ searchUICore.updateSettings(settings);
+ }
+
+ private void startNearestCitySearch() {
+ SearchSettings settings = searchUICore.getSearchSettings()
+ .setEmptyQueryAllowed(true)
+ .setAddressSearch(true)
+ .setSortByName(false)
+ .setSearchTypes(ObjectType.CITY)
+ .setRadiusLevel(1);
+
+ searchUICore.updateSettings(settings);
+ }
+
+ private void startPostcodeSearch() {
SearchSettings settings = searchUICore.getSearchSettings()
.setSearchTypes(ObjectType.POSTCODE)
.setEmptyQueryAllowed(false)
.setAddressSearch(true)
+ .setSortByName(true)
.setRadiusLevel(1);
- if (sortByName) {
- settings = settings.setSortByName(true);
- }
searchUICore.updateSettings(settings);
}
- private void updateAddressSearch(SearchResult searchResult) {
- if (searchResult != null) {
- if (searchResult.objectType == ObjectType.STREET) {
- SearchSettings settings = searchUICore.getSearchSettings()
- .setSearchTypes(ObjectType.HOUSE, ObjectType.STREET_INTERSECTION)
- .setEmptyQueryAllowed(false)
- .setSortByName(false)
- .setRadiusLevel(1);
-
- searchUICore.updateSettings(settings);
- } else if (searchResult.objectType == ObjectType.CITY || searchResult.objectType == ObjectType.VILLAGE) {
- SearchSettings settings = searchUICore.getSearchSettings()
- .setSearchTypes(ObjectType.STREET)
- .setEmptyQueryAllowed(false)
- .setSortByName(false)
- .setRadiusLevel(1);
-
- searchUICore.updateSettings(settings);
- }
- }
- }
-
private void stopAddressSearch() {
SearchSettings settings = searchUICore.getSearchSettings()
.resetSearchTypes()
@@ -1384,9 +1386,6 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
}
}
searchUICore.selectSearchResult(sr);
- if (addressSearch) {
- updateAddressSearch(sr);
- }
String txt = searchUICore.getPhrase().getText(true);
searchQuery = txt;
searchEditText.setText(txt);
@@ -1573,8 +1572,8 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
historySearchFragment.updateLocation(latLon, heading);
} else if (categoriesSearchFragment != null && viewPager.getCurrentItem() == 1) {
categoriesSearchFragment.updateLocation(latLon, heading);
- } else if (addrSearchFragment != null && viewPager.getCurrentItem() == 2) {
- addrSearchFragment.updateLocation(latLon, heading);
+ } else if (addressSearchFragment != null && viewPager.getCurrentItem() == 2) {
+ addressSearchFragment.updateLocation(latLon, heading);
}
}
}
@@ -1590,8 +1589,8 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
if (categoriesSearchFragment != null) {
categoriesSearchFragment.getListAdapter().setUseMapCenter(useMapCenter);
}
- if (addrSearchFragment != null) {
- addrSearchFragment.getListAdapter().setUseMapCenter(useMapCenter);
+ if (addressSearchFragment != null) {
+ addressSearchFragment.getListAdapter().setUseMapCenter(useMapCenter);
}
}
}
diff --git a/OsmAnd/src/net/osmand/plus/search/QuickSearchListAdapter.java b/OsmAnd/src/net/osmand/plus/search/QuickSearchListAdapter.java
index 33508f5e11..c4840ca60e 100644
--- a/OsmAnd/src/net/osmand/plus/search/QuickSearchListAdapter.java
+++ b/OsmAnd/src/net/osmand/plus/search/QuickSearchListAdapter.java
@@ -174,6 +174,9 @@ public class QuickSearchListAdapter extends ArrayAdapter {
}
public void insertListItem(@NonNull QuickSearchListItem item, int index) {
+ if (hasSearchMoreItem && item.getType() == QuickSearchListItemType.SEARCH_MORE) {
+ return;
+ }
setNotifyOnChange(false);
insert(item, index);
if (item.getType() == QuickSearchListItemType.SEARCH_MORE) {
@@ -185,7 +188,10 @@ public class QuickSearchListAdapter extends ArrayAdapter {
@Override
public boolean isEnabled(int position) {
- return getItem(position).getType() != QuickSearchListItemType.HEADER;
+ QuickSearchListItemType type = getItem(position).getType();
+ return type != QuickSearchListItemType.HEADER
+ && type != QuickSearchListItemType.TOP_SHADOW
+ && type != QuickSearchListItemType.BOTTOM_SHADOW;
}
@Override
@@ -257,6 +263,26 @@ public class QuickSearchListAdapter extends ArrayAdapter {
view.findViewById(R.id.top_divider)
.setVisibility(((QuickSearchHeaderListItem)listItem).isShowTopDivider() ? View.VISIBLE : View.GONE);
((TextView) view.findViewById(R.id.title)).setText(listItem.getName());
+ } else if (type == QuickSearchListItemType.TOP_SHADOW) {
+ if (convertView == null) {
+ LayoutInflater inflater = (LayoutInflater) app
+ .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ view = (LinearLayout) inflater.inflate(
+ R.layout.list_shadow_header, null);
+ } else {
+ view = (LinearLayout) convertView;
+ }
+ return view;
+ } else if (type == QuickSearchListItemType.BOTTOM_SHADOW) {
+ if (convertView == null) {
+ LayoutInflater inflater = (LayoutInflater) app
+ .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ view = (LinearLayout) inflater.inflate(
+ R.layout.list_shadow_footer, null);
+ } else {
+ view = (LinearLayout) convertView;
+ }
+ return view;
} else {
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) app
@@ -344,7 +370,8 @@ public class QuickSearchListAdapter extends ArrayAdapter {
app.getSettings().isLightContent() ? R.color.bg_color_light : R.color.bg_color_dark));
View divider = view.findViewById(R.id.divider);
if (divider != null) {
- if (position == getCount() - 1 || getItem(position + 1).getType() == QuickSearchListItemType.HEADER) {
+ if (position == getCount() - 1 || getItem(position + 1).getType() == QuickSearchListItemType.HEADER
+ || getItem(position + 1).getType() == QuickSearchListItemType.BOTTOM_SHADOW) {
divider.setVisibility(View.GONE);
} else {
divider.setVisibility(View.VISIBLE);
diff --git a/OsmAnd/src/net/osmand/plus/search/QuickSearchListFragment.java b/OsmAnd/src/net/osmand/plus/search/QuickSearchListFragment.java
index e567bae7b4..c8465e9938 100644
--- a/OsmAnd/src/net/osmand/plus/search/QuickSearchListFragment.java
+++ b/OsmAnd/src/net/osmand/plus/search/QuickSearchListFragment.java
@@ -29,15 +29,18 @@ import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.OsmAndListFragment;
import net.osmand.plus.dashboard.DashLocationFragment;
import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry;
+import net.osmand.plus.search.listitems.QuickSearchBottomShadowListItem;
import net.osmand.plus.search.listitems.QuickSearchButtonListItem;
import net.osmand.plus.search.listitems.QuickSearchListItem;
import net.osmand.plus.search.listitems.QuickSearchListItemType;
import net.osmand.plus.search.listitems.QuickSearchMoreListItem;
+import net.osmand.plus.search.listitems.QuickSearchTopShadowListItem;
import net.osmand.search.core.ObjectType;
import net.osmand.search.core.SearchResult;
import net.osmand.util.Algorithms;
import net.osmand.util.MapUtils;
+import java.util.ArrayList;
import java.util.List;
public abstract class QuickSearchListFragment extends OsmAndListFragment {
@@ -77,10 +80,10 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment {
}
}
});
- View header = getLayoutInflater(savedInstanceState).inflate(R.layout.list_shadow_header, null);
- View footer = getLayoutInflater(savedInstanceState).inflate(R.layout.list_shadow_footer, null);
- listView.addHeaderView(header, null, false);
- listView.addFooterView(footer, null, false);
+ //View header = getLayoutInflater(savedInstanceState).inflate(R.layout.list_shadow_header, null);
+ //View footer = getLayoutInflater(savedInstanceState).inflate(R.layout.list_shadow_footer, null);
+ //listView.addHeaderView(header, null, false);
+ //listView.addFooterView(footer, null, false);
}
}
@@ -322,7 +325,12 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment {
public void updateListAdapter(List listItems, boolean append) {
if (listAdapter != null) {
- listAdapter.setListItems(listItems);
+ List list = new ArrayList<>(listItems);
+ if (list.size() > 0) {
+ list.add(0, new QuickSearchTopShadowListItem(getMyApplication()));
+ list.add(new QuickSearchBottomShadowListItem(getMyApplication()));
+ }
+ listAdapter.setListItems(list);
if (!append) {
getListView().setSelection(0);
}
@@ -331,7 +339,20 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment {
public void addListItem(QuickSearchListItem listItem) {
if (listItem != null) {
- listAdapter.addListItem(listItem);
+ if (listAdapter.getCount() == 0) {
+ List list = new ArrayList<>();
+ list.add(new QuickSearchTopShadowListItem(getMyApplication()));
+ list.add(listItem);
+ list.add(new QuickSearchBottomShadowListItem(getMyApplication()));
+ listAdapter.setListItems(list);
+ } else {
+ QuickSearchListItem lastItem = listAdapter.getItem(listAdapter.getCount() - 1);
+ if (lastItem.getType() == QuickSearchListItemType.BOTTOM_SHADOW) {
+ listAdapter.insertListItem(listItem, listAdapter.getCount() - 1);
+ } else {
+ listAdapter.addListItem(listItem);
+ }
+ }
}
}
}
\ No newline at end of file
diff --git a/OsmAnd/src/net/osmand/plus/search/listitems/QuickSearchBottomShadowListItem.java b/OsmAnd/src/net/osmand/plus/search/listitems/QuickSearchBottomShadowListItem.java
new file mode 100644
index 0000000000..8ea5254df1
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/search/listitems/QuickSearchBottomShadowListItem.java
@@ -0,0 +1,14 @@
+package net.osmand.plus.search.listitems;
+
+import net.osmand.plus.OsmandApplication;
+
+public class QuickSearchBottomShadowListItem extends QuickSearchListItem {
+
+ public QuickSearchBottomShadowListItem(OsmandApplication app) {
+ super(app, null);
+ }
+
+ public QuickSearchListItemType getType() {
+ return QuickSearchListItemType.BOTTOM_SHADOW;
+ }
+}
diff --git a/OsmAnd/src/net/osmand/plus/search/listitems/QuickSearchListItemType.java b/OsmAnd/src/net/osmand/plus/search/listitems/QuickSearchListItemType.java
index 975e6bd388..6a9d390385 100644
--- a/OsmAnd/src/net/osmand/plus/search/listitems/QuickSearchListItemType.java
+++ b/OsmAnd/src/net/osmand/plus/search/listitems/QuickSearchListItemType.java
@@ -5,5 +5,7 @@ public enum QuickSearchListItemType {
HEADER,
BUTTON,
SEARCH_MORE,
- SELECT_ALL
+ SELECT_ALL,
+ TOP_SHADOW,
+ BOTTOM_SHADOW
}
diff --git a/OsmAnd/src/net/osmand/plus/search/listitems/QuickSearchTopShadowListItem.java b/OsmAnd/src/net/osmand/plus/search/listitems/QuickSearchTopShadowListItem.java
new file mode 100644
index 0000000000..a2766d12a7
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/search/listitems/QuickSearchTopShadowListItem.java
@@ -0,0 +1,14 @@
+package net.osmand.plus.search.listitems;
+
+import net.osmand.plus.OsmandApplication;
+
+public class QuickSearchTopShadowListItem extends QuickSearchListItem {
+
+ public QuickSearchTopShadowListItem(OsmandApplication app) {
+ super(app, null);
+ }
+
+ public QuickSearchListItemType getType() {
+ return QuickSearchListItemType.TOP_SHADOW;
+ }
+}