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 static final String UI_CATEGORY_HIDDEN = "ui_hidden";
public static final String A_ENGINE_V1 = "engine_v1";
public static final String A_APP_MODE= "appMode";
@ -307,12 +308,17 @@ public class RenderingRuleStorageProperties {
}
private RenderingRuleProperty registerRuleInternal(RenderingRuleProperty p) {
if(get(p.getAttrName()) == null) {
properties.put(p.getAttrName(), p);
RenderingRuleProperty existing = get(p.getAttrName());
properties.put(p.getAttrName(), p);
if(existing == null) {
p.setId(rules.size());
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) {

View file

@ -7,6 +7,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
@ -470,12 +471,13 @@ public class RenderingRulesStorage {
public static void main(String[] args) throws XmlPullParserException, IOException {
STORE_ATTTRIBUTES = true;
// 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) {
defaultFile = args[0];
}
Map<String, String> renderingConstants = new LinkedHashMap<String, String>();
InputStream is = new FileInputStream(defaultFile);
final Map<String, String> renderingConstants = new LinkedHashMap<String, String>();
InputStream is = new FileInputStream(loc + "default.render.xml");
try {
XmlPullParser parser = PlatformUtil.newXMLPullParser();
parser.setInput(is, "UTF-8");
@ -498,8 +500,9 @@ public class RenderingRulesStorage {
final RenderingRulesStorageResolver resolver = new RenderingRulesStorageResolver() {
@Override
public RenderingRulesStorage resolve(String name, RenderingRulesStorageResolver ref) throws XmlPullParserException, IOException {
RenderingRulesStorage depends = new RenderingRulesStorage(name, null);
depends.parseRulesFromXmlInputStream(RenderingRulesStorage.class.getResourceAsStream(name + ".render.xml"), ref);
RenderingRulesStorage depends = new RenderingRulesStorage(name, renderingConstants);
// depends.parseRulesFromXmlInputStream(RenderingRulesStorage.class.getResourceAsStream(name + ".render.xml"), ref);
depends.parseRulesFromXmlInputStream(new FileInputStream(loc + name + ".render.xml"), ref);
return depends;
}
};
@ -508,9 +511,10 @@ public class RenderingRulesStorage {
// storage = new RenderingRulesStorage("", null);
// new DefaultRenderingRulesStorage().createStyle(storage);
printAllRules(storage);
for (RenderingRuleProperty p : storage.PROPS.getCustomRules()) {
System.out.println(p.getCategory() + " " + p.getName() + " " + p.getAttrName());
}
// printAllRules(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.render.RendererRegistry;
import net.osmand.render.RenderingRuleProperty;
import net.osmand.render.RenderingRuleStorageProperties;
import net.osmand.render.RenderingRulesStorage;
import net.osmand.util.Algorithms;
@ -175,7 +176,9 @@ public class MapRendererContext implements RendererRegistry.IRendererLoadedEvent
RenderingRulesStorage storage = app.getRendererRegistry().getCurrentSelectedRenderer();
Map<String, String> props = new HashMap<String, String>();
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());
props.put(customProp.getAttrName(), pref.get() + "");
} else {

View file

@ -399,7 +399,12 @@ public class ConfigureMapMenu {
RenderingRulesStorage renderer = activity.getMyApplication().getRendererRegistry().getCurrentSelectedRenderer();
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",
adapter, activity);

View file

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