Hide disabled routers from ui

This commit is contained in:
Vitaliy 2020-03-18 16:51:20 +02:00
parent 1f10ea75de
commit c585feb1fa
4 changed files with 12 additions and 15 deletions

View file

@ -561,16 +561,6 @@ public abstract class OsmandPlugin {
return lst; return lst;
} }
public static List<OsmandPlugin> getDisabledPlugins() {
ArrayList<OsmandPlugin> lst = new ArrayList<OsmandPlugin>(allPlugins.size());
for (OsmandPlugin p : allPlugins) {
if (!p.isActive()) {
lst.add(p);
}
}
return lst;
}
public static List<OsmandPlugin> getEnabledVisiblePlugins() { public static List<OsmandPlugin> getEnabledVisiblePlugins() {
ArrayList<OsmandPlugin> lst = new ArrayList<OsmandPlugin>(allPlugins.size()); ArrayList<OsmandPlugin> lst = new ArrayList<OsmandPlugin>(allPlugins.size());
for (OsmandPlugin p : allPlugins) { for (OsmandPlugin p : allPlugins) {

View file

@ -177,7 +177,7 @@ public class SelectMapStyleBottomSheetDialogFragment extends MenuBottomSheetDial
}); });
List<String> names = new ArrayList<>(getMyApplication().getRendererRegistry().getRendererNames()); List<String> names = new ArrayList<>(getMyApplication().getRendererRegistry().getRendererNames());
for (OsmandPlugin plugin : OsmandPlugin.getDisabledPlugins()) { for (OsmandPlugin plugin : OsmandPlugin.getNotEnabledPlugins()) {
for (String name : plugin.getRendererNames()) { for (String name : plugin.getRendererNames()) {
names.remove(name); names.remove(name);
} }

View file

@ -145,7 +145,7 @@ public class MapStyleAction extends SwitchableAction<String> {
final List<String> visibleNamesList = new ArrayList<>(); final List<String> visibleNamesList = new ArrayList<>();
final ArrayList<String> items = new ArrayList<>(app.getRendererRegistry().getRendererNames()); final ArrayList<String> items = new ArrayList<>(app.getRendererRegistry().getRendererNames());
for (OsmandPlugin plugin : OsmandPlugin.getDisabledPlugins()) { for (OsmandPlugin plugin : OsmandPlugin.getNotEnabledPlugins()) {
for (String name : plugin.getRendererNames()) { for (String name : plugin.getRendererNames()) {
items.remove(name); items.remove(name);
} }

View file

@ -8,6 +8,7 @@ import androidx.preference.SwitchPreferenceCompat;
import net.osmand.plus.ApplicationMode; import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.profiles.ProfileDataObject; import net.osmand.plus.profiles.ProfileDataObject;
@ -221,17 +222,23 @@ public class NavigationFragment extends BaseSettingsFragment {
false, null)); false, null));
} }
List<String> disabledRouterNames = new ArrayList<>();
for (OsmandPlugin plugin : OsmandPlugin.getNotEnabledPlugins()) {
disabledRouterNames.addAll(plugin.getRouterNames());
}
for (RoutingConfiguration.Builder builder : context.getAllRoutingConfigs()) { for (RoutingConfiguration.Builder builder : context.getAllRoutingConfigs()) {
collectRoutingProfilesFromConfig(context, builder, profilesObjects); collectRoutingProfilesFromConfig(context, builder, profilesObjects, disabledRouterNames);
} }
return profilesObjects; return profilesObjects;
} }
private static void collectRoutingProfilesFromConfig(OsmandApplication app, RoutingConfiguration.Builder builder, Map<String, RoutingProfileDataObject> profilesObjects) { private static void collectRoutingProfilesFromConfig(OsmandApplication app, RoutingConfiguration.Builder builder,
Map<String, RoutingProfileDataObject> profilesObjects, List<String> disabledRouterNames) {
for (Map.Entry<String, GeneralRouter> entry : builder.getAllRouters().entrySet()) { for (Map.Entry<String, GeneralRouter> entry : builder.getAllRouters().entrySet()) {
String routerKey = entry.getKey(); String routerKey = entry.getKey();
GeneralRouter router = entry.getValue(); GeneralRouter router = entry.getValue();
if (!routerKey.equals("geocoding")) { if (!routerKey.equals("geocoding") && !disabledRouterNames.contains(routerKey)) {
int iconRes = R.drawable.ic_action_gdirections_dark; int iconRes = R.drawable.ic_action_gdirections_dark;
String name = router.getProfileName(); String name = router.getProfileName();
String description = app.getString(R.string.osmand_default_routing); String description = app.getString(R.string.osmand_default_routing);