diff --git a/OsmAnd-java/src/main/java/net/osmand/IndexConstants.java b/OsmAnd-java/src/main/java/net/osmand/IndexConstants.java index 9670a029f5..b4c42cd3a2 100644 --- a/OsmAnd-java/src/main/java/net/osmand/IndexConstants.java +++ b/OsmAnd-java/src/main/java/net/osmand/IndexConstants.java @@ -69,4 +69,5 @@ public class IndexConstants { public static final String ROUTING_XML_FILE= "routing.xml"; public static final String SETTINGS_DIR = "settings/"; //$NON-NLS-1$ public static final String TEMP_DIR = "temp/"; + public static final String ROUTING_PROFILES_DIR = "routing/"; } diff --git a/OsmAnd-java/src/main/java/net/osmand/router/GeneralRouter.java b/OsmAnd-java/src/main/java/net/osmand/router/GeneralRouter.java index 3cfc80806f..1f5f9bdb99 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/GeneralRouter.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/GeneralRouter.java @@ -44,6 +44,8 @@ public class GeneralRouter implements VehicleRouter { private boolean shortestRoute; private boolean heightObstacles; private boolean allowPrivate; + private String filename = null; + private String profileName = ""; private Map> regionConvert = new LinkedHashMap>(); @@ -119,7 +121,23 @@ public class GeneralRouter implements VehicleRouter { ruleToValue = new ArrayList(); parameters = new LinkedHashMap(); } - + + public String getFilename() { + return filename; + } + + public void setFilename(String filename) { + this.filename = filename; + } + + public String getProfileName() { + return profileName; + } + + public void setProfileName(String profileName) { + this.profileName = profileName; + } + public GeneralRouter(GeneralRouter parent, Map params) { this.profile = parent.profile; this.attributes = new LinkedHashMap(); diff --git a/OsmAnd-java/src/main/java/net/osmand/router/RoutingConfiguration.java b/OsmAnd-java/src/main/java/net/osmand/router/RoutingConfiguration.java index d3d73dd828..32ca81f560 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/RoutingConfiguration.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/RoutingConfiguration.java @@ -19,7 +19,7 @@ import java.util.Map; import java.util.Stack; public class RoutingConfiguration { - + public static final int DEFAULT_MEMORY_LIMIT = 30; public final float DEVIATION_RADIUS = 3000; public Map attributes = new LinkedHashMap(); @@ -46,14 +46,13 @@ public class RoutingConfiguration { // 1.5 Recalculate distance help public float recalculateDistance = 20000f; - public static class Builder { // Design time storage private String defaultRouter = ""; - private Map routers = new LinkedHashMap(); - private Map attributes = new LinkedHashMap(); - private HashMap impassableRoadLocations = new HashMap(); + private Map routers = new LinkedHashMap<>(); + private Map attributes = new LinkedHashMap<>(); + private HashMap impassableRoadLocations = new HashMap<>(); // Example // { @@ -125,12 +124,16 @@ public class RoutingConfiguration { public String getDefaultRouter() { return defaultRouter; } - - public GeneralRouter getRouter(String applicationMode) { - return routers.get(applicationMode); + + public GeneralRouter getRouter(String routingProfileName) { + return routers.get(routingProfileName); } + public Map getAllRoutes() { + return routers; + } + public void removeImpassableRoad(RouteDataObject obj) { impassableRoadLocations.remove(obj.id); } @@ -164,10 +167,13 @@ public class RoutingConfiguration { } return DEFAULT; } - - public static RoutingConfiguration.Builder parseFromInputStream(InputStream is) throws IOException, XmlPullParserException { + + static RoutingConfiguration.Builder parseFromInputStream(InputStream is) throws IOException, XmlPullParserException { + return parseFromInputStream(is, null, new RoutingConfiguration.Builder()); + } + + public static RoutingConfiguration.Builder parseFromInputStream(InputStream is, String filename, RoutingConfiguration.Builder config) throws IOException, XmlPullParserException { XmlPullParser parser = PlatformUtil.newXMLPullParser(); - final RoutingConfiguration.Builder config = new RoutingConfiguration.Builder(); GeneralRouter currentRouter = null; RouteDataObjectAttribute currentAttribute = null; String preType = null; @@ -180,7 +186,7 @@ public class RoutingConfiguration { if ("osmand_routing_config".equals(name)) { config.defaultRouter = parser.getAttributeValue("", "defaultProfile"); } else if ("routingProfile".equals(name)) { - currentRouter = parseRoutingProfile(parser, config); + currentRouter = parseRoutingProfile(parser, config, filename); } else if ("attribute".equals(name)) { parseAttribute(parser, config, currentRouter); } else if ("parameter".equals(name)) { @@ -295,10 +301,8 @@ public class RoutingConfiguration { } } - - - private static GeneralRouter parseRoutingProfile(XmlPullParser parser, final RoutingConfiguration.Builder config) { - String currentSelectedRouter = parser.getAttributeValue("", "name"); + private static GeneralRouter parseRoutingProfile(XmlPullParser parser, final RoutingConfiguration.Builder config, String filename) { + String currentSelectedRouterName = parser.getAttributeValue("", "name"); Map attrs = new LinkedHashMap(); for(int i=0; i< parser.getAttributeCount(); i++) { attrs.put(parser.getAttributeName(i), parser.getAttributeValue(i)); @@ -306,7 +310,13 @@ public class RoutingConfiguration { GeneralRouterProfile c = Algorithms.parseEnumValue(GeneralRouterProfile.values(), parser.getAttributeValue("", "baseProfile"), GeneralRouterProfile.CAR); GeneralRouter currentRouter = new GeneralRouter(c, attrs); - config.routers.put(currentSelectedRouter, currentRouter); + currentRouter.setProfileName(currentSelectedRouterName); + if (filename != null) { + currentRouter.setFilename(filename); + currentSelectedRouterName = filename + "/" + currentSelectedRouterName; + } + + config.routers.put(currentSelectedRouterName, currentRouter); return currentRouter; } @@ -315,7 +325,7 @@ public class RoutingConfiguration { currentRouter.addAttribute(parser.getAttributeValue("", "name"), parser.getAttributeValue("", "value")); } else { - config.attributes.put(parser.getAttributeValue("", "name"), + config.attributes.put(parser.getAttributeValue("", "name"), parser.getAttributeValue("", "value")); } } diff --git a/OsmAnd/AndroidManifest.xml b/OsmAnd/AndroidManifest.xml index d523ab0dc2..02776da9a6 100644 --- a/OsmAnd/AndroidManifest.xml +++ b/OsmAnd/AndroidManifest.xml @@ -891,5 +891,15 @@ + + + + + diff --git a/OsmAnd/res/drawable/btn_right_round.xml b/OsmAnd/res/drawable/btn_right_round.xml index 843840c380..dd4ff6f2e0 100644 --- a/OsmAnd/res/drawable/btn_right_round.xml +++ b/OsmAnd/res/drawable/btn_right_round.xml @@ -10,7 +10,7 @@ diff --git a/OsmAnd/res/drawable/btn_round_profile_blue.xml b/OsmAnd/res/drawable/btn_round_profile_blue.xml new file mode 100644 index 0000000000..61df3c0cba --- /dev/null +++ b/OsmAnd/res/drawable/btn_round_profile_blue.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/drawable/btn_round_profile_gray.xml b/OsmAnd/res/drawable/btn_round_profile_gray.xml new file mode 100644 index 0000000000..a171b96212 --- /dev/null +++ b/OsmAnd/res/drawable/btn_round_profile_gray.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/drawable/fab_extended_drawable.xml b/OsmAnd/res/drawable/fab_extended_drawable.xml new file mode 100644 index 0000000000..b4e52993b4 --- /dev/null +++ b/OsmAnd/res/drawable/fab_extended_drawable.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/OsmAnd/res/layout/bottom_sheet_item_with_descr_and_radio_btn.xml b/OsmAnd/res/layout/bottom_sheet_item_with_descr_and_radio_btn.xml new file mode 100644 index 0000000000..a6eb4639e0 --- /dev/null +++ b/OsmAnd/res/layout/bottom_sheet_item_with_descr_and_radio_btn.xml @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OsmAnd/res/layout/bottom_sheet_select_type_fragment.xml b/OsmAnd/res/layout/bottom_sheet_select_type_fragment.xml new file mode 100644 index 0000000000..b5b6b1de29 --- /dev/null +++ b/OsmAnd/res/layout/bottom_sheet_select_type_fragment.xml @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + +