Fix url in map context menu. Fix marker under context menu after returning from fav/wpt edit mode
This commit is contained in:
parent
45e4083611
commit
23106903a4
12 changed files with 55 additions and 31 deletions
|
@ -42,7 +42,7 @@ public class AudioVideoNoteMenuBuilder extends MenuBuilder {
|
|||
DateFormat dateFormat = android.text.format.DateFormat.getMediumDateFormat(view.getContext());
|
||||
DateFormat timeFormat = android.text.format.DateFormat.getTimeFormat(view.getContext());
|
||||
Date date = new Date(recording.getFile().lastModified());
|
||||
buildRow(view, R.drawable.ic_action_data, dateFormat.format(date) + " — " + timeFormat.format(date), 0, false, 0);
|
||||
buildRow(view, R.drawable.ic_action_data, dateFormat.format(date) + " — " + timeFormat.format(date), 0, false, 0, false);
|
||||
|
||||
buildPlainMenuItems(view);
|
||||
|
||||
|
|
|
@ -1057,6 +1057,9 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
|||
public void setFragmentVisibility(boolean visible) {
|
||||
if (visible) {
|
||||
view.setVisibility(View.VISIBLE);
|
||||
if (mapCenter != null) {
|
||||
map.setLatLon(mapCenter.getLatitude(), mapCenter.getLongitude());
|
||||
}
|
||||
adjustMapPosition(getPosY(), true, false);
|
||||
} else {
|
||||
view.setVisibility(View.GONE);
|
||||
|
|
|
@ -2,9 +2,11 @@ package net.osmand.plus.mapcontextmenu;
|
|||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.text.ClipboardManager;
|
||||
import android.text.util.Linkify;
|
||||
import android.util.TypedValue;
|
||||
|
@ -40,11 +42,13 @@ public class MenuBuilder {
|
|||
private int iconId;
|
||||
private String text;
|
||||
private boolean needLinks;
|
||||
private boolean url;
|
||||
|
||||
public PlainMenuItem(int iconId, String text, boolean needLinks) {
|
||||
public PlainMenuItem(int iconId, String text, boolean needLinks, boolean url) {
|
||||
this.iconId = iconId;
|
||||
this.text = text;
|
||||
this.needLinks = needLinks;
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public int getIconId() {
|
||||
|
@ -58,6 +62,10 @@ public class MenuBuilder {
|
|||
public boolean isNeedLinks() {
|
||||
return needLinks;
|
||||
}
|
||||
|
||||
public boolean isUrl() {
|
||||
return url;
|
||||
}
|
||||
}
|
||||
|
||||
public MenuBuilder(OsmandApplication app) {
|
||||
|
@ -80,7 +88,7 @@ public class MenuBuilder {
|
|||
|
||||
protected void buildPlainMenuItems(View view) {
|
||||
for (PlainMenuItem item : plainMenuItems) {
|
||||
buildRow(view, item.getIconId(), item.getText(), 0, item.isNeedLinks(), 0);
|
||||
buildRow(view, item.getIconId(), item.getText(), 0, item.isNeedLinks(), 0, item.isUrl());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,11 +111,11 @@ public class MenuBuilder {
|
|||
firstRow = false;
|
||||
}
|
||||
|
||||
protected View buildRow(View view, int iconId, String text, int textColor, boolean needLinks, int textLinesLimit) {
|
||||
return buildRow(view, getRowIcon(iconId), text, textColor, needLinks, textLinesLimit);
|
||||
protected View buildRow(View view, int iconId, String text, int textColor, boolean needLinks, int textLinesLimit, boolean isUrl) {
|
||||
return buildRow(view, getRowIcon(iconId), text, textColor, needLinks, textLinesLimit, isUrl);
|
||||
}
|
||||
|
||||
protected View buildRow(final View view, Drawable icon, final String text, int textColor, boolean needLinks, int textLinesLimit) {
|
||||
protected View buildRow(final View view, Drawable icon, final String text, int textColor, boolean needLinks, int textLinesLimit, boolean isUrl) {
|
||||
|
||||
if (!isFirstRow()) {
|
||||
buildRowDivider(view, false);
|
||||
|
@ -154,7 +162,9 @@ public class MenuBuilder {
|
|||
textView.setTextSize(16);
|
||||
textView.setTextColor(app.getResources().getColor(light ? R.color.ctx_menu_info_text_light : R.color.ctx_menu_info_text_dark));
|
||||
|
||||
if (needLinks) {
|
||||
if (isUrl) {
|
||||
textView.setTextColor(textView.getLinkTextColors());
|
||||
} else if (needLinks) {
|
||||
textView.setAutoLinkMask(Linkify.ALL);
|
||||
textView.setLinksClickable(true);
|
||||
}
|
||||
|
@ -173,6 +183,17 @@ public class MenuBuilder {
|
|||
llText.setLayoutParams(llTextViewParams);
|
||||
llText.addView(textView);
|
||||
|
||||
if (isUrl) {
|
||||
ll.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.setData(Uri.parse(text));
|
||||
v.getContext().startActivity(intent);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
((LinearLayout) view).addView(ll);
|
||||
|
||||
rowBuilt();
|
||||
|
@ -248,8 +269,8 @@ public class MenuBuilder {
|
|||
public void buildCustomAddressLine(LinearLayout ll) {
|
||||
}
|
||||
|
||||
public void addPlainMenuItem(int iconId, String text, boolean needLinks) {
|
||||
plainMenuItems.add(new PlainMenuItem(iconId, text, needLinks));
|
||||
public void addPlainMenuItem(int iconId, String text, boolean needLinks, boolean isUrl) {
|
||||
plainMenuItems.add(new PlainMenuItem(iconId, text, needLinks, isUrl));
|
||||
}
|
||||
|
||||
public void clearPlainMenuItems() {
|
||||
|
|
|
@ -125,8 +125,8 @@ public abstract class MenuController extends BaseMenuController {
|
|||
|
||||
protected abstract void setObject(Object object);
|
||||
|
||||
public void addPlainMenuItem(int iconId, String text, boolean needLinks) {
|
||||
builder.addPlainMenuItem(iconId, text, needLinks);
|
||||
public void addPlainMenuItem(int iconId, String text, boolean needLinks, boolean isUrl) {
|
||||
builder.addPlainMenuItem(iconId, text, needLinks, isUrl);
|
||||
}
|
||||
|
||||
public void clearPlainMenuItems() {
|
||||
|
@ -139,7 +139,7 @@ public abstract class MenuController extends BaseMenuController {
|
|||
|
||||
protected void addMyLocationToPlainItems(LatLon latLon) {
|
||||
addPlainMenuItem(R.drawable.ic_action_get_my_location, PointDescription.getLocationName(getMapActivity(),
|
||||
latLon.getLatitude(), latLon.getLongitude(), true).replaceAll("\n", ""), false);
|
||||
latLon.getLatitude(), latLon.getLongitude(), true).replaceAll("\n", ""), false, false);
|
||||
}
|
||||
|
||||
public PointDescription getPointDescription() {
|
||||
|
|
|
@ -344,7 +344,7 @@ public class AmenityMenuBuilder extends MenuBuilder {
|
|||
|
||||
buildRow(view, R.drawable.ic_action_get_my_location, PointDescription.getLocationName(app,
|
||||
amenity.getLocation().getLatitude(), amenity.getLocation().getLongitude(), true)
|
||||
.replaceAll("\n", ""), 0, false, 0);
|
||||
.replaceAll("\n", ""), 0, false, 0, false);
|
||||
}
|
||||
|
||||
public void buildAmenityRow(View view, AmenityInfoRow info) {
|
||||
|
|
|
@ -25,7 +25,7 @@ public class FavouritePointMenuBuilder extends MenuBuilder {
|
|||
@Override
|
||||
public void buildInternal(View view) {
|
||||
if (!Algorithms.isEmpty(fav.getDescription())) {
|
||||
buildRow(view, R.drawable.ic_action_note_dark, fav.getDescription(), 0, true, 0);
|
||||
buildRow(view, R.drawable.ic_action_note_dark, fav.getDescription(), 0, true, 0, false);
|
||||
}
|
||||
|
||||
buildPlainMenuItems(view);
|
||||
|
|
|
@ -34,7 +34,7 @@ public class GpxItemMenuBuilder extends MenuBuilder {
|
|||
String description = GpxUiHelper.getDescription(app, item.analysis, false);
|
||||
String[] lines = description.split("\n");
|
||||
for (String line : lines) {
|
||||
buildRow(view, R.drawable.ic_action_info_dark, line, 0, false, 0);
|
||||
buildRow(view, R.drawable.ic_action_info_dark, line, 0, false, 0, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -34,23 +34,23 @@ public class WptPtMenuBuilder extends MenuBuilder {
|
|||
DateFormat timeFormat = android.text.format.DateFormat.getTimeFormat(view.getContext());
|
||||
Date date = new Date(wpt.time);
|
||||
buildRow(view, R.drawable.ic_action_data,
|
||||
dateFormat.format(date) + " — " + timeFormat.format(date), 0, false, 0);
|
||||
dateFormat.format(date) + " — " + timeFormat.format(date), 0, false, 0, false);
|
||||
}
|
||||
if (wpt.speed > 0) {
|
||||
buildRow(view, R.drawable.ic_action_speed,
|
||||
OsmAndFormatter.getFormattedSpeed((float)wpt.speed, app), 0, false, 0);
|
||||
OsmAndFormatter.getFormattedSpeed((float)wpt.speed, app), 0, false, 0, false);
|
||||
}
|
||||
if (!Double.isNaN(wpt.ele)) {
|
||||
buildRow(view, R.drawable.ic_action_altitude,
|
||||
OsmAndFormatter.getFormattedDistance((float) wpt.ele, app), 0, false, 0);
|
||||
OsmAndFormatter.getFormattedDistance((float) wpt.ele, app), 0, false, 0, false);
|
||||
}
|
||||
if (!Double.isNaN(wpt.hdop)) {
|
||||
buildRow(view, R.drawable.ic_action_gps_info,
|
||||
Algorithms.capitalizeFirstLetterAndLowercase(app.getString(R.string.plugin_distance_point_hdop)) + ": "
|
||||
+ OsmAndFormatter.getFormattedDistance((float)wpt.hdop, app), 0, false, 0);
|
||||
+ OsmAndFormatter.getFormattedDistance((float)wpt.hdop, app), 0, false, 0, false);
|
||||
}
|
||||
if (!Algorithms.isEmpty(wpt.desc)) {
|
||||
final View row = buildRow(view, R.drawable.ic_action_note_dark, wpt.desc, 0, true, 10);
|
||||
final View row = buildRow(view, R.drawable.ic_action_note_dark, wpt.desc, 0, true, 10, false);
|
||||
row.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
|
|
@ -97,7 +97,7 @@ public class AmenityMenuController extends MenuController {
|
|||
if (resId == 0) {
|
||||
resId = R.drawable.ic_action_folder_stroke;
|
||||
}
|
||||
addPlainMenuItem(resId, typeStr, false);
|
||||
addPlainMenuItem(resId, typeStr, false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -184,8 +184,8 @@ public class MapDataMenuController extends MenuController {
|
|||
@Override
|
||||
public void addPlainMenuItems(String typeStr, PointDescription pointDescription, LatLon latLon) {
|
||||
if (indexItem != null) {
|
||||
addPlainMenuItem(R.drawable.ic_action_info_dark, indexItem.getType().getString(getMapActivity()), false);
|
||||
addPlainMenuItem(R.drawable.ic_action_info_dark, indexItem.getSizeDescription(getMapActivity()), false);
|
||||
addPlainMenuItem(R.drawable.ic_action_info_dark, indexItem.getType().getString(getMapActivity()), false, false);
|
||||
addPlainMenuItem(R.drawable.ic_action_info_dark, indexItem.getSizeDescription(getMapActivity()), false, false);
|
||||
}
|
||||
if (!Algorithms.isEmpty(mapObject.getWorldRegion().getParams().getWikiLink())) {
|
||||
String[] items = mapObject.getWorldRegion().getParams().getWikiLink().split(":");
|
||||
|
@ -195,11 +195,11 @@ public class MapDataMenuController extends MenuController {
|
|||
} else {
|
||||
url = "https://wikipedia.org/wiki/" + items[0].replace(' ', '_');
|
||||
}
|
||||
addPlainMenuItem(R.drawable.ic_world_globe_dark, url, true);
|
||||
addPlainMenuItem(R.drawable.ic_world_globe_dark, url, false, true);
|
||||
}
|
||||
if (indexItem != null) {
|
||||
DateFormat dateFormat = android.text.format.DateFormat.getMediumDateFormat(getMapActivity());
|
||||
addPlainMenuItem(R.drawable.ic_action_data, indexItem.getRemoteDate(dateFormat), false);
|
||||
addPlainMenuItem(R.drawable.ic_action_data, indexItem.getRemoteDate(dateFormat), false, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,8 +31,8 @@ public class EditPOIMenuBuilder extends MenuBuilder {
|
|||
if (osmPoint instanceof OsmNotesPoint) {
|
||||
OsmNotesPoint notes = (OsmNotesPoint) osmPoint;
|
||||
|
||||
buildRow(view, R.drawable.ic_action_note_dark, notes.getText(), 0, false, 0);
|
||||
buildRow(view, R.drawable.ic_group, notes.getAuthor(), 0, false, 0);
|
||||
buildRow(view, R.drawable.ic_action_note_dark, notes.getText(), 0, false, 0, false);
|
||||
buildRow(view, R.drawable.ic_group, notes.getAuthor(), 0, false, 0, false);
|
||||
|
||||
} else if (osmPoint instanceof OpenstreetmapPoint) {
|
||||
OpenstreetmapPoint point = (OpenstreetmapPoint) osmPoint;
|
||||
|
@ -57,7 +57,7 @@ public class EditPOIMenuBuilder extends MenuBuilder {
|
|||
if (resId == 0) {
|
||||
resId = R.drawable.ic_action_folder_stroke;
|
||||
}
|
||||
buildRow(view, resId, poiTranslation, 0, false, 0);
|
||||
buildRow(view, resId, poiTranslation, 0, false, 0, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -67,12 +67,12 @@ public class EditPOIMenuBuilder extends MenuBuilder {
|
|||
continue;
|
||||
}
|
||||
String text = e.getKey() + "=" + e.getValue();
|
||||
buildRow(view, R.drawable.ic_action_info_dark, text, 0, false, 0);
|
||||
buildRow(view, R.drawable.ic_action_info_dark, text, 0, false, 0, false);
|
||||
}
|
||||
}
|
||||
|
||||
buildRow(view, R.drawable.ic_action_get_my_location, PointDescription.getLocationName(app,
|
||||
osmPoint.getLatitude(), osmPoint.getLongitude(), true)
|
||||
.replaceAll("\n", ""), 0, false, 0);
|
||||
.replaceAll("\n", ""), 0, false, 0, false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@ public class OsmBugMenuController extends MenuController {
|
|||
public void addPlainMenuItems(String typeStr, PointDescription pointDescription, LatLon latLon) {
|
||||
super.addPlainMenuItems(typeStr, pointDescription, latLon);
|
||||
for (String description : bug.getCommentDescriptionList()) {
|
||||
addPlainMenuItem(R.drawable.ic_action_note_dark, description, true);
|
||||
addPlainMenuItem(R.drawable.ic_action_note_dark, description, true, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue