diff --git a/OsmAnd-java/src/main/java/net/osmand/util/Algorithms.java b/OsmAnd-java/src/main/java/net/osmand/util/Algorithms.java index c95d5aaf0e..75f61e8a71 100644 --- a/OsmAnd-java/src/main/java/net/osmand/util/Algorithms.java +++ b/OsmAnd-java/src/main/java/net/osmand/util/Algorithms.java @@ -104,6 +104,14 @@ public class Algorithms { return name.substring(i + 1); } + public static String getFileWithoutDirs(String name) { + int i = name.lastIndexOf(File.separator); + if (i != -1) { + return name.substring(i + 1); + } + return name; + } + public static File[] getSortedFilesVersions(File dir) { File[] listFiles = dir.listFiles(); if (listFiles != null) { diff --git a/OsmAnd/src/net/osmand/plus/CustomOsmandPlugin.java b/OsmAnd/src/net/osmand/plus/CustomOsmandPlugin.java index b08b1a941f..8920f8bf69 100644 --- a/OsmAnd/src/net/osmand/plus/CustomOsmandPlugin.java +++ b/OsmAnd/src/net/osmand/plus/CustomOsmandPlugin.java @@ -22,6 +22,7 @@ import net.osmand.plus.helpers.AvoidSpecificRoads; import net.osmand.plus.poi.PoiUIFilter; import net.osmand.plus.quickaction.QuickAction; import net.osmand.plus.quickaction.QuickActionRegistry; +import net.osmand.plus.render.RendererRegistry; import net.osmand.util.Algorithms; import org.apache.commons.logging.Log; @@ -135,8 +136,11 @@ public class CustomOsmandPlugin extends OsmandPlugin { PoiUiFilterSettingsItem poiUiFilterSettingsItem = (PoiUiFilterSettingsItem) item; List poiUIFilters = poiUiFilterSettingsItem.getItems(); for (PoiUIFilter filter : poiUIFilters) { - app.getPoiFilters().removePoiFilter(filter); + PoiUIFilter savedFilter = app.getPoiFilters().getFilterById(filter.getFilterId()); + app.getPoiFilters().removePoiFilter(savedFilter); } + app.getPoiFilters().reloadAllPoiFilters(); + app.getPoiFilters().loadSelectedPoiFilters(); app.getSearchUICore().refreshCustomPoiFilters(); } else if (item instanceof AvoidRoadsSettingsItem) { AvoidRoadsSettingsItem avoidRoadsSettingsItem = (AvoidRoadsSettingsItem) item; @@ -280,4 +284,9 @@ public class CustomOsmandPlugin extends OsmandPlugin { public List getRouterNames() { return routerNames; } + + public void addRenderer(String fileName) { + String renderer = RendererRegistry.formatRenderFileName(fileName); + rendererNames.add(renderer.replace('_', ' ').replace('-', ' ')); + } } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/SettingsHelper.java b/OsmAnd/src/net/osmand/plus/SettingsHelper.java index 695428ac0b..5679f0e417 100644 --- a/OsmAnd/src/net/osmand/plus/SettingsHelper.java +++ b/OsmAnd/src/net/osmand/plus/SettingsHelper.java @@ -372,9 +372,9 @@ public class SettingsHelper { if (item instanceof SettingsHelper.FileSettingsItem) { FileSettingsItem fileItem = (FileSettingsItem) item; if (fileItem.getSubtype() == FileSettingsItem.FileSubtype.RENDERING_STYLE) { - plugin.rendererNames.add(fileItem.getFileName()); + plugin.addRenderer(fileItem.getName()); } else if (fileItem.getSubtype() == FileSettingsItem.FileSubtype.ROUTING_CONFIG) { - plugin.routerNames.add(fileItem.getFileName()); + plugin.getRouterNames().add(fileItem.getName()); } } } @@ -1005,7 +1005,10 @@ public class SettingsHelper { } public static FileSubtype getSubtypeByFileName(@NonNull String fileName) { - String name = fileName.substring(1); + String name = fileName; + if (fileName.startsWith(File.separator)) { + name = fileName.substring(1); + } for (FileSubtype subtype : FileSubtype.values()) { if (subtype == ROUTING_CONFIG || subtype == RENDERING_STYLE) { if (name.startsWith(subtype.subtypeFolder) || name.startsWith(subtype.subtypeName)) { @@ -1080,12 +1083,7 @@ public class SettingsHelper { if (subtype == FileSubtype.OTHER) { name = fileName; } else if (subtype != null && subtype != FileSubtype.UNKNOWN) { - int index = fileName.lastIndexOf(File.separator); - if (index != -1) { - name = fileName.substring(index); - } else { - name = fileName; - } + name = Algorithms.getFileWithoutDirs(fileName); } } } diff --git a/OsmAnd/src/net/osmand/plus/render/RendererRegistry.java b/OsmAnd/src/net/osmand/plus/render/RendererRegistry.java index 3225f77ee3..b6a8cb09cc 100644 --- a/OsmAnd/src/net/osmand/plus/render/RendererRegistry.java +++ b/OsmAnd/src/net/osmand/plus/render/RendererRegistry.java @@ -260,9 +260,9 @@ public class RendererRegistry { if (lf != null) { for (File f : lf) { if (f != null && f.getName().endsWith(IndexConstants.ROUTING_AND_RENDERING_FILE_EXT)) { - if(!internalRenderers.containsValue(f.getName())) { - String name = f.getName().substring(0, f.getName().length() - IndexConstants.ROUTING_AND_RENDERING_FILE_EXT.length()); - externalRenderers.put(name.replace('_', ' ').replace('-', ' '), f); + if (!internalRenderers.containsValue(f.getName())) { + String name = formatRenderFileName(f.getName()); + externalRenderers.put(name, f); } } } @@ -270,7 +270,12 @@ public class RendererRegistry { } this.externalRenderers = externalRenderers; } - + + public static String formatRenderFileName(String fileName) { + String name = fileName.substring(0, fileName.length() - IndexConstants.ROUTING_AND_RENDERING_FILE_EXT.length()); + return name.replace('_', ' ').replace('-', ' '); + } + public Collection getRendererNames(){ LinkedHashSet names = new LinkedHashSet(); names.add(DEFAULT_RENDER); diff --git a/OsmAnd/src/net/osmand/plus/settings/NavigationFragment.java b/OsmAnd/src/net/osmand/plus/settings/NavigationFragment.java index 06e2982845..07b2206a05 100644 --- a/OsmAnd/src/net/osmand/plus/settings/NavigationFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/NavigationFragment.java @@ -238,7 +238,7 @@ public class NavigationFragment extends BaseSettingsFragment { for (Map.Entry entry : builder.getAllRouters().entrySet()) { String routerKey = entry.getKey(); GeneralRouter router = entry.getValue(); - if (!routerKey.equals("geocoding") && !disabledRouterNames.contains(routerKey)) { + if (!routerKey.equals("geocoding") && !disabledRouterNames.contains(router.getFilename())) { int iconRes = R.drawable.ic_action_gdirections_dark; String name = router.getProfileName(); String description = app.getString(R.string.osmand_default_routing);