Hide plugin map styles for disabled plugins
This commit is contained in:
parent
109101ae97
commit
c884105147
5 changed files with 40 additions and 15 deletions
|
@ -158,6 +158,10 @@ public abstract class OsmandPlugin {
|
|||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public List<String> getRendererNames() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Plugin was installed
|
||||
*/
|
||||
|
@ -460,6 +464,16 @@ public abstract class OsmandPlugin {
|
|||
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() {
|
||||
ArrayList<OsmandPlugin> lst = new ArrayList<OsmandPlugin>(allPlugins.size());
|
||||
for (OsmandPlugin p : allPlugins) {
|
||||
|
|
|
@ -29,7 +29,6 @@ import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
|
|||
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemTitleWithDescrAndButton;
|
||||
import net.osmand.plus.base.bottomsheetmenu.simpleitems.SubtitleDividerItem;
|
||||
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
|
||||
import net.osmand.plus.openseamapsplugin.NauticalMapsPlugin;
|
||||
import net.osmand.plus.render.RendererRegistry;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
import net.osmand.render.RenderingRulesStorage;
|
||||
|
@ -178,8 +177,10 @@ public class SelectMapStyleBottomSheetDialogFragment extends MenuBottomSheetDial
|
|||
});
|
||||
|
||||
List<String> names = new ArrayList<>(getMyApplication().getRendererRegistry().getRendererNames());
|
||||
if (OsmandPlugin.getEnabledPlugin(NauticalMapsPlugin.class) == null) {
|
||||
names.remove(RendererRegistry.NAUTICAL_RENDER);
|
||||
for (OsmandPlugin plugin : OsmandPlugin.getDisabledPlugins()) {
|
||||
for (String name : plugin.getRendererNames()) {
|
||||
names.remove(name);
|
||||
}
|
||||
}
|
||||
for (String name : names) {
|
||||
String translation = RendererRegistry.getTranslatedRendererName(context, name);
|
||||
|
|
|
@ -9,6 +9,7 @@ import net.osmand.plus.ApplicationMode;
|
|||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.render.RendererRegistry;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
@ -77,7 +78,12 @@ public class NauticalMapsPlugin extends OsmandPlugin {
|
|||
public List<ApplicationMode> getAddedAppModes() {
|
||||
return Collections.singletonList(ApplicationMode.BOAT);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<String> getRendererNames() {
|
||||
return Collections.singletonList(RendererRegistry.NAUTICAL_RENDER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable(OsmandApplication app) {
|
||||
super.disable(app);
|
||||
|
|
|
@ -26,7 +26,6 @@ import net.osmand.util.Algorithms;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class MapStyleAction extends SwitchableAction<String> {
|
||||
|
@ -145,20 +144,19 @@ public class MapStyleAction extends SwitchableAction<String> {
|
|||
|
||||
final List<String> visibleNamesList = new ArrayList<>();
|
||||
final ArrayList<String> items = new ArrayList<>(app.getRendererRegistry().getRendererNames());
|
||||
final boolean nauticalPluginDisabled = OsmandPlugin.getEnabledPlugin(NauticalMapsPlugin.class) == null;
|
||||
|
||||
Iterator<String> iterator = items.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
String item = iterator.next();
|
||||
if (nauticalPluginDisabled && item.equals(RendererRegistry.NAUTICAL_RENDER)) {
|
||||
iterator.remove();
|
||||
} else {
|
||||
String translation = RendererRegistry.getTranslatedRendererName(activity, item);
|
||||
visibleNamesList.add(translation != null ? translation
|
||||
: item.replace('_', ' ').replace('-', ' '));
|
||||
for (OsmandPlugin plugin : OsmandPlugin.getDisabledPlugins()) {
|
||||
for (String name : plugin.getRendererNames()) {
|
||||
items.remove(name);
|
||||
}
|
||||
}
|
||||
|
||||
for (String item : items) {
|
||||
String translation = RendererRegistry.getTranslatedRendererName(activity, item);
|
||||
visibleNamesList.add(translation != null ? translation
|
||||
: item.replace('_', ' ').replace('-', ' '));
|
||||
}
|
||||
|
||||
final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(themedContext, R.layout.dialog_text_item);
|
||||
|
||||
arrayAdapter.addAll(visibleNamesList);
|
||||
|
|
|
@ -9,6 +9,7 @@ import net.osmand.plus.ApplicationMode;
|
|||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.render.RendererRegistry;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
@ -77,6 +78,11 @@ public class SkiMapsPlugin extends OsmandPlugin {
|
|||
return Collections.singletonList(ApplicationMode.SKI);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getRendererNames() {
|
||||
return Collections.singletonList(RendererRegistry.WINTER_SKI_RENDER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable(OsmandApplication app) {
|
||||
super.disable(app);
|
||||
|
|
Loading…
Reference in a new issue