diff --git a/OsmAnd/res/drawable/bg_bottom_menu_dark.xml b/OsmAnd/res/drawable/bg_bottom_menu_dark.xml
new file mode 100644
index 0000000000..da3897aaf9
--- /dev/null
+++ b/OsmAnd/res/drawable/bg_bottom_menu_dark.xml
@@ -0,0 +1,12 @@
+
+
+ -
+
+
+ -
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/drawable/bg_bottom_menu_light.xml b/OsmAnd/res/drawable/bg_bottom_menu_light.xml
new file mode 100644
index 0000000000..14afe84331
--- /dev/null
+++ b/OsmAnd/res/drawable/bg_bottom_menu_light.xml
@@ -0,0 +1,12 @@
+
+
+ -
+
+
+ -
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/drawable/bg_left_menu_dark.xml b/OsmAnd/res/drawable/bg_left_menu_dark.xml
new file mode 100644
index 0000000000..6300bc82a3
--- /dev/null
+++ b/OsmAnd/res/drawable/bg_left_menu_dark.xml
@@ -0,0 +1,12 @@
+
+
+ -
+
+
+ -
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/drawable/bg_left_menu_light.xml b/OsmAnd/res/drawable/bg_left_menu_light.xml
new file mode 100644
index 0000000000..9edc174531
--- /dev/null
+++ b/OsmAnd/res/drawable/bg_left_menu_light.xml
@@ -0,0 +1,12 @@
+
+
+ -
+
+
+ -
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/layout-land/point_editor_fragment.xml b/OsmAnd/res/layout-land/point_editor_fragment.xml
new file mode 100644
index 0000000000..82eaecb526
--- /dev/null
+++ b/OsmAnd/res/layout-land/point_editor_fragment.xml
@@ -0,0 +1,256 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/layout-land/share_menu_fragment.xml b/OsmAnd/res/layout-land/share_menu_fragment.xml
new file mode 100644
index 0000000000..a8422a2d31
--- /dev/null
+++ b/OsmAnd/res/layout-land/share_menu_fragment.xml
@@ -0,0 +1,52 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/layout/point_editor_fragment.xml b/OsmAnd/res/layout/point_editor_fragment.xml
index 519fa141da..47b7bb7868 100644
--- a/OsmAnd/res/layout/point_editor_fragment.xml
+++ b/OsmAnd/res/layout/point_editor_fragment.xml
@@ -71,7 +71,7 @@
android:background="?android:selectableItemBackground"
android:textColor="?attr/contextMenuButtonColor"
android:text="@string/update_existing"
- android:visibility="visible"/>
+ android:visibility="gone"/>
diff --git a/OsmAnd/res/layout/point_editor_fragment_land.xml b/OsmAnd/res/layout/point_editor_fragment_land.xml
deleted file mode 100644
index a06be57cb0..0000000000
--- a/OsmAnd/res/layout/point_editor_fragment_land.xml
+++ /dev/null
@@ -1,246 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/OsmAnd/res/layout/share_list_item.xml b/OsmAnd/res/layout/share_list_item.xml
new file mode 100644
index 0000000000..6bb8835871
--- /dev/null
+++ b/OsmAnd/res/layout/share_list_item.xml
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/layout/share_menu_fragment.xml b/OsmAnd/res/layout/share_menu_fragment.xml
new file mode 100644
index 0000000000..6a04aceef2
--- /dev/null
+++ b/OsmAnd/res/layout/share_menu_fragment.xml
@@ -0,0 +1,53 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/values/attrs.xml b/OsmAnd/res/values/attrs.xml
index 3f47de8df5..f4b3be9fa3 100644
--- a/OsmAnd/res/values/attrs.xml
+++ b/OsmAnd/res/values/attrs.xml
@@ -14,6 +14,8 @@
+
+
diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml
index cff0ab2cac..84e76696c5 100644
--- a/OsmAnd/res/values/strings.xml
+++ b/OsmAnd/res/values/strings.xml
@@ -9,6 +9,9 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
-->
+ Clipboard
+ geo:
+ QR-Code
Specified category name already exists. Please define other name.
Category name
Add new category
diff --git a/OsmAnd/res/values/styles.xml b/OsmAnd/res/values/styles.xml
index 25b96c53f2..f755809156 100644
--- a/OsmAnd/res/values/styles.xml
+++ b/OsmAnd/res/values/styles.xml
@@ -67,6 +67,8 @@
- @color/bg_color_light
- @drawable/bg_card_light
- @drawable/bg_map_context_menu_light
+ - @drawable/bg_bottom_menu_light
+ - @drawable/bg_left_menu_light
- @drawable/bg_point_editor_view_light
- @color/dashboard_divider_light
- @color/divider_color
@@ -158,6 +160,8 @@
- @color/bg_color_dark
- @drawable/bg_card_dark
- @drawable/bg_map_context_menu_dark
+ - @drawable/bg_bottom_menu_dark
+ - @drawable/bg_left_menu_dark
- @drawable/bg_point_editor_view_dark
- @color/dashboard_divider_dark
- @color/dashboard_divider_dark
diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java
index 717477096f..8d863844b0 100644
--- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java
+++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java
@@ -1,10 +1,25 @@
package net.osmand.plus.activities;
-import java.io.File;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.AlertDialog.Builder;
+import android.app.Dialog;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.graphics.drawable.Drawable;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.ViewGroup;
+import android.view.WindowManager;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.ListView;
+import android.widget.TextView;
+import android.widget.Toast;
import net.londatiga.android.ActionItem;
import net.londatiga.android.QuickAction;
@@ -31,7 +46,6 @@ import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper;
import net.osmand.plus.activities.actions.OsmAndDialogs;
-import net.osmand.plus.activities.actions.ShareLocation;
import net.osmand.plus.activities.search.SearchActivity;
import net.osmand.plus.dashboard.DashboardOnMap.DashboardType;
import net.osmand.plus.dialogs.FavoriteDialogs;
@@ -44,26 +58,11 @@ import net.osmand.util.MapUtils;
import org.apache.commons.logging.Log;
-import android.app.Activity;
-import android.app.AlertDialog;
-import android.app.AlertDialog.Builder;
-import android.app.Dialog;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.graphics.drawable.Drawable;
-import android.os.AsyncTask;
-import android.os.Bundle;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.view.ViewGroup;
-import android.view.WindowManager;
-import android.widget.AdapterView;
-import android.widget.ArrayAdapter;
-import android.widget.Button;
-import android.widget.EditText;
-import android.widget.ListView;
-import android.widget.TextView;
-import android.widget.Toast;
+import java.io.File;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
public class MapActivityActions implements DialogProvider {
private static final Log LOG = PlatformUtil.getLog(MapActivityActions.class);
@@ -92,11 +91,6 @@ public class MapActivityActions implements DialogProvider {
routingHelper = mapActivity.getMyApplication().getRoutingHelper();
}
- public void shareLocation(double latitude, double longitude) {
- enhance(dialogBundle, latitude, longitude, mapActivity.getMapView().getZoom());
- new ShareLocation(mapActivity).run();
- }
-
public void showNavigationContextMenuPoint(final double latitude, final double longitude) {
final ContextMenuAdapter adapter = new ContextMenuAdapter(mapActivity);
diff --git a/OsmAnd/src/net/osmand/plus/activities/actions/ShareLocation.java b/OsmAnd/src/net/osmand/plus/activities/actions/ShareLocation.java
deleted file mode 100644
index 3208180c30..0000000000
--- a/OsmAnd/src/net/osmand/plus/activities/actions/ShareLocation.java
+++ /dev/null
@@ -1,104 +0,0 @@
-package net.osmand.plus.activities.actions;
-
-import net.osmand.plus.R;
-import net.osmand.plus.activities.MapActivity;
-import net.osmand.plus.activities.MapActivityActions;
-import net.osmand.util.MapUtils;
-import android.app.Activity;
-import android.app.AlertDialog;
-import android.app.AlertDialog.Builder;
-import android.app.Dialog;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.net.Uri;
-import android.os.Bundle;
-import android.widget.Toast;
-
-public class ShareLocation extends OsmAndAction {
-
- public ShareLocation(MapActivity mapActivity) {
- super(mapActivity);
- }
-
- @Override
- public int getDialogID() {
- return OsmAndDialogs.DIALOG_SHARE_LOCATION;
- }
-
- @Override
- public void run() {
- super.showDialog();
- }
-
- public Dialog createDialog(Activity activity, final Bundle args) {
- mapActivity = (MapActivity) activity;
- AlertDialog.Builder builder = new Builder(mapActivity);
- builder.setTitle(R.string.send_location_way_choose_title);
-// "Email", "SMS",
- builder.setItems(new String[]{
- activity.getString(R.string.shared_string_message), "Clipboard", "geo:", "QR-Code"
- }, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- final double latitude = args.getDouble(MapActivityActions.KEY_LATITUDE);
- final double longitude = args.getDouble(MapActivityActions.KEY_LONGITUDE);
- final int zoom = args.getInt(MapActivityActions.KEY_ZOOM);
- try {
- final String geoUrl = MapUtils.buildGeoUrl(latitude, longitude, zoom);
- // TODO change this to HTTPS once it is setup!
- final String httpUrl = "http://osmand.net/go?lat=" + ((float) latitude) + "&lon=" + ((float) longitude) + "&z=" + zoom;
- String sms = mapActivity.getString(R.string.send_location_sms_pattern, geoUrl, httpUrl);
- if (which == 0) {
- sendMessage(sms);
-// } else if (which == 1) {
-// sendEmail(httpUrl, geoUrl);
-// } else if (which == 2) {
-// sendSms(sms);
- } else if (which == 1) {
- sendToClipboard(sms);
- } else if (which == 2) {
- sendGeoActivity(geoUrl);
- } else if (which == 3) {
- sendQRCode(latitude, longitude);
- }
- } catch (RuntimeException e) {
- Toast.makeText(mapActivity, R.string.shared_string_io_error, Toast.LENGTH_SHORT).show();
- }
- }
- });
- return builder.create();
- }
-
- private void sendMessage(String sms) {
- ShareDialog.sendMessage(mapActivity, sms);
- }
-
-
- private void sendEmail(final String httpUrl, final String geoUrl) {
- String email = mapActivity.getString(R.string.send_location_email_pattern, httpUrl, geoUrl);
- ShareDialog.sendEmail(mapActivity, email, getString(R.string.send_location));
- }
-
- private void sendSms(String sms) {
- ShareDialog.sendSms(mapActivity, sms);
- }
-
- private void sendToClipboard(String sms) {
- ShareDialog.sendToClipboard(mapActivity, sms);
-
- }
-
- private void sendGeoActivity(final String geoUrl) {
- Intent mapIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(geoUrl));
- mapActivity.startActivity(mapIntent);
- }
-
- private void sendQRCode(final double latitude, final double longitude) {
- Bundle bundle = new Bundle();
- bundle.putFloat("LAT", (float) latitude);
- bundle.putFloat("LONG", (float) longitude);
- ShareDialog.sendQRCode(mapActivity, "LOCATION_TYPE", bundle, null);
- }
-
-
-}
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java
index 33fd07201d..f0e77d9a25 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java
@@ -23,6 +23,7 @@ import net.osmand.plus.mapcontextmenu.details.FavouritePointMenuController;
import net.osmand.plus.mapcontextmenu.details.HistoryMenuController;
import net.osmand.plus.mapcontextmenu.details.MenuController;
import net.osmand.plus.mapcontextmenu.details.PointDescriptionMenuController;
+import net.osmand.plus.mapcontextmenu.other.ShareMenu;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.views.ContextMenuLayer;
import net.osmand.plus.views.OsmandMapLayer;
@@ -397,7 +398,7 @@ public class MapContextMenu {
}
public void buttonSharePressed() {
- mapActivity.getMapActions().shareLocation(latLon.getLatitude(), latLon.getLongitude());
+ ShareMenu.show(latLon, pointDescription, mapActivity);
}
public void buttonMorePressed() {
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java
index 0d4f06bda1..1687a78b49 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java
@@ -27,7 +27,6 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
-import net.osmand.PlatformUtil;
import net.osmand.data.LatLon;
import net.osmand.data.QuadPoint;
import net.osmand.data.RotatedTileBox;
@@ -40,8 +39,6 @@ import net.osmand.plus.mapcontextmenu.details.MenuController;
import net.osmand.plus.views.AnimateDraggingMapThread;
import net.osmand.plus.views.OsmandMapTileView;
-import org.apache.commons.logging.Log;
-
import static android.util.TypedValue.COMPLEX_UNIT_DIP;
import static net.osmand.plus.mapcontextmenu.details.MenuBuilder.SHADOW_HEIGHT_BOTTOM_DP;
import static net.osmand.plus.mapcontextmenu.details.MenuBuilder.SHADOW_HEIGHT_TOP_DP;
@@ -50,7 +47,6 @@ import static net.osmand.plus.mapcontextmenu.details.MenuBuilder.SHADOW_HEIGHT_T
public class MapContextMenuFragment extends Fragment {
public static final String TAG = "MapContextMenuFragment";
- private static final Log LOG = PlatformUtil.getLog(MapContextMenuFragment.class);
public static final float FAB_PADDING_TOP_DP = 4f;
public static final float MARKER_PADDING_DP = 20f;
@@ -62,6 +58,7 @@ public class MapContextMenuFragment extends Fragment {
MapContextMenu menu;
+ private int menuTopViewHeight;
private int menuTopShadowHeight;
private int menuTopShadowAllHeight;
private int menuTitleHeight;
@@ -319,7 +316,6 @@ public class MapContextMenuFragment extends Fragment {
// FAB
fabView = (ImageView)view.findViewById(R.id.context_menu_fab_view);
- fabView.setImageDrawable(iconsCache.getIcon(menu.getFabIconId()));
fabView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@@ -438,11 +434,17 @@ public class MapContextMenuFragment extends Fragment {
@Override
public void onGlobalLayout() {
+ int newMenuTopViewHeight = view.findViewById(R.id.context_menu_top_view).getHeight();
menuTopShadowHeight = view.findViewById(R.id.context_menu_top_shadow).getHeight();
menuTopShadowAllHeight = view.findViewById(R.id.context_menu_top_shadow_all).getHeight();
menuFullHeight = view.findViewById(R.id.context_menu_main).getHeight();
- menuTitleHeight = menuTopShadowHeight + menuTopShadowAllHeight;
+ int dy = 0;
+ if (!menu.isLandscapeLayout() && menuTopViewHeight != 0) {
+ dy = newMenuTopViewHeight - menuTopViewHeight;
+ }
+ menuTopViewHeight = newMenuTopViewHeight;
+ menuTitleHeight = menuTopShadowHeight + menuTopShadowAllHeight + dy;
menuBottomViewHeight = view.findViewById(R.id.context_menu_bottom_view).getHeight();
recalculateFullHeightMax();
@@ -605,6 +607,11 @@ public class MapContextMenuFragment extends Fragment {
}
}
}
+
+ if (map.getLatitude() == latlon.getLatitude() && map.getLongitude() == latlon.getLongitude()) {
+ return;
+ }
+
if (animated) {
showOnMap(latlon, false, true);
} else {
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/details/MenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/details/MenuController.java
index 22303be18a..adeb0025c9 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/details/MenuController.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/details/MenuController.java
@@ -12,6 +12,8 @@ import net.osmand.plus.helpers.AndroidUiHelper;
public abstract class MenuController {
+ public final static float LANDSCAPE_WIDTH_DP = 350f;
+
public class MenuState {
public static final int HEADER_ONLY = 1;
public static final int HALF_SCREEN = 2;
@@ -60,7 +62,7 @@ public abstract class MenuController {
}
public float getLandscapeWidthDp() {
- return 350f;
+ return LANDSCAPE_WIDTH_DP;
}
public int getSupportedMenuStates() {
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragment.java
index ffb60c1d28..f756b9c0ad 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragment.java
@@ -66,11 +66,8 @@ public abstract class PointEditorFragment extends Fragment {
getActivity().findViewById(R.id.MapHudButtonsOverlay).setVisibility(View.INVISIBLE);
- if (getEditor().isLandscapeLayout()) {
- view = inflater.inflate(R.layout.point_editor_fragment_land, container, false);
- } else {
- view = inflater.inflate(R.layout.point_editor_fragment, container, false);
- }
+ view = inflater.inflate(R.layout.point_editor_fragment, container, false);
+
Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);
toolbar.setTitle(getToolbarTitle());
toolbar.setNavigationIcon(getMyApplication().getIconsCache().getIcon(R.drawable.abc_ic_ab_back_mtrl_am_alpha));
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/ShareMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/ShareMenu.java
new file mode 100644
index 0000000000..14bce8c8da
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/ShareMenu.java
@@ -0,0 +1,168 @@
+package net.osmand.plus.mapcontextmenu.other;
+
+import android.content.Intent;
+import android.net.Uri;
+import android.os.Bundle;
+
+import net.osmand.data.LatLon;
+import net.osmand.data.PointDescription;
+import net.osmand.plus.R;
+import net.osmand.plus.activities.MapActivity;
+import net.osmand.plus.activities.MapActivityActions;
+import net.osmand.plus.activities.actions.ShareDialog;
+import net.osmand.plus.helpers.AndroidUiHelper;
+import net.osmand.plus.mapcontextmenu.details.MenuController;
+import net.osmand.util.MapUtils;
+
+import java.util.LinkedList;
+import java.util.List;
+
+public class ShareMenu {
+
+ private final MapActivity mapActivity;
+
+ private LatLon latLon;
+ private PointDescription pointDescription;
+ 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_DESC = "key_share_menu_point_desc";
+
+ public enum ShareItem {
+ MESSAGE(R.drawable.ic_action_aircraft, R.string.shared_string_message),
+ CLIPBOARD(R.drawable.ic_action_aircraft, R.string.share_clipboard),
+ GEO(R.drawable.ic_action_aircraft, R.string.share_geo),
+ QR_CODE(R.drawable.ic_action_aircraft, R.string.share_qr_code);
+
+ final int iconResourceId;
+ final int titleResourceId;
+
+ ShareItem(int iconResourceId, int titleResourceId) {
+ this.iconResourceId = iconResourceId;
+ this.titleResourceId = titleResourceId;
+ }
+
+ public int getIconResourceId() {
+ return iconResourceId;
+ }
+
+ public int getTitleResourceId() {
+ return titleResourceId;
+ }
+ }
+
+ private ShareMenu(MapActivity mapActivity) {
+ this.mapActivity = mapActivity;
+ portraitMode = AndroidUiHelper.isOrientationPortrait(mapActivity);
+ largeDevice = AndroidUiHelper.isXLargeDevice(mapActivity);
+ }
+
+ public List getItems() {
+ List list = new LinkedList<>();
+ list.add(ShareItem.MESSAGE);
+ list.add(ShareItem.CLIPBOARD);
+ list.add(ShareItem.GEO);
+ list.add(ShareItem.QR_CODE);
+ 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;
+ }
+
+ public PointDescription getPointDescription() {
+ return pointDescription;
+ }
+
+ public static void show(LatLon latLon, PointDescription pointDescription, MapActivity mapActivity) {
+
+ ShareMenu menu = new ShareMenu(mapActivity);
+
+ if (pointDescription == null) {
+ menu.pointDescription = new PointDescription(latLon.getLatitude(), latLon.getLongitude());
+ } else {
+ menu.pointDescription = pointDescription;
+ }
+
+ menu.latLon = latLon;
+
+ ShareMenuFragment.showInstance(menu);
+ }
+
+ public void share(ShareItem item) {
+ final int zoom = mapActivity.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;
+ String sms = mapActivity.getString(R.string.send_location_sms_pattern, geoUrl, httpUrl);
+ switch (item) {
+ case MESSAGE:
+ ShareDialog.sendMessage(mapActivity, sms);
+ break;
+ case CLIPBOARD:
+ ShareDialog.sendToClipboard(mapActivity, sms);
+ break;
+ case GEO:
+ Intent mapIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(geoUrl));
+ mapActivity.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);
+ break;
+ }
+ }
+
+ public float getLandscapeWidthDp() {
+ return MenuController.LANDSCAPE_WIDTH_DP;
+ }
+
+ public void saveMenu(Bundle bundle) {
+ bundle.putSerializable(KEY_SHARE_MENU_LATLON, latLon);
+ bundle.putSerializable(KEY_SHARE_MENU_POINT_DESC, pointDescription);
+ }
+
+ public static ShareMenu restoreMenu(Bundle bundle, MapActivity mapActivity) {
+
+ ShareMenu menu = new ShareMenu(mapActivity);
+
+ Object pDescObj = bundle.getSerializable(KEY_SHARE_MENU_POINT_DESC);
+ if (pDescObj != null) {
+ menu.pointDescription = (PointDescription) pDescObj;
+ }
+ Object latLonObj = bundle.getSerializable(KEY_SHARE_MENU_LATLON);
+ if (latLonObj != null) {
+ menu.latLon = (LatLon) latLonObj;
+ }
+
+ return menu;
+ }
+
+}
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/ShareMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/ShareMenuFragment.java
new file mode 100644
index 0000000000..992c5f145f
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/ShareMenuFragment.java
@@ -0,0 +1,132 @@
+package net.osmand.plus.mapcontextmenu.other;
+
+import android.annotation.SuppressLint;
+import android.content.res.Resources;
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentActivity;
+import android.support.v4.app.FragmentManager;
+import android.util.TypedValue;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.AdapterView.OnItemClickListener;
+import android.widget.ArrayAdapter;
+import android.widget.FrameLayout;
+import android.widget.ImageView;
+import android.widget.ListView;
+import android.widget.TextView;
+
+import net.osmand.plus.R;
+import net.osmand.plus.activities.MapActivity;
+import net.osmand.plus.mapcontextmenu.other.ShareMenu.ShareItem;
+
+import java.util.List;
+
+import static android.util.TypedValue.COMPLEX_UNIT_DIP;
+
+
+public class ShareMenuFragment extends Fragment implements OnItemClickListener {
+ public static final String TAG = "ShareMenuFragment";
+
+ private ArrayAdapter listAdapter;
+ private ShareMenu menu;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ if (savedInstanceState != null && getActivity() instanceof MapActivity) {
+ menu = ShareMenu.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(ShareMenu menu) {
+ int slideInAnim = menu.getSlideInAnimation();
+ int slideOutAnim = menu.getSlideOutAnimation();
+
+ ShareMenuFragment fragment = new ShareMenuFragment();
+ fragment.menu = menu;
+ menu.getMapActivity().getSupportFragmentManager().beginTransaction()
+ .setCustomAnimations(slideInAnim, slideOutAnim, slideInAnim, slideOutAnim)
+ .add(R.id.fragmentContainer, fragment, TAG)
+ .addToBackStack(TAG).commit();
+ }
+
+ private ArrayAdapter createAdapter() {
+ final List items = menu.getItems();
+ return new ArrayAdapter(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 ShareItem 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();
+ }
+ }
+
+ private int dpToPx(float dp) {
+ Resources r = getActivity().getResources();
+ return (int) TypedValue.applyDimension(
+ COMPLEX_UNIT_DIP,
+ dp,
+ r.getDisplayMetrics()
+ );
+ }
+
+}