Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2015-03-10 23:47:24 +01:00
commit d74658e06d
5 changed files with 56 additions and 28 deletions

View file

@ -95,7 +95,7 @@ public class RenderingRule {
public float getFloatPropertyValue(String property) {
int i = getPropertyIndex(property);
if(i >= 0){
if(i >= 0 && floatProperties != null){
return floatProperties[i];
}
return 0;

View file

@ -372,10 +372,10 @@ public class RenderingRulesStorage {
List<RenderingRule> apply = applyRules;
if(!renderingRule.getIfChildren().isEmpty()) {
apply = new ArrayList<RenderingRule>();
apply.addAll(renderingRule.getIfChildren());
if(applyRules != null) {
apply.addAll(applyRules);
}
apply.addAll(renderingRule.getIfChildren());
}
Map<String, String> cattrs = new HashMap<String, String>(attrs);
cattrs.putAll(renderingRule.getAttributes());
@ -460,22 +460,44 @@ public class RenderingRulesStorage {
public static void main(String[] args) throws XmlPullParserException, IOException {
InputStream is = RenderingRulesStorage.class.getResourceAsStream("default.render.xml");
// InputStream is = RenderingRulesStorage.class.getResourceAsStream("default.render.xml");
String file = "/Users/victorshcherb/osmand/repos/resources/rendering_styles/default.render.xml";
Map<String, String> renderingConstants = new LinkedHashMap<String, String>();
InputStream is = new FileInputStream(file);
if(args != null && args.length > 0) {
is = new FileInputStream(args[0]);
}
RenderingRulesStorage storage = new RenderingRulesStorage("test", null);
try {
XmlPullParser parser = PlatformUtil.newXMLPullParser();
parser.setInput(is, "UTF-8");
int tok;
while ((tok = parser.next()) != XmlPullParser.END_DOCUMENT) {
if (tok == XmlPullParser.START_TAG) {
String tagName = parser.getName();
if (tagName.equals("renderingConstant")) {
if (!renderingConstants.containsKey(parser.getAttributeValue("", "name"))) {
renderingConstants.put(parser.getAttributeValue("", "name"),
parser.getAttributeValue("", "value"));
}
}
}
}
} finally {
is.close();
}
is = new FileInputStream(file);
RenderingRulesStorage storage = new RenderingRulesStorage("default", renderingConstants);
final RenderingRulesStorageResolver resolver = new RenderingRulesStorageResolver() {
@Override
public RenderingRulesStorage resolve(String name, RenderingRulesStorageResolver ref) throws XmlPullParserException, IOException {
RenderingRulesStorage depends = new RenderingRulesStorage("test", null);
RenderingRulesStorage depends = new RenderingRulesStorage(name, null);
depends.parseRulesFromXmlInputStream(RenderingRulesStorage.class.getResourceAsStream(name + ".render.xml"), ref);
return depends;
}
};
storage.parseRulesFromXmlInputStream(is, resolver);
// printAllRules(storage);
printAllRules(storage);
testSearch(storage);
}
@ -485,11 +507,11 @@ public class RenderingRulesStorage {
// for (int i = 0; i < count; i++) {
RenderingRuleSearchRequest searchRequest = new RenderingRuleSearchRequest(storage);
searchRequest.setStringFilter(storage.PROPS.R_TAG, "highway");
searchRequest.setStringFilter(storage.PROPS.R_VALUE, "primary");
searchRequest.setStringFilter(storage.PROPS.R_VALUE, "residential");
// searchRequest.setStringFilter(storage.PROPS.R_ADDITIONAL, "leaf_type=broadleaved");
// searchRequest.setIntFilter(storage.PROPS.R_LAYER, 1);
searchRequest.setIntFilter(storage.PROPS.R_MINZOOM, 9);
searchRequest.setIntFilter(storage.PROPS.R_MAXZOOM, 9);
searchRequest.setIntFilter(storage.PROPS.R_MINZOOM, 13);
searchRequest.setIntFilter(storage.PROPS.R_MAXZOOM, 13);
// searchRequest.setBooleanFilter(storage.PROPS.R_NIGHT_MODE, true);
// for (RenderingRuleProperty customProp : storage.PROPS.getCustomRules()) {
// if (customProp.isBoolean()) {

View file

@ -1,11 +1,8 @@
package net.osmand.plus;
import android.app.Activity;
import android.content.Context;
import gnu.trove.map.hash.TLongObjectHashMap;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import gnu.trove.map.hash.TIntObjectHashMap;
import gnu.trove.map.hash.TLongObjectHashMap;
public class IconsCache {

View file

@ -11,6 +11,7 @@ import net.osmand.plus.GPXUtilities.GPXFile;
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
import net.osmand.plus.OsmAndAppCustomization;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
@ -113,7 +114,8 @@ public class DashTrackFragment extends DashBaseFragment {
}
}
if (list.size() == 0) {
if (list.size() == 0 &&
OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class) == null) {
(mainView.findViewById(R.id.main_fav)).setVisibility(View.GONE);
return;
} else {
@ -124,20 +126,22 @@ public class DashTrackFragment extends DashBaseFragment {
tracks.removeAllViews();
LayoutInflater inflater = getActivity().getLayoutInflater();
View view = inflater.inflate(R.layout.dash_gpx_track_item, null, false);
if (OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class) != null) {
View view = inflater.inflate(R.layout.dash_gpx_track_item, null, false);
AvailableGPXFragment.createCurrentTrackView(view, app);
((TextView) view.findViewById(R.id.name)).setText(R.string.shared_string_currently_recording_track);
AvailableGPXFragment.updateCurrentTrack(view, getActivity(), app);
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AvailableGPXFragment.openTrack(getActivity(), null);
}
});
view.findViewById(R.id.divider).setVisibility(View.VISIBLE);
tracks.addView(view);
startHandler(view);
AvailableGPXFragment.createCurrentTrackView(view, app);
((TextView) view.findViewById(R.id.name)).setText(R.string.shared_string_currently_recording_track);
AvailableGPXFragment.updateCurrentTrack(view, getActivity(), app);
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AvailableGPXFragment.openTrack(getActivity(), null);
}
});
view.findViewById(R.id.divider).setVisibility(View.VISIBLE);
tracks.addView(view);
startHandler(view);
}
for (String filename : list) {
final File f = new File(filename);

View file

@ -156,6 +156,9 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
}
public void updateCurrentTrack() {
if (OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class) == null) {
return;
}
updateCurrentTrack(getView(), getActivity(), app);
final CheckBox checkbox = (CheckBox) getView().findViewById(R.id.check_local_index);
checkbox.setVisibility(selectionMode && showOnMapMode? View.VISIBLE : View.GONE);
@ -178,6 +181,9 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
}
public static void updateCurrentTrack(View v, final Activity ctx, OsmandApplication app) {
if (OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class) != null) {
return;
}
if (v == null) {
return;
}
@ -236,7 +242,6 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
listView.setAdapter(this.adapter);
}
setHasOptionsMenu(true);
View currentTrackView = v.findViewById(R.id.current_track);
createCurrentTrackView(v, getMyApplication());
if (OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class) == null) {