This commit is contained in:
Alexey Kulish 2016-11-10 15:34:20 +03:00
parent e38b2424df
commit ccaa339a4a
28 changed files with 216 additions and 145 deletions

View file

@ -10,6 +10,7 @@
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="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>

View file

@ -11,8 +11,8 @@ import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.audionotes.AudioVideoNotesPlugin.Recording;
import net.osmand.plus.mapcontextmenu.MenuBuilder;
@ -24,8 +24,8 @@ public class AudioVideoNoteMenuBuilder extends MenuBuilder {
private final Recording recording;
public AudioVideoNoteMenuBuilder(OsmandApplication app, final Recording recording) {
super(app);
public AudioVideoNoteMenuBuilder(MapActivity mapActivity, final Recording recording) {
super(mapActivity);
this.recording = recording;
}

View file

@ -22,8 +22,8 @@ public class AudioVideoNoteMenuController extends MenuController {
private AudioVideoNotesPlugin mPlugin;
private boolean mIsFileAvailable;
public AudioVideoNoteMenuController(OsmandApplication app, MapActivity mapActivity, PointDescription pointDescription, final Recording recording) {
super(new AudioVideoNoteMenuBuilder(app, recording), pointDescription, mapActivity);
public AudioVideoNoteMenuController(MapActivity mapActivity, PointDescription pointDescription, final Recording recording) {
super(new AudioVideoNoteMenuBuilder(mapActivity, recording), pointDescription, mapActivity);
this.mRecording = recording;
mPlugin = OsmandPlugin.getPlugin(AudioVideoNotesPlugin.class);
mIsFileAvailable = mRecording.getFile().exists();

View file

@ -23,6 +23,7 @@ import android.widget.Toast;
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 java.util.LinkedList;
@ -33,6 +34,7 @@ public class MenuBuilder {
public static final float SHADOW_HEIGHT_TOP_DP = 17f;
protected MapActivity mapActivity;
protected OsmandApplication app;
protected LinkedList<PlainMenuItem> plainMenuItems;
private boolean firstRow;
@ -74,8 +76,9 @@ public class MenuBuilder {
}
}
public MenuBuilder(OsmandApplication app) {
this.app = app;
public MenuBuilder(MapActivity mapActivity) {
this.mapActivity = mapActivity;
this.app = mapActivity.getMyApplication();
plainMenuItems = new LinkedList<>();
}

View file

@ -122,47 +122,47 @@ public abstract class MenuController extends BaseMenuController {
MenuController menuController = null;
if (object != null) {
if (object instanceof Amenity) {
menuController = new AmenityMenuController(app, mapActivity, pointDescription, (Amenity) object);
menuController = new AmenityMenuController(mapActivity, pointDescription, (Amenity) object);
} else if (object instanceof FavouritePoint) {
menuController = new FavouritePointMenuController(app, mapActivity, pointDescription, (FavouritePoint) object);
menuController = new FavouritePointMenuController(mapActivity, pointDescription, (FavouritePoint) object);
} else if (object instanceof SearchHistoryHelper.HistoryEntry) {
menuController = new HistoryMenuController(app, mapActivity, pointDescription, (SearchHistoryHelper.HistoryEntry) object);
menuController = new HistoryMenuController(mapActivity, pointDescription, (SearchHistoryHelper.HistoryEntry) object);
} else if (object instanceof TargetPoint) {
menuController = new TargetPointMenuController(app, mapActivity, pointDescription, (TargetPoint) object);
menuController = new TargetPointMenuController(mapActivity, pointDescription, (TargetPoint) object);
} else if (object instanceof OsMoDevice) {
menuController = new OsMoMenuController(app, mapActivity, pointDescription, (OsMoDevice) object);
menuController = new OsMoMenuController(mapActivity, pointDescription, (OsMoDevice) object);
} else if (object instanceof Recording) {
menuController = new AudioVideoNoteMenuController(app, mapActivity, pointDescription, (Recording) object);
menuController = new AudioVideoNoteMenuController(mapActivity, pointDescription, (Recording) object);
} else if (object instanceof OsmPoint) {
menuController = new EditPOIMenuController(app, mapActivity, pointDescription, (OsmPoint) object);
menuController = new EditPOIMenuController(mapActivity, pointDescription, (OsmPoint) object);
} else if (object instanceof WptPt) {
menuController = new WptPtMenuController(app, mapActivity, pointDescription, (WptPt) object);
menuController = new WptPtMenuController(mapActivity, pointDescription, (WptPt) object);
} else if (object instanceof DownloadMapObject) {
menuController = new MapDataMenuController(app, mapActivity, pointDescription, (DownloadMapObject) object);
menuController = new MapDataMenuController(mapActivity, pointDescription, (DownloadMapObject) object);
} else if (object instanceof OpenStreetNote) {
menuController = new OsmBugMenuController(app, mapActivity, pointDescription, (OpenStreetNote) object);
menuController = new OsmBugMenuController(mapActivity, pointDescription, (OpenStreetNote) object);
} else if (object instanceof GpxDisplayItem) {
menuController = new GpxItemMenuController(app, mapActivity, pointDescription, (GpxDisplayItem) object);
menuController = new GpxItemMenuController(mapActivity, pointDescription, (GpxDisplayItem) object);
} else if (object instanceof MapMarker) {
menuController = new MapMarkerMenuController(app, mapActivity, pointDescription, (MapMarker) object);
menuController = new MapMarkerMenuController(mapActivity, pointDescription, (MapMarker) object);
} else if (object instanceof TransportStopRoute) {
menuController = new TransportRouteController(app, mapActivity, pointDescription, (TransportStopRoute) object);
menuController = new TransportRouteController(mapActivity, pointDescription, (TransportStopRoute) object);
} else if (object instanceof TransportStop) {
menuController = new TransportStopController(app, mapActivity, pointDescription, (TransportStop) object);
menuController = new TransportStopController(mapActivity, pointDescription, (TransportStop) object);
} else if (object instanceof LatLon) {
if (pointDescription.isParking()) {
menuController = new ParkingPositionMenuController(app, mapActivity, pointDescription);
menuController = new ParkingPositionMenuController(mapActivity, pointDescription);
} else if (pointDescription.isMyLocation()) {
menuController = new MyLocationMenuController(app, mapActivity, pointDescription);
menuController = new MyLocationMenuController(mapActivity, pointDescription);
}
} else if (object instanceof RouteDataObject) {
menuController = new ImpassibleRoadsMenuController(app, mapActivity, pointDescription, (RouteDataObject) object);
menuController = new ImpassibleRoadsMenuController(mapActivity, pointDescription, (RouteDataObject) object);
} else if (object instanceof RenderedObject) {
menuController = new RenderedObjectMenuController(app, mapActivity, pointDescription, (RenderedObject) object);
menuController = new RenderedObjectMenuController(mapActivity, pointDescription, (RenderedObject) object);
}
}
if (menuController == null) {
menuController = new PointDescriptionMenuController(app, mapActivity, pointDescription);
menuController = new PointDescriptionMenuController(mapActivity, pointDescription);
}
menuController.menuType = menuType;
menuController.setLatLon(latLon);

View file

@ -1,11 +1,13 @@
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;
@ -19,44 +21,54 @@ 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.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.OsmandApplication;
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(OsmandApplication app, final Amenity amenity) {
super(app);
public AmenityMenuBuilder(MapActivity mapActivity, final Amenity amenity) {
super(mapActivity);
this.amenity = amenity;
processNearstWiki();
}
private void buildRow(View view, int iconId, String text, String textPrefix,
final String textDescription, boolean collapsable,
boolean collapsable, final View collapsableView,
int textColor, boolean isWiki, boolean isText, boolean needLinks,
boolean isPhoneNumber, boolean isUrl) {
buildRow(view, getRowIcon(iconId), text, textPrefix, textDescription, collapsable, textColor,
buildRow(view, getRowIcon(iconId), text, textPrefix, collapsable, collapsableView, textColor,
isWiki, isText, needLinks, isPhoneNumber, isUrl);
}
protected void buildRow(final View view, Drawable icon, final String text, final String textPrefix,
final String textDescription, boolean collapsable,
boolean collapsable, final View collapsableView,
int textColor, boolean isWiki, boolean isText, boolean needLinks,
boolean isPhoneNumber, boolean isUrl) {
@ -71,6 +83,11 @@ public class AmenityMenuBuilder extends MenuBuilder {
txt = text;
}
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);
@ -84,6 +101,8 @@ public class AmenityMenuBuilder extends MenuBuilder {
}
});
baseView.addView(ll);
// Icon
LinearLayout llIcon = new LinearLayout(view.getContext());
llIcon.setOrientation(LinearLayout.HORIZONTAL);
@ -149,7 +168,7 @@ public class AmenityMenuBuilder extends MenuBuilder {
llText.addView(textView);
final ImageView iconViewCollapse = new ImageView(view.getContext());
if (collapsable && !Algorithms.isEmpty(textDescription)) {
if (collapsable && collapsableView != null) {
// Icon
LinearLayout llIconCollapse = new LinearLayout(view.getContext());
llIconCollapse.setLayoutParams(new LinearLayout.LayoutParams(dpToPx(40f), dpToPx(48f)));
@ -162,47 +181,28 @@ public class AmenityMenuBuilder extends MenuBuilder {
llIconCollapseParams.gravity = Gravity.CENTER_VERTICAL;
iconViewCollapse.setLayoutParams(llIconCollapseParams);
iconViewCollapse.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
iconViewCollapse.setImageDrawable(app.getIconsCache().getThemedIcon(iconViewCollapse.getTag() == null ?
iconViewCollapse.setImageDrawable(app.getIconsCache().getThemedIcon(collapsableView.getVisibility() == View.GONE ?
R.drawable.ic_action_arrow_down : R.drawable.ic_action_arrow_up));
llIconCollapse.addView(iconViewCollapse);
}
if (!Algorithms.isEmpty(textDescription)) {
final TextView textViewDesc = new TextView(view.getContext());
boolean collapsed = false;
if (collapsable) {
collapsed = textView.getTag() == null;
ll.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (iconViewCollapse.getTag() != null) {
textViewDesc.setVisibility(View.GONE);
iconViewCollapse.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_arrow_down));
iconViewCollapse.setTag(null);
} else {
textViewDesc.setVisibility(View.VISIBLE);
iconViewCollapse.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_arrow_up));
iconViewCollapse.setTag(1);
}
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));
}
});
}
textViewDesc.setVisibility(collapsed ? View.GONE : View.VISIBLE);
LinearLayout.LayoutParams llTextDescParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
llTextDescParams.setMargins(0, 0, 0, collapsable ? dpToPx(13f) : dpToPx(8f));
textViewDesc.setLayoutParams(llTextDescParams);
textViewDesc.setTextSize(16);
textViewDesc.setTextColor(app.getResources().getColor(light ? R.color.ctx_menu_info_text_light : R.color.ctx_menu_info_text_dark));
textViewDesc.setText(textDescription);
llText.addView(textViewDesc);
}
});
baseView.addView(collapsableView);
}
if (isWiki) {
AppCompatButton wikiButton = new AppCompatButton(view.getContext());
LinearLayout.LayoutParams llWikiButtonParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
llWikiButtonParams.setMargins(0, dpToPx(10f), 0, dpToPx(10f));
llWikiButtonParams.setMargins(0, dpToPx(10f), dpToPx(2f), dpToPx(10f));
wikiButton.setLayoutParams(llWikiButtonParams);
wikiButton.setPadding(dpToPx(14f), 0, dpToPx(14f), 0);
wikiButton.setBackgroundResource(R.drawable.blue_button_drawable);
@ -217,7 +217,7 @@ public class AmenityMenuBuilder extends MenuBuilder {
llText.addView(wikiButton);
}
((LinearLayout) view).addView(ll);
((LinearLayout) view).addView(baseView);
if (isPhoneNumber) {
ll.setOnClickListener(new View.OnClickListener() {
@ -271,6 +271,55 @@ 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;
@ -290,7 +339,7 @@ public class AmenityMenuBuilder extends MenuBuilder {
String vl = e.getValue();
String textPrefix = "";
String textDescription = "";
View collapsableView = null;
boolean collapsable = false;
boolean isWiki = false;
boolean isText = false;
@ -339,7 +388,7 @@ public class AmenityMenuBuilder extends MenuBuilder {
continue;
} else if (Amenity.OPENING_HOURS.equals(key)) {
iconId = R.drawable.ic_action_time;
textDescription = amenity.getOpeningHours();
collapsableView = getCollapsableTextView(view.getContext(), true, amenity.getOpeningHours());
collapsable = true;
OpeningHoursParser.OpeningHours rs = OpeningHoursParser.parseOpenedHours(amenity.getOpeningHours());
if (rs != null) {
@ -418,12 +467,12 @@ public class AmenityMenuBuilder extends MenuBuilder {
if (isDescription) {
descriptions.add(new AmenityInfoRow(key, R.drawable.ic_action_note_dark, textPrefix,
vl, textDescription, collapsable, 0, false, true, true, 0, "", false, false));
vl, collapsable, collapsableView, 0, false, true, true, 0, "", false, false));
} else if (icon != null) {
infoRows.add(new AmenityInfoRow(key, icon, textPrefix, vl, textDescription, collapsable,
infoRows.add(new AmenityInfoRow(key, icon, textPrefix, vl, collapsable, collapsableView,
textColor, isWiki, isText, needLinks, poiTypeOrder, poiTypeKeyName, isPhoneNumber, isUrl));
} else {
infoRows.add(new AmenityInfoRow(key, iconId, textPrefix, vl, textDescription, collapsable,
infoRows.add(new AmenityInfoRow(key, iconId, textPrefix, vl, collapsable, collapsableView,
textColor, isWiki, isText, needLinks, poiTypeOrder, poiTypeKeyName, isPhoneNumber, isUrl));
}
}
@ -463,6 +512,14 @@ public class AmenityMenuBuilder extends MenuBuilder {
buildAmenityRow(view, info);
}
if (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),
0, false, false, false, 1000, null, false, false);
buildAmenityRow(view, wikiInfo);
}
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);
@ -470,21 +527,44 @@ public class AmenityMenuBuilder extends MenuBuilder {
public void buildAmenityRow(View view, AmenityInfoRow info) {
if (info.icon != null) {
buildRow(view, info.icon, info.text, info.textPrefix, info.textDescription, info.collapsable,
buildRow(view, info.icon, info.text, info.textPrefix, info.collapsable, info.collapsableView,
info.textColor, info.isWiki, info.isText, info.needLinks, info.isPhoneNumber, info.isUrl);
} else if (info.iconId != 0) {
buildRow(view, info.iconId, info.text, info.textPrefix, info.textDescription, info.collapsable,
buildRow(view, info.iconId, info.text, info.textPrefix, info.collapsable, info.collapsableView,
info.textColor, info.isWiki, info.isText, info.needLinks, info.isPhoneNumber, info.isUrl);
}
}
private void processNearstWiki() {
QuadRect rect = MapUtils.calculateLatLonBbox(
amenity.getLocation().getLatitude(), amenity.getLocation().getLongitude(), 100);
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);
for (Amenity wiki : nearestWiki) {
if (wiki.getId().equals(amenity.getId())) {
nearestWiki.remove(wiki);
break;
}
}
}
private static class AmenityInfoRow {
private String key;
private Drawable icon;
private int iconId;
private String textPrefix;
private String text;
private String textDescription;
private View collapsableView;
private boolean collapsable;
private int textColor;
private boolean isWiki;
@ -496,15 +576,15 @@ public class AmenityMenuBuilder extends MenuBuilder {
private String name;
public AmenityInfoRow(String key, Drawable icon, String textPrefix, String text,
String textDescription, boolean collapsable,
boolean collapsable, View collapsableView,
int textColor, boolean isWiki, boolean isText, boolean needLinks,
int order, String name, boolean isPhoneNumber, boolean isUrl) {
this.key = key;
this.icon = icon;
this.textPrefix = textPrefix;
this.text = text;
this.textDescription = textDescription;
this.collapsable = collapsable;
this.collapsableView = collapsableView;
this.textColor = textColor;
this.isWiki = isWiki;
this.isText = isText;
@ -516,15 +596,15 @@ public class AmenityMenuBuilder extends MenuBuilder {
}
public AmenityInfoRow(String key, int iconId, String textPrefix, String text,
String textDescription, boolean collapsable,
boolean collapsable, View collapsableView,
int textColor, boolean isWiki, boolean isText, boolean needLinks,
int order, String name, boolean isPhoneNumber, boolean isUrl) {
this.key = key;
this.iconId = iconId;
this.textPrefix = textPrefix;
this.text = text;
this.textDescription = textDescription;
this.collapsable = collapsable;
this.collapsableView = collapsableView;
this.textColor = textColor;
this.isWiki = isWiki;
this.isText = isText;

View file

@ -9,7 +9,7 @@ import net.osmand.data.FavouritePoint;
import net.osmand.data.QuadRect;
import net.osmand.data.TransportStop;
import net.osmand.osm.PoiCategory;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.mapcontextmenu.MenuBuilder;
import net.osmand.util.MapUtils;
@ -20,8 +20,8 @@ public class FavouritePointMenuBuilder extends MenuBuilder {
private final FavouritePoint fav;
private Object originObject;
public FavouritePointMenuBuilder(OsmandApplication app, final FavouritePoint fav) {
super(app);
public FavouritePointMenuBuilder(MapActivity mapActivity, final FavouritePoint fav) {
super(mapActivity);
this.fav = fav;
acquireOriginObject();
}
@ -46,7 +46,7 @@ public class FavouritePointMenuBuilder extends MenuBuilder {
public void buildInternal(View view) {
if (originObject != null) {
if (originObject instanceof Amenity) {
AmenityMenuBuilder builder = new AmenityMenuBuilder(app, (Amenity) originObject);
AmenityMenuBuilder builder = new AmenityMenuBuilder(mapActivity, (Amenity) originObject);
builder.setLight(light);
builder.buildInternal(view);
}

View file

@ -10,8 +10,8 @@ import android.widget.TextView;
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.helpers.GpxUiHelper;
import net.osmand.plus.mapcontextmenu.MenuBuilder;
import net.osmand.util.Algorithms;
@ -19,8 +19,8 @@ import net.osmand.util.Algorithms;
public class GpxItemMenuBuilder extends MenuBuilder {
private GpxDisplayItem item;
public GpxItemMenuBuilder(OsmandApplication app, GpxDisplayItem item) {
super(app);
public GpxItemMenuBuilder(MapActivity mapActivity, GpxDisplayItem item) {
super(mapActivity);
this.item = item;
}

View file

@ -4,8 +4,8 @@ import android.view.View;
import net.osmand.plus.GPXUtilities.WptPt;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.mapcontextmenu.MenuBuilder;
import net.osmand.plus.views.POIMapLayer;
import net.osmand.util.Algorithms;
@ -17,8 +17,8 @@ public class WptPtMenuBuilder extends MenuBuilder {
private final WptPt wpt;
public WptPtMenuBuilder(OsmandApplication app, final WptPt wpt) {
super(app);
public WptPtMenuBuilder(MapActivity mapActivity, final WptPt wpt) {
super(mapActivity);
this.wpt = wpt;
}

View file

@ -11,7 +11,6 @@ import net.osmand.data.TransportStop;
import net.osmand.osm.PoiCategory;
import net.osmand.osm.PoiFilter;
import net.osmand.osm.PoiType;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.mapcontextmenu.MapContextMenu;
@ -36,8 +35,8 @@ public class AmenityMenuController extends MenuController {
private Amenity amenity;
private List<TransportStopRoute> routes = new ArrayList<>();
public AmenityMenuController(OsmandApplication app, MapActivity mapActivity, PointDescription pointDescription, Amenity amenity) {
super(new AmenityMenuBuilder(app, amenity), pointDescription, mapActivity);
public AmenityMenuController(MapActivity mapActivity, PointDescription pointDescription, Amenity amenity) {
super(new AmenityMenuBuilder(mapActivity, amenity), pointDescription, mapActivity);
this.amenity = amenity;
if (amenity.getType().getKeyName().equals("transportation")) {
boolean showTransportStops = false;

View file

@ -8,7 +8,6 @@ import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.data.TransportStop;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.FavoriteImageDrawable;
@ -22,8 +21,8 @@ public class FavouritePointMenuController extends MenuController {
private FavouritePoint fav;
public FavouritePointMenuController(OsmandApplication app, MapActivity mapActivity, PointDescription pointDescription, final FavouritePoint fav) {
super(new FavouritePointMenuBuilder(app, fav), pointDescription, mapActivity);
public FavouritePointMenuController(MapActivity mapActivity, PointDescription pointDescription, final FavouritePoint fav) {
super(new FavouritePointMenuBuilder(mapActivity, fav), pointDescription, mapActivity);
this.fav = fav;
}
@ -112,7 +111,7 @@ public class FavouritePointMenuController extends MenuController {
} else if (originObject instanceof TransportStop) {
TransportStop stop = (TransportStop) originObject;
TransportStopController transportStopController =
new TransportStopController(getMapActivity().getMyApplication(), getMapActivity(), pointDescription, stop);
new TransportStopController(getMapActivity(), pointDescription, stop);
transportStopController.addPlainMenuItems(builder, latLon);
addMyLocationToPlainItems(latLon);
}

View file

@ -4,7 +4,6 @@ import android.graphics.drawable.Drawable;
import net.osmand.data.PointDescription;
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.mapcontextmenu.MenuController;
@ -13,8 +12,8 @@ import net.osmand.plus.mapcontextmenu.builders.GpxItemMenuBuilder;
public class GpxItemMenuController extends MenuController {
private GpxDisplayItem item;
public GpxItemMenuController(OsmandApplication app, MapActivity mapActivity, PointDescription pointDescription, GpxDisplayItem item) {
super(new GpxItemMenuBuilder(app, item), pointDescription, mapActivity);
public GpxItemMenuController(MapActivity mapActivity, PointDescription pointDescription, GpxDisplayItem item) {
super(new GpxItemMenuBuilder(mapActivity, item), pointDescription, mapActivity);
this.item = item;
}

View file

@ -3,7 +3,6 @@ package net.osmand.plus.mapcontextmenu.controllers;
import android.graphics.drawable.Drawable;
import net.osmand.data.PointDescription;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.search.SearchHistoryFragment;
@ -17,8 +16,8 @@ public class HistoryMenuController extends MenuController {
private HistoryEntry entry;
private boolean hasTypeInDescription;
public HistoryMenuController(OsmandApplication app, MapActivity mapActivity, PointDescription pointDescription, final HistoryEntry entry) {
super(new MenuBuilder(app), pointDescription, mapActivity);
public HistoryMenuController(MapActivity mapActivity, PointDescription pointDescription, final HistoryEntry entry) {
super(new MenuBuilder(mapActivity), pointDescription, mapActivity);
this.entry = entry;
initData();
}

View file

@ -16,10 +16,11 @@ public class ImpassibleRoadsMenuController extends MenuController {
private RouteDataObject route;
public ImpassibleRoadsMenuController(final OsmandApplication app, final MapActivity mapActivity,
public ImpassibleRoadsMenuController(final MapActivity mapActivity,
PointDescription pointDescription, RouteDataObject route) {
super(new MenuBuilder(app), pointDescription, mapActivity);
super(new MenuBuilder(mapActivity), pointDescription, mapActivity);
this.route = route;
final OsmandApplication app = mapActivity.getMyApplication();
rightTitleButtonController = new TitleButtonController() {
@Override
public void buttonPressed() {

View file

@ -52,11 +52,12 @@ public class MapDataMenuController extends MenuController {
private DownloadIndexesThread downloadThread;
public MapDataMenuController(final OsmandApplication app, final MapActivity mapActivity, PointDescription pointDescription, final DownloadMapObject mapObject) {
super(new MenuBuilder(app), pointDescription, mapActivity);
public MapDataMenuController(final MapActivity mapActivity, PointDescription pointDescription, final DownloadMapObject mapObject) {
super(new MenuBuilder(mapActivity), pointDescription, mapActivity);
this.mapObject = mapObject;
indexItem = mapObject.getIndexItem();
localIndexInfo = mapObject.getLocalIndexInfo();
final OsmandApplication app = mapActivity.getMyApplication();
downloadThread = app.getDownloadThread();
if (indexItem != null) {
downloaded = indexItem.isDownloaded();

View file

@ -5,7 +5,6 @@ import android.graphics.drawable.Drawable;
import net.osmand.data.PointDescription;
import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.helpers.MapMarkerDialogHelper;
@ -17,10 +16,10 @@ public class MapMarkerMenuController extends MenuController {
private MapMarker mapMarker;
public MapMarkerMenuController(OsmandApplication app, MapActivity mapActivity, PointDescription pointDescription, MapMarker mapMarker) {
super(new MenuBuilder(app), pointDescription, mapActivity);
public MapMarkerMenuController(MapActivity mapActivity, PointDescription pointDescription, MapMarker mapMarker) {
super(new MenuBuilder(mapActivity), pointDescription, mapActivity);
this.mapMarker = mapMarker;
final MapMarkersHelper markersHelper = app.getMapMarkersHelper();
final MapMarkersHelper markersHelper = mapActivity.getMyApplication().getMapMarkersHelper();
leftTitleButtonController = new TitleButtonController() {
@Override
public void buttonPressed() {

View file

@ -2,10 +2,8 @@ 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.ApplicationMode;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.mapcontextmenu.MenuBuilder;
@ -13,8 +11,8 @@ import net.osmand.plus.mapcontextmenu.MenuController;
public class MyLocationMenuController extends MenuController {
public MyLocationMenuController(OsmandApplication app, MapActivity mapActivity, PointDescription pointDescription) {
super(new MenuBuilder(app), pointDescription, mapActivity);
public MyLocationMenuController(MapActivity mapActivity, PointDescription pointDescription) {
super(new MenuBuilder(mapActivity), pointDescription, mapActivity);
}
@Override

View file

@ -3,7 +3,6 @@ package net.osmand.plus.mapcontextmenu.controllers;
import android.graphics.drawable.Drawable;
import net.osmand.data.PointDescription;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.search.SearchHistoryFragment;
@ -15,8 +14,8 @@ public class PointDescriptionMenuController extends MenuController {
private boolean hasTypeInDescription;
public PointDescriptionMenuController(OsmandApplication app, MapActivity mapActivity, final PointDescription pointDescription) {
super(new MenuBuilder(app), pointDescription, mapActivity);
public PointDescriptionMenuController(MapActivity mapActivity, final PointDescription pointDescription) {
super(new MenuBuilder(mapActivity), pointDescription, mapActivity);
initData();
}

View file

@ -2,7 +2,6 @@ package net.osmand.plus.mapcontextmenu.controllers;
import net.osmand.NativeLibrary.RenderedObject;
import net.osmand.data.PointDescription;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.mapcontextmenu.MenuBuilder;
@ -14,8 +13,8 @@ public class RenderedObjectMenuController extends MenuController {
private RenderedObject renderedObject;
public RenderedObjectMenuController(OsmandApplication app, MapActivity mapActivity, PointDescription pointDescription, final RenderedObject renderedObject) {
super(new MenuBuilder(app), pointDescription, mapActivity);
public RenderedObjectMenuController(MapActivity mapActivity, PointDescription pointDescription, final RenderedObject renderedObject) {
super(new MenuBuilder(mapActivity), pointDescription, mapActivity);
this.renderedObject = renderedObject;
}

View file

@ -3,7 +3,6 @@ package net.osmand.plus.mapcontextmenu.controllers;
import android.graphics.drawable.Drawable;
import net.osmand.data.PointDescription;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper;
import net.osmand.plus.TargetPointsHelper.TargetPoint;
@ -17,8 +16,8 @@ public class TargetPointMenuController extends MenuController {
private TargetPoint targetPoint;
public TargetPointMenuController(OsmandApplication app, MapActivity mapActivity, PointDescription pointDescription, TargetPoint targetPoint) {
super(new MenuBuilder(app), pointDescription, mapActivity);
public TargetPointMenuController(MapActivity mapActivity, PointDescription pointDescription, TargetPoint targetPoint) {
super(new MenuBuilder(mapActivity), pointDescription, mapActivity);
this.targetPoint = targetPoint;
final TargetPointsHelper targetPointsHelper = getMapActivity().getMyApplication().getTargetPointsHelper();
final int intermediatePointsCount = targetPointsHelper.getIntermediatePoints().size();

View file

@ -7,7 +7,6 @@ import net.osmand.binary.OsmandOdb.TransportRouteStop;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.data.TransportStop;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.mapcontextmenu.MapContextMenu;
@ -24,9 +23,9 @@ public class TransportRouteController extends MenuController {
private TransportStopRoute transportRoute;
public TransportRouteController(OsmandApplication app, final MapActivity mapActivity, PointDescription pointDescription,
public TransportRouteController(final MapActivity mapActivity, PointDescription pointDescription,
final TransportStopRoute transportRoute) {
super(new MenuBuilder(app), pointDescription, mapActivity);
super(new MenuBuilder(mapActivity), pointDescription, mapActivity);
this.transportRoute = transportRoute;
toolbarController = new ContextMenuToolbarController(this);
toolbarController.setTitle(getNameStr());

View file

@ -78,9 +78,9 @@ public class TransportStopController extends MenuController {
private List<TransportStopRoute> routes = new ArrayList<>();
private TransportStopType topType;
public TransportStopController(OsmandApplication app, MapActivity mapActivity,
public TransportStopController(MapActivity mapActivity,
PointDescription pointDescription, TransportStop transportStop) {
super(new MenuBuilder(app), pointDescription, mapActivity);
super(new MenuBuilder(mapActivity), pointDescription, mapActivity);
this.transportStop = transportStop;
processTransportStop();
}

View file

@ -5,7 +5,6 @@ import android.support.v4.content.ContextCompat;
import net.osmand.data.PointDescription;
import net.osmand.plus.GPXUtilities.WptPt;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.FavoriteImageDrawable;
@ -17,8 +16,8 @@ public class WptPtMenuController extends MenuController {
private WptPt wpt;
public WptPtMenuController(OsmandApplication app, MapActivity mapActivity, PointDescription pointDescription, WptPt wpt) {
super(new WptPtMenuBuilder(app, wpt), pointDescription, mapActivity);
public WptPtMenuController(MapActivity mapActivity, PointDescription pointDescription, WptPt wpt) {
super(new WptPtMenuBuilder(mapActivity, wpt), pointDescription, mapActivity);
this.wpt = wpt;
}

View file

@ -5,8 +5,8 @@ import android.view.View;
import net.osmand.data.PointDescription;
import net.osmand.osm.MapPoiTypes;
import net.osmand.osm.PoiType;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.mapcontextmenu.MenuBuilder;
import net.osmand.plus.render.RenderingIcons;
@ -16,8 +16,8 @@ public class EditPOIMenuBuilder extends MenuBuilder {
private final OsmPoint osmPoint;
public EditPOIMenuBuilder(OsmandApplication app, final OsmPoint osmPoint) {
super(app);
public EditPOIMenuBuilder(MapActivity mapActivity, final OsmPoint osmPoint) {
super(mapActivity);
this.osmPoint = osmPoint;
}

View file

@ -6,7 +6,6 @@ import android.support.annotation.NonNull;
import android.support.v7.app.AlertDialog;
import net.osmand.data.PointDescription;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
@ -23,8 +22,8 @@ public class EditPOIMenuController extends MenuController {
private String pointTypeStr;
private ProgressDialogPoiUploader poiUploader;
public EditPOIMenuController(OsmandApplication app, final MapActivity mapActivity, PointDescription pointDescription, OsmPoint osmPoint) {
super(new EditPOIMenuBuilder(app, osmPoint), pointDescription, mapActivity);
public EditPOIMenuController(final MapActivity mapActivity, PointDescription pointDescription, OsmPoint osmPoint) {
super(new EditPOIMenuBuilder(mapActivity, osmPoint), pointDescription, mapActivity);
this.osmPoint = osmPoint;
plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);

View file

@ -4,7 +4,6 @@ import android.graphics.drawable.Drawable;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
@ -17,8 +16,8 @@ public class OsmBugMenuController extends MenuController {
private OsmEditingPlugin plugin;
private OpenStreetNote bug;
public OsmBugMenuController(OsmandApplication app, MapActivity mapActivity, PointDescription pointDescription, OpenStreetNote bug) {
super(new MenuBuilder(app), pointDescription, mapActivity);
public OsmBugMenuController(MapActivity mapActivity, PointDescription pointDescription, OpenStreetNote bug) {
super(new MenuBuilder(mapActivity), pointDescription, mapActivity);
plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
this.bug = bug;

View file

@ -19,8 +19,8 @@ public class OsMoMenuController extends MenuController {
private OsMoDevice device;
public OsMoMenuController(OsmandApplication app, MapActivity mapActivity, PointDescription pointDescription, OsMoDevice device) {
super(new MenuBuilder(app), pointDescription, mapActivity);
public OsMoMenuController(MapActivity mapActivity, PointDescription pointDescription, OsMoDevice device) {
super(new MenuBuilder(mapActivity), pointDescription, mapActivity);
this.device = device;
leftTitleButtonController = new TitleButtonController() {

View file

@ -3,7 +3,6 @@ package net.osmand.plus.parkingpoint;
import android.graphics.drawable.Drawable;
import net.osmand.data.PointDescription;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
@ -16,8 +15,8 @@ public class ParkingPositionMenuController extends MenuController {
private ParkingPositionPlugin plugin;
private String parkingDescription = "";
public ParkingPositionMenuController(OsmandApplication app, MapActivity mapActivity, PointDescription pointDescription) {
super(new MenuBuilder(app), pointDescription, mapActivity);
public ParkingPositionMenuController(MapActivity mapActivity, PointDescription pointDescription) {
super(new MenuBuilder(mapActivity), pointDescription, mapActivity);
plugin = OsmandPlugin.getPlugin(ParkingPositionPlugin.class);
if (plugin != null) {
buildParkingDescription(mapActivity);