Refactor names

This commit is contained in:
max-klaus 2020-06-20 11:05:28 +03:00
parent 43ded8c0e7
commit b2fb7e7cfb
7 changed files with 18 additions and 21 deletions

View file

@ -772,7 +772,7 @@ public class BinaryMapPoiReaderAdapter {
} }
} }
subtype = poiTypes.replaceDeprecatedSubtype(type, subtype); subtype = poiTypes.replaceDeprecatedSubtype(type, subtype);
boolean isForbidden = poiTypes.isKeyNameForbidden(subtype); boolean isForbidden = poiTypes.isTypeForbidden(subtype);
if (!isForbidden && (req.poiTypeFilter == null || req.poiTypeFilter.accept(type, subtype))) { if (!isForbidden && (req.poiTypeFilter == null || req.poiTypeFilter.accept(type, subtype))) {
if (amenityType == null) { if (amenityType == null) {
amenityType = type; amenityType = type;

View file

@ -35,13 +35,14 @@ public class MapPoiTypes {
private static final Log log = PlatformUtil.getLog(MapRenderingTypes.class); private static final Log log = PlatformUtil.getLog(MapRenderingTypes.class);
private String resourceName; private String resourceName;
private List<PoiCategory> categories = new ArrayList<PoiCategory>(); private List<PoiCategory> categories = new ArrayList<PoiCategory>();
private Set<String> forbiddenKeyNames = new HashSet<>(); private Set<String> forbiddenTypes = new HashSet<>();
private PoiCategory otherCategory; private PoiCategory otherCategory;
private PoiCategory otherMapCategory; private PoiCategory otherMapCategory;
public static final String WIKI_LANG = "wiki_lang"; public static final String WIKI_LANG = "wiki_lang";
public static final String WIKI_PLACE = "wiki_place"; public static final String WIKI_PLACE = "wiki_place";
public static final String OSM_WIKI_CATEGORY = "osmwiki"; public static final String OSM_WIKI_CATEGORY = "osmwiki";
public static final String SPEED_CAMERA = "speed_camera";
private PoiTranslator poiTranslator = null; private PoiTranslator poiTranslator = null;
private boolean init; private boolean init;
@ -948,11 +949,11 @@ public class MapPoiTypes {
} }
} }
public void setForbiddenKeyNames(Set<String> forbiddenKeyNames) { public void setForbiddenTypes(Set<String> forbiddenTypes) {
this.forbiddenKeyNames = forbiddenKeyNames; this.forbiddenTypes = forbiddenTypes;
} }
public boolean isKeyNameForbidden(String key) { public boolean isTypeForbidden(String typeName) {
return forbiddenKeyNames.contains(key); return forbiddenTypes.contains(typeName);
} }
} }

View file

@ -31,7 +31,7 @@ public class PoiFilter extends AbstractPoiType {
Map<String, PoiType> nmap = null; Map<String, PoiType> nmap = null;
for (PoiType poiType : poiTypesToAdd.values()) { for (PoiType poiType : poiTypesToAdd.values()) {
String keyName = poiType.getKeyName(); String keyName = poiType.getKeyName();
if (!map.containsKey(keyName) && !registry.isKeyNameForbidden(keyName)) { if (!map.containsKey(keyName) && !registry.isTypeForbidden(keyName)) {
if (npoiTypes == null) { if (npoiTypes == null) {
npoiTypes = new ArrayList<PoiType>(this.poiTypes); npoiTypes = new ArrayList<PoiType>(this.poiTypes);
nmap = new LinkedHashMap<>(map); nmap = new LinkedHashMap<>(map);
@ -47,7 +47,7 @@ public class PoiFilter extends AbstractPoiType {
} }
public void addPoiType(PoiType type) { public void addPoiType(PoiType type) {
if (registry.isKeyNameForbidden(type.keyName)) { if (registry.isTypeForbidden(type.keyName)) {
return; return;
} }
if (!map.containsKey(type.getKeyName())) { if (!map.containsKey(type.getKeyName())) {

View file

@ -302,7 +302,7 @@ public class AppInitializer implements IProgress {
} }
private void initPoiTypes() { private void initPoiTypes() {
app.poiTypes.setForbiddenKeyNames(app.osmandSettings.getForbiddenPoiKeyNames()); app.poiTypes.setForbiddenTypes(app.osmandSettings.getForbiddenTypes());
if (app.getAppPath(IndexConstants.SETTINGS_DIR + "poi_types.xml").exists()) { if (app.getAppPath(IndexConstants.SETTINGS_DIR + "poi_types.xml").exists()) {
app.poiTypes.init(app.getAppPath(IndexConstants.SETTINGS_DIR + "poi_types.xml").getAbsolutePath()); app.poiTypes.init(app.getAppPath(IndexConstants.SETTINGS_DIR + "poi_types.xml").getAbsolutePath());
} else { } else {

View file

@ -17,14 +17,11 @@ import net.osmand.plus.UiUtilities;
import net.osmand.plus.base.MenuBottomSheetDialogFragment; import net.osmand.plus.base.MenuBottomSheetDialogFragment;
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
import net.osmand.plus.helpers.FontCache; import net.osmand.plus.helpers.FontCache;
import net.osmand.plus.settings.backend.OsmandSettings;
public class SpeedCamerasBottomSheet extends MenuBottomSheetDialogFragment { public class SpeedCamerasBottomSheet extends MenuBottomSheetDialogFragment {
public static final String TAG = SpeedCamerasBottomSheet.class.getName(); public static final String TAG = SpeedCamerasBottomSheet.class.getName();
public static final String SPEED_CAMERA_KEY_NAME = "speed_camera";
private OsmandApplication app; private OsmandApplication app;
private OsmandSettings settings;
public static void showInstance(@NonNull FragmentManager fm, @Nullable Fragment targetFragment) { public static void showInstance(@NonNull FragmentManager fm, @Nullable Fragment targetFragment) {
if (!fm.isStateSaved()) { if (!fm.isStateSaved()) {
@ -38,7 +35,6 @@ public class SpeedCamerasBottomSheet extends MenuBottomSheetDialogFragment {
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
app = requiredMyApplication(); app = requiredMyApplication();
settings = app.getSettings();
} }
@Override @Override

View file

@ -428,7 +428,7 @@ public class SearchHistoryHelper {
do { do {
String name = query.getString(0); String name = query.getString(0);
PointDescription p = PointDescription.deserializeFromString(name, new LatLon(query.getDouble(1), query.getDouble(2))); PointDescription p = PointDescription.deserializeFromString(name, new LatLon(query.getDouble(1), query.getDouble(2)));
if (context.getPoiTypes().isKeyNameForbidden(p.getName())){ if (context.getPoiTypes().isTypeForbidden(p.getName())){
query.moveToNext(); query.moveToNext();
} }
HistoryEntry e = new HistoryEntry(query.getDouble(1), query.getDouble(2), HistoryEntry e = new HistoryEntry(query.getDouble(1), query.getDouble(2),

View file

@ -34,9 +34,8 @@ import net.osmand.data.PointDescription;
import net.osmand.map.ITileSource; import net.osmand.map.ITileSource;
import net.osmand.map.TileSourceManager; import net.osmand.map.TileSourceManager;
import net.osmand.map.TileSourceManager.TileSourceTemplate; import net.osmand.map.TileSourceManager.TileSourceTemplate;
import net.osmand.osm.MapPoiTypes;
import net.osmand.osm.io.NetworkUtils; import net.osmand.osm.io.NetworkUtils;
import net.osmand.plus.settings.backend.ApplicationMode.ApplicationModeBean;
import net.osmand.plus.settings.backend.ApplicationMode.ApplicationModeBuilder;
import net.osmand.plus.FavouritesDbHelper; import net.osmand.plus.FavouritesDbHelper;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
@ -56,6 +55,8 @@ import net.osmand.plus.profiles.NavigationIcon;
import net.osmand.plus.profiles.ProfileIconColors; import net.osmand.plus.profiles.ProfileIconColors;
import net.osmand.plus.render.RendererRegistry; import net.osmand.plus.render.RendererRegistry;
import net.osmand.plus.routing.RouteProvider.RouteService; import net.osmand.plus.routing.RouteProvider.RouteService;
import net.osmand.plus.settings.backend.ApplicationMode.ApplicationModeBean;
import net.osmand.plus.settings.backend.ApplicationMode.ApplicationModeBuilder;
import net.osmand.plus.voice.CommandPlayer; import net.osmand.plus.voice.CommandPlayer;
import net.osmand.render.RenderingRulesStorage; import net.osmand.render.RenderingRulesStorage;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
@ -88,7 +89,6 @@ import java.util.StringTokenizer;
import static net.osmand.aidlapi.OsmAndCustomizationConstants.CONFIGURE_MAP_ITEM_ID_SCHEME; import static net.osmand.aidlapi.OsmAndCustomizationConstants.CONFIGURE_MAP_ITEM_ID_SCHEME;
import static net.osmand.aidlapi.OsmAndCustomizationConstants.DRAWER_ITEM_ID_SCHEME; import static net.osmand.aidlapi.OsmAndCustomizationConstants.DRAWER_ITEM_ID_SCHEME;
import static net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_CONTEXT_MENU_ACTIONS; import static net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_CONTEXT_MENU_ACTIONS;
import static net.osmand.plus.dialogs.SpeedCamerasBottomSheet.SPEED_CAMERA_KEY_NAME;
public class OsmandSettings { public class OsmandSettings {
@ -2113,12 +2113,12 @@ public class OsmandSettings {
public final OsmandPreference<Boolean> SPEED_CAMERAS_UNINSTALLED = new BooleanPreference("speed_cameras_uninstalled", false).makeGlobal(); public final OsmandPreference<Boolean> SPEED_CAMERAS_UNINSTALLED = new BooleanPreference("speed_cameras_uninstalled", false).makeGlobal();
public final OsmandPreference<Boolean> SPEED_CAMERAS_ALERT_SHOWED = new BooleanPreference("speed_cameras_alert_showed", false).makeGlobal(); public final OsmandPreference<Boolean> SPEED_CAMERAS_ALERT_SHOWED = new BooleanPreference("speed_cameras_alert_showed", false).makeGlobal();
public Set<String> getForbiddenPoiKeyNames() { public Set<String> getForbiddenTypes() {
Set<String> keyNames = new HashSet<>(); Set<String> typeNames = new HashSet<>();
if (SPEED_CAMERAS_UNINSTALLED.get()) { if (SPEED_CAMERAS_UNINSTALLED.get()) {
keyNames.add(SPEED_CAMERA_KEY_NAME); typeNames.add(MapPoiTypes.SPEED_CAMERA);
} }
return keyNames; return typeNames;
} }
public final OsmandPreference<Boolean> ANNOUNCE_WPT = new BooleanPreference("announce_wpt", true) { public final OsmandPreference<Boolean> ANNOUNCE_WPT = new BooleanPreference("announce_wpt", true) {