hide speed cameras from search
This commit is contained in:
parent
66413f856e
commit
f2b1836e53
3 changed files with 23 additions and 0 deletions
|
@ -11,6 +11,7 @@ import net.osmand.data.MapObject;
|
|||
import net.osmand.data.Street;
|
||||
import net.osmand.osm.AbstractPoiType;
|
||||
import net.osmand.osm.MapPoiTypes;
|
||||
import net.osmand.osm.PoiType;
|
||||
import net.osmand.search.core.CustomSearchPoiFilter;
|
||||
import net.osmand.search.core.ObjectType;
|
||||
import net.osmand.search.core.SearchCoreAPI;
|
||||
|
@ -656,6 +657,8 @@ public class SearchUICore {
|
|||
private List<MapObject> exportedObjects;
|
||||
private List<City> exportedCities;
|
||||
|
||||
private static boolean speedCamerasUninstalled = false;
|
||||
|
||||
public SearchResultMatcher(ResultMatcher<SearchResult> matcher, SearchPhrase phrase, int request,
|
||||
AtomicInteger requestNumber, int totalLimit) {
|
||||
this.matcher = matcher;
|
||||
|
@ -733,6 +736,9 @@ public class SearchUICore {
|
|||
|
||||
@Override
|
||||
public boolean publish(SearchResult object) {
|
||||
if (speedCamerasUninstalled && isSpeedCameraObject(object.object)) {
|
||||
return false;
|
||||
}
|
||||
if (phrase != null && object.otherNames != null && !phrase.getFirstUnknownNameStringMatcher().matches(object.localeName)) {
|
||||
for (String s : object.otherNames) {
|
||||
if (phrase.getFirstUnknownNameStringMatcher().matches(s)) {
|
||||
|
@ -886,6 +892,20 @@ public class SearchUICore {
|
|||
}
|
||||
return json;
|
||||
}
|
||||
|
||||
private boolean isSpeedCameraObject(Object object) {
|
||||
String key = "";
|
||||
if (object instanceof PoiType) {
|
||||
key = ((PoiType) object).getKeyName();
|
||||
} else if (object instanceof Amenity) {
|
||||
key = ((Amenity) object).getSubType();
|
||||
}
|
||||
return "speed_camera".equals(key);
|
||||
}
|
||||
|
||||
public static void setSpeedCamerasUninstalled(boolean speedCamerasUninstalled) {
|
||||
SearchResultMatcher.speedCamerasUninstalled = speedCamerasUninstalled;
|
||||
}
|
||||
}
|
||||
|
||||
private enum ResultCompareStep {
|
||||
|
|
|
@ -17,6 +17,7 @@ import net.osmand.plus.R;
|
|||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
|
||||
import net.osmand.search.SearchUICore.SearchResultMatcher;
|
||||
|
||||
public class SpeedCamerasBottomSheet extends MenuBottomSheetDialogFragment {
|
||||
|
||||
|
@ -62,6 +63,7 @@ public class SpeedCamerasBottomSheet extends MenuBottomSheetDialogFragment {
|
|||
app.getSettings().SPEED_CAMERAS_UNINSTALLED.set(true);
|
||||
app.getSettings().SPEAK_SPEED_CAMERA.set(false);
|
||||
app.getSettings().SHOW_CAMERAS.set(false);
|
||||
SearchResultMatcher.setSpeedCamerasUninstalled(true);
|
||||
Fragment targetFragment = getTargetFragment();
|
||||
if (targetFragment instanceof OnSpeedCamerasUninstallListener) {
|
||||
((OnSpeedCamerasUninstallListener) targetFragment).onSpeedCamerasUninstalled();
|
||||
|
|
|
@ -68,6 +68,7 @@ public class QuickSearchHelper implements ResourceListener {
|
|||
core = new SearchUICore(app.getPoiTypes(), app.getSettings().MAP_PREFERRED_LOCALE.get(),
|
||||
app.getSettings().MAP_TRANSLITERATE_NAMES.get());
|
||||
app.getResourceManager().addResourceListener(this);
|
||||
SearchResultMatcher.setSpeedCamerasUninstalled(app.getSettings().SPEED_CAMERAS_UNINSTALLED.get());
|
||||
}
|
||||
|
||||
public SearchUICore getCore() {
|
||||
|
|
Loading…
Reference in a new issue