Merge remote-tracking branch 'origin/r3.7' into searchRefactor
This commit is contained in:
commit
d926ded6ef
27 changed files with 27979 additions and 298 deletions
|
@ -161,8 +161,12 @@ public class City extends MapObject {
|
|||
|
||||
public JSONObject toJSON(boolean includingBuildings) {
|
||||
JSONObject json = super.toJSON();
|
||||
if (type != null) {
|
||||
json.put("type", type.name());
|
||||
}
|
||||
if (postcode != null) {
|
||||
json.put("postcode", postcode);
|
||||
}
|
||||
JSONArray listOfStreetsArr = new JSONArray();
|
||||
for (Street s : listOfStreets) {
|
||||
listOfStreetsArr.put(s.toJSON(includingBuildings));
|
||||
|
|
|
@ -787,7 +787,7 @@ public class SearchUICore {
|
|||
cities = new HashSet<>();
|
||||
}
|
||||
Set<Street> streets = new HashSet<>();
|
||||
|
||||
if (exportedObjects != null) {
|
||||
for (MapObject obj : exportedObjects) {
|
||||
if (obj instanceof Amenity) {
|
||||
amenities.add((Amenity) obj);
|
||||
|
@ -805,6 +805,7 @@ public class SearchUICore {
|
|||
matchedCities.add(city);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (City city : cities) {
|
||||
List<Street> cityStreets = city.getStreets();
|
||||
for (Street street : streets) {
|
||||
|
@ -835,7 +836,7 @@ public class SearchUICore {
|
|||
JSONArray citiesArr = new JSONArray();
|
||||
for (City city : cities) {
|
||||
final JSONObject cityObj = city.toJSON(exportSettings.isExportBuildings());
|
||||
if (exportedCities.contains(city)) {
|
||||
if (exportedCities != null && exportedCities.contains(city)) {
|
||||
if (!exportSettings.isExportEmptyCities()) {
|
||||
continue;
|
||||
}
|
||||
|
|
6866
OsmAnd-java/src/test/resources/search/100_bridge_street.json
Normal file
6866
OsmAnd-java/src/test/resources/search/100_bridge_street.json
Normal file
File diff suppressed because it is too large
Load diff
1598
OsmAnd-java/src/test/resources/search/bank_abcd.json
Normal file
1598
OsmAnd-java/src/test/resources/search/bank_abcd.json
Normal file
File diff suppressed because it is too large
Load diff
4340
OsmAnd-java/src/test/resources/search/burger_king.json
Normal file
4340
OsmAnd-java/src/test/resources/search/burger_king.json
Normal file
File diff suppressed because it is too large
Load diff
6956
OsmAnd-java/src/test/resources/search/carrer_de_vic.json
Normal file
6956
OsmAnd-java/src/test/resources/search/carrer_de_vic.json
Normal file
File diff suppressed because it is too large
Load diff
1483
OsmAnd-java/src/test/resources/search/charging_stations.json
Normal file
1483
OsmAnd-java/src/test/resources/search/charging_stations.json
Normal file
File diff suppressed because it is too large
Load diff
|
@ -11,6 +11,7 @@
|
|||
},
|
||||
"phrase": "Calle de las eras 5, Navacerrada",
|
||||
"results": [
|
||||
<<<<<<< HEAD
|
||||
"5, Calle de las Eras (Uranización Los Corales), Navacerrada"
|
||||
],
|
||||
"extra-results": [
|
||||
|
@ -74,6 +75,44 @@
|
|||
"Travesía de las Huertas, Navacerrada",
|
||||
"Vereda de las Encinillas, Navacerrada",
|
||||
"Centro Municipal de Mayores «Navacerrada»",
|
||||
=======
|
||||
"5, Calle de las Eras (Uranización Los Corales), Navacerrada",
|
||||
"5, Calle Navacerrada (Urb. Las Suertes), Las Suertes",
|
||||
"50, Calle de Francisco Navacerrada, Salamanca",
|
||||
"52, Calle de Francisco Navacerrada, Salamanca",
|
||||
"53, Calle de Francisco Navacerrada, Salamanca",
|
||||
"54, Calle de Francisco Navacerrada, Salamanca",
|
||||
"55, Calle de Francisco Navacerrada, Salamanca",
|
||||
"56, Calle de Francisco Navacerrada, Salamanca",
|
||||
"57, Calle de Francisco Navacerrada, Salamanca",
|
||||
"58, Calle de Francisco Navacerrada, Salamanca",
|
||||
"59, Calle de Francisco Navacerrada, Salamanca",
|
||||
"Calle del Puerto de Navacerrada, Las Nieves",
|
||||
"Calle Puerto de Navacerrada, La Poveda",
|
||||
"Calle del Embalse de Navacerrada, Villa de Vallecas",
|
||||
"Calle del Puerto de Navacerrada, Puente de Vallecas",
|
||||
"Calle de Francisco Navacerrada, Salamanca",
|
||||
"Calle de Navacerrada, Moraleja de Enmedio",
|
||||
"Calle Navacerrada (Urb. Las Suertes), Las Suertes",
|
||||
"Calle Puerto de Navacerrada, Roman Candelas",
|
||||
"Calle Navacerrada, Becerril de la Sierra",
|
||||
"Carretera de Collado Villalba a Navacerrada, El Baillo y las Hojarascas",
|
||||
"Calle Navacerrada (Cerceda), El Boalo",
|
||||
"Calle Navacerrada (El Pedregal), Bustarviejo",
|
||||
"Calle Navacerrada, Buitrago del Lozoya",
|
||||
"Carretera de Colmenar Viejo a Navacerrada, Becerril de la Sierra",
|
||||
"Carretera de Colmenar Viejo a Navacerrada, Manzanares el Real",
|
||||
"Carretera de Collado Villalba a Navacerrada, Dehesa Boyal",
|
||||
"Carretera de Collado Villalba a Navacerrada, Polideportivo Dehesa Boyal",
|
||||
"Carretera de Navacerrada, Jazmines",
|
||||
"Carretera de Colmenar Viejo a Navacerrada (Cerceda), El Boalo",
|
||||
"Carretera de Collado Villalba a Navacerrada, Cerca de Cascarrilla",
|
||||
"Carretera de Navacerrada, El Boalo",
|
||||
"Carretera de Collado Villalba a Navacerrada, Collado Mediano",
|
||||
"Camino de Navacerrada (Serranía de la Paloma), Collado Mediano",
|
||||
"Camino de Los Molinos a Navacerrada, Collado Mediano",
|
||||
"Carretera de Collado Villalba a Navacerrada, Navacerrada"
|
||||
>>>>>>> e69e0d95cc... Added search test
|
||||
],
|
||||
"amenities": [
|
||||
{
|
||||
|
|
17
OsmAnd-java/src/test/resources/search/olc.json
Normal file
17
OsmAnd-java/src/test/resources/search/olc.json
Normal file
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"settings": {
|
||||
"lat": "55.75138",
|
||||
"lon": "37.62940",
|
||||
"radiusLevel": 1,
|
||||
"totalLimit": -1,
|
||||
"lang": "",
|
||||
"transliterateIfMissing": false,
|
||||
"emptyQueryAllowed": false,
|
||||
"sortByName": false
|
||||
},
|
||||
"phrase": "QHW6+CQ",
|
||||
"results": [
|
||||
"55.796062, 37.56194"
|
||||
],
|
||||
"cities": []
|
||||
}
|
6452
OsmAnd-java/src/test/resources/search/starbucks.json
Normal file
6452
OsmAnd-java/src/test/resources/search/starbucks.json
Normal file
File diff suppressed because it is too large
Load diff
|
@ -65,8 +65,6 @@ import java.util.LinkedHashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import static net.osmand.plus.poi.PoiFiltersHelper.PoiTemplateList;
|
||||
|
||||
/**
|
||||
* Object is responsible to maintain layers using by map activity
|
||||
*/
|
||||
|
@ -273,8 +271,10 @@ public class MapActivityLayers {
|
|||
final ContextMenuAdapter adapter = new ContextMenuAdapter(app);
|
||||
final List<PoiUIFilter> list = new ArrayList<>();
|
||||
for (PoiUIFilter f : poiFilters.getSortedPoiFilters(true)) {
|
||||
if (!f.isTopWikiFilter()) {
|
||||
addFilterToList(adapter, list, f, true);
|
||||
}
|
||||
}
|
||||
list.add(poiFilters.getCustomPOIFilter());
|
||||
adapter.setProfileDependent(true);
|
||||
adapter.setNightMode(isNightMode(app));
|
||||
|
@ -306,9 +306,9 @@ public class MapActivityLayers {
|
|||
if (filter.isStandardFilter()) {
|
||||
filter.removeUnsavedFilterByName();
|
||||
}
|
||||
poiFilters.addSelectedPoiFilter(PoiTemplateList.POI, filter);
|
||||
poiFilters.addSelectedPoiFilter(filter);
|
||||
} else {
|
||||
poiFilters.removeSelectedPoiFilter(PoiTemplateList.POI, filter);
|
||||
poiFilters.removeSelectedPoiFilter(filter);
|
||||
}
|
||||
}
|
||||
mapView.refreshMap();
|
||||
|
@ -351,8 +351,10 @@ public class MapActivityLayers {
|
|||
final List<PoiUIFilter> list = new ArrayList<>();
|
||||
list.add(poiFilters.getCustomPOIFilter());
|
||||
for (PoiUIFilter f : poiFilters.getSortedPoiFilters(true)) {
|
||||
if (!f.isTopWikiFilter()) {
|
||||
addFilterToList(adapter, list, f, false);
|
||||
}
|
||||
}
|
||||
|
||||
final ArrayAdapter<ContextMenuItem> listAdapter = adapter.createListAdapter(activity, !isNightMode(app));
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(activity, getThemeRes(app)));
|
||||
|
@ -370,8 +372,9 @@ public class MapActivityLayers {
|
|||
if (pf.isStandardFilter()) {
|
||||
pf.removeUnsavedFilterByName();
|
||||
}
|
||||
poiFilters.clearSelectedPoiFilters(PoiTemplateList.POI);
|
||||
poiFilters.addSelectedPoiFilter(PoiTemplateList.POI, pf);
|
||||
PoiUIFilter wiki = poiFilters.getTopWikiPoiFilter();
|
||||
poiFilters.clearSelectedPoiFilters(wiki);
|
||||
poiFilters.addSelectedPoiFilter(pf);
|
||||
mapView.refreshMap();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,8 +78,6 @@ import java.util.TreeMap;
|
|||
|
||||
import gnu.trove.set.hash.TLongHashSet;
|
||||
|
||||
import static net.osmand.plus.poi.PoiFiltersHelper.PoiTemplateList;
|
||||
|
||||
/**
|
||||
* Search poi activity
|
||||
*/
|
||||
|
@ -166,7 +164,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
|
|||
public boolean onMenuItemClick(MenuItem item) {
|
||||
OsmandSettings settings = app.getSettings();
|
||||
filter.setFilterByName(searchFilter.getText().toString().trim());
|
||||
app.getPoiFilters().addSelectedPoiFilter(PoiTemplateList.POI, filter);
|
||||
app.getPoiFilters().addSelectedPoiFilter(filter);
|
||||
if (location != null) {
|
||||
settings.setMapLocationToShow(location.getLatitude(), location.getLongitude(), 15);
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ import net.osmand.plus.activities.SettingsActivity;
|
|||
import net.osmand.plus.dashboard.DashboardOnMap;
|
||||
import net.osmand.plus.inapp.InAppPurchaseHelper;
|
||||
import net.osmand.plus.poi.PoiFiltersHelper;
|
||||
import net.osmand.plus.poi.PoiUIFilter;
|
||||
import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
|
||||
import net.osmand.plus.render.RendererRegistry;
|
||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||
|
@ -101,7 +102,6 @@ import static net.osmand.aidlapi.OsmAndCustomizationConstants.TEXT_SIZE_ID;
|
|||
import static net.osmand.aidlapi.OsmAndCustomizationConstants.TRANSPORT_ID;
|
||||
import static net.osmand.aidlapi.OsmAndCustomizationConstants.WIKIPEDIA_ID;
|
||||
import static net.osmand.plus.ContextMenuAdapter.makeDeleteAction;
|
||||
import static net.osmand.plus.poi.PoiFiltersHelper.PoiTemplateList;
|
||||
import static net.osmand.plus.srtmplugin.SRTMPlugin.CONTOUR_DENSITY_ATTR;
|
||||
import static net.osmand.plus.srtmplugin.SRTMPlugin.CONTOUR_LINES_ATTR;
|
||||
import static net.osmand.plus.srtmplugin.SRTMPlugin.CONTOUR_LINES_SCHEME_ATTR;
|
||||
|
@ -255,7 +255,8 @@ public class ConfigureMapMenu {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> adapter, int itemId, final int pos, boolean isChecked, int[] viewCoordinates) {
|
||||
public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> adapter, int itemId,
|
||||
final int pos, boolean isChecked, int[] viewCoordinates) {
|
||||
final OsmandSettings settings = ma.getMyApplication().getSettings();
|
||||
final PoiFiltersHelper poiFiltersHelper = ma.getMyApplication().getPoiFilters();
|
||||
final ContextMenuItem item = cm.getItem(pos);
|
||||
|
@ -263,12 +264,13 @@ public class ConfigureMapMenu {
|
|||
item.setColorRes(isChecked ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
|
||||
}
|
||||
if (itemId == R.string.layer_poi) {
|
||||
poiFiltersHelper.clearSelectedPoiFilters(PoiTemplateList.POI);
|
||||
PoiUIFilter wiki = poiFiltersHelper.getTopWikiPoiFilter();
|
||||
poiFiltersHelper.clearSelectedPoiFilters(wiki);
|
||||
if (isChecked) {
|
||||
showPoiFilterDialog(adapter, adapter.getItem(pos));
|
||||
} else {
|
||||
adapter.getItem(pos).setDescription(
|
||||
poiFiltersHelper.getSelectedPoiFiltersName(PoiTemplateList.POI));
|
||||
poiFiltersHelper.getSelectedPoiFiltersName(wiki));
|
||||
}
|
||||
} else if (itemId == R.string.layer_amenity_label) {
|
||||
settings.SHOW_POI_LABEL.set(isChecked);
|
||||
|
@ -283,13 +285,13 @@ public class ConfigureMapMenu {
|
|||
showGpxSelectionDialog(adapter, adapter.getItem(pos));
|
||||
}
|
||||
} else if (itemId == R.string.shared_string_wikipedia) {
|
||||
WikipediaPoiMenu.toggleWikipediaPoi(ma, isChecked, true,
|
||||
new CallbackWithObject<Boolean>() {
|
||||
WikipediaPoiMenu.toggleWikipediaPoi(ma, isChecked, new CallbackWithObject<Boolean>() {
|
||||
@Override
|
||||
public boolean processResult(Boolean selected) {
|
||||
item.setSelected(selected);
|
||||
item.setColorRes(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
|
||||
item.setDescription(selected ? WikipediaPoiMenu.getLanguagesSummary(ma.getMyApplication()) : null);
|
||||
item.setDescription(selected ?
|
||||
WikipediaPoiMenu.getLanguagesSummary(ma.getMyApplication()) : null);
|
||||
adapter.notifyDataSetChanged();
|
||||
return true;
|
||||
}
|
||||
|
@ -343,19 +345,20 @@ public class ConfigureMapMenu {
|
|||
protected void showPoiFilterDialog(final ArrayAdapter<ContextMenuItem> adapter,
|
||||
final ContextMenuItem item) {
|
||||
final PoiFiltersHelper poiFiltersHelper = ma.getMyApplication().getPoiFilters();
|
||||
final PoiUIFilter wiki = poiFiltersHelper.getTopWikiPoiFilter();
|
||||
MapActivityLayers.DismissListener dismissListener =
|
||||
new MapActivityLayers.DismissListener() {
|
||||
@Override
|
||||
public void dismiss() {
|
||||
PoiFiltersHelper pf = ma.getMyApplication().getPoiFilters();
|
||||
boolean selected = pf.isShowingAnyPoi(PoiTemplateList.POI);
|
||||
boolean selected = pf.isShowingAnyPoi(wiki);
|
||||
item.setSelected(selected);
|
||||
item.setDescription(pf.getSelectedPoiFiltersName(PoiTemplateList.POI));
|
||||
item.setDescription(pf.getSelectedPoiFiltersName(wiki));
|
||||
item.setColorRes(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
};
|
||||
if (poiFiltersHelper.isShowingAnyPoi(PoiTemplateList.POI)) {
|
||||
if (poiFiltersHelper.isShowingAnyPoi(wiki)) {
|
||||
ma.getMapLayers().showMultichoicePoiFilterDialog(ma.getMapView(),
|
||||
dismissListener);
|
||||
} else {
|
||||
|
@ -387,12 +390,13 @@ public class ConfigureMapMenu {
|
|||
.setItemDeleteAction(makeDeleteAction(settings.SHOW_FAVORITES))
|
||||
.setListener(l)
|
||||
.createItem());
|
||||
selected = app.getPoiFilters().isShowingAnyPoi(PoiTemplateList.POI);
|
||||
PoiUIFilter wiki = app.getPoiFilters().getTopWikiPoiFilter();
|
||||
selected = app.getPoiFilters().isShowingAnyPoi(wiki);
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setId(POI_OVERLAY_ID)
|
||||
.setTitleId(R.string.layer_poi, activity)
|
||||
.setSelected(selected)
|
||||
.setDescription(app.getPoiFilters().getSelectedPoiFiltersName(PoiTemplateList.POI))
|
||||
.setDescription(app.getPoiFilters().getSelectedPoiFiltersName(wiki))
|
||||
.setColor(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)
|
||||
.setIcon(R.drawable.ic_action_info_dark)
|
||||
.setSecondaryIcon(R.drawable.ic_action_additional_option)
|
||||
|
@ -428,7 +432,7 @@ public class ConfigureMapMenu {
|
|||
.setSecondaryIcon(R.drawable.ic_action_additional_option)
|
||||
.setListener(l).createItem());
|
||||
|
||||
selected = app.getPoiFilters().isShowingAnyPoi(PoiTemplateList.WIKI);
|
||||
selected = app.getPoiFilters().isTopWikiFilterSelected();
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setId(WIKIPEDIA_ID)
|
||||
.setTitleId(R.string.shared_string_wikipedia, activity)
|
||||
|
@ -437,7 +441,6 @@ public class ConfigureMapMenu {
|
|||
.setColor(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)
|
||||
.setIcon(R.drawable.ic_plugin_wikipedia)
|
||||
.setSecondaryIcon(R.drawable.ic_action_additional_option)
|
||||
.setItemDeleteAction(makeDeleteAction(settings.SHOW_WIKIPEDIA_POI))
|
||||
.setListener(l).createItem());
|
||||
|
||||
selected = settings.SHOW_MAP_MARKERS.get();
|
||||
|
|
|
@ -13,7 +13,6 @@ import net.osmand.osm.PoiCategory;
|
|||
import net.osmand.osm.PoiType;
|
||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.api.SQLiteAPI;
|
||||
import net.osmand.plus.api.SQLiteAPI.SQLiteConnection;
|
||||
|
@ -38,10 +37,11 @@ import java.util.LinkedHashSet;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import static net.osmand.osm.MapPoiTypes.WIKI_PLACE;
|
||||
import static net.osmand.plus.wikipedia.WikipediaPoiMenu.ENABLED_WIKI_POI_LANGUAGES_KEY;
|
||||
import static net.osmand.plus.wikipedia.WikipediaPoiMenu.GLOBAL_WIKI_POI_ENABLED_KEY;
|
||||
|
||||
public class PoiFiltersHelper {
|
||||
|
||||
|
@ -55,10 +55,9 @@ public class PoiFiltersHelper {
|
|||
private PoiUIFilter customPOIFilter;
|
||||
private PoiUIFilter showAllPOIFilter;
|
||||
private PoiUIFilter localWikiPoiFilter;
|
||||
private PoiUIFilter globalWikiPoiFilter;
|
||||
private PoiUIFilter topWikiPoiFilter;
|
||||
private List<PoiUIFilter> cacheTopStandardFilters;
|
||||
private List<PoiUIFilter> cacheWikipediaFilters;
|
||||
private Map<PoiTemplateList, Set<PoiUIFilter>> selectedPoiFilters = new TreeMap<>();
|
||||
private Set<PoiUIFilter> selectedPoiFilters = new TreeSet<>();
|
||||
|
||||
private static final String UDF_CAR_AID = "car_aid";
|
||||
private static final String UDF_FOR_TOURISTS = "for_tourists";
|
||||
|
@ -76,10 +75,6 @@ public class PoiFiltersHelper {
|
|||
UDF_PUBLIC_TRANSPORT, UDF_ACCOMMODATION, UDF_RESTAURANTS, UDF_PARKING
|
||||
};
|
||||
|
||||
public enum PoiTemplateList {
|
||||
POI, WIKI
|
||||
}
|
||||
|
||||
public PoiFiltersHelper(OsmandApplication application) {
|
||||
this.application = application;
|
||||
PoiFilterDbHelper helper = openDbHelperNoPois();
|
||||
|
@ -139,56 +134,42 @@ public class PoiFiltersHelper {
|
|||
return localWikiPoiFilter;
|
||||
}
|
||||
|
||||
public PoiUIFilter getGlobalWikiPoiFilter() {
|
||||
if (globalWikiPoiFilter == null) {
|
||||
public void prepareTopWikiFilter(@NonNull PoiUIFilter wiki) {
|
||||
boolean prepareByDefault = true;
|
||||
Bundle wikiSettings = WikipediaPoiMenu.getWikiPoiSettings(application);
|
||||
if (wikiSettings != null) {
|
||||
boolean allLanguages = wikiSettings.getBoolean(GLOBAL_WIKI_POI_ENABLED_KEY);
|
||||
List<String> languages = wikiSettings
|
||||
.getStringArrayList(ENABLED_WIKI_POI_LANGUAGES_KEY);
|
||||
if (!allLanguages && languages != null) {
|
||||
prepareByDefault = false;
|
||||
String wikiLang = "wiki:lang:";
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (String lang : languages) {
|
||||
if (sb.length() > 1) {
|
||||
sb.append(" ");
|
||||
}
|
||||
sb.append(wikiLang).append(lang);
|
||||
}
|
||||
wiki.setFilterByName(sb.toString());
|
||||
}
|
||||
}
|
||||
if (prepareByDefault) {
|
||||
wiki.setFilterByName(null);
|
||||
}
|
||||
}
|
||||
|
||||
public PoiUIFilter getTopWikiPoiFilter() {
|
||||
if (topWikiPoiFilter == null) {
|
||||
String wikiFilterId = PoiUIFilter.STD_PREFIX + "osmwiki";
|
||||
for (PoiUIFilter filter : getTopDefinedPoiFilters()) {
|
||||
if (wikiFilterId.equals(filter.getFilterId())) {
|
||||
globalWikiPoiFilter = filter;
|
||||
topWikiPoiFilter = filter;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return globalWikiPoiFilter;
|
||||
}
|
||||
|
||||
public List<PoiUIFilter> getLocalWikipediaPoiFilters(boolean onlyActiveLocales) {
|
||||
String wikiLang = "wiki:lang:";
|
||||
if (cacheWikipediaFilters == null) {
|
||||
List<PoiUIFilter> wikipediaFilters = new ArrayList<>();
|
||||
PoiType place = application.getPoiTypes().getPoiTypeByKey(WIKI_PLACE);
|
||||
if (place != null) {
|
||||
for (String locale : application.getPoiTypes().getAllAvailableWikiLocales()) {
|
||||
PoiUIFilter filter = new PoiUIFilter(place, application, " " +
|
||||
WikipediaPoiMenu.getTranslation(application, locale));
|
||||
filter.setSavedFilterByName(wikiLang + locale);
|
||||
filter.setStandardFilter(true);
|
||||
wikipediaFilters.add(filter);
|
||||
}
|
||||
}
|
||||
cacheWikipediaFilters = wikipediaFilters;
|
||||
}
|
||||
if (onlyActiveLocales && cacheWikipediaFilters.size() > 0) {
|
||||
List<PoiUIFilter> onlyActiveLocalFilters = new ArrayList<>();
|
||||
Bundle wikiPoiSettings = WikipediaPoiMenu.getWikiPoiSettings(application);
|
||||
if (wikiPoiSettings != null) {
|
||||
List<String> enabledWikipediaPoiLocales =
|
||||
wikiPoiSettings.getStringArrayList(WikipediaPoiMenu.ENABLED_WIKI_POI_LANGUAGES_KEY);
|
||||
if (enabledWikipediaPoiLocales != null) {
|
||||
for (PoiUIFilter filter : cacheWikipediaFilters) {
|
||||
for (String locale : enabledWikipediaPoiLocales) {
|
||||
String filterId = filter.getSavedFilterByName();
|
||||
String filterLocale = filterId.substring(wikiLang.length());
|
||||
if (locale.equalsIgnoreCase(filterLocale)) {
|
||||
onlyActiveLocalFilters.add(filter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return onlyActiveLocalFilters;
|
||||
}
|
||||
return cacheWikipediaFilters;
|
||||
return topWikiPoiFilter;
|
||||
}
|
||||
|
||||
public PoiUIFilter getShowAllPOIFilter() {
|
||||
|
@ -235,13 +216,9 @@ public class PoiFiltersHelper {
|
|||
return f;
|
||||
}
|
||||
}
|
||||
for (PoiUIFilter f : getLocalWikipediaPoiFilters(true)) {
|
||||
if (f.getFilterId().equals(filterId)) {
|
||||
return f;
|
||||
}
|
||||
}
|
||||
PoiUIFilter ff = getFilterById(filterId, getCustomPOIFilter(), getSearchByNamePOIFilter(),
|
||||
getGlobalWikiPoiFilter(), getShowAllPOIFilter(), getNominatimPOIFilter(), getNominatimAddressFilter());
|
||||
getTopWikiPoiFilter(), getLocalWikiPOIFilter(), getShowAllPOIFilter(),
|
||||
getNominatimPOIFilter(), getNominatimAddressFilter());
|
||||
if (ff != null) {
|
||||
return ff;
|
||||
}
|
||||
|
@ -306,6 +283,9 @@ public class PoiFiltersHelper {
|
|||
List<PoiUIFilter> top = new ArrayList<>();
|
||||
// user defined
|
||||
top.addAll(getUserDefinedPoiFilters(true));
|
||||
if (getLocalWikiPOIFilter() != null) {
|
||||
top.add(getLocalWikiPOIFilter());
|
||||
}
|
||||
// default
|
||||
MapPoiTypes poiTypes = application.getPoiTypes();
|
||||
for (AbstractPoiType t : poiTypes.getTopVisibleFilters()) {
|
||||
|
@ -505,76 +485,65 @@ public class PoiFiltersHelper {
|
|||
return false;
|
||||
}
|
||||
|
||||
public Set<PoiUIFilter> getSelectedPoiFilters() {
|
||||
Set<PoiUIFilter> result = new TreeSet<>();
|
||||
for (Set<PoiUIFilter> template : selectedPoiFilters.values()) {
|
||||
if (template != null) {
|
||||
result.addAll(template);
|
||||
public Set<PoiUIFilter> getSelectedPoiFilters(PoiUIFilter ... filtersToExclude) {
|
||||
if (filtersToExclude != null && filtersToExclude.length > 0) {
|
||||
Set<PoiUIFilter> filters = new TreeSet<>();
|
||||
for (PoiUIFilter filter : selectedPoiFilters) {
|
||||
boolean skip = false;
|
||||
for (PoiUIFilter filterToExclude : filtersToExclude) {
|
||||
String filterToExcludeId = filterToExclude.getFilterId();
|
||||
if (filterToExcludeId != null && filterToExcludeId.equals(filter.getFilterId())) {
|
||||
skip = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
if (!skip) {
|
||||
filters.add(filter);
|
||||
}
|
||||
}
|
||||
return filters;
|
||||
}
|
||||
return selectedPoiFilters;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Set<PoiUIFilter> getSelectedPoiFilters(PoiTemplateList type) {
|
||||
Set<PoiUIFilter> result = selectedPoiFilters.get(type);
|
||||
if (result == null) {
|
||||
return new TreeSet<>();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void addSelectedPoiFilter(PoiTemplateList type, PoiUIFilter filter) {
|
||||
if (!selectedPoiFilters.containsKey(type)) {
|
||||
selectedPoiFilters.put(type, new TreeSet<PoiUIFilter>());
|
||||
}
|
||||
Set<PoiUIFilter> templateFilters = selectedPoiFilters.get(type);
|
||||
if (templateFilters != null) {
|
||||
templateFilters.add(filter);
|
||||
public void addSelectedPoiFilter(PoiUIFilter filter) {
|
||||
if (filter.isTopWikiFilter()) {
|
||||
prepareTopWikiFilter(filter);
|
||||
}
|
||||
selectedPoiFilters.add(filter);
|
||||
saveSelectedPoiFilters();
|
||||
}
|
||||
|
||||
public void removeSelectedPoiFilter(PoiTemplateList type, PoiUIFilter filter) {
|
||||
if (selectedPoiFilters.containsKey(type)) {
|
||||
Set<PoiUIFilter> templateFilters = selectedPoiFilters.get(type);
|
||||
if (templateFilters != null) {
|
||||
templateFilters.remove(filter);
|
||||
}
|
||||
}
|
||||
public void removeSelectedPoiFilter(PoiUIFilter filter) {
|
||||
selectedPoiFilters.remove(filter);
|
||||
saveSelectedPoiFilters();
|
||||
}
|
||||
|
||||
public boolean isShowingAnyPoi() {
|
||||
for (PoiTemplateList type : selectedPoiFilters.keySet()) {
|
||||
if (isShowingAnyPoi(type)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
public boolean isShowingAnyPoi(PoiUIFilter ... filtersToExclude) {
|
||||
return !getSelectedPoiFilters(filtersToExclude).isEmpty();
|
||||
}
|
||||
|
||||
public boolean isShowingAnyPoi(PoiTemplateList type) {
|
||||
return !getSelectedPoiFilters(type).isEmpty();
|
||||
public void clearSelectedPoiFilters(PoiUIFilter ... filtersToExclude) {
|
||||
if (filtersToExclude != null && filtersToExclude.length > 0) {
|
||||
Iterator<PoiUIFilter> it = selectedPoiFilters.iterator();
|
||||
while (it.hasNext()) {
|
||||
PoiUIFilter filter = it.next();
|
||||
boolean skip = false;
|
||||
for (PoiUIFilter filterToExclude : filtersToExclude) {
|
||||
String filterToExcludeId = filterToExclude.getFilterId();
|
||||
if (filterToExcludeId != null
|
||||
&& filterToExcludeId.equals(filter.getFilterId())) {
|
||||
skip = true;
|
||||
break;
|
||||
}
|
||||
|
||||
public void clearSelectedPoiFilters() {
|
||||
for (PoiTemplateList t : selectedPoiFilters.keySet()) {
|
||||
clearSelectedPoiFilters(t);
|
||||
}
|
||||
saveSelectedPoiFilters();
|
||||
if (!skip) {
|
||||
it.remove();
|
||||
}
|
||||
|
||||
public void clearSelectedPoiFilters(PoiTemplateList type) {
|
||||
Set<PoiUIFilter> templateFilters = selectedPoiFilters.get(type);
|
||||
if (templateFilters != null) {
|
||||
templateFilters.clear();
|
||||
}
|
||||
saveSelectedPoiFilters();
|
||||
}
|
||||
|
||||
public void hidePoiFilters() {
|
||||
} else {
|
||||
selectedPoiFilters.clear();
|
||||
}
|
||||
saveSelectedPoiFilters();
|
||||
}
|
||||
|
||||
|
@ -590,25 +559,30 @@ public class PoiFiltersHelper {
|
|||
}
|
||||
}
|
||||
|
||||
public String getSelectedPoiFiltersName(PoiTemplateList type) {
|
||||
return getFiltersName(getSelectedPoiFilters(type));
|
||||
public String getSelectedPoiFiltersName(PoiUIFilter ... filtersToExclude) {
|
||||
return getFiltersName(getSelectedPoiFilters(filtersToExclude));
|
||||
}
|
||||
|
||||
public boolean isPoiFilterSelected(PoiUIFilter filter) {
|
||||
for (Set<PoiUIFilter> template : selectedPoiFilters.values()) {
|
||||
return template.contains(filter);
|
||||
return selectedPoiFilters.contains(filter);
|
||||
}
|
||||
|
||||
public boolean isTopWikiFilterSelected() {
|
||||
String wikiFilterId = getTopWikiPoiFilter().getFilterId();
|
||||
for (PoiUIFilter filter : selectedPoiFilters) {
|
||||
if (wikiFilterId.equals(filter.getFilterId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isPoiFilterSelected(String filterId) {
|
||||
for (Set<PoiUIFilter> template : selectedPoiFilters.values()) {
|
||||
for (PoiUIFilter filter : template) {
|
||||
for (PoiUIFilter filter : selectedPoiFilters) {
|
||||
if (filter.filterId.equals(filterId)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -617,20 +591,14 @@ public class PoiFiltersHelper {
|
|||
if(!application.getPoiTypes().isInit()) {
|
||||
return;
|
||||
}
|
||||
selectedPoiFilters.clear();
|
||||
OsmandSettings settings = application.getSettings();
|
||||
Set<String> filters = settings.getSelectedPoiFilters();
|
||||
boolean shouldShowWikiPoi = WikipediaPoiMenu.isWikiPoiEnabled(application);
|
||||
for (String f : filters) {
|
||||
selectedPoiFilters = new TreeSet<>();
|
||||
for (String f : application.getSettings().getSelectedPoiFilters()) {
|
||||
PoiUIFilter filter = getFilterById(f);
|
||||
if (filter != null) {
|
||||
if (filter.isWikiFilter()) {
|
||||
if (shouldShowWikiPoi) {
|
||||
addSelectedPoiFilter(PoiTemplateList.WIKI, filter);
|
||||
}
|
||||
} else {
|
||||
addSelectedPoiFilter(PoiTemplateList.POI, filter);
|
||||
if (filter.isTopWikiFilter()) {
|
||||
prepareTopWikiFilter(filter);
|
||||
}
|
||||
selectedPoiFilters.add(filter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -664,11 +632,9 @@ public class PoiFiltersHelper {
|
|||
|
||||
private void saveSelectedPoiFilters() {
|
||||
Set<String> filters = new HashSet<>();
|
||||
for (Set<PoiUIFilter> template : selectedPoiFilters.values()) {
|
||||
for (PoiUIFilter filter : template) {
|
||||
for (PoiUIFilter filter : selectedPoiFilters) {
|
||||
filters.add(filter.filterId);
|
||||
}
|
||||
}
|
||||
application.getSettings().setSelectedPoiFilters(filters);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ package net.osmand.plus.poi;
|
|||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import net.osmand.CollatorStringMatcher;
|
||||
import net.osmand.CollatorStringMatcher.StringMatcherMode;
|
||||
|
@ -150,8 +151,11 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter>
|
|||
}
|
||||
|
||||
public boolean isWikiFilter() {
|
||||
return filterId.startsWith(STD_PREFIX + WIKI_PLACE)
|
||||
|| filterId.equals(STD_PREFIX + OSM_WIKI_CATEGORY);
|
||||
return filterId.startsWith(STD_PREFIX + WIKI_PLACE) || isTopWikiFilter();
|
||||
}
|
||||
|
||||
public boolean isTopWikiFilter() {
|
||||
return filterId.equals(STD_PREFIX + OSM_WIKI_CATEGORY);
|
||||
}
|
||||
|
||||
public String getFilterByName() {
|
||||
|
|
|
@ -33,8 +33,6 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static net.osmand.plus.poi.PoiFiltersHelper.PoiTemplateList;
|
||||
|
||||
public class ShowHidePoiAction extends QuickAction {
|
||||
|
||||
|
||||
|
@ -114,18 +112,18 @@ public class ShowHidePoiAction extends QuickAction {
|
|||
PoiFiltersHelper pf = activity.getMyApplication().getPoiFilters();
|
||||
List<PoiUIFilter> poiFilters = loadPoiFilters(activity.getMyApplication().getPoiFilters());
|
||||
|
||||
if (!isCurrentFilters(pf.getSelectedPoiFilters(PoiTemplateList.POI), poiFilters)) {
|
||||
if (!isCurrentFilters(pf.getSelectedPoiFilters(), poiFilters)) {
|
||||
|
||||
pf.clearSelectedPoiFilters(PoiTemplateList.POI);
|
||||
pf.clearSelectedPoiFilters();
|
||||
|
||||
for (PoiUIFilter filter : poiFilters) {
|
||||
if (filter.isStandardFilter()) {
|
||||
filter.removeUnsavedFilterByName();
|
||||
}
|
||||
pf.addSelectedPoiFilter(PoiTemplateList.POI, filter);
|
||||
pf.addSelectedPoiFilter(filter);
|
||||
}
|
||||
|
||||
} else pf.clearSelectedPoiFilters(PoiTemplateList.POI);
|
||||
} else pf.clearSelectedPoiFilters();
|
||||
|
||||
activity.getMapLayers().updateLayers(activity.getMapView());
|
||||
}
|
||||
|
@ -135,7 +133,7 @@ public class ShowHidePoiAction extends QuickAction {
|
|||
PoiFiltersHelper pf = application.getPoiFilters();
|
||||
List<PoiUIFilter> poiFilters = loadPoiFilters(application.getPoiFilters());
|
||||
|
||||
return isCurrentFilters(pf.getSelectedPoiFilters(PoiTemplateList.POI), poiFilters);
|
||||
return isCurrentFilters(pf.getSelectedPoiFilters(), poiFilters);
|
||||
}
|
||||
|
||||
private boolean isCurrentFilters(Set<PoiUIFilter> currentPoiFilters, List<PoiUIFilter> poiFilters) {
|
||||
|
|
|
@ -120,8 +120,6 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
import java.util.Stack;
|
||||
|
||||
import static net.osmand.plus.poi.PoiFiltersHelper.PoiTemplateList;
|
||||
|
||||
public class MapRouteInfoMenu implements IRouteInformationListener, CardListener, FavoritesListener {
|
||||
|
||||
private static final Log LOG = PlatformUtil.getLog(MapRouteInfoMenu.class);
|
||||
|
@ -1158,7 +1156,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
|||
private void createShowAlongTheRouteItems(MapActivity mapActivity, LinearLayout optionsContainer) {
|
||||
OsmandApplication app = mapActivity.getMyApplication();
|
||||
final ApplicationMode applicationMode = app.getRoutingHelper().getAppMode();
|
||||
final Set<PoiUIFilter> poiFilters = app.getPoiFilters().getSelectedPoiFilters(PoiTemplateList.POI);
|
||||
final Set<PoiUIFilter> poiFilters = app.getPoiFilters().getSelectedPoiFilters();
|
||||
final boolean traffic = app.getSettings().SHOW_TRAFFIC_WARNINGS.getModeValue(applicationMode);
|
||||
final boolean fav = app.getSettings().SHOW_NEARBY_FAVORITES.getModeValue(applicationMode);
|
||||
if (!poiFilters.isEmpty()) {
|
||||
|
@ -1184,7 +1182,8 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
|||
public void onClick(View v) {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
mapActivity.getMyApplication().getPoiFilters().removeSelectedPoiFilter(PoiTemplateList.POI, poiUIFilter);
|
||||
mapActivity.getMyApplication().getPoiFilters()
|
||||
.removeSelectedPoiFilter(poiUIFilter);
|
||||
mapActivity.getMapView().refreshMap();
|
||||
updateOptionsButtons();
|
||||
}
|
||||
|
|
|
@ -45,8 +45,6 @@ import java.lang.ref.WeakReference;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static net.osmand.plus.poi.PoiFiltersHelper.PoiTemplateList;
|
||||
|
||||
public class ShowAlongTheRouteBottomSheet extends MenuBottomSheetDialogFragment implements IRouteInformationListener, IRoutingDataUpdateListener {
|
||||
|
||||
public static final String TAG = "ShowAlongTheRouteBottomSheet";
|
||||
|
@ -436,8 +434,8 @@ public class ShowAlongTheRouteBottomSheet extends MenuBottomSheetDialogFragment
|
|||
View v;
|
||||
if (type == WaypointHelper.POI) {
|
||||
v = themedInflater.inflate(R.layout.along_the_route_radius_poi, null);
|
||||
String descEx = !app.getPoiFilters().isShowingAnyPoi(PoiTemplateList.POI) ?
|
||||
getString(R.string.poi) : app.getPoiFilters().getSelectedPoiFiltersName(PoiTemplateList.POI);
|
||||
String descEx = !app.getPoiFilters().isShowingAnyPoi() ?
|
||||
getString(R.string.poi) : app.getPoiFilters().getSelectedPoiFiltersName();
|
||||
((TextView) v.findViewById(R.id.title)).setText(getString(R.string.search_radius_proximity) + ":");
|
||||
((TextView) v.findViewById(R.id.titleEx)).setText(getString(R.string.shared_string_type) + ":");
|
||||
final TextView radiusEx = (TextView) v.findViewById(R.id.descriptionEx);
|
||||
|
@ -487,7 +485,7 @@ public class ShowAlongTheRouteBottomSheet extends MenuBottomSheetDialogFragment
|
|||
new MapActivityLayers.DismissListener() {
|
||||
@Override
|
||||
public void dismiss() {
|
||||
if (app.getPoiFilters().isShowingAnyPoi(PoiTemplateList.POI)) {
|
||||
if (app.getPoiFilters().isShowingAnyPoi()) {
|
||||
enableType(type, enable);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1040,9 +1040,8 @@ public class RouteProvider {
|
|||
points.add(pt);
|
||||
}
|
||||
|
||||
int currentRoute = route.currentRoute;
|
||||
List<Location> locations = route.getRouteLocations();
|
||||
List<RouteSegmentResult> originalRoute = route.getOriginalRoute(currentRoute);
|
||||
List<Location> locations = route.getImmutableAllLocations();
|
||||
List<RouteSegmentResult> originalRoute = route.getOriginalRoute();
|
||||
RouteExporter exporter = new RouteExporter(name, originalRoute, locations, points);
|
||||
return exporter.exportRoute();
|
||||
}
|
||||
|
|
|
@ -111,7 +111,6 @@ import java.io.IOException;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static net.osmand.plus.poi.PoiFiltersHelper.PoiTemplateList;
|
||||
import static net.osmand.plus.search.SendSearchQueryBottomSheet.MISSING_SEARCH_LOCATION_KEY;
|
||||
import static net.osmand.plus.search.SendSearchQueryBottomSheet.MISSING_SEARCH_QUERY_KEY;
|
||||
import static net.osmand.search.core.ObjectType.POI_TYPE;
|
||||
|
@ -388,8 +387,8 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
} else {
|
||||
filter = (PoiUIFilter) searchPhrase.getLastSelectedWord().getResult().object;
|
||||
}
|
||||
app.getPoiFilters().clearSelectedPoiFilters(PoiTemplateList.POI);
|
||||
app.getPoiFilters().addSelectedPoiFilter(PoiTemplateList.POI, filter);
|
||||
app.getPoiFilters().clearSelectedPoiFilters();
|
||||
app.getPoiFilters().addSelectedPoiFilter(filter);
|
||||
|
||||
mapActivity.getContextMenu().closeActiveToolbar();
|
||||
showToolbar();
|
||||
|
@ -864,7 +863,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
}
|
||||
|
||||
public void closeSearch() {
|
||||
app.getPoiFilters().clearSelectedPoiFilters(PoiTemplateList.POI);
|
||||
app.getPoiFilters().clearSelectedPoiFilters();
|
||||
dismiss();
|
||||
}
|
||||
|
||||
|
|
|
@ -46,8 +46,6 @@ import java.io.IOException;
|
|||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static net.osmand.plus.poi.PoiFiltersHelper.PoiTemplateList;
|
||||
|
||||
public class QuickSearchHelper implements ResourceListener {
|
||||
|
||||
public static final int SEARCH_FAVORITE_API_PRIORITY = 50;
|
||||
|
@ -504,8 +502,8 @@ public class QuickSearchHelper implements ResourceListener {
|
|||
});
|
||||
controller.setTitle(filter.getName());
|
||||
PoiFiltersHelper helper = mapActivity.getMyApplication().getPoiFilters();
|
||||
helper.clearSelectedPoiFilters(PoiTemplateList.POI);
|
||||
helper.addSelectedPoiFilter(PoiTemplateList.POI, filter);
|
||||
helper.clearSelectedPoiFilters();
|
||||
helper.addSelectedPoiFilter(filter);
|
||||
mapActivity.showTopToolbar(controller);
|
||||
mapActivity.refreshMap();
|
||||
}
|
||||
|
@ -514,7 +512,7 @@ public class QuickSearchHelper implements ResourceListener {
|
|||
@NonNull TopToolbarController controller,
|
||||
@Nullable Runnable action) {
|
||||
mapActivity.hideTopToolbar(controller);
|
||||
mapActivity.getMyApplication().getPoiFilters().clearSelectedPoiFilters(PoiTemplateList.POI);
|
||||
mapActivity.getMyApplication().getPoiFilters().clearSelectedPoiFilters();
|
||||
mapActivity.refreshMap();
|
||||
if (action != null) {
|
||||
action.run();
|
||||
|
|
|
@ -1525,7 +1525,6 @@ public class OsmandSettings {
|
|||
|
||||
public final CommonPreference<Boolean> WIKI_ARTICLE_SHOW_IMAGES_ASKED = new BooleanPreference("wikivoyage_show_images_asked", false).makeGlobal();
|
||||
public final CommonPreference<WikiArticleShowImages> WIKI_ARTICLE_SHOW_IMAGES = new EnumStringPreference<>("wikivoyage_show_imgs", WikiArticleShowImages.OFF, WikiArticleShowImages.values()).makeGlobal();
|
||||
public final CommonPreference<Boolean> SHOW_WIKIPEDIA_POI = new BooleanPreference("show_wikipedia_poi", false).makeProfile();
|
||||
public final CommonPreference<Boolean> GLOBAL_WIKIPEDIA_POI_ENABLED = new BooleanPreference("global_wikipedia_poi_enabled", false).makeProfile();
|
||||
public final ListStringPreference WIKIPEDIA_POI_ENABLED_LANGUAGES = (ListStringPreference) new ListStringPreference("wikipedia_poi_enabled_languages", null, ",").makeProfile().cache();
|
||||
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package net.osmand.plus.views;
|
||||
|
||||
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
|
@ -103,19 +101,7 @@ public class OsmAndMapSurfaceView extends SurfaceView implements Callback {
|
|||
return mapView.onTouchEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
if(mapView == null) {
|
||||
return;
|
||||
}
|
||||
boolean nightMode = mapView.getApplication().getDaynightHelper().isNightMode();
|
||||
DrawSettings drawSettings = new DrawSettings(nightMode, false);
|
||||
mapView.drawOverMap(canvas, mapView.getCurrentRotatedTileBox().copy(), drawSettings);
|
||||
}
|
||||
|
||||
|
||||
public OsmandMapTileView getMapView() {
|
||||
return mapView;
|
||||
}
|
||||
|
||||
}
|
|
@ -13,6 +13,7 @@ import android.graphics.Paint;
|
|||
import android.graphics.Paint.Style;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.RectF;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.os.SystemClock;
|
||||
|
@ -42,10 +43,10 @@ import net.osmand.map.MapTileDownloader.IMapDownloaderCallback;
|
|||
import net.osmand.plus.OsmAndConstants;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.helpers.TwoFingerTapDetector;
|
||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||
import net.osmand.plus.views.MultiTouchSupport.MultiTouchZoomListener;
|
||||
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
||||
import net.osmand.render.RenderingRuleSearchRequest;
|
||||
|
@ -267,6 +268,9 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
|
|||
view.setClickable(true);
|
||||
view.setLongClickable(true);
|
||||
view.setFocusable(true);
|
||||
if (Build.VERSION.SDK_INT >= 26) {
|
||||
view.setDefaultFocusHighlightEnabled(false);
|
||||
}
|
||||
refreshMap(true);
|
||||
}
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ import net.osmand.plus.OsmandApplication;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.helpers.WaypointHelper;
|
||||
import net.osmand.plus.poi.PoiFiltersHelper;
|
||||
import net.osmand.plus.poi.PoiUIFilter;
|
||||
import net.osmand.plus.render.RenderingIcons;
|
||||
import net.osmand.plus.routing.IRouteInformationListener;
|
||||
|
@ -205,8 +206,8 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
|
|||
@Override
|
||||
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
|
||||
Set<PoiUIFilter> selectedPoiFilters = app.getPoiFilters().getSelectedPoiFilters();
|
||||
if (!this.filters.equals(selectedPoiFilters)) {
|
||||
this.filters = new TreeSet<>(selectedPoiFilters);
|
||||
if (this.filters != selectedPoiFilters) {
|
||||
this.filters = selectedPoiFilters;
|
||||
data.clearCache();
|
||||
}
|
||||
|
||||
|
|
|
@ -151,6 +151,7 @@ public class SelectWikiLanguagesBottomSheet extends MenuBottomSheetDialogFragmen
|
|||
languages.add(new WikiLanguageItem(locale, WikipediaPoiMenu.getTranslation(app, locale), checked, topDefined));
|
||||
}
|
||||
} else {
|
||||
isGlobalWikiPoiEnabled = true;
|
||||
for (String locale : app.getPoiTypes().getAllAvailableWikiLocales()) {
|
||||
boolean topDefined = preferredLocales.contains(locale);
|
||||
languages.add(new WikiLanguageItem(locale, WikipediaPoiMenu.getTranslation(app, locale), false, topDefined));
|
||||
|
|
|
@ -29,7 +29,6 @@ import java.util.List;
|
|||
import java.util.Set;
|
||||
|
||||
import static net.osmand.osm.MapPoiTypes.WIKI_LANG;
|
||||
import static net.osmand.plus.poi.PoiFiltersHelper.PoiTemplateList;
|
||||
|
||||
public class WikipediaPoiMenu {
|
||||
|
||||
|
@ -54,7 +53,7 @@ public class WikipediaPoiMenu {
|
|||
final int toggleActionStringId = R.string.shared_string_wikipedia;
|
||||
final int languageActionStringId = R.string.shared_string_language;
|
||||
final int spaceHeight = app.getResources().getDimensionPixelSize(R.dimen.bottom_sheet_big_item_height);
|
||||
final boolean enabled = app.getPoiFilters().isShowingAnyPoi(PoiTemplateList.WIKI);
|
||||
final boolean enabled = app.getPoiFilters().isTopWikiFilterSelected();
|
||||
ContextMenuAdapter adapter = new ContextMenuAdapter(app);
|
||||
adapter.setDefaultLayoutId(R.layout.dash_item_with_description_72dp);
|
||||
adapter.setProfileDependent(true);
|
||||
|
@ -76,11 +75,11 @@ public class WikipediaPoiMenu {
|
|||
app.runInUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
toggleWikipediaPoi(mapActivity, !enabled, true, callback);
|
||||
toggleWikipediaPoi(mapActivity, !enabled, callback);
|
||||
}
|
||||
});
|
||||
} else if (itemId == languageActionStringId) {
|
||||
showLanguagesDialog(mapActivity, appMode, true, true, callback);
|
||||
showLanguagesDialog(mapActivity, appMode, true, callback);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -234,7 +233,6 @@ public class WikipediaPoiMenu {
|
|||
private static void showLanguagesDialog(@NonNull final MapActivity mapActivity,
|
||||
@NonNull final ApplicationMode appMode,
|
||||
final boolean usedOnMap,
|
||||
final boolean refresh,
|
||||
final CallbackWithObject<Boolean> callback) {
|
||||
final OsmandApplication app = mapActivity.getMyApplication();
|
||||
SelectWikiLanguagesBottomSheet.showInstance(mapActivity, appMode, usedOnMap,
|
||||
|
@ -244,15 +242,9 @@ public class WikipediaPoiMenu {
|
|||
if (result) {
|
||||
Bundle wikiPoiSetting = getWikiPoiSettingsForProfile(app, appMode);
|
||||
if (wikiPoiSetting != null) {
|
||||
boolean globalWikiEnabled =
|
||||
wikiPoiSetting.getBoolean(GLOBAL_WIKI_POI_ENABLED_KEY);
|
||||
if (refresh) {
|
||||
refreshWikiPoi(mapActivity, globalWikiEnabled);
|
||||
refreshWikipediaOnMap(mapActivity);
|
||||
} else {
|
||||
toggleWikipediaPoi(mapActivity, true, usedOnMap, callback);
|
||||
}
|
||||
} else {
|
||||
toggleWikipediaPoi(mapActivity, false, usedOnMap, callback);
|
||||
toggleWikipediaPoi(mapActivity, false, callback);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -304,65 +296,46 @@ public class WikipediaPoiMenu {
|
|||
}
|
||||
|
||||
public static void toggleWikipediaPoi(final MapActivity mapActivity, boolean enable,
|
||||
boolean usedOnMap, CallbackWithObject<Boolean> callback) {
|
||||
CallbackWithObject<Boolean> callback) {
|
||||
OsmandApplication app = mapActivity.getMyApplication();
|
||||
OsmandSettings settings = app.getSettings();
|
||||
if (enable) {
|
||||
Bundle wikiPoiSettings = getWikiPoiSettings(app);
|
||||
if (wikiPoiSettings != null) {
|
||||
settings.SHOW_WIKIPEDIA_POI.set(true);
|
||||
boolean globalWikiEnabled = wikiPoiSettings.getBoolean(GLOBAL_WIKI_POI_ENABLED_KEY);
|
||||
showWikiOnMap(app, globalWikiEnabled);
|
||||
showWikipediaOnMap(app);
|
||||
} else {
|
||||
ApplicationMode appMode = settings.getApplicationMode();
|
||||
showLanguagesDialog(mapActivity, appMode, usedOnMap, false, callback);
|
||||
}
|
||||
} else {
|
||||
settings.SHOW_WIKIPEDIA_POI.set(false);
|
||||
hideWikiFromMap(app);
|
||||
hideWikipediaFromMap(app);
|
||||
}
|
||||
if (callback != null) {
|
||||
callback.processResult(settings.SHOW_WIKIPEDIA_POI.get());
|
||||
callback.processResult(enable);
|
||||
}
|
||||
mapActivity.refreshMap();
|
||||
}
|
||||
|
||||
public static void refreshWikiPoi(MapActivity mapActivity, boolean globalWikiEnabled) {
|
||||
public static void refreshWikipediaOnMap(MapActivity mapActivity) {
|
||||
OsmandApplication app = mapActivity.getMyApplication();
|
||||
hideWikiFromMap(app);
|
||||
showWikiOnMap(app, globalWikiEnabled);
|
||||
app.getPoiFilters().loadSelectedPoiFilters();
|
||||
mapActivity.getDashboard().refreshContent(true);
|
||||
mapActivity.refreshMap();
|
||||
}
|
||||
|
||||
private static void showWikiOnMap(OsmandApplication app, boolean globalWikiEnabled) {
|
||||
private static void showWikipediaOnMap(OsmandApplication app) {
|
||||
PoiFiltersHelper ph = app.getPoiFilters();
|
||||
if (globalWikiEnabled) {
|
||||
ph.addSelectedPoiFilter(PoiTemplateList.WIKI, ph.getGlobalWikiPoiFilter());
|
||||
} else {
|
||||
List<PoiUIFilter> filters = ph.getLocalWikipediaPoiFilters(true);
|
||||
for (PoiUIFilter filter : filters) {
|
||||
ph.addSelectedPoiFilter(PoiTemplateList.WIKI, filter);
|
||||
}
|
||||
}
|
||||
PoiUIFilter wiki = ph.getTopWikiPoiFilter();
|
||||
ph.loadSelectedPoiFilters();
|
||||
ph.addSelectedPoiFilter(wiki);
|
||||
}
|
||||
|
||||
private static void hideWikiFromMap(OsmandApplication app) {
|
||||
private static void hideWikipediaFromMap(OsmandApplication app) {
|
||||
PoiFiltersHelper ph = app.getPoiFilters();
|
||||
for (PoiUIFilter filter : ph.getSelectedPoiFilters(PoiTemplateList.WIKI)) {
|
||||
ph.removePoiFilter(filter);
|
||||
}
|
||||
ph.clearSelectedPoiFilters(PoiTemplateList.WIKI);
|
||||
PoiUIFilter wiki = ph.getTopWikiPoiFilter();
|
||||
ph.removePoiFilter(wiki);
|
||||
ph.removeSelectedPoiFilter(wiki);
|
||||
}
|
||||
|
||||
public static String getLanguagesSummary(OsmandApplication app) {
|
||||
Bundle wikiLanguagesSetting = getWikiPoiSettings(app);
|
||||
if (wikiLanguagesSetting != null) {
|
||||
boolean globalWikiEnabled = wikiLanguagesSetting.getBoolean(GLOBAL_WIKI_POI_ENABLED_KEY);
|
||||
List<String> enabledLocales = wikiLanguagesSetting.getStringArrayList(ENABLED_WIKI_POI_LANGUAGES_KEY);
|
||||
if (globalWikiEnabled) {
|
||||
return app.getString(R.string.shared_string_all_languages);
|
||||
} else if (enabledLocales != null) {
|
||||
Bundle wikiSetting = getWikiPoiSettings(app);
|
||||
if (wikiSetting != null) {
|
||||
boolean globalWikiEnabled = wikiSetting.getBoolean(GLOBAL_WIKI_POI_ENABLED_KEY);
|
||||
List<String> enabledLocales = wikiSetting.getStringArrayList(ENABLED_WIKI_POI_LANGUAGES_KEY);
|
||||
if (!globalWikiEnabled && enabledLocales != null) {
|
||||
List<String> translations = new ArrayList<>();
|
||||
for (String locale : enabledLocales) {
|
||||
translations.add(getTranslation(app, locale));
|
||||
|
@ -370,11 +343,7 @@ public class WikipediaPoiMenu {
|
|||
return android.text.TextUtils.join(", ", translations);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isWikiPoiEnabled(OsmandApplication app) {
|
||||
return app.getSettings().SHOW_WIKIPEDIA_POI.get() && getWikiPoiSettings(app) != null;
|
||||
return app.getString(R.string.shared_string_all_languages);
|
||||
}
|
||||
|
||||
public static ContextMenuAdapter createListAdapter(final MapActivity mapActivity) {
|
||||
|
@ -385,7 +354,7 @@ public class WikipediaPoiMenu {
|
|||
@NonNull Set<String> availableArticleLangs,
|
||||
String preferredLanguage) {
|
||||
Bundle wikiPoiSettings = getWikiPoiSettings(app);
|
||||
if (!app.getSettings().SHOW_WIKIPEDIA_POI.get() || wikiPoiSettings == null) {
|
||||
if (!app.getPoiFilters().isTopWikiFilterSelected() || wikiPoiSettings == null) {
|
||||
// Wikipedia POI setting disabled
|
||||
return preferredLanguage;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue