Update default values

This commit is contained in:
Victor Shcherb 2015-06-06 13:01:49 +02:00
parent 731e4b87c2
commit eee2db4a38
6 changed files with 41 additions and 36400 deletions

View file

@ -30,6 +30,7 @@ public class RenderingRuleProperty {
// use for custom rendering rule properties // use for custom rendering rule properties
protected String name; protected String name;
protected String description; protected String description;
protected String defaultValueDescription;
protected String[] possibleValues; protected String[] possibleValues;
protected String category; protected String category;
@ -74,6 +75,10 @@ public class RenderingRuleProperty {
return description; return description;
} }
public String getDefaultValueDescription() {
return defaultValueDescription;
}
protected void setName(String name) { protected void setName(String name) {
this.name = name; this.name = name;
} }
@ -82,6 +87,10 @@ public class RenderingRuleProperty {
this.description = description; this.description = description;
} }
public void setDefaultValueDescription(String defaultValueDescription) {
this.defaultValueDescription = defaultValueDescription;
}
public void setCategory(String category) { public void setCategory(String category) {
this.category = category; this.category = category;
} }

View file

@ -287,6 +287,7 @@ public class RenderingRulesStorage {
prop = RenderingRuleProperty.createInputIntProperty(attr); prop = RenderingRuleProperty.createInputIntProperty(attr);
} }
prop.setDescription(parser.getAttributeValue("", "description")); prop.setDescription(parser.getAttributeValue("", "description"));
prop.setDefaultValueDescription(parser.getAttributeValue("", "defaultValueDescription"));
prop.setCategory(parser.getAttributeValue("", "category")); prop.setCategory(parser.getAttributeValue("", "category"));
prop.setName(parser.getAttributeValue("", "name")); prop.setName(parser.getAttributeValue("", "name"));
if(parser.getAttributeValue("", "possibleValues") != null){ if(parser.getAttributeValue("", "possibleValues") != null){

View file

@ -31,6 +31,7 @@ import net.osmand.core.android.MapRendererContext;
import net.osmand.render.RenderingRuleProperty; import net.osmand.render.RenderingRuleProperty;
import net.osmand.render.RenderingRuleStorageProperties; import net.osmand.render.RenderingRuleStorageProperties;
import net.osmand.render.RenderingRulesStorage; import net.osmand.render.RenderingRulesStorage;
import net.osmand.util.Algorithms;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.AlertDialog.Builder; import android.app.AlertDialog.Builder;
import android.content.Context; import android.content.Context;
@ -552,7 +553,13 @@ public class ConfigureMapMenu {
} else { } else {
final OsmandSettings.CommonPreference<String> pref = view.getApplication().getSettings() final OsmandSettings.CommonPreference<String> pref = view.getApplication().getSettings()
.getCustomRenderProperty(p.getAttrName()); .getCustomRenderProperty(p.getAttrName());
String descr = SettingsActivity.getStringPropertyValue(activity, pref.get()); String descr;
if(Algorithms.isEmpty(pref.get())) {
descr = SettingsActivity.getStringPropertyValue(activity, pref.get());
} else {
descr = SettingsActivity.getStringPropertyValue(view.getContext(),
p.getDefaultValueDescription());
}
adapter.item(propertyName).listen(new OnContextMenuClick() { adapter.item(propertyName).listen(new OnContextMenuClick() {
@Override @Override
@ -562,18 +569,27 @@ public class ConfigureMapMenu {
b.setTitle(propertyDescr); b.setTitle(propertyDescr);
int i = Arrays.asList(p.getPossibleValues()).indexOf(pref.get()); int i = Arrays.asList(p.getPossibleValues()).indexOf(pref.get());
if(Algorithms.isEmpty(pref.get())) {
i = 0;
}
String[] possibleValuesString = new String[p.getPossibleValues().length]; String[] possibleValuesString = new String[p.getPossibleValues().length + 1];
possibleValuesString[0] = SettingsActivity.getStringPropertyValue(view.getContext(),
p.getDefaultValueDescription());
for (int j = 0; j < p.getPossibleValues().length; j++) { for (int j = 0; j < p.getPossibleValues().length; j++) {
possibleValuesString[j] = SettingsActivity.getStringPropertyValue(view.getContext(), possibleValuesString[j + 1] = SettingsActivity.getStringPropertyValue(view.getContext(),
p.getPossibleValues()[j]); p.getPossibleValues()[j]);
} }
b.setSingleChoiceItems(possibleValuesString, i, new DialogInterface.OnClickListener() { b.setSingleChoiceItems(possibleValuesString, i, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
pref.set(p.getPossibleValues()[which]); if(which == 0) {
pref.set("");
} else {
pref.set(p.getPossibleValues()[which - 1]);
}
refreshMapComplete(activity); refreshMapComplete(activity);
adapter.setItemDescription(pos, SettingsActivity.getStringPropertyValue(activity, pref.get())); adapter.setItemDescription(pos, SettingsActivity.getStringPropertyValue(activity, pref.get()));
dialog.dismiss(); dialog.dismiss();

View file

@ -622,8 +622,6 @@ public class MapRenderRepositories {
if (!Algorithms.isEmpty(res)) { if (!Algorithms.isEmpty(res)) {
if (customProp.isString()) { if (customProp.isString()) {
renderingReq.setStringFilter(customProp, res); renderingReq.setStringFilter(customProp, res);
} else if (customProp.isBoolean()) {
renderingReq.setBooleanFilter(customProp, "true".equalsIgnoreCase(res));
} else { } else {
try { try {
renderingReq.setIntFilter(customProp, Integer.parseInt(res)); renderingReq.setIntFilter(customProp, Integer.parseInt(res));
@ -631,6 +629,10 @@ public class MapRenderRepositories {
e.printStackTrace(); e.printStackTrace();
} }
} }
} else {
if (customProp.isString()) {
renderingReq.setStringFilter(customProp, "");
}
} }
} }
} }

View file

@ -15,7 +15,6 @@ import net.osmand.IProgress;
import net.osmand.IndexConstants; import net.osmand.IndexConstants;
import net.osmand.PlatformUtil; import net.osmand.PlatformUtil;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.render.DefaultRenderingRulesStorage;
import net.osmand.render.RenderingRulesStorage; import net.osmand.render.RenderingRulesStorage;
import net.osmand.render.RenderingRulesStorage.RenderingRulesStorageResolver; import net.osmand.render.RenderingRulesStorage.RenderingRulesStorageResolver;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
@ -91,15 +90,15 @@ public class RendererRegistry {
return externalRenderers.containsKey(name) || internalRenderers.containsKey(name); return externalRenderers.containsKey(name) || internalRenderers.containsKey(name);
} }
private static boolean USE_PRECOMPILED_STYLE = false; // private static boolean USE_PRECOMPILED_STYLE = false;
private RenderingRulesStorage loadRenderer(String name, final Map<String, RenderingRulesStorage> loadedRenderers, private RenderingRulesStorage loadRenderer(String name, final Map<String, RenderingRulesStorage> loadedRenderers,
final Map<String, String> renderingConstants) throws IOException, XmlPullParserException { final Map<String, String> renderingConstants) throws IOException, XmlPullParserException {
if ((name.equals(DEFAULT_RENDER) || name.equalsIgnoreCase("default")) && USE_PRECOMPILED_STYLE) { // if ((name.equals(DEFAULT_RENDER) || name.equalsIgnoreCase("default")) && USE_PRECOMPILED_STYLE) {
RenderingRulesStorage rrs = new RenderingRulesStorage("", null); // RenderingRulesStorage rrs = new RenderingRulesStorage("", null);
new DefaultRenderingRulesStorage().createStyle(rrs); // new DefaultRenderingRulesStorage().createStyle(rrs);
log.info("INIT rendering from class"); // log.info("INIT rendering from class");
return rrs; // return rrs;
} // }
InputStream is = getInputStream(name); InputStream is = getInputStream(name);
if(is == null) { if(is == null) {
return null; return null;