add expandable coordinates list, copy on click. #7051
This commit is contained in:
parent
b55363cf53
commit
5911752d2f
3 changed files with 38 additions and 15 deletions
|
@ -677,6 +677,23 @@ public class MenuBuilder {
|
|||
Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
protected CollapsableView getLocationCollapsableView(Map<String, String> locationData) {
|
||||
LinearLayout llv = buildCollapsableContentView(mapActivity, true, true);
|
||||
for (final Map.Entry<String, String> line : locationData.entrySet()) {
|
||||
final TextViewEx button = buildButtonInCollapsableView(mapActivity, false, false);
|
||||
button.setText(line.getValue());
|
||||
button.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
copyToClipboard(line.getValue(), mapActivity);
|
||||
}
|
||||
});
|
||||
llv.addView(button);
|
||||
}
|
||||
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);
|
||||
|
|
|
@ -17,6 +17,7 @@ import android.view.View;
|
|||
import android.view.View.OnClickListener;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import java.util.Map;
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.NativeLibrary.RenderedObject;
|
||||
|
@ -45,6 +46,7 @@ import net.osmand.plus.download.DownloadIndexesThread;
|
|||
import net.osmand.plus.download.DownloadValidationManager;
|
||||
import net.osmand.plus.download.IndexItem;
|
||||
import net.osmand.plus.helpers.SearchHistoryHelper;
|
||||
import net.osmand.plus.mapcontextmenu.MenuBuilder.CollapsableView;
|
||||
import net.osmand.plus.mapcontextmenu.MenuBuilder.CollapseExpandListener;
|
||||
import net.osmand.plus.mapcontextmenu.controllers.AMapPointMenuController;
|
||||
import net.osmand.plus.mapcontextmenu.controllers.AmenityMenuController;
|
||||
|
@ -257,6 +259,12 @@ public abstract class MenuController extends BaseMenuController implements Colla
|
|||
builder.addPlainMenuItem(iconId, buttonText, text, needLinks, isUrl, onClickListener);
|
||||
}
|
||||
|
||||
public void addPlainMenuItem(int iconId, String text, boolean needLinks, boolean isUrl,
|
||||
boolean collapsable, CollapsableView collapsableView, OnClickListener onClickListener) {
|
||||
|
||||
builder.addPlainMenuItem(iconId, text, needLinks, isUrl, collapsable, collapsableView, onClickListener);
|
||||
}
|
||||
|
||||
public void clearPlainMenuItems() {
|
||||
builder.clearPlainMenuItems();
|
||||
}
|
||||
|
@ -265,19 +273,13 @@ public abstract class MenuController extends BaseMenuController implements Colla
|
|||
addMyLocationToPlainItems(latLon);
|
||||
}
|
||||
|
||||
protected void addMyLocationToPlainItems(LatLon latLon) {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
protected void addMyLocationToPlainItems(LatLon latlon) {
|
||||
final MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
|
||||
addPlainMenuItem(R.drawable.ic_action_get_my_location, null, PointDescription.getLocationName(mapActivity,
|
||||
latLon.getLatitude(), latLon.getLongitude(), true).replaceAll("\n", " "), false, false, null);
|
||||
}
|
||||
}
|
||||
|
||||
protected void addMyLocationCollapsableView(LatLon latlon) {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
int iconId = R.drawable.ic_action_get_my_location;
|
||||
String f = PointDescription.formatToHumanString(mapActivity, mapActivity.getMyApplication().getSettings().COORDINATES_FORMAT.get());
|
||||
Map<String, String> locationData = PointDescription.getLocationData(mapActivity, latlon.getLatitude(), latlon.getLongitude(), true);
|
||||
CollapsableView cv = builder.getLocationCollapsableView(locationData);
|
||||
addPlainMenuItem(R.drawable.ic_action_get_my_location, locationData.get(f).replace("\n", " "), true, false, true, cv, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -665,9 +665,13 @@ public class AmenityMenuBuilder extends MenuBuilder {
|
|||
buildRow(view, R.drawable.ic_action_openstreetmap_logo, null, link + (amenity.getId() >> 1),
|
||||
0, false, null, true, 0, true, null, false);
|
||||
}
|
||||
buildRow(view, R.drawable.ic_action_get_my_location, null, PointDescription.getLocationName(app,
|
||||
amenity.getLocation().getLatitude(), amenity.getLocation().getLongitude(), true)
|
||||
.replaceAll("\n", " "), 0, false, null, false, 0, false, null, false);
|
||||
|
||||
String f = PointDescription.formatToHumanString(mapActivity, app.getSettings().COORDINATES_FORMAT.get());
|
||||
Map<String, String> locationData = PointDescription.getLocationData(mapActivity, amenity.getLocation().getLatitude(), amenity.getLocation().getLongitude(), true);
|
||||
CollapsableView cv = getLocationCollapsableView(locationData);
|
||||
buildRow(view, R.drawable.ic_action_get_my_location, null, locationData.get(f).replace("\n", " "), 0, true, cv,
|
||||
true, 1, false, null, false);
|
||||
|
||||
}
|
||||
|
||||
private String getFormattedInt(String value) {
|
||||
|
|
Loading…
Reference in a new issue