Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
849254aaea
8 changed files with 377 additions and 111 deletions
|
@ -100,7 +100,39 @@ public class DownloadResourceGroup {
|
|||
this.type = type;
|
||||
this.parentGroup = parentGroup;
|
||||
}
|
||||
|
||||
|
||||
public WorldRegion getIndexItemRegion(IndexItem item) {
|
||||
DownloadResourceGroup group = getIndexItemGroup(item);
|
||||
if (group != null) {
|
||||
if (group.getRegion() != null) {
|
||||
return group.getRegion();
|
||||
} else if (group.getParentGroup() != null) {
|
||||
return group.getParentGroup().getRegion();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public DownloadResourceGroup getIndexItemGroup(IndexItem item) {
|
||||
DownloadResourceGroup res = null;
|
||||
for (DownloadResourceGroup group : getGroups()) {
|
||||
if (group.getIndividualResources() != null) {
|
||||
for (IndexItem i : group.getIndividualResources()) {
|
||||
if (i == item) {
|
||||
res = group;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
res = group.getIndexItemGroup(item);
|
||||
if (res != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public void trimEmptyGroups() {
|
||||
if(groups != null) {
|
||||
for(DownloadResourceGroup gr : groups) {
|
||||
|
|
|
@ -292,6 +292,6 @@ public class DownloadResources extends DownloadResourceGroup {
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
package net.osmand.plus.mapcontextmenu;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
import net.osmand.plus.IconsCache;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
|
||||
public abstract class BaseMenuController {
|
||||
|
||||
public final static float LANDSCAPE_WIDTH_DP = 350f;
|
||||
|
||||
private MapActivity mapActivity;
|
||||
private boolean portraitMode;
|
||||
private boolean largeDevice;
|
||||
private boolean light;
|
||||
|
||||
public BaseMenuController(MapActivity mapActivity) {
|
||||
this.mapActivity = mapActivity;
|
||||
portraitMode = AndroidUiHelper.isOrientationPortrait(mapActivity);
|
||||
largeDevice = AndroidUiHelper.isXLargeDevice(mapActivity);
|
||||
light = mapActivity.getMyApplication().getSettings().isLightContent();
|
||||
}
|
||||
|
||||
public MapActivity getMapActivity() {
|
||||
return mapActivity;
|
||||
}
|
||||
|
||||
public boolean isLight() {
|
||||
return light;
|
||||
}
|
||||
|
||||
public boolean isLandscapeLayout() {
|
||||
return !portraitMode && !largeDevice;
|
||||
}
|
||||
|
||||
public float getLandscapeWidthDp() {
|
||||
return LANDSCAPE_WIDTH_DP;
|
||||
}
|
||||
|
||||
public float getHalfScreenMaxHeightKoef() {
|
||||
return .7f;
|
||||
}
|
||||
|
||||
public int getSlideInAnimation() {
|
||||
if (isLandscapeLayout()) {
|
||||
return R.anim.slide_in_left;
|
||||
} else {
|
||||
return R.anim.slide_in_bottom;
|
||||
}
|
||||
}
|
||||
|
||||
public int getSlideOutAnimation() {
|
||||
if (isLandscapeLayout()) {
|
||||
return R.anim.slide_out_left;
|
||||
} else {
|
||||
return R.anim.slide_out_bottom;
|
||||
}
|
||||
}
|
||||
|
||||
protected Drawable getIcon(int iconId) {
|
||||
return getIcon(iconId, R.color.icon_color, R.color.icon_color_light);
|
||||
}
|
||||
|
||||
protected Drawable getIcon(int iconId, int colorLightId, int colorDarkId) {
|
||||
IconsCache iconsCache = getMapActivity().getMyApplication().getIconsCache();
|
||||
return iconsCache.getIcon(iconId,
|
||||
isLight() ? colorLightId : colorDarkId);
|
||||
}
|
||||
}
|
|
@ -212,22 +212,7 @@ public class MapContextMenu {
|
|||
}
|
||||
|
||||
private void acquireMenuController() {
|
||||
menuController = null;
|
||||
if (object != null) {
|
||||
if (object instanceof Amenity) {
|
||||
menuController = new AmenityMenuController(app, mapActivity, (Amenity) object);
|
||||
} else if (object instanceof FavouritePoint) {
|
||||
menuController = new FavouritePointMenuController(app, mapActivity, (FavouritePoint) object);
|
||||
} else if (object instanceof HistoryEntry) {
|
||||
menuController = new HistoryMenuController(app, mapActivity, (HistoryEntry) object);
|
||||
} else if (object instanceof LatLon) {
|
||||
if (pointDescription.isParking()) {
|
||||
menuController = new ParkingPositionController(app, mapActivity, pointDescription, (LatLon) object);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
menuController = new PointDescriptionMenuController(app, mapActivity, pointDescription, latLon);
|
||||
}
|
||||
menuController = MenuController.getMenuController(mapActivity, latLon, pointDescription, object);
|
||||
}
|
||||
|
||||
public void onSingleTapOnMap() {
|
||||
|
|
|
@ -4,15 +4,22 @@ import android.graphics.drawable.Drawable;
|
|||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
import net.osmand.data.Amenity;
|
||||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
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.helpers.AndroidUiHelper;
|
||||
import net.osmand.plus.helpers.SearchHistoryHelper;
|
||||
import net.osmand.plus.mapcontextmenu.details.AmenityMenuController;
|
||||
import net.osmand.plus.mapcontextmenu.details.FavouritePointMenuController;
|
||||
import net.osmand.plus.mapcontextmenu.details.HistoryMenuController;
|
||||
import net.osmand.plus.mapcontextmenu.details.ParkingPositionController;
|
||||
import net.osmand.plus.mapcontextmenu.details.PointDescriptionMenuController;
|
||||
|
||||
public abstract class MenuController {
|
||||
|
||||
public final static float LANDSCAPE_WIDTH_DP = 350f;
|
||||
public abstract class MenuController extends BaseMenuController {
|
||||
|
||||
public class MenuState {
|
||||
public static final int HEADER_ONLY = 1;
|
||||
|
@ -20,30 +27,41 @@ public abstract class MenuController {
|
|||
public static final int FULL_SCREEN = 4;
|
||||
}
|
||||
|
||||
private MapActivity mapActivity;
|
||||
private MenuBuilder builder;
|
||||
private int currentMenuState;
|
||||
private boolean portraitMode;
|
||||
private boolean largeDevice;
|
||||
private boolean light;
|
||||
|
||||
public MenuController(MenuBuilder builder, MapActivity mapActivity) {
|
||||
super(mapActivity);
|
||||
this.builder = builder;
|
||||
this.mapActivity = mapActivity;
|
||||
portraitMode = AndroidUiHelper.isOrientationPortrait(mapActivity);
|
||||
largeDevice = AndroidUiHelper.isXLargeDevice(mapActivity);
|
||||
light = mapActivity.getMyApplication().getSettings().isLightContent();
|
||||
this.currentMenuState = getInitialMenuState();
|
||||
}
|
||||
|
||||
public MapActivity getMapActivity() {
|
||||
return mapActivity;
|
||||
}
|
||||
|
||||
public void build(View rootView) {
|
||||
builder.build(rootView);
|
||||
}
|
||||
|
||||
public static MenuController getMenuController(MapActivity mapActivity,
|
||||
LatLon latLon, PointDescription pointDescription, Object object) {
|
||||
OsmandApplication app = mapActivity.getMyApplication();
|
||||
MenuController menuController = null;
|
||||
if (object != null) {
|
||||
if (object instanceof Amenity) {
|
||||
menuController = new AmenityMenuController(app, mapActivity, (Amenity) object);
|
||||
} else if (object instanceof FavouritePoint) {
|
||||
menuController = new FavouritePointMenuController(app, mapActivity, (FavouritePoint) object);
|
||||
} else if (object instanceof SearchHistoryHelper.HistoryEntry) {
|
||||
menuController = new HistoryMenuController(app, mapActivity, (SearchHistoryHelper.HistoryEntry) object);
|
||||
} else if (object instanceof LatLon) {
|
||||
if (pointDescription.isParking()) {
|
||||
menuController = new ParkingPositionController(app, mapActivity, pointDescription, (LatLon) object);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
menuController = new PointDescriptionMenuController(app, mapActivity, pointDescription, latLon);
|
||||
}
|
||||
return menuController;
|
||||
}
|
||||
|
||||
public void addPlainMenuItem(int iconId, String text) {
|
||||
builder.addPlainMenuItem(iconId, text);
|
||||
}
|
||||
|
@ -59,14 +77,6 @@ public abstract class MenuController {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean isLandscapeLayout() {
|
||||
return !portraitMode && !largeDevice;
|
||||
}
|
||||
|
||||
public float getLandscapeWidthDp() {
|
||||
return LANDSCAPE_WIDTH_DP;
|
||||
}
|
||||
|
||||
public int getSupportedMenuStates() {
|
||||
if (isLandscapeLayout()) {
|
||||
return MenuState.FULL_SCREEN;
|
||||
|
@ -75,22 +85,6 @@ public abstract class MenuController {
|
|||
}
|
||||
}
|
||||
|
||||
public int getSlideInAnimation() {
|
||||
if (isLandscapeLayout()) {
|
||||
return R.anim.slide_in_left;
|
||||
} else {
|
||||
return R.anim.slide_in_bottom;
|
||||
}
|
||||
}
|
||||
|
||||
public int getSlideOutAnimation() {
|
||||
if (isLandscapeLayout()) {
|
||||
return R.anim.slide_out_left;
|
||||
} else {
|
||||
return R.anim.slide_out_bottom;
|
||||
}
|
||||
}
|
||||
|
||||
protected int getInitialMenuStatePortrait() {
|
||||
return MenuState.HEADER_ONLY;
|
||||
}
|
||||
|
@ -131,20 +125,6 @@ public abstract class MenuController {
|
|||
this.currentMenuState = currentMenuState;
|
||||
}
|
||||
|
||||
public float getHalfScreenMaxHeightKoef() {
|
||||
return .7f;
|
||||
}
|
||||
|
||||
protected Drawable getIcon(int iconId) {
|
||||
return getIcon(iconId, R.color.icon_color, R.color.icon_color_light);
|
||||
}
|
||||
|
||||
protected Drawable getIcon(int iconId, int colorLightId, int colorDarkId) {
|
||||
IconsCache iconsCache = mapActivity.getMyApplication().getIconsCache();
|
||||
return iconsCache.getIcon(iconId,
|
||||
light ? colorLightId : colorDarkId);
|
||||
}
|
||||
|
||||
public boolean hasTitleButton() {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,115 @@
|
|||
package net.osmand.plus.mapcontextmenu.other;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.mapcontextmenu.BaseMenuController;
|
||||
import net.osmand.plus.mapcontextmenu.MenuController;
|
||||
import net.osmand.plus.views.ContextMenuLayer.IContextMenuProvider;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ObjectSelectionMenu extends BaseMenuController {
|
||||
|
||||
private static final String KEY_OBJ_SEL_MENU_LATLON = "key_obj_sel_menu_latlon";
|
||||
private static final String KEY_OBJ_SEL_MENU_OBJECTS = "key_obj_sel_menu_objects";
|
||||
|
||||
private LatLon latLon;
|
||||
private LinkedList<MenuMapObject> objects = new LinkedList<>();
|
||||
|
||||
public static class MenuMapObject implements Serializable {
|
||||
|
||||
private LatLon latLon;
|
||||
private PointDescription pointDescription;
|
||||
private Object object;
|
||||
private transient MenuController controller;
|
||||
|
||||
public MenuMapObject(LatLon latLon, PointDescription pointDescription, Object object) {
|
||||
this.latLon = latLon;
|
||||
this.pointDescription = pointDescription;
|
||||
this.object = object;
|
||||
}
|
||||
|
||||
public LatLon getLatLon() {
|
||||
return latLon;
|
||||
}
|
||||
|
||||
public PointDescription getPointDescription() {
|
||||
return pointDescription;
|
||||
}
|
||||
|
||||
public Object getObject() {
|
||||
return object;
|
||||
}
|
||||
|
||||
public MenuController getController(MapActivity mapActivity) {
|
||||
if (controller == null) {
|
||||
controller = MenuController.getMenuController(mapActivity, latLon, pointDescription, object);
|
||||
}
|
||||
return controller;
|
||||
}
|
||||
}
|
||||
|
||||
private ObjectSelectionMenu(LatLon latLon, MapActivity mapActivity) {
|
||||
super(mapActivity);
|
||||
this.latLon = latLon;
|
||||
}
|
||||
|
||||
public List<MenuMapObject> getObjects() {
|
||||
return objects;
|
||||
}
|
||||
|
||||
private void createCollection(Map<Object, IContextMenuProvider> selectedObjects) {
|
||||
for (Map.Entry<Object, IContextMenuProvider> e : selectedObjects.entrySet()) {
|
||||
Object selectedObj = e.getKey();
|
||||
IContextMenuProvider contextObject = selectedObjects.get(selectedObj);
|
||||
LatLon ll = null;
|
||||
PointDescription pointDescription = null;
|
||||
if (contextObject != null) {
|
||||
ll = contextObject.getObjectLocation(selectedObj);
|
||||
pointDescription = contextObject.getObjectName(selectedObj);
|
||||
}
|
||||
if (ll == null) {
|
||||
ll = latLon;
|
||||
}
|
||||
if (pointDescription == null) {
|
||||
pointDescription = new PointDescription(latLon.getLatitude(), latLon.getLongitude());
|
||||
}
|
||||
|
||||
objects.add(new MenuMapObject(ll, pointDescription, selectedObj));
|
||||
}
|
||||
}
|
||||
|
||||
public static void show(LatLon latLon, MapActivity mapActivity, Map<Object, IContextMenuProvider> selectedObjects) {
|
||||
|
||||
ObjectSelectionMenu menu = new ObjectSelectionMenu(latLon, mapActivity);
|
||||
menu.createCollection(selectedObjects);
|
||||
}
|
||||
|
||||
public void saveMenu(Bundle bundle) {
|
||||
bundle.putSerializable(KEY_OBJ_SEL_MENU_LATLON, latLon);
|
||||
bundle.putSerializable(KEY_OBJ_SEL_MENU_OBJECTS, objects);
|
||||
}
|
||||
|
||||
public static ObjectSelectionMenu restoreMenu(Bundle bundle, MapActivity mapActivity) {
|
||||
|
||||
LatLon latLon = null;
|
||||
Object latLonObj = bundle.getSerializable(KEY_OBJ_SEL_MENU_LATLON);
|
||||
if (latLonObj != null) {
|
||||
latLon = (LatLon) latLonObj;
|
||||
}
|
||||
Object objects = bundle.getSerializable(KEY_OBJ_SEL_MENU_OBJECTS);
|
||||
|
||||
ObjectSelectionMenu menu = new ObjectSelectionMenu(latLon, mapActivity);
|
||||
if (objects != null) {
|
||||
menu.objects = (LinkedList<MenuMapObject>) objects;
|
||||
}
|
||||
|
||||
return menu;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,113 @@
|
|||
package net.osmand.plus.mapcontextmenu.other;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ListView;
|
||||
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.mapcontextmenu.other.ObjectSelectionMenu.MenuMapObject;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ObjectSelectionMenuFragment extends Fragment implements AdapterView.OnItemClickListener {
|
||||
public static final String TAG = "ObjectSelectionMenuFragment";
|
||||
|
||||
private ArrayAdapter<MenuMapObject> listAdapter;
|
||||
private ObjectSelectionMenu menu;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (savedInstanceState != null && getActivity() instanceof MapActivity) {
|
||||
menu = ObjectSelectionMenu.restoreMenu(savedInstanceState, (MapActivity) getActivity());
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.share_menu_fragment, container, false);
|
||||
|
||||
ListView listView = (ListView) view.findViewById(R.id.list);
|
||||
listAdapter = createAdapter();
|
||||
listView.setAdapter(listAdapter);
|
||||
listView.setOnItemClickListener(this);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
menu.getMapActivity().getContextMenu().setBaseFragmentVisibility(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
menu.getMapActivity().getContextMenu().setBaseFragmentVisibility(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
menu.saveMenu(outState);
|
||||
}
|
||||
|
||||
public static void showInstance(ObjectSelectionMenu menu) {
|
||||
int slideInAnim = menu.getSlideInAnimation();
|
||||
int slideOutAnim = menu.getSlideOutAnimation();
|
||||
|
||||
ObjectSelectionMenuFragment fragment = new ObjectSelectionMenuFragment();
|
||||
fragment.menu = menu;
|
||||
menu.getMapActivity().getSupportFragmentManager().beginTransaction()
|
||||
.setCustomAnimations(slideInAnim, slideOutAnim, slideInAnim, slideOutAnim)
|
||||
.add(R.id.fragmentContainer, fragment, TAG)
|
||||
.addToBackStack(TAG).commit();
|
||||
}
|
||||
|
||||
private ArrayAdapter<MenuMapObject> createAdapter() {
|
||||
final List<MenuMapObject> items = menu.getObjects();
|
||||
return new ArrayAdapter<MenuMapObject>(menu.getMapActivity(), R.layout.share_list_item, items) {
|
||||
|
||||
@SuppressLint("InflateParams")
|
||||
@Override
|
||||
public View getView(final int position, View convertView, ViewGroup parent) {
|
||||
View v = convertView;
|
||||
if (v == null) {
|
||||
v = menu.getMapActivity().getLayoutInflater().inflate(R.layout.share_list_item, null);
|
||||
}
|
||||
final MenuMapObject item = getItem(position);
|
||||
/*
|
||||
ImageView icon = (ImageView) v.findViewById(R.id.icon);
|
||||
icon.setImageDrawable(menu.getMapActivity().getMyApplication()
|
||||
.getIconsCache().getContentIcon(item.getIconResourceId()));
|
||||
TextView name = (TextView) v.findViewById(R.id.name);
|
||||
name.setText(getContext().getText(item.getTitleResourceId()));
|
||||
*/
|
||||
return v;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
//menu.share(listAdapter.getItem(position));
|
||||
dismissMenu();
|
||||
}
|
||||
|
||||
public void dismissMenu() {
|
||||
if (menu.getMapActivity().getContextMenu().isVisible()) {
|
||||
menu.getMapActivity().getContextMenu().hide();
|
||||
} else {
|
||||
menu.getMapActivity().getSupportFragmentManager().popBackStack();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,21 +8,17 @@ import net.osmand.data.LatLon;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.actions.ShareDialog;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
import net.osmand.plus.mapcontextmenu.BaseMenuController;
|
||||
import net.osmand.util.Algorithms;
|
||||
import net.osmand.util.MapUtils;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public class ShareMenu {
|
||||
|
||||
private final MapActivity mapActivity;
|
||||
public class ShareMenu extends BaseMenuController {
|
||||
|
||||
private LatLon latLon;
|
||||
private String title;
|
||||
private boolean portraitMode;
|
||||
private boolean largeDevice;
|
||||
|
||||
private static final String KEY_SHARE_MENU_LATLON = "key_share_menu_latlon";
|
||||
private static final String KEY_SHARE_MENU_POINT_TITLE = "key_share_menu_point_title";
|
||||
|
@ -51,9 +47,7 @@ public class ShareMenu {
|
|||
}
|
||||
|
||||
private ShareMenu(MapActivity mapActivity) {
|
||||
this.mapActivity = mapActivity;
|
||||
portraitMode = AndroidUiHelper.isOrientationPortrait(mapActivity);
|
||||
largeDevice = AndroidUiHelper.isXLargeDevice(mapActivity);
|
||||
super(mapActivity);
|
||||
}
|
||||
|
||||
public List<ShareItem> getItems() {
|
||||
|
@ -65,30 +59,6 @@ public class ShareMenu {
|
|||
return list;
|
||||
}
|
||||
|
||||
public boolean isLandscapeLayout() {
|
||||
return !portraitMode && !largeDevice;
|
||||
}
|
||||
|
||||
public int getSlideInAnimation() {
|
||||
if (isLandscapeLayout()) {
|
||||
return R.anim.slide_in_left;
|
||||
} else {
|
||||
return R.anim.slide_in_bottom;
|
||||
}
|
||||
}
|
||||
|
||||
public int getSlideOutAnimation() {
|
||||
if (isLandscapeLayout()) {
|
||||
return R.anim.slide_out_left;
|
||||
} else {
|
||||
return R.anim.slide_out_bottom;
|
||||
}
|
||||
}
|
||||
|
||||
public MapActivity getMapActivity() {
|
||||
return mapActivity;
|
||||
}
|
||||
|
||||
public LatLon getLatLon() {
|
||||
return latLon;
|
||||
}
|
||||
|
@ -108,7 +78,7 @@ public class ShareMenu {
|
|||
}
|
||||
|
||||
public void share(ShareItem item) {
|
||||
final int zoom = mapActivity.getMapView().getZoom();
|
||||
final int zoom = getMapActivity().getMapView().getZoom();
|
||||
final String geoUrl = MapUtils.buildGeoUrl(latLon.getLatitude(), latLon.getLongitude(), zoom);
|
||||
final String httpUrl = "http://osmand.net/go?lat=" + ((float) latLon.getLatitude())
|
||||
+ "&lon=" + ((float) latLon.getLongitude()) + "&z=" + zoom;
|
||||
|
@ -116,25 +86,25 @@ public class ShareMenu {
|
|||
if (!Algorithms.isEmpty(title)) {
|
||||
sb.append(title).append("\n");
|
||||
}
|
||||
sb.append(mapActivity.getString(R.string.search_tabs_location)).append(": ");
|
||||
sb.append(getMapActivity().getString(R.string.search_tabs_location)).append(": ");
|
||||
sb.append(geoUrl).append("\n").append(httpUrl);
|
||||
String sms = sb.toString();
|
||||
switch (item) {
|
||||
case MESSAGE:
|
||||
ShareDialog.sendMessage(mapActivity, sms);
|
||||
ShareDialog.sendMessage(getMapActivity(), sms);
|
||||
break;
|
||||
case CLIPBOARD:
|
||||
ShareDialog.sendToClipboard(mapActivity, sms);
|
||||
ShareDialog.sendToClipboard(getMapActivity(), sms);
|
||||
break;
|
||||
case GEO:
|
||||
Intent mapIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(geoUrl));
|
||||
mapActivity.startActivity(mapIntent);
|
||||
getMapActivity().startActivity(mapIntent);
|
||||
break;
|
||||
case QR_CODE:
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putFloat("LAT", (float) latLon.getLatitude());
|
||||
bundle.putFloat("LONG", (float) latLon.getLongitude());
|
||||
ShareDialog.sendQRCode(mapActivity, "LOCATION_TYPE", bundle, null);
|
||||
ShareDialog.sendQRCode(getMapActivity(), "LOCATION_TYPE", bundle, null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue