Merge pull request #9009 from osmandapp/fix_elevation
Fix elevation duplicates
This commit is contained in:
commit
68d334e838
2 changed files with 13 additions and 57 deletions
|
@ -21,7 +21,6 @@ import android.view.Gravity;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
@ -44,7 +43,6 @@ import net.osmand.osm.PoiCategory;
|
||||||
import net.osmand.plus.OsmAndFormatter;
|
import net.osmand.plus.OsmAndFormatter;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandPlugin;
|
import net.osmand.plus.OsmandPlugin;
|
||||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.UiUtilities;
|
import net.osmand.plus.UiUtilities;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
@ -70,6 +68,7 @@ import java.util.Comparator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import static net.osmand.plus.mapcontextmenu.builders.cards.ImageCard.GetImageCardsTask.GetImageCardsListener;
|
import static net.osmand.plus.mapcontextmenu.builders.cards.ImageCard.GetImageCardsTask.GetImageCardsListener;
|
||||||
|
|
||||||
|
@ -281,7 +280,7 @@ public class MenuBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void buildNearestWikiRow(View view) {
|
protected void buildNearestWikiRow(View view) {
|
||||||
if (processNearstWiki() && nearestWiki.size() > 0) {
|
if (processNearestWiki() && nearestWiki.size() > 0) {
|
||||||
buildRow(view, R.drawable.ic_action_wikipedia, null, app.getString(R.string.wiki_around) + " (" + nearestWiki.size()+")", 0,
|
buildRow(view, R.drawable.ic_action_wikipedia, null, app.getString(R.string.wiki_around) + " (" + nearestWiki.size()+")", 0,
|
||||||
true, getCollapsableWikiView(view.getContext(), true),
|
true, getCollapsableWikiView(view.getContext(), true),
|
||||||
false, 0, false, null, false);
|
false, 0, false, null, false);
|
||||||
|
@ -697,15 +696,15 @@ public class MenuBuilder {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CollapsableView getDistanceCollapsableView(Map<OsmandSettings.MetricsConstants, String> distanceData) {
|
protected CollapsableView getDistanceCollapsableView(Set<String> distanceData) {
|
||||||
LinearLayout llv = buildCollapsableContentView(mapActivity, true, true);
|
LinearLayout llv = buildCollapsableContentView(mapActivity, true, true);
|
||||||
for (final Map.Entry<OsmandSettings.MetricsConstants, String> line : distanceData.entrySet()) {
|
for (final String distance : distanceData) {
|
||||||
TextView button = buildButtonInCollapsableView(mapActivity, false, false);
|
TextView button = buildButtonInCollapsableView(mapActivity, false, false);
|
||||||
button.setText(line.getValue());
|
button.setText(distance);
|
||||||
button.setOnClickListener(new View.OnClickListener() {
|
button.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
copyToClipboard(line.getValue(), mapActivity);
|
copyToClipboard(distance, mapActivity);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
llv.addView(button);
|
llv.addView(button);
|
||||||
|
@ -713,48 +712,6 @@ public class MenuBuilder {
|
||||||
return new CollapsableView(llv, this, true);
|
return new CollapsableView(llv, this, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void buildButtonRow(final View view, Drawable buttonIcon, String text, OnClickListener onClickListener) {
|
|
||||||
LinearLayout ll = new LinearLayout(view.getContext());
|
|
||||||
ll.setOrientation(LinearLayout.HORIZONTAL);
|
|
||||||
LinearLayout.LayoutParams llParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
|
||||||
ll.setLayoutParams(llParams);
|
|
||||||
ll.setBackgroundResource(AndroidUtils.resolveAttribute(view.getContext(), android.R.attr.selectableItemBackground));
|
|
||||||
|
|
||||||
// Empty
|
|
||||||
LinearLayout llIcon = new LinearLayout(view.getContext());
|
|
||||||
llIcon.setOrientation(LinearLayout.HORIZONTAL);
|
|
||||||
llIcon.setLayoutParams(new LinearLayout.LayoutParams(dpToPx(62f), dpToPx(58f)));
|
|
||||||
llIcon.setGravity(Gravity.CENTER_VERTICAL);
|
|
||||||
ll.addView(llIcon);
|
|
||||||
|
|
||||||
|
|
||||||
// Button
|
|
||||||
LinearLayout llButton = new LinearLayout(view.getContext());
|
|
||||||
llButton.setOrientation(LinearLayout.VERTICAL);
|
|
||||||
ll.addView(llButton);
|
|
||||||
|
|
||||||
Button buttonView = new Button(view.getContext());
|
|
||||||
LinearLayout.LayoutParams llBtnParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
|
||||||
buttonView.setLayoutParams(llBtnParams);
|
|
||||||
AndroidUtils.setPadding(buttonView, dpToPx(10f), 0, dpToPx(10f), 0);
|
|
||||||
buttonView.setGravity(Gravity.START | Gravity.CENTER_VERTICAL);
|
|
||||||
//buttonView.setTextSize(view.getResources().getDimension(resolveAttribute(view.getContext(), R.dimen.default_desc_text_size)));
|
|
||||||
buttonView.setTextColor(view.getResources().getColor(AndroidUtils.resolveAttribute(view.getContext(), R.attr.contextMenuButtonColor)));
|
|
||||||
buttonView.setText(text);
|
|
||||||
|
|
||||||
if (buttonIcon != null) {
|
|
||||||
buttonView.setCompoundDrawablesWithIntrinsicBounds(buttonIcon, null, null, null);
|
|
||||||
buttonView.setCompoundDrawablePadding(dpToPx(8f));
|
|
||||||
}
|
|
||||||
llButton.addView(buttonView);
|
|
||||||
|
|
||||||
((LinearLayout) view).addView(ll);
|
|
||||||
|
|
||||||
ll.setOnClickListener(onClickListener);
|
|
||||||
|
|
||||||
rowBuilt();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void buildRowDivider(View view) {
|
public void buildRowDivider(View view) {
|
||||||
View horizontalLine = new View(view.getContext());
|
View horizontalLine = new View(view.getContext());
|
||||||
LinearLayout.LayoutParams llHorLineParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dpToPx(1f));
|
LinearLayout.LayoutParams llHorLineParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dpToPx(1f));
|
||||||
|
@ -1027,7 +984,7 @@ public class MenuBuilder {
|
||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean processNearstWiki() {
|
protected boolean processNearestWiki() {
|
||||||
if (showNearestWiki && latLon != null) {
|
if (showNearestWiki && latLon != null) {
|
||||||
QuadRect rect = MapUtils.calculateLatLonBbox(
|
QuadRect rect = MapUtils.calculateLatLonBbox(
|
||||||
latLon.getLatitude(), latLon.getLongitude(), 250);
|
latLon.getLatitude(), latLon.getLongitude(), 250);
|
||||||
|
|
|
@ -28,16 +28,16 @@ import net.osmand.osm.PoiCategory;
|
||||||
import net.osmand.osm.PoiType;
|
import net.osmand.osm.PoiType;
|
||||||
import net.osmand.plus.OsmAndFormatter;
|
import net.osmand.plus.OsmAndFormatter;
|
||||||
import net.osmand.plus.OsmandPlugin;
|
import net.osmand.plus.OsmandPlugin;
|
||||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
|
||||||
import net.osmand.plus.settings.backend.OsmandSettings.MetricsConstants;
|
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.Version;
|
import net.osmand.plus.Version;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.helpers.FontCache;
|
import net.osmand.plus.helpers.FontCache;
|
||||||
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
|
||||||
import net.osmand.plus.mapcontextmenu.CollapsableView;
|
import net.osmand.plus.mapcontextmenu.CollapsableView;
|
||||||
|
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
||||||
import net.osmand.plus.osmedit.OsmEditingPlugin;
|
import net.osmand.plus.osmedit.OsmEditingPlugin;
|
||||||
import net.osmand.plus.poi.PoiUIFilter;
|
import net.osmand.plus.poi.PoiUIFilter;
|
||||||
|
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||||
|
import net.osmand.plus.settings.backend.OsmandSettings.MetricsConstants;
|
||||||
import net.osmand.plus.views.POIMapLayer;
|
import net.osmand.plus.views.POIMapLayer;
|
||||||
import net.osmand.plus.widgets.TextViewEx;
|
import net.osmand.plus.widgets.TextViewEx;
|
||||||
import net.osmand.plus.widgets.tools.ClickableSpanTouchListener;
|
import net.osmand.plus.widgets.tools.ClickableSpanTouchListener;
|
||||||
|
@ -529,10 +529,9 @@ public class AmenityMenuBuilder extends MenuBuilder {
|
||||||
if ("ele".equals(key)) {
|
if ("ele".equals(key)) {
|
||||||
try {
|
try {
|
||||||
float distance = Float.parseFloat(vl);
|
float distance = Float.parseFloat(vl);
|
||||||
|
vl = OsmAndFormatter.getFormattedDistance(distance, app, true, metricSystem);
|
||||||
Map<MetricsConstants, String> distanceData = OsmAndFormatter.getDistanceData(app, distance);
|
Map<MetricsConstants, String> distanceData = OsmAndFormatter.getDistanceData(app, distance);
|
||||||
MetricsConstants currentFormat = app.getSettings().METRIC_SYSTEM.get();
|
collapsableView = getDistanceCollapsableView(new LinkedHashSet<>(distanceData.values()));
|
||||||
vl = OsmAndFormatter.getFormattedDistance(distance, app, true, currentFormat);
|
|
||||||
collapsableView = getDistanceCollapsableView(distanceData);
|
|
||||||
collapsable = true;
|
collapsable = true;
|
||||||
} catch (NumberFormatException ex) {
|
} catch (NumberFormatException ex) {
|
||||||
LOG.error(ex);
|
LOG.error(ex);
|
||||||
|
@ -654,7 +653,7 @@ public class AmenityMenuBuilder extends MenuBuilder {
|
||||||
buildAmenityRow(view, info);
|
buildAmenityRow(view, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (processNearstWiki() && nearestWiki.size() > 0) {
|
if (processNearestWiki() && nearestWiki.size() > 0) {
|
||||||
AmenityInfoRow wikiInfo = new AmenityInfoRow(
|
AmenityInfoRow wikiInfo = new AmenityInfoRow(
|
||||||
"nearest_wiki", R.drawable.ic_plugin_wikipedia, null, app.getString(R.string.wiki_around) + " (" + nearestWiki.size() + ")", true,
|
"nearest_wiki", R.drawable.ic_plugin_wikipedia, null, app.getString(R.string.wiki_around) + " (" + nearestWiki.size() + ")", true,
|
||||||
getCollapsableWikiView(view.getContext(), true),
|
getCollapsableWikiView(view.getContext(), true),
|
||||||
|
|
Loading…
Reference in a new issue