diff --git a/OsmAnd-java/src/main/java/net/osmand/render/RenderingRulesStorage.java b/OsmAnd-java/src/main/java/net/osmand/render/RenderingRulesStorage.java index 1c9214f660..d4d97d547c 100644 --- a/OsmAnd-java/src/main/java/net/osmand/render/RenderingRulesStorage.java +++ b/OsmAnd-java/src/main/java/net/osmand/render/RenderingRulesStorage.java @@ -40,6 +40,10 @@ public class RenderingRulesStorage { private final static int SHIFT_TAG_VAL = 16; + + private final static String SEQ_ATTR_KEY = "seq"; + private final static String SEQ_PLACEHOLDER = "#SEQ"; + // C++ List dictionary = new ArrayList(); Map dictionaryMap = new LinkedHashMap(); @@ -191,8 +195,19 @@ public class RenderingRulesStorage { List children = new ArrayList(); private void process(RenderingRulesHandler handler, int el) throws XmlPullParserException, IOException { - // TODO create new attrsMap and replace #SEQ -> el - handler.startElement(attrsMap, name); + Map seqAttrsMap = new HashMap(attrsMap); + if (attrsMap.containsKey(SEQ_ATTR_KEY)) { + attrsMap.remove(SEQ_ATTR_KEY); + } + + for (Entry attr: attrsMap.entrySet()) { + if (attr.getValue().contains(SEQ_PLACEHOLDER)) { + seqAttrsMap.put(attr.getKey(), attr.getValue().replace(SEQ_PLACEHOLDER, el+"")); + } else { + seqAttrsMap.put(attr.getKey(), attr.getValue()); + } + } + handler.startElement(seqAttrsMap, name); for(XmlTreeSequence s : children) { s.process(handler, el); } @@ -223,13 +238,13 @@ public class RenderingRulesStorage { attrsMap.clear(); parseAttributes(parser, attrsMap); String name = parser.getName(); - if (!Algorithms.isEmpty(parser.getAttributeValue("", "seq")) || currentSeqElement != null) { + if (!Algorithms.isEmpty(parser.getAttributeValue("", SEQ_ATTR_KEY)) || currentSeqElement != null) { XmlTreeSequence seq = new XmlTreeSequence(); seq.name = name; - seq.attrsMap = attrsMap; + seq.attrsMap = new HashMap(attrsMap); seq.parent = currentSeqElement; if (currentSeqElement == null) { - seq.seqOrder = parser.getAttributeValue("", "seq"); + seq.seqOrder = parser.getAttributeValue("", SEQ_ATTR_KEY); } else { currentSeqElement.children.add(seq); seq.seqOrder = currentSeqElement.seqOrder; @@ -246,7 +261,8 @@ public class RenderingRulesStorage { currentSeqElement = currentSeqElement.parent; if (currentSeqElement == null) { // Here we process sequence element - for(int i = 1; i < 5; i++) { + int seqEnd = Integer.parseInt(process.seqOrder.substring(process.seqOrder.indexOf(':') + 1, process.seqOrder.length())); + for(int i = 1; i < seqEnd; i++) { process.process(this, i); } } diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java index c3fb488891..92970e2a5e 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java @@ -1606,7 +1606,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment { } private void onGpxSaved(Exception warning) { - MapActivity mapActivity = getMapActivity(); + final MapActivity mapActivity = getMapActivity(); if (mapActivity == null) { return; } @@ -1626,8 +1626,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment { .setAction(R.string.shared_string_rename, new View.OnClickListener() { @Override public void onClick(View view) { - MapActivity mapActivity = getMapActivity(); - if (mapActivity != null) { + if (AndroidUtils.isActivityNotDestroyed(mapActivity)) { FileUtils.renameFile(mapActivity, toSave, null); } } diff --git a/OsmAnd/src/net/osmand/plus/views/MapQuickActionLayer.java b/OsmAnd/src/net/osmand/plus/views/MapQuickActionLayer.java index 97e9f64f2d..67fad90019 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapQuickActionLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapQuickActionLayer.java @@ -172,25 +172,43 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe } private void setQuickActionButtonMargin() { + int defRightMargin = calculateTotalSizePx(R.dimen.map_button_size, R.dimen.map_button_spacing_land) * 2; + int defBottomMargin = calculateTotalSizePx(R.dimen.map_button_size, R.dimen.map_button_spacing) * 2; FrameLayout.LayoutParams param = (FrameLayout.LayoutParams) quickActionButton.getLayoutParams(); if (AndroidUiHelper.isOrientationPortrait(mapActivity)) { Pair fabMargin = settings.getPortraitFabMargin(); - if (fabMargin != null) { - param.rightMargin = fabMargin.first; - param.bottomMargin = fabMargin.second; - } else { - param.bottomMargin = calculateTotalSizePx(R.dimen.map_button_size, R.dimen.map_button_spacing) * 2; - } + setQuickActionButtonMargin(param, fabMargin, 0, defBottomMargin); } else { Pair fabMargin = settings.getLandscapeFabMargin(); - if (fabMargin != null) { - param.rightMargin = fabMargin.first; - param.bottomMargin = fabMargin.second; - } else { - param.rightMargin = calculateTotalSizePx(R.dimen.map_button_size, R.dimen.map_button_spacing_land) * 2; - } + setQuickActionButtonMargin(param, fabMargin, defRightMargin, 0); } - quickActionButton.setLayoutParams(param); + } + + private void setQuickActionButtonMargin(FrameLayout.LayoutParams params, + Pair fabMargin, + int defRightMargin, int defBottomMargin) { + int screenHeight = AndroidUtils.getScreenHeight(mapActivity); + int screenWidth = AndroidUtils.getScreenWidth(mapActivity); + int btnHeight = quickActionButton.getHeight(); + int btnWidth = quickActionButton.getWidth(); + int rightMargin; + int bottomMargin; + if (fabMargin != null) { + rightMargin = fabMargin.first; + bottomMargin = fabMargin.second; + if (rightMargin < 0 || rightMargin > screenWidth - btnWidth) { + rightMargin = defRightMargin; + } + if (bottomMargin < 0 || bottomMargin > screenHeight - btnHeight) { + bottomMargin = defBottomMargin; + } + } else { + rightMargin = defRightMargin; + bottomMargin = defBottomMargin; + } + params.rightMargin = rightMargin; + params.bottomMargin = bottomMargin; + quickActionButton.setLayoutParams(params); } private int calculateTotalSizePx(@DimenRes int... dimensId) { diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java index 816798ad80..f23dd569a5 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java @@ -977,6 +977,9 @@ public class MapInfoWidgetsFactory { updateVisibility(true); AndroidUiHelper.updateVisibility(addressText, false); AndroidUiHelper.updateVisibility(addressTextShadow, false); + AndroidUiHelper.updateVisibility(turnIcon, false); + AndroidUiHelper.updateVisibility(shieldIcon, false); + AndroidUiHelper.updateVisibility(exitRefText, false); } else if (streetName == null) { updateVisibility(false); } else {