From c585feb1faa091234a4f7a1be75556f5aa8664d7 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Wed, 18 Mar 2020 16:51:20 +0200 Subject: [PATCH] Hide disabled routers from ui --- OsmAnd/src/net/osmand/plus/OsmandPlugin.java | 10 ---------- .../SelectMapStyleBottomSheetDialogFragment.java | 2 +- .../plus/quickaction/actions/MapStyleAction.java | 2 +- .../osmand/plus/settings/NavigationFragment.java | 13 ++++++++++--- 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/OsmandPlugin.java b/OsmAnd/src/net/osmand/plus/OsmandPlugin.java index c932d7fadf..c10cc7d7a9 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandPlugin.java +++ b/OsmAnd/src/net/osmand/plus/OsmandPlugin.java @@ -561,16 +561,6 @@ public abstract class OsmandPlugin { return lst; } - public static List getDisabledPlugins() { - ArrayList lst = new ArrayList(allPlugins.size()); - for (OsmandPlugin p : allPlugins) { - if (!p.isActive()) { - lst.add(p); - } - } - return lst; - } - public static List getEnabledVisiblePlugins() { ArrayList lst = new ArrayList(allPlugins.size()); for (OsmandPlugin p : allPlugins) { diff --git a/OsmAnd/src/net/osmand/plus/dialogs/SelectMapStyleBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/dialogs/SelectMapStyleBottomSheetDialogFragment.java index 7c3cfbf772..e15c8d169f 100644 --- a/OsmAnd/src/net/osmand/plus/dialogs/SelectMapStyleBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/dialogs/SelectMapStyleBottomSheetDialogFragment.java @@ -177,7 +177,7 @@ public class SelectMapStyleBottomSheetDialogFragment extends MenuBottomSheetDial }); List names = new ArrayList<>(getMyApplication().getRendererRegistry().getRendererNames()); - for (OsmandPlugin plugin : OsmandPlugin.getDisabledPlugins()) { + for (OsmandPlugin plugin : OsmandPlugin.getNotEnabledPlugins()) { for (String name : plugin.getRendererNames()) { names.remove(name); } diff --git a/OsmAnd/src/net/osmand/plus/quickaction/actions/MapStyleAction.java b/OsmAnd/src/net/osmand/plus/quickaction/actions/MapStyleAction.java index 55d71f4364..54f7806abe 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/actions/MapStyleAction.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/actions/MapStyleAction.java @@ -145,7 +145,7 @@ public class MapStyleAction extends SwitchableAction { final List visibleNamesList = new ArrayList<>(); final ArrayList items = new ArrayList<>(app.getRendererRegistry().getRendererNames()); - for (OsmandPlugin plugin : OsmandPlugin.getDisabledPlugins()) { + for (OsmandPlugin plugin : OsmandPlugin.getNotEnabledPlugins()) { for (String name : plugin.getRendererNames()) { items.remove(name); } diff --git a/OsmAnd/src/net/osmand/plus/settings/NavigationFragment.java b/OsmAnd/src/net/osmand/plus/settings/NavigationFragment.java index b0cd78e02b..06e2982845 100644 --- a/OsmAnd/src/net/osmand/plus/settings/NavigationFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/NavigationFragment.java @@ -8,6 +8,7 @@ import androidx.preference.SwitchPreferenceCompat; import net.osmand.plus.ApplicationMode; import net.osmand.plus.OsmandApplication; +import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.profiles.ProfileDataObject; @@ -221,17 +222,23 @@ public class NavigationFragment extends BaseSettingsFragment { false, null)); } + List disabledRouterNames = new ArrayList<>(); + for (OsmandPlugin plugin : OsmandPlugin.getNotEnabledPlugins()) { + disabledRouterNames.addAll(plugin.getRouterNames()); + } + for (RoutingConfiguration.Builder builder : context.getAllRoutingConfigs()) { - collectRoutingProfilesFromConfig(context, builder, profilesObjects); + collectRoutingProfilesFromConfig(context, builder, profilesObjects, disabledRouterNames); } return profilesObjects; } - private static void collectRoutingProfilesFromConfig(OsmandApplication app, RoutingConfiguration.Builder builder, Map profilesObjects) { + private static void collectRoutingProfilesFromConfig(OsmandApplication app, RoutingConfiguration.Builder builder, + Map profilesObjects, List disabledRouterNames) { for (Map.Entry entry : builder.getAllRouters().entrySet()) { String routerKey = entry.getKey(); GeneralRouter router = entry.getValue(); - if (!routerKey.equals("geocoding")) { + if (!routerKey.equals("geocoding") && !disabledRouterNames.contains(routerKey)) { int iconRes = R.drawable.ic_action_gdirections_dark; String name = router.getProfileName(); String description = app.getString(R.string.osmand_default_routing);