Fix #3265
This commit is contained in:
parent
b15aca3570
commit
52d92ae996
24 changed files with 237 additions and 196 deletions
|
@ -10,7 +10,8 @@
|
|||
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
||||
-->
|
||||
|
||||
<string name="wiki_around">Wikipedia articles around</string>
|
||||
<string name="upload_osm_note_description">You can upload your OSM Note anonymously or using your OpenStreetMap.org profile.</string>
|
||||
<string name="wiki_around">Nearby Wikipedia articles</string>
|
||||
<string name="search_map_hint">Search city or region</string>
|
||||
<string name="route_roundabout_short">Take %1$d exit and go</string>
|
||||
<string name="upload_poi">Upload POI</string>
|
||||
|
|
|
@ -42,7 +42,8 @@ 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, false, null);
|
||||
buildRow(view, R.drawable.ic_action_data, dateFormat.format(date) + " — " + timeFormat.format(date),
|
||||
0, false, null, false, 0, false, null);
|
||||
|
||||
buildPlainMenuItems(view);
|
||||
|
||||
|
|
|
@ -85,11 +85,6 @@ public class AudioVideoNoteMenuController extends MenuController {
|
|||
return mRecording;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getSupportedMenuStatesPortrait() {
|
||||
return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN | MenuState.FULL_SCREEN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Drawable getLeftIcon() {
|
||||
if (mRecording.isPhoto()) {
|
||||
|
|
|
@ -7,7 +7,10 @@ import android.content.res.Resources;
|
|||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.support.v7.view.ContextThemeWrapper;
|
||||
import android.support.v7.widget.AppCompatButton;
|
||||
import android.text.ClipboardManager;
|
||||
import android.text.TextUtils;
|
||||
import android.text.util.Linkify;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
|
@ -20,13 +23,24 @@ import android.widget.LinearLayout;
|
|||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import net.osmand.binary.BinaryMapIndexReader;
|
||||
import net.osmand.data.Amenity;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.data.QuadRect;
|
||||
import net.osmand.osm.PoiCategory;
|
||||
import net.osmand.plus.IconsCache;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.render.RenderingIcons;
|
||||
import net.osmand.util.MapUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import static android.util.TypedValue.COMPLEX_UNIT_DIP;
|
||||
|
||||
|
@ -39,6 +53,10 @@ public class MenuBuilder {
|
|||
protected LinkedList<PlainMenuItem> plainMenuItems;
|
||||
private boolean firstRow;
|
||||
protected boolean light;
|
||||
private long objectId;
|
||||
private LatLon latLon;
|
||||
private boolean showNearestWiki = false;
|
||||
protected List<Amenity> nearestWiki = new ArrayList<>();
|
||||
|
||||
public class PlainMenuItem {
|
||||
private int iconId;
|
||||
|
@ -82,12 +100,34 @@ public class MenuBuilder {
|
|||
plainMenuItems = new LinkedList<>();
|
||||
}
|
||||
|
||||
public LatLon getLatLon() {
|
||||
return latLon;
|
||||
}
|
||||
|
||||
public void setLatLon(LatLon objectLocation) {
|
||||
this.latLon = objectLocation;
|
||||
}
|
||||
|
||||
public boolean isShowNearestWiki() {
|
||||
return showNearestWiki;
|
||||
}
|
||||
|
||||
public void setShowNearestWiki(boolean showNearestWiki) {
|
||||
this.showNearestWiki = showNearestWiki;
|
||||
}
|
||||
|
||||
public void setShowNearestWiki(boolean showNearestWiki, long objectId) {
|
||||
this.objectId = objectId;
|
||||
this.showNearestWiki = showNearestWiki;
|
||||
}
|
||||
|
||||
public void setLight(boolean light) {
|
||||
this.light = light;
|
||||
}
|
||||
|
||||
public void build(View view) {
|
||||
firstRow = true;
|
||||
buildNearestWikiRow(view);
|
||||
if (needBuildPlainMenuItems()) {
|
||||
buildPlainMenuItems(view);
|
||||
}
|
||||
|
@ -97,7 +137,8 @@ public class MenuBuilder {
|
|||
|
||||
protected void buildPlainMenuItems(View view) {
|
||||
for (PlainMenuItem item : plainMenuItems) {
|
||||
buildRow(view, item.getIconId(), item.getText(), 0, item.isNeedLinks(), 0, item.isUrl(), item.getOnClickListener());
|
||||
buildRow(view, item.getIconId(), item.getText(), 0, false, null,
|
||||
item.isNeedLinks(), 0, item.isUrl(), item.getOnClickListener());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -105,6 +146,14 @@ public class MenuBuilder {
|
|||
return true;
|
||||
}
|
||||
|
||||
protected void buildNearestWikiRow(View view) {
|
||||
if (processNearstWiki() && nearestWiki.size() > 0) {
|
||||
buildRow(view, R.drawable.ic_action_wikipedia, app.getString(R.string.wiki_around) + " (" + nearestWiki.size()+")", 0,
|
||||
true, getCollapsableWikiView(view.getContext(), true),
|
||||
false, 0, false, null);
|
||||
}
|
||||
}
|
||||
|
||||
protected void buildInternal(View view) {
|
||||
}
|
||||
|
||||
|
@ -120,16 +169,26 @@ public class MenuBuilder {
|
|||
firstRow = false;
|
||||
}
|
||||
|
||||
protected View buildRow(View view, int iconId, String text, int textColor, boolean needLinks, int textLinesLimit, boolean isUrl, OnClickListener onClickListener) {
|
||||
return buildRow(view, getRowIcon(iconId), text, textColor, needLinks, textLinesLimit, isUrl, onClickListener);
|
||||
protected View buildRow(View view, int iconId, String text, int textColor,
|
||||
boolean collapsable, final View collapsableView,
|
||||
boolean needLinks, int textLinesLimit, boolean isUrl, OnClickListener onClickListener) {
|
||||
return buildRow(view, getRowIcon(iconId), text, textColor, collapsable, collapsableView,
|
||||
needLinks, textLinesLimit, isUrl, onClickListener);
|
||||
}
|
||||
|
||||
protected View buildRow(final View view, Drawable icon, final String text, int textColor, boolean needLinks, int textLinesLimit, boolean isUrl, OnClickListener onClickListener) {
|
||||
protected View buildRow(final View view, Drawable icon, final String text, int textColor,
|
||||
boolean collapsable, final View collapsableView, boolean needLinks,
|
||||
int textLinesLimit, boolean isUrl, OnClickListener onClickListener) {
|
||||
|
||||
if (!isFirstRow()) {
|
||||
buildRowDivider(view, false);
|
||||
}
|
||||
|
||||
LinearLayout baseView = new LinearLayout(view.getContext());
|
||||
baseView.setOrientation(LinearLayout.VERTICAL);
|
||||
LinearLayout.LayoutParams llBaseViewParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
baseView.setLayoutParams(llBaseViewParams);
|
||||
|
||||
LinearLayout ll = new LinearLayout(view.getContext());
|
||||
ll.setOrientation(LinearLayout.HORIZONTAL);
|
||||
LinearLayout.LayoutParams llParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
|
@ -143,6 +202,8 @@ public class MenuBuilder {
|
|||
}
|
||||
});
|
||||
|
||||
baseView.addView(ll);
|
||||
|
||||
// Icon
|
||||
LinearLayout llIcon = new LinearLayout(view.getContext());
|
||||
llIcon.setOrientation(LinearLayout.HORIZONTAL);
|
||||
|
@ -192,6 +253,38 @@ public class MenuBuilder {
|
|||
llText.setLayoutParams(llTextViewParams);
|
||||
llText.addView(textView);
|
||||
|
||||
final ImageView iconViewCollapse = new ImageView(view.getContext());
|
||||
if (collapsable && collapsableView != null) {
|
||||
// Icon
|
||||
LinearLayout llIconCollapse = new LinearLayout(view.getContext());
|
||||
llIconCollapse.setLayoutParams(new LinearLayout.LayoutParams(dpToPx(40f), dpToPx(48f)));
|
||||
llIconCollapse.setOrientation(LinearLayout.HORIZONTAL);
|
||||
llIconCollapse.setGravity(Gravity.CENTER_VERTICAL);
|
||||
ll.addView(llIconCollapse);
|
||||
|
||||
LinearLayout.LayoutParams llIconCollapseParams = new LinearLayout.LayoutParams(dpToPx(24f), dpToPx(24f));
|
||||
llIconCollapseParams.setMargins(0, dpToPx(12f), dpToPx(32f), dpToPx(12f));
|
||||
llIconCollapseParams.gravity = Gravity.CENTER_VERTICAL;
|
||||
iconViewCollapse.setLayoutParams(llIconCollapseParams);
|
||||
iconViewCollapse.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
|
||||
iconViewCollapse.setImageDrawable(app.getIconsCache().getThemedIcon(collapsableView.getVisibility() == View.GONE ?
|
||||
R.drawable.ic_action_arrow_down : R.drawable.ic_action_arrow_up));
|
||||
llIconCollapse.addView(iconViewCollapse);
|
||||
ll.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (collapsableView.getVisibility() == View.VISIBLE) {
|
||||
collapsableView.setVisibility(View.GONE);
|
||||
iconViewCollapse.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_arrow_down));
|
||||
} else {
|
||||
collapsableView.setVisibility(View.VISIBLE);
|
||||
iconViewCollapse.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_arrow_up));
|
||||
}
|
||||
}
|
||||
});
|
||||
baseView.addView(collapsableView);
|
||||
}
|
||||
|
||||
if (onClickListener != null) {
|
||||
ll.setOnClickListener(onClickListener);
|
||||
} else if (isUrl) {
|
||||
|
@ -205,7 +298,7 @@ public class MenuBuilder {
|
|||
});
|
||||
}
|
||||
|
||||
((LinearLayout) view).addView(ll);
|
||||
((LinearLayout) view).addView(baseView);
|
||||
|
||||
rowBuilt();
|
||||
|
||||
|
@ -319,4 +412,92 @@ public class MenuBuilder {
|
|||
r.getDisplayMetrics()
|
||||
);
|
||||
}
|
||||
|
||||
protected View getCollapsableTextView(Context context, boolean collapsed, String text) {
|
||||
final TextView textView = new TextView(context);
|
||||
textView.setVisibility(collapsed ? View.GONE : View.VISIBLE);
|
||||
LinearLayout.LayoutParams llTextDescParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
llTextDescParams.setMargins(dpToPx(72f), 0, dpToPx(40f), dpToPx(13f));
|
||||
textView.setLayoutParams(llTextDescParams);
|
||||
textView.setTextSize(16);
|
||||
textView.setTextColor(app.getResources().getColor(light ? R.color.ctx_menu_info_text_light : R.color.ctx_menu_info_text_dark));
|
||||
textView.setText(text);
|
||||
return textView;
|
||||
}
|
||||
|
||||
protected View getCollapsableWikiView(Context context, boolean collapsed) {
|
||||
final LinearLayout view = new LinearLayout(context);
|
||||
view.setOrientation(LinearLayout.VERTICAL);
|
||||
view.setVisibility(collapsed ? View.GONE : View.VISIBLE);
|
||||
LinearLayout.LayoutParams llParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
llParams.setMargins(dpToPx(68f), 0, dpToPx(12f), dpToPx(13f));
|
||||
view.setLayoutParams(llParams);
|
||||
|
||||
for (final Amenity wiki : nearestWiki) {
|
||||
AppCompatButton wikiButton = new AppCompatButton(
|
||||
new ContextThemeWrapper(view.getContext(), light ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme));
|
||||
LinearLayout.LayoutParams llWikiButtonParams =
|
||||
new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
wikiButton.setLayoutParams(llWikiButtonParams);
|
||||
wikiButton.setPadding(dpToPx(14f), 0, dpToPx(14f), 0);
|
||||
wikiButton.setTextColor(app.getResources()
|
||||
.getColor(light ? R.color.color_dialog_buttons_light : R.color.color_dialog_buttons_dark));
|
||||
wikiButton.setText(wiki.getName());
|
||||
|
||||
wikiButton.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
|
||||
wikiButton.setSingleLine(true);
|
||||
wikiButton.setEllipsize(TextUtils.TruncateAt.END);
|
||||
wikiButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
PointDescription pointDescription = mapActivity.getMapLayers().getPoiMapLayer().getObjectName(wiki);
|
||||
mapActivity.getContextMenu().show(
|
||||
new LatLon(wiki.getLocation().getLatitude(), wiki.getLocation().getLongitude()),
|
||||
pointDescription, wiki);
|
||||
}
|
||||
});
|
||||
view.addView(wikiButton);
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
protected boolean processNearstWiki() {
|
||||
if (showNearestWiki && latLon != null) {
|
||||
QuadRect rect = MapUtils.calculateLatLonBbox(
|
||||
latLon.getLatitude(), latLon.getLongitude(), 250);
|
||||
nearestWiki = app.getResourceManager().searchAmenities(
|
||||
new BinaryMapIndexReader.SearchPoiTypeFilter() {
|
||||
@Override
|
||||
public boolean accept(PoiCategory type, String subcategory) {
|
||||
return type.isWiki();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return false;
|
||||
}
|
||||
}, rect.top, rect.left, rect.bottom, rect.right, -1, null);
|
||||
Collections.sort(nearestWiki, new Comparator<Amenity>() {
|
||||
|
||||
@Override
|
||||
public int compare(Amenity o1, Amenity o2) {
|
||||
double d1 = MapUtils.getDistance(latLon, o1.getLocation());
|
||||
double d2 = MapUtils.getDistance(latLon, o2.getLocation());
|
||||
return Double.compare(d1, d2);
|
||||
}
|
||||
});
|
||||
Long id = objectId;
|
||||
if (id != 0) {
|
||||
for (Amenity wiki : nearestWiki) {
|
||||
if (wiki.getId().equals(id)) {
|
||||
nearestWiki.remove(wiki);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -501,6 +501,9 @@ public abstract class MenuController extends BaseMenuController {
|
|||
|
||||
public void setLatLon(@NonNull LatLon latLon) {
|
||||
this.latLon = latLon;
|
||||
if (builder != null) {
|
||||
builder.setLatLon(latLon);
|
||||
}
|
||||
}
|
||||
|
||||
public void buildMapDownloadButton(LatLon latLon) {
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
package net.osmand.plus.mapcontextmenu.builders;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.view.ContextThemeWrapper;
|
||||
import android.support.v7.widget.AppCompatButton;
|
||||
import android.text.Html;
|
||||
import android.text.SpannableString;
|
||||
|
@ -20,43 +18,38 @@ import android.view.ViewGroup;
|
|||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import net.osmand.binary.BinaryMapIndexReader;
|
||||
|
||||
import net.osmand.data.Amenity;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.MapObject.MapObjectComparator;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.data.QuadRect;
|
||||
import net.osmand.osm.AbstractPoiType;
|
||||
import net.osmand.osm.MapPoiTypes;
|
||||
import net.osmand.osm.PoiCategory;
|
||||
import net.osmand.osm.PoiType;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
||||
import net.osmand.plus.views.ContextMenuLayer;
|
||||
import net.osmand.plus.views.POIMapLayer;
|
||||
import net.osmand.util.Algorithms;
|
||||
import net.osmand.util.MapUtils;
|
||||
import net.osmand.util.OpeningHoursParser;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
public class AmenityMenuBuilder extends MenuBuilder {
|
||||
|
||||
private final Amenity amenity;
|
||||
private List<Amenity> nearestWiki = new ArrayList<>();
|
||||
|
||||
public AmenityMenuBuilder(MapActivity mapActivity, final Amenity amenity) {
|
||||
super(mapActivity);
|
||||
this.amenity = amenity;
|
||||
processNearstWiki();
|
||||
setShowNearestWiki(true, amenity.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void buildNearestWikiRow(View view) {
|
||||
}
|
||||
|
||||
private void buildRow(View view, int iconId, String text, String textPrefix,
|
||||
|
@ -271,55 +264,6 @@ public class AmenityMenuBuilder extends MenuBuilder {
|
|||
rowBuilt();
|
||||
}
|
||||
|
||||
private View getCollapsableTextView(Context context, boolean collapsed, String text) {
|
||||
final TextView textView = new TextView(context);
|
||||
textView.setVisibility(collapsed ? View.GONE : View.VISIBLE);
|
||||
LinearLayout.LayoutParams llTextDescParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
llTextDescParams.setMargins(dpToPx(72f), 0, dpToPx(40f), dpToPx(13f));
|
||||
textView.setLayoutParams(llTextDescParams);
|
||||
textView.setTextSize(16);
|
||||
textView.setTextColor(app.getResources().getColor(light ? R.color.ctx_menu_info_text_light : R.color.ctx_menu_info_text_dark));
|
||||
textView.setText(text);
|
||||
return textView;
|
||||
}
|
||||
|
||||
private View getCollapsableWikiView(Context context, boolean collapsed) {
|
||||
final LinearLayout view = new LinearLayout(context);
|
||||
view.setOrientation(LinearLayout.VERTICAL);
|
||||
view.setVisibility(collapsed ? View.GONE : View.VISIBLE);
|
||||
LinearLayout.LayoutParams llParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
llParams.setMargins(dpToPx(68f), 0, dpToPx(12f), dpToPx(13f));
|
||||
view.setLayoutParams(llParams);
|
||||
|
||||
for (final Amenity wiki : nearestWiki) {
|
||||
AppCompatButton wikiButton = new AppCompatButton(
|
||||
new ContextThemeWrapper(view.getContext(), light ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme));
|
||||
LinearLayout.LayoutParams llWikiButtonParams =
|
||||
new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
wikiButton.setLayoutParams(llWikiButtonParams);
|
||||
wikiButton.setPadding(dpToPx(14f), 0, dpToPx(14f), 0);
|
||||
wikiButton.setTextColor(app.getResources()
|
||||
.getColor(light ? R.color.color_dialog_buttons_light : R.color.color_dialog_buttons_dark));
|
||||
wikiButton.setText(wiki.getName());
|
||||
|
||||
wikiButton.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
|
||||
wikiButton.setSingleLine(true);
|
||||
wikiButton.setEllipsize(TextUtils.TruncateAt.END);
|
||||
wikiButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
PointDescription pointDescription = mapActivity.getMapLayers().getPoiMapLayer().getObjectName(wiki);
|
||||
mapActivity.getContextMenu().show(
|
||||
new LatLon(wiki.getLocation().getLatitude(), wiki.getLocation().getLongitude()),
|
||||
pointDescription, wiki);
|
||||
}
|
||||
});
|
||||
view.addView(wikiButton);
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildInternal(View view) {
|
||||
boolean hasWiki = false;
|
||||
|
@ -512,7 +456,7 @@ public class AmenityMenuBuilder extends MenuBuilder {
|
|||
buildAmenityRow(view, info);
|
||||
}
|
||||
|
||||
if (nearestWiki.size() > 0) {
|
||||
if (processNearstWiki() && nearestWiki.size() > 0) {
|
||||
AmenityInfoRow wikiInfo = new AmenityInfoRow(
|
||||
"nearest_wiki", R.drawable.ic_action_wikipedia, null, app.getString(R.string.wiki_around) + " (" + nearestWiki.size()+")", true,
|
||||
getCollapsableWikiView(view.getContext(), true),
|
||||
|
@ -522,7 +466,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, false, null);
|
||||
.replaceAll("\n", " "), 0, false, null, false, 0, false, null);
|
||||
}
|
||||
|
||||
public void buildAmenityRow(View view, AmenityInfoRow info) {
|
||||
|
@ -535,38 +479,6 @@ public class AmenityMenuBuilder extends MenuBuilder {
|
|||
}
|
||||
}
|
||||
|
||||
private void processNearstWiki() {
|
||||
QuadRect rect = MapUtils.calculateLatLonBbox(
|
||||
amenity.getLocation().getLatitude(), amenity.getLocation().getLongitude(), 250);
|
||||
nearestWiki = app.getResourceManager().searchAmenities(
|
||||
new BinaryMapIndexReader.SearchPoiTypeFilter() {
|
||||
@Override
|
||||
public boolean accept(PoiCategory type, String subcategory) {
|
||||
return type.isWiki();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return false;
|
||||
}
|
||||
}, rect.top, rect.left, rect.bottom, rect.right, -1, null);
|
||||
Collections.sort(nearestWiki, new Comparator<Amenity>() {
|
||||
|
||||
@Override
|
||||
public int compare(Amenity o1, Amenity o2) {
|
||||
double d1 = MapUtils.getDistance(amenity.getLocation(), o1.getLocation());
|
||||
double d2 = MapUtils.getDistance(amenity.getLocation(), o2.getLocation());
|
||||
return Double.compare(d1, d2);
|
||||
}
|
||||
});
|
||||
for (Amenity wiki : nearestWiki) {
|
||||
if (wiki.getId().equals(amenity.getId())) {
|
||||
nearestWiki.remove(wiki);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class AmenityInfoRow {
|
||||
private String key;
|
||||
private Drawable icon;
|
||||
|
|
|
@ -23,6 +23,7 @@ public class FavouritePointMenuBuilder extends MenuBuilder {
|
|||
public FavouritePointMenuBuilder(MapActivity mapActivity, final FavouritePoint fav) {
|
||||
super(mapActivity);
|
||||
this.fav = fav;
|
||||
setShowNearestWiki(true);
|
||||
acquireOriginObject();
|
||||
}
|
||||
|
||||
|
@ -42,16 +43,22 @@ public class FavouritePointMenuBuilder extends MenuBuilder {
|
|||
return originObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void buildNearestWikiRow(View view) {
|
||||
if (originObject == null || !(originObject instanceof Amenity)) {
|
||||
super.buildNearestWikiRow(view);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildInternal(View view) {
|
||||
if (originObject != null) {
|
||||
if (originObject instanceof Amenity) {
|
||||
if (originObject != null && originObject instanceof Amenity) {
|
||||
AmenityMenuBuilder builder = new AmenityMenuBuilder(mapActivity, (Amenity) originObject);
|
||||
builder.setLatLon(getLatLon());
|
||||
builder.setLight(light);
|
||||
builder.buildInternal(view);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Amenity findAmenity(String nameStringEn, double lat, double lon) {
|
||||
QuadRect rect = MapUtils.calculateLatLonBbox(lat, lon, 15);
|
||||
|
|
|
@ -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, false, null);
|
||||
buildRow(view, R.drawable.ic_action_info_dark, line, 0, false, null, false, 0, false, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ public class WptPtMenuBuilder extends MenuBuilder {
|
|||
public WptPtMenuBuilder(MapActivity mapActivity, final WptPt wpt) {
|
||||
super(mapActivity);
|
||||
this.wpt = wpt;
|
||||
setShowNearestWiki(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -34,22 +35,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, false, null);
|
||||
dateFormat.format(date) + " — " + timeFormat.format(date), 0, false, null, false, 0, false, null);
|
||||
}
|
||||
if (wpt.speed > 0) {
|
||||
buildRow(view, R.drawable.ic_action_speed,
|
||||
OsmAndFormatter.getFormattedSpeed((float)wpt.speed, app), 0, false, 0, false, null);
|
||||
OsmAndFormatter.getFormattedSpeed((float)wpt.speed, app), 0, false, null, false, 0, false, null);
|
||||
}
|
||||
if (!Double.isNaN(wpt.ele)) {
|
||||
buildRow(view, R.drawable.ic_action_altitude,
|
||||
OsmAndFormatter.getFormattedDistance((float) wpt.ele, app), 0, false, 0, false, null);
|
||||
OsmAndFormatter.getFormattedDistance((float) wpt.ele, app), 0, false, null, false, 0, false, null);
|
||||
}
|
||||
if (!Double.isNaN(wpt.hdop)) {
|
||||
buildRow(view, R.drawable.ic_action_gps_info,
|
||||
Algorithms.capitalizeFirstLetterAndLowercase(app.getString(R.string.plugin_distance_point_hdop)) + ": " + (int)wpt.hdop, 0, false, 0, false, null);
|
||||
Algorithms.capitalizeFirstLetterAndLowercase(app.getString(R.string.plugin_distance_point_hdop)) + ": " + (int)wpt.hdop, 0,
|
||||
false, null, false, 0, false, null);
|
||||
}
|
||||
if (!Algorithms.isEmpty(wpt.desc)) {
|
||||
final View row = buildRow(view, R.drawable.ic_action_note_dark, wpt.desc, 0, true, 10, false, null);
|
||||
final View row = buildRow(view, R.drawable.ic_action_note_dark, wpt.desc, 0, false, null, true, 10, false, null);
|
||||
row.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
@ -59,7 +61,8 @@ public class WptPtMenuBuilder extends MenuBuilder {
|
|||
});
|
||||
}
|
||||
if (!Algorithms.isEmpty(wpt.comment)) {
|
||||
final View rowc = buildRow(view, R.drawable.ic_action_note_dark, wpt.comment, 0, true, 10, false, null);
|
||||
final View rowc = buildRow(view, R.drawable.ic_action_note_dark, wpt.comment, 0,
|
||||
false, null, true, 10, false, null);
|
||||
rowc.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
|
|
@ -67,11 +67,6 @@ public class AmenityMenuController extends MenuController {
|
|||
return amenity;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getSupportedMenuStatesPortrait() {
|
||||
return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN | MenuState.FULL_SCREEN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needStreetName() {
|
||||
if (amenity.getSubType() != null && amenity.getType() != null) {
|
||||
|
|
|
@ -38,11 +38,6 @@ public class FavouritePointMenuController extends MenuController {
|
|||
return fav;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getSupportedMenuStatesPortrait() {
|
||||
return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN | MenuState.FULL_SCREEN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleSingleTapOnMap() {
|
||||
Fragment fragment = getMapActivity().getSupportFragmentManager().findFragmentByTag(FavoritePointEditor.TAG);
|
||||
|
|
|
@ -29,11 +29,6 @@ public class GpxItemMenuController extends MenuController {
|
|||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getSupportedMenuStatesPortrait() {
|
||||
return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN | MenuState.FULL_SCREEN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeStr() {
|
||||
return getPointDescription().getTypeName();
|
||||
|
|
|
@ -2,6 +2,7 @@ package net.osmand.plus.mapcontextmenu.controllers;
|
|||
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
|
@ -19,6 +20,7 @@ public class HistoryMenuController extends MenuController {
|
|||
public HistoryMenuController(MapActivity mapActivity, PointDescription pointDescription, final HistoryEntry entry) {
|
||||
super(new MenuBuilder(mapActivity), pointDescription, mapActivity);
|
||||
this.entry = entry;
|
||||
builder.setShowNearestWiki(true);
|
||||
initData();
|
||||
}
|
||||
|
||||
|
@ -39,11 +41,6 @@ public class HistoryMenuController extends MenuController {
|
|||
return entry;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getSupportedMenuStatesPortrait() {
|
||||
return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean displayStreetNameInTitle() {
|
||||
return entry.getName().isLocation();
|
||||
|
|
|
@ -2,6 +2,7 @@ package net.osmand.plus.mapcontextmenu.controllers;
|
|||
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.MapMarkersHelper;
|
||||
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||
|
@ -19,6 +20,7 @@ public class MapMarkerMenuController extends MenuController {
|
|||
public MapMarkerMenuController(MapActivity mapActivity, PointDescription pointDescription, MapMarker mapMarker) {
|
||||
super(new MenuBuilder(mapActivity), pointDescription, mapActivity);
|
||||
this.mapMarker = mapMarker;
|
||||
builder.setShowNearestWiki(true);
|
||||
final MapMarkersHelper markersHelper = mapActivity.getMyApplication().getMapMarkersHelper();
|
||||
leftTitleButtonController = new TitleButtonController() {
|
||||
@Override
|
||||
|
@ -48,11 +50,6 @@ public class MapMarkerMenuController extends MenuController {
|
|||
return mapMarker;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getSupportedMenuStatesPortrait() {
|
||||
return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needTypeStr() {
|
||||
return !Algorithms.isEmpty(getNameStr());
|
||||
|
|
|
@ -13,6 +13,7 @@ public class MyLocationMenuController extends MenuController {
|
|||
|
||||
public MyLocationMenuController(MapActivity mapActivity, PointDescription pointDescription) {
|
||||
super(new MenuBuilder(mapActivity), pointDescription, mapActivity);
|
||||
builder.setShowNearestWiki(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -24,11 +25,6 @@ public class MyLocationMenuController extends MenuController {
|
|||
return getLatLon();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getSupportedMenuStatesPortrait() {
|
||||
return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeStr() {
|
||||
return getPointDescription().getTypeName();
|
||||
|
|
|
@ -16,6 +16,7 @@ public class PointDescriptionMenuController extends MenuController {
|
|||
|
||||
public PointDescriptionMenuController(MapActivity mapActivity, final PointDescription pointDescription) {
|
||||
super(new MenuBuilder(mapActivity), pointDescription, mapActivity);
|
||||
builder.setShowNearestWiki(true);
|
||||
initData();
|
||||
}
|
||||
|
||||
|
@ -33,11 +34,6 @@ public class PointDescriptionMenuController extends MenuController {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getSupportedMenuStatesPortrait() {
|
||||
return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN | MenuState.FULL_SCREEN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean displayStreetNameInTitle() {
|
||||
return true;
|
||||
|
|
|
@ -15,6 +15,7 @@ public class RenderedObjectMenuController extends MenuController {
|
|||
|
||||
public RenderedObjectMenuController(MapActivity mapActivity, PointDescription pointDescription, final RenderedObject renderedObject) {
|
||||
super(new MenuBuilder(mapActivity), pointDescription, mapActivity);
|
||||
builder.setShowNearestWiki(true);
|
||||
this.renderedObject = renderedObject;
|
||||
}
|
||||
|
||||
|
@ -30,11 +31,6 @@ public class RenderedObjectMenuController extends MenuController {
|
|||
return renderedObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getSupportedMenuStatesPortrait() {
|
||||
return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN | MenuState.FULL_SCREEN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean displayStreetNameInTitle() {
|
||||
return Algorithms.isEmpty(getNameStr());
|
||||
|
|
|
@ -19,6 +19,7 @@ public class TargetPointMenuController extends MenuController {
|
|||
public TargetPointMenuController(MapActivity mapActivity, PointDescription pointDescription, TargetPoint targetPoint) {
|
||||
super(new MenuBuilder(mapActivity), pointDescription, mapActivity);
|
||||
this.targetPoint = targetPoint;
|
||||
builder.setShowNearestWiki(true);
|
||||
final TargetPointsHelper targetPointsHelper = getMapActivity().getMyApplication().getTargetPointsHelper();
|
||||
final int intermediatePointsCount = targetPointsHelper.getIntermediatePoints().size();
|
||||
RoutingHelper routingHelper = getMapActivity().getMyApplication().getRoutingHelper();
|
||||
|
@ -66,11 +67,6 @@ public class TargetPointMenuController extends MenuController {
|
|||
return targetPoint;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getSupportedMenuStatesPortrait() {
|
||||
return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needTypeStr() {
|
||||
return !Algorithms.isEmpty(getNameStr());
|
||||
|
|
|
@ -61,11 +61,6 @@ public class TransportRouteController extends MenuController {
|
|||
return transportRoute;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getSupportedMenuStatesPortrait() {
|
||||
return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN | MenuState.FULL_SCREEN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLeftIconId() {
|
||||
return this.transportRoute.type == null ?
|
||||
|
|
|
@ -98,11 +98,6 @@ public class TransportStopController extends MenuController {
|
|||
return transportStop;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getSupportedMenuStatesPortrait() {
|
||||
return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN | MenuState.FULL_SCREEN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLeftIconId() {
|
||||
if (topType == null) {
|
||||
|
|
|
@ -33,11 +33,6 @@ public class WptPtMenuController extends MenuController {
|
|||
return wpt;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getSupportedMenuStatesPortrait() {
|
||||
return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN | MenuState.FULL_SCREEN;
|
||||
}
|
||||
|
||||
/*
|
||||
@Override
|
||||
public boolean handleSingleTapOnMap() {
|
||||
|
|
|
@ -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, false, null);
|
||||
buildRow(view, R.drawable.ic_group, notes.getAuthor(), 0, false, 0, false, null);
|
||||
buildRow(view, R.drawable.ic_action_note_dark, notes.getText(), 0, false, null, false, 0, false, null);
|
||||
buildRow(view, R.drawable.ic_group, notes.getAuthor(), 0, false, null, false, 0, false, null);
|
||||
|
||||
} 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, false, null);
|
||||
buildRow(view, resId, poiTranslation, 0, false, null, false, 0, false, null);
|
||||
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, false, null);
|
||||
buildRow(view, R.drawable.ic_action_info_dark, text, 0, false, null, false, 0, false, null);
|
||||
}
|
||||
}
|
||||
|
||||
buildRow(view, R.drawable.ic_action_get_my_location, PointDescription.getLocationName(app,
|
||||
osmPoint.getLatitude(), osmPoint.getLongitude(), true)
|
||||
.replaceAll("\n", " "), 0, false, 0, false, null);
|
||||
.replaceAll("\n", " "), 0, false, null, false, 0, false, null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -118,11 +118,6 @@ public class EditPOIMenuController extends MenuController {
|
|||
return osmPoint;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getSupportedMenuStatesPortrait() {
|
||||
return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN | MenuState.FULL_SCREEN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needTypeStr() {
|
||||
return !Algorithms.isEmpty(pointTypeStr);
|
||||
|
|
|
@ -72,11 +72,6 @@ public class OsmBugMenuController extends MenuController {
|
|||
return bug;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getSupportedMenuStatesPortrait() {
|
||||
return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN | MenuState.FULL_SCREEN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Drawable getLeftIcon() {
|
||||
if (bug.isOpened()) {
|
||||
|
|
Loading…
Reference in a new issue