Add category ui_hidden in order to disable properties in dependent styles

This commit is contained in:
Victor Shcherb 2016-02-08 01:22:58 +01:00
parent 6569d7e83e
commit d5eed1cd28
26 changed files with 39 additions and 13 deletions

View file

@ -7,6 +7,7 @@ import java.util.Map;
public class RenderingRuleStorageProperties { public class RenderingRuleStorageProperties {
public static final String UI_CATEGORY_HIDDEN = "ui_hidden";
public static final String A_ENGINE_V1 = "engine_v1"; public static final String A_ENGINE_V1 = "engine_v1";
public static final String A_APP_MODE= "appMode"; public static final String A_APP_MODE= "appMode";
@ -307,12 +308,17 @@ public class RenderingRuleStorageProperties {
} }
private RenderingRuleProperty registerRuleInternal(RenderingRuleProperty p) { private RenderingRuleProperty registerRuleInternal(RenderingRuleProperty p) {
if(get(p.getAttrName()) == null) { RenderingRuleProperty existing = get(p.getAttrName());
properties.put(p.getAttrName(), p); properties.put(p.getAttrName(), p);
if(existing == null) {
p.setId(rules.size()); p.setId(rules.size());
rules.add(p); rules.add(p);
} else {
p.setId(existing.getId());
rules.set(existing.getId(), p);
customRules.remove(existing);
} }
return get(p.getAttrName()); return p;
} }
public RenderingRuleProperty registerRule(RenderingRuleProperty p) { public RenderingRuleProperty registerRule(RenderingRuleProperty p) {

View file

@ -7,6 +7,7 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.PrintStream; import java.io.PrintStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
@ -470,12 +471,13 @@ public class RenderingRulesStorage {
public static void main(String[] args) throws XmlPullParserException, IOException { public static void main(String[] args) throws XmlPullParserException, IOException {
STORE_ATTTRIBUTES = true; STORE_ATTTRIBUTES = true;
// InputStream is = RenderingRulesStorage.class.getResourceAsStream("default.render.xml"); // InputStream is = RenderingRulesStorage.class.getResourceAsStream("default.render.xml");
String defaultFile = "/Users/victorshcherb/osmand/repos/resources/rendering_styles/default.render.xml"; final String loc = "/Users/victorshcherb/osmand/repos/resources/rendering_styles/";
String defaultFile = loc + "UniRS.render.xml";
if(args.length > 0) { if(args.length > 0) {
defaultFile = args[0]; defaultFile = args[0];
} }
Map<String, String> renderingConstants = new LinkedHashMap<String, String>(); final Map<String, String> renderingConstants = new LinkedHashMap<String, String>();
InputStream is = new FileInputStream(defaultFile); InputStream is = new FileInputStream(loc + "default.render.xml");
try { try {
XmlPullParser parser = PlatformUtil.newXMLPullParser(); XmlPullParser parser = PlatformUtil.newXMLPullParser();
parser.setInput(is, "UTF-8"); parser.setInput(is, "UTF-8");
@ -498,8 +500,9 @@ public class RenderingRulesStorage {
final RenderingRulesStorageResolver resolver = new RenderingRulesStorageResolver() { final RenderingRulesStorageResolver resolver = new RenderingRulesStorageResolver() {
@Override @Override
public RenderingRulesStorage resolve(String name, RenderingRulesStorageResolver ref) throws XmlPullParserException, IOException { public RenderingRulesStorage resolve(String name, RenderingRulesStorageResolver ref) throws XmlPullParserException, IOException {
RenderingRulesStorage depends = new RenderingRulesStorage(name, null); RenderingRulesStorage depends = new RenderingRulesStorage(name, renderingConstants);
depends.parseRulesFromXmlInputStream(RenderingRulesStorage.class.getResourceAsStream(name + ".render.xml"), ref); // depends.parseRulesFromXmlInputStream(RenderingRulesStorage.class.getResourceAsStream(name + ".render.xml"), ref);
depends.parseRulesFromXmlInputStream(new FileInputStream(loc + name + ".render.xml"), ref);
return depends; return depends;
} }
}; };
@ -508,9 +511,10 @@ public class RenderingRulesStorage {
// storage = new RenderingRulesStorage("", null); // storage = new RenderingRulesStorage("", null);
// new DefaultRenderingRulesStorage().createStyle(storage); // new DefaultRenderingRulesStorage().createStyle(storage);
for (RenderingRuleProperty p : storage.PROPS.getCustomRules()) {
System.out.println(p.getCategory() + " " + p.getName() + " " + p.getAttrName());
printAllRules(storage); }
// printAllRules(storage);
// testSearch(storage); // testSearch(storage);
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

View file

@ -28,6 +28,7 @@ import net.osmand.plus.OsmandSettings;
import net.osmand.plus.OsmandSettings.CommonPreference; import net.osmand.plus.OsmandSettings.CommonPreference;
import net.osmand.plus.render.RendererRegistry; import net.osmand.plus.render.RendererRegistry;
import net.osmand.render.RenderingRuleProperty; import net.osmand.render.RenderingRuleProperty;
import net.osmand.render.RenderingRuleStorageProperties;
import net.osmand.render.RenderingRulesStorage; import net.osmand.render.RenderingRulesStorage;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
@ -175,7 +176,9 @@ public class MapRendererContext implements RendererRegistry.IRendererLoadedEvent
RenderingRulesStorage storage = app.getRendererRegistry().getCurrentSelectedRenderer(); RenderingRulesStorage storage = app.getRendererRegistry().getCurrentSelectedRenderer();
Map<String, String> props = new HashMap<String, String>(); Map<String, String> props = new HashMap<String, String>();
for (RenderingRuleProperty customProp : storage.PROPS.getCustomRules()) { for (RenderingRuleProperty customProp : storage.PROPS.getCustomRules()) {
if (customProp.isBoolean()) { if(RenderingRuleStorageProperties.UI_CATEGORY_HIDDEN.equals(customProp.getCategory())){
continue;
} else if (customProp.isBoolean()) {
CommonPreference<Boolean> pref = prefs.getCustomRenderBooleanProperty(customProp.getAttrName()); CommonPreference<Boolean> pref = prefs.getCustomRenderBooleanProperty(customProp.getAttrName());
props.put(customProp.getAttrName(), pref.get() + ""); props.put(customProp.getAttrName(), pref.get() + "");
} else { } else {

View file

@ -399,7 +399,12 @@ public class ConfigureMapMenu {
RenderingRulesStorage renderer = activity.getMyApplication().getRendererRegistry().getCurrentSelectedRenderer(); RenderingRulesStorage renderer = activity.getMyApplication().getRendererRegistry().getCurrentSelectedRenderer();
if (renderer != null) { if (renderer != null) {
List<RenderingRuleProperty> customRules = new ArrayList<RenderingRuleProperty>(renderer.PROPS.getCustomRules()); List<RenderingRuleProperty> customRules = new ArrayList<RenderingRuleProperty>();
for(RenderingRuleProperty p : renderer.PROPS.getCustomRules()) {
if(!RenderingRuleStorageProperties.UI_CATEGORY_HIDDEN.equals(p.getCategory())){
customRules.add(p);
}
}
createProperties(customRules, R.string.rendering_category_transport, "transport", createProperties(customRules, R.string.rendering_category_transport, "transport",
adapter, activity); adapter, activity);

View file

@ -620,10 +620,18 @@ public class MapRenderRepositories {
if (customProp.isBoolean()) { if (customProp.isBoolean()) {
if(customProp.getAttrName().equals(RenderingRuleStorageProperties.A_ENGINE_V1)) { if(customProp.getAttrName().equals(RenderingRuleStorageProperties.A_ENGINE_V1)) {
renderingReq.setBooleanFilter(customProp, true); renderingReq.setBooleanFilter(customProp, true);
} else if (RenderingRuleStorageProperties.UI_CATEGORY_HIDDEN.equals(customProp.getCategory())) {
renderingReq.setBooleanFilter(customProp, false);
} else { } else {
CommonPreference<Boolean> pref = prefs.getCustomRenderBooleanProperty(customProp.getAttrName()); CommonPreference<Boolean> pref = prefs.getCustomRenderBooleanProperty(customProp.getAttrName());
renderingReq.setBooleanFilter(customProp, pref.get()); renderingReq.setBooleanFilter(customProp, pref.get());
} }
} else if (RenderingRuleStorageProperties.UI_CATEGORY_HIDDEN.equals(customProp.getCategory())) {
if (customProp.isString()) {
renderingReq.setStringFilter(customProp, "");
} else {
renderingReq.setIntFilter(customProp, 0);
}
} else { } else {
CommonPreference<String> settings = prefs.getCustomRenderProperty(customProp.getAttrName()); CommonPreference<String> settings = prefs.getCustomRenderProperty(customProp.getAttrName());
String res = settings.get(); String res = settings.get();