From a2e513285f1a88c38844e314082ff71d3da24742 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Tue, 17 Oct 2017 13:21:10 +0300 Subject: [PATCH 01/17] Fix #4579 (cherry picked from commit 175c6be) --- OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java index 95dc1638b4..b599107212 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java @@ -182,7 +182,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment { if (!importing) { if (asyncLoader == null || asyncLoader.getResult() == null) { asyncLoader = new LoadGpxTask(); - asyncLoader.execute(getActivity()); + asyncLoader.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } else { allGpxAdapter.refreshSelected(); allGpxAdapter.notifyDataSetChanged(); From ae28933d2230715bda3ff089f0d6e294e51b004d Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Tue, 17 Oct 2017 16:59:38 +0300 Subject: [PATCH 02/17] Fix saving snap to road (cherry picked from commit 7f830d7) --- .../osmand/plus/measurementtool/MeasurementToolFragment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java index 3813c19899..cc65e048fe 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java @@ -665,7 +665,7 @@ public class MeasurementToolFragment extends Fragment { return new SaveAsNewTrackFragmentListener() { @Override public void saveAsRoutePointOnClick() { - saveAsGpx(SaveType.ROUTE_POINT); + saveAsGpx(editingCtx.isInSnapToRoadMode() ? SaveType.SNAP_TO_ROAD : SaveType.ROUTE_POINT); } @Override From d43a4357cbf2658138bcadf73808adaf206f9470 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Tue, 17 Oct 2017 17:09:59 +0300 Subject: [PATCH 03/17] Fix #4589 (cherry picked from commit 969506a) --- OsmAnd/src/net/osmand/plus/views/MapMarkersLayer.java | 1 - 1 file changed, 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/views/MapMarkersLayer.java b/OsmAnd/src/net/osmand/plus/views/MapMarkersLayer.java index 438a5d58b9..e09b67eb12 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapMarkersLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapMarkersLayer.java @@ -107,7 +107,6 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi private void initUI() { bitmapPaint = new Paint(); - bitmapPaint.setDither(true); bitmapPaint.setAntiAlias(true); bitmapPaint.setFilterBitmap(true); markerBitmapBlue = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_marker_blue); From 44c640db487e352b7c7549d3bd7a7115c1be8679 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Tue, 17 Oct 2017 13:14:14 +0300 Subject: [PATCH 04/17] Fix history menu (cherry picked from commit 017aa48) --- ...fragment_marker_history_bottom_sheet_dialog.xml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/OsmAnd/res/layout/fragment_marker_history_bottom_sheet_dialog.xml b/OsmAnd/res/layout/fragment_marker_history_bottom_sheet_dialog.xml index c3d82544c8..daf7ff4969 100644 --- a/OsmAnd/res/layout/fragment_marker_history_bottom_sheet_dialog.xml +++ b/OsmAnd/res/layout/fragment_marker_history_bottom_sheet_dialog.xml @@ -52,8 +52,7 @@ android:layout_height="wrap_content" android:maxLines="1" android:ellipsize="end" - android:textSize="@dimen/default_list_text_size" - android:textColor="?android:textColorPrimary" + android:textAppearance="@style/TextAppearance.ListItemTitle" tools:text="Bloemstraat 179"/> @@ -97,7 +95,8 @@ android:layout_marginRight="@dimen/bottom_sheet_icon_margin" tools:src="@drawable/ic_action_reset_to_default_dark"/> - - Date: Tue, 17 Oct 2017 17:19:23 +0300 Subject: [PATCH 05/17] Fix history menu (cherry picked from commit c306743) --- ...ment_marker_history_bottom_sheet_dialog.xml | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/OsmAnd/res/layout/fragment_marker_history_bottom_sheet_dialog.xml b/OsmAnd/res/layout/fragment_marker_history_bottom_sheet_dialog.xml index daf7ff4969..440dc8bf98 100644 --- a/OsmAnd/res/layout/fragment_marker_history_bottom_sheet_dialog.xml +++ b/OsmAnd/res/layout/fragment_marker_history_bottom_sheet_dialog.xml @@ -45,24 +45,24 @@ android:gravity="center_vertical" android:orientation="vertical"> - - @@ -95,8 +95,7 @@ android:layout_marginRight="@dimen/bottom_sheet_icon_margin" tools:src="@drawable/ic_action_reset_to_default_dark"/> - - Date: Tue, 17 Oct 2017 17:20:26 +0300 Subject: [PATCH 06/17] Reformat code (cherry picked from commit d396c75) --- ...ent_marker_history_bottom_sheet_dialog.xml | 272 +++++++++--------- 1 file changed, 136 insertions(+), 136 deletions(-) diff --git a/OsmAnd/res/layout/fragment_marker_history_bottom_sheet_dialog.xml b/OsmAnd/res/layout/fragment_marker_history_bottom_sheet_dialog.xml index 440dc8bf98..b89be37e6b 100644 --- a/OsmAnd/res/layout/fragment_marker_history_bottom_sheet_dialog.xml +++ b/OsmAnd/res/layout/fragment_marker_history_bottom_sheet_dialog.xml @@ -1,161 +1,161 @@ + xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:osmand="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:background="?attr/bg_color" + android:orientation="vertical"> - + - + - + - + - + - + - + - + - + - + - + - + - - + + - + - + - - + + - + - + - + - + - - + + \ No newline at end of file From 6091daeaab37287b6beea99e35690e493229c717 Mon Sep 17 00:00:00 2001 From: PavelRatushnyi Date: Tue, 17 Oct 2017 18:26:14 +0300 Subject: [PATCH 07/17] FIx crash in proxy setting (cherry picked from commit 9050c44) --- OsmAnd/res/values/strings.xml | 1 + .../activities/SettingsGeneralActivity.java | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 340d70a08a..a9418a8cd0 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -9,6 +9,7 @@ 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 --> + Wrong format Road Show map Route is calculated diff --git a/OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java b/OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java index 3ad0466430..860662b3d4 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java @@ -58,6 +58,12 @@ import java.util.List; public class SettingsGeneralActivity extends SettingsBaseActivity implements OnRequestPermissionsResultCallback { + private static final String IP_ADDRESS_PATTERN = + "^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." + + "([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." + + "([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." + + "([01]?\\d\\d?|2[0-4]\\d|25[0-5])$"; + private Preference applicationDir; private ListPreference applicationModePreference; private Preference drivingRegionPreference; @@ -366,9 +372,15 @@ public class SettingsGeneralActivity extends SettingsBaseActivity implements OnR hostPref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { - settings.PROXY_HOST.set((String) newValue); - enableProxy(NetworkUtils.getProxy() != null); - return true; + String ipAddress = (String) newValue; + if (ipAddress.matches(IP_ADDRESS_PATTERN)) { + settings.PROXY_HOST.set(ipAddress); + enableProxy(NetworkUtils.getProxy() != null); + return true; + } else { + Toast.makeText(SettingsGeneralActivity.this, getString(R.string.wrong_format), Toast.LENGTH_SHORT).show(); + return false; + } } }); From da8146459725d5a69480592b448b7b10d721a4d8 Mon Sep 17 00:00:00 2001 From: PavelRatushnyi Date: Tue, 17 Oct 2017 18:49:05 +0300 Subject: [PATCH 08/17] Fix crash in settings (cherry picked from commit 9287b94) --- .../net/osmand/plus/activities/SettingsGeneralActivity.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java b/OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java index 860662b3d4..43e5f25d1d 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java @@ -42,6 +42,7 @@ import net.osmand.plus.OsmandSettings.DrivingRegion; import net.osmand.plus.OsmandSettings.MetricsConstants; import net.osmand.plus.R; import net.osmand.plus.Version; +import net.osmand.plus.base.MapViewTrackingUtilities; import net.osmand.plus.dashboard.DashChooseAppDirFragment; import net.osmand.plus.dashboard.DashChooseAppDirFragment.ChooseAppDirFragment; import net.osmand.plus.dashboard.DashChooseAppDirFragment.MoveFilesToDifferentDirectory; @@ -166,7 +167,10 @@ public class SettingsGeneralActivity extends SettingsBaseActivity implements OnR public void onClick(DialogInterface dialog, int which) { if (drs.get(which) == null) { settings.DRIVING_REGION_AUTOMATIC.set(true); - MapActivity.getSingleMapViewTrackingUtilities().resetDrivingRegionUpdate(); + MapViewTrackingUtilities mapViewTrackingUtilities = MapActivity.getSingleMapViewTrackingUtilities(); + if (mapViewTrackingUtilities != null) { + mapViewTrackingUtilities.resetDrivingRegionUpdate(); + } } else { settings.DRIVING_REGION_AUTOMATIC.set(false); settings.DRIVING_REGION.set(drs.get(which)); From ba7c11a25d2bc0ffbeb812a61c7f8cfbf9a4ad80 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Wed, 18 Oct 2017 13:59:10 +0200 Subject: [PATCH 09/17] Fix #3665 --- .../osmand/router/RouteResultPreparation.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/OsmAnd-java/src/net/osmand/router/RouteResultPreparation.java b/OsmAnd-java/src/net/osmand/router/RouteResultPreparation.java index 99e26ca3e2..00738df442 100644 --- a/OsmAnd-java/src/net/osmand/router/RouteResultPreparation.java +++ b/OsmAnd-java/src/net/osmand/router/RouteResultPreparation.java @@ -1429,16 +1429,16 @@ public class RouteResultPreparation { } } } - // remove all non-slight turns - if(possibleTurns.size() > 1) { - TIntIterator it = possibleTurns.iterator(); - while(it.hasNext()) { - int nxt = it.next(); - if(!TurnType.isSlightTurn(nxt)) { - it.remove(); - } - } - } + // remove all non-slight turns // TEST don't pass +// if(possibleTurns.size() > 1) { +// TIntIterator it = possibleTurns.iterator(); +// while(it.hasNext()) { +// int nxt = it.next(); +// if(!TurnType.isSlightTurn(nxt)) { +// it.remove(); +// } +// } +// } int infer = 0; if (possibleTurns.size() == 1) { infer = possibleTurns.iterator().next(); From 47af2254c995f7a2e8a20fb114cf22250d3cce8a Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Wed, 18 Oct 2017 15:43:19 +0300 Subject: [PATCH 10/17] Fix #4266 --- .../res/layout/map_context_menu_fragment.xml | 29 +++++ .../plus/mapcontextmenu/MapContextMenu.java | 51 ++++++-- .../MapContextMenuFragment.java | 112 ++++++++++++++---- .../plus/mapcontextmenu/MenuController.java | 4 + .../osmand/plus/views/MapControlsLayer.java | 17 ++- .../mapwidgets/MapInfoWidgetsFactory.java | 4 +- .../mapwidgets/MapMarkersWidgetsFactory.java | 2 +- 7 files changed, 179 insertions(+), 40 deletions(-) diff --git a/OsmAnd/res/layout/map_context_menu_fragment.xml b/OsmAnd/res/layout/map_context_menu_fragment.xml index e51c489a04..1924bf56a3 100644 --- a/OsmAnd/res/layout/map_context_menu_fragment.xml +++ b/OsmAnd/res/layout/map_context_menu_fragment.xml @@ -436,6 +436,35 @@ android:layout_width="match_parent" android:layout_height="match_parent"> + + + + + + + fragmentRef = findMenuFragment(); + if (fragmentRef != null) { + fragmentRef.get().doZoomIn(); + return true; + } + return false; + } + + public boolean zoomOutPressed() { + WeakReference fragmentRef = findMenuFragment(); + if (fragmentRef != null) { + fragmentRef.get().doZoomOut(); + return true; + } + return false; + } + public void buttonWaypointPressed() { if (pointDescription.isDestination()) { mapActivity.getMapActions().editWaypoints(); @@ -1033,6 +1060,10 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL return menuController == null || menuController.fabVisible(); } + public boolean zoomButtonsVisible() { + return menuController == null || menuController.zoomButtonsVisible(); + } + public boolean isClosable() { return menuController == null || menuController.isClosable(); } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java index 3f83428f8c..02422e6039 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java @@ -66,7 +66,10 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents { private View view; private View mainView; - ImageView fabView; + private ImageView fabView; + private View zoomButtonsView; + private ImageButton zoomInButtonView; + private ImageButton zoomOutButtonView; private MapContextMenu menu; private OnLayoutChangeListener containerLayoutListener; @@ -83,6 +86,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents { private int screenHeight; private int viewHeight; + private int zoomButtonsHeight; private int fabPaddingTopPx; private int markerPaddingPx; @@ -257,7 +261,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents { if (singleTapDetector.onTouchEvent(event)) { moving = false; if (hasMoved) { - applyPosY(getViewY(), false, false, 0, 0); + applyPosY(getViewY(), false, false, 0, 0, 0); } openMenuHalfScreen(); return true; @@ -386,6 +390,32 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents { fabView.setVisibility(View.GONE); } + // Zoom buttons + zoomButtonsView = view.findViewById(R.id.context_menu_zoom_buttons); + zoomInButtonView = (ImageButton) view.findViewById(R.id.context_menu_zoom_in_button); + zoomOutButtonView = (ImageButton) view.findViewById(R.id.context_menu_zoom_out_button); + if (menu.zoomButtonsVisible()) { + updateImageButton(zoomInButtonView, R.drawable.map_zoom_in, R.drawable.map_zoom_in_night, + R.drawable.btn_circle_trans, R.drawable.btn_circle_night, nightMode); + updateImageButton(zoomOutButtonView, R.drawable.map_zoom_out, R.drawable.map_zoom_out_night, + R.drawable.btn_circle_trans, R.drawable.btn_circle_night, nightMode); + zoomInButtonView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + menu.zoomInPressed(); + } + }); + zoomOutButtonView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + menu.zoomOutPressed(); + } + }); + zoomButtonsView.setVisibility(View.VISIBLE); + } else { + zoomButtonsView.setVisibility(View.GONE); + } + View buttonsTopBorder = view.findViewById(R.id.buttons_top_border); AndroidUtils.setBackground(getMapActivity(), buttonsTopBorder, nightMode, R.color.dashboard_divider_light, R.color.dashboard_divider_dark); @@ -481,6 +511,16 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents { return view; } + private void updateImageButton(ImageButton button, int iconLightId, int iconDarkId, int bgLightId, int bgDarkId, boolean night) { + button.setImageDrawable(getMapActivity().getMyApplication().getIconsCache().getIcon(night ? iconDarkId : iconLightId)); + if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) { + button.setBackground(getMapActivity().getResources().getDrawable(night ? bgDarkId : bgLightId, + getMapActivity().getTheme())); + } else { + button.setBackgroundDrawable(getMapActivity().getResources().getDrawable(night ? bgDarkId : bgLightId)); + } + } + private void processScreenHeight(ViewParent parent) { View container = (View)parent; if (Build.VERSION.SDK_INT >= 11) { @@ -525,17 +565,33 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents { boolean needMapAdjust = oldMenuState != newMenuState && newMenuState != MenuState.FULL_SCREEN; if (newMenuState != oldMenuState) { - menu.updateControlsVisibility(); + menu.updateControlsVisibility(true); doBeforeMenuStateChange(oldMenuState, newMenuState); } - applyPosY(currentY, needCloseMenu, needMapAdjust, oldMenuState, newMenuState); + applyPosY(currentY, needCloseMenu, needMapAdjust, oldMenuState, newMenuState, 0); + } + + public void doZoomIn() { + if (!centered) { + centered = true; + calculateCenterLatLon(menu.getLatLon(), getZoom() + 1, true); + } + applyPosY(getViewY(), false, true, 0, 0, 1); + } + + public void doZoomOut() { + if (!centered) { + centered = true; + calculateCenterLatLon(menu.getLatLon(), getZoom() - 1, true); + } + applyPosY(getViewY(), false, true, 0, 0, -1); } private void applyPosY(final int currentY, final boolean needCloseMenu, boolean needMapAdjust, - final int previousMenuState, final int newMenuState) { + final int previousMenuState, final int newMenuState, int dZoom) { final int posY = getPosY(needCloseMenu); - if (currentY != posY) { + if (currentY != posY || dZoom != 0) { if (posY < currentY) { updateMainViewLayout(posY); } @@ -574,8 +630,13 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents { .setInterpolator(new DecelerateInterpolator()) .start(); + zoomButtonsView.animate().y(getZoomButtonsY(posY)) + .setDuration(200) + .setInterpolator(new DecelerateInterpolator()) + .start(); + if (needMapAdjust) { - adjustMapPosition(posY, true, centered); + adjustMapPosition(posY, true, centered, dZoom); } } else { setViewY(posY, false, needMapAdjust); @@ -791,7 +852,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents { if (parent != null && containerLayoutListener != null) { ((View) parent).addOnLayoutChangeListener(containerLayoutListener); } - + menu.updateControlsVisibility(true); } @Override @@ -805,6 +866,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents { if (!wasDrawerDisabled) { getMapActivity().enableDrawer(); } + menu.updateControlsVisibility(false); super.onPause(); } @@ -874,6 +936,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents { menuTopShadowHeight = view.findViewById(R.id.context_menu_top_shadow).getHeight(); int newMenuTopShadowAllHeight = view.findViewById(R.id.context_menu_top_shadow_all).getHeight(); menuFullHeight = view.findViewById(R.id.context_menu_main).getHeight(); + zoomButtonsHeight = zoomButtonsView.getHeight(); int dy = 0; if (!menu.isLandscapeLayout()) { @@ -960,7 +1023,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents { public void centerMarkerLocation() { centered = true; - showOnMap(menu.getLatLon(), true, true, false); + showOnMap(menu.getLatLon(), true, true, false, getZoom()); } private int getZoom() { @@ -994,21 +1057,20 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents { return new LatLon(flat, flon); } - private void showOnMap(LatLon latLon, boolean updateCoords, boolean needMove, boolean alreadyAdjusted) { + private void showOnMap(LatLon latLon, boolean updateCoords, boolean needMove, boolean alreadyAdjusted, int zoom) { AnimateDraggingMapThread thread = map.getAnimatedDraggingThread(); - int fZoom = getZoom(); - LatLon calcLatLon = calculateCenterLatLon(latLon, fZoom, updateCoords); + LatLon calcLatLon = calculateCenterLatLon(latLon, zoom, updateCoords); if (updateCoords) { mapCenter = calcLatLon; menu.setMapCenter(mapCenter); } if (!alreadyAdjusted) { - calcLatLon = getAdjustedMarkerLocation(getPosY(), calcLatLon, true, fZoom); + calcLatLon = getAdjustedMarkerLocation(getPosY(), calcLatLon, true, zoom); } if (needMove) { - thread.startMoving(calcLatLon.getLatitude(), calcLatLon.getLongitude(), fZoom, true); + thread.startMoving(calcLatLon.getLatitude(), calcLatLon.getLongitude(), zoom, true); } } @@ -1137,30 +1199,36 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents { if (!oldAndroid()) { mainView.setY(y); fabView.setY(getFabY(y)); + zoomButtonsView.setY(getZoomButtonsY(y)); } else { mainView.setPadding(0, y, 0, 0); fabView.setPadding(0, getFabY(y), 0, 0); + zoomButtonsView.setPadding(0, getZoomButtonsY(y), 0, 0); } if (!customMapCenter) { if (adjustMapPos) { - adjustMapPosition(y, animated, centered); + adjustMapPosition(y, animated, centered, 0); } } else { customMapCenter = false; } } - private void adjustMapPosition(int y, boolean animated, boolean center) { + private void adjustMapPosition(int y, boolean animated, boolean center, int dZoom) { map.getAnimatedDraggingThread().stopAnimatingSync(); - LatLon latlon = getAdjustedMarkerLocation(y, menu.getLatLon(), center, getZoom()); + int zoom = getZoom() + dZoom; + LatLon latlon = getAdjustedMarkerLocation(y, menu.getLatLon(), center, zoom); - if (map.getLatitude() == latlon.getLatitude() && map.getLongitude() == latlon.getLongitude()) { + if (map.getLatitude() == latlon.getLatitude() && map.getLongitude() == latlon.getLongitude() && dZoom == 0) { return; } if (animated) { - showOnMap(latlon, false, true, true); + showOnMap(latlon, false, true, true, zoom); } else { + if (dZoom != 0) { + map.setIntZoom(zoom); + } map.setLatLon(latlon.getLatitude(), latlon.getLongitude()); } } @@ -1236,6 +1304,10 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents { return fabY; } + private int getZoomButtonsY(int y) { + return y - zoomButtonsHeight - fabPaddingTopPx; + } + private boolean oldAndroid() { return (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH); } @@ -1268,7 +1340,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents { if (mapCenter != null) { map.setLatLon(mapCenter.getLatitude(), mapCenter.getLongitude()); } - adjustMapPosition(getPosY(), true, false); + adjustMapPosition(getPosY(), true, false, 0); } else { view.setVisibility(View.GONE); } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java index d7e9d64af4..e6e0d4faa2 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java @@ -353,6 +353,10 @@ public abstract class MenuController extends BaseMenuController { return true; } + public boolean zoomButtonsVisible() { + return !isLandscapeLayout(); + } + public boolean buttonsVisible() { return true; } diff --git a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java index d1b750845f..9d4d5e82e1 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java @@ -628,12 +628,14 @@ public class MapControlsLayer extends OsmandMapLayer { zoomInButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { + if (mapActivity.getContextMenu().zoomInPressed()) { + return; + } if (view.isZooming()) { mapActivity.changeZoom(2, System.currentTimeMillis()); } else { mapActivity.changeZoom(1, System.currentTimeMillis()); } - } }); final View.OnLongClickListener listener = MapControlsLayer.getOnClickMagnifierListener(view); @@ -645,6 +647,9 @@ public class MapControlsLayer extends OsmandMapLayer { zoomOutButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { + if (mapActivity.getContextMenu().zoomOutPressed()) { + return; + } mapActivity.changeZoom(-1, System.currentTimeMillis()); } }); @@ -708,7 +713,7 @@ public class MapControlsLayer extends OsmandMapLayer { boolean routeFollowingMode = !routePlanningMode && rh.isFollowingMode(); boolean routeDialogOpened = MapRouteInfoMenu.isVisible(); boolean trackDialogOpened = TrackDetailsMenu.isVisible(); - boolean contextMenuOpened = mapActivity.getContextMenu().shouldShowControls(); + boolean contextMenuOpened = mapActivity.getContextMenu().shouldShowTopControls(); boolean showRouteCalculationControls = routePlanningMode || ((app.accessibilityEnabled() || (System.currentTimeMillis() - touchEvent < TIMEOUT_TO_SHOW_BUTTONS)) && routeFollowingMode); updateMyLocation(rh, routeDialogOpened || trackDialogOpened || !contextMenuOpened); @@ -790,8 +795,8 @@ public class MapControlsLayer extends OsmandMapLayer { private boolean shouldShowCompass() { float mapRotate = mapActivity.getMapView().getRotate(); return forceShowCompass || mapRotate != 0 - || settings.ROTATE_MAP.get() != OsmandSettings.ROTATE_MAP_NONE - || mapActivity.getMapLayers().getMapInfoLayer().getMapInfoControls().isVisible("compass"); + || settings.ROTATE_MAP.get() != OsmandSettings.ROTATE_MAP_NONE + || mapActivity.getMapLayers().getMapInfoLayer().getMapInfoControls().isVisible("compass"); } public CompassDrawable getCompassDrawable(Drawable originalDrawable) { @@ -1122,8 +1127,8 @@ public class MapControlsLayer extends OsmandMapLayer { this.mapQuickActionLayer = mapQuickActionLayer; } - private boolean isInMovingMarkerMode(){ - return mapQuickActionLayer == null ? contextMenuLayer.isInChangeMarkerPositionMode() || contextMenuLayer.isInAddGpxPointMode(): + private boolean isInMovingMarkerMode() { + return mapQuickActionLayer == null ? contextMenuLayer.isInChangeMarkerPositionMode() || contextMenuLayer.isInAddGpxPointMode() : mapQuickActionLayer.isInMovingMarkerMode() || contextMenuLayer.isInChangeMarkerPositionMode() || contextMenuLayer.isInAddGpxPointMode(); } diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java index b82129c738..0a62258445 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java @@ -28,8 +28,6 @@ import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.helpers.WaypointDialogHelper; import net.osmand.plus.helpers.WaypointHelper; import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper; -import net.osmand.plus.mapcontextmenu.MapContextMenu; -import net.osmand.plus.mapcontextmenu.MenuController; import net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenu; import net.osmand.plus.routing.RouteDirectionInfo; import net.osmand.plus.routing.RoutingHelper; @@ -813,7 +811,7 @@ public class MapInfoWidgetsFactory { } } } - if (map.isTopToolbarActive() || !map.getContextMenu().shouldShowControls()) { + if (map.isTopToolbarActive() || !map.getContextMenu().shouldShowTopControls()) { updateVisibility(false); } else if (!showNextTurn && updateWaypoint()) { updateVisibility(true); diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapMarkersWidgetsFactory.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapMarkersWidgetsFactory.java index d83d387f7a..ad6af0b50a 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapMarkersWidgetsFactory.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapMarkersWidgetsFactory.java @@ -200,7 +200,7 @@ public class MapMarkersWidgetsFactory { || MapRouteInfoMenu.isVisible() || addressTopBar.getVisibility() == View.VISIBLE || map.isTopToolbarActive() - || !map.getContextMenu().shouldShowControls() + || !map.getContextMenu().shouldShowTopControls() || map.getMapLayers().getMapMarkersLayer().isInPlanRouteMode()) { updateVisibility(false); return; From 91feb152966581858896f2a554c8d9215e74e409 Mon Sep 17 00:00:00 2001 From: Dmitriy Prodchenko Date: Wed, 18 Oct 2017 15:46:10 +0300 Subject: [PATCH 11/17] Fix NL string. --- OsmAnd/res/values-nl/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/res/values-nl/strings.xml b/OsmAnd/res/values-nl/strings.xml index a71c1c77ab..08f646ec30 100644 --- a/OsmAnd/res/values-nl/strings.xml +++ b/OsmAnd/res/values-nl/strings.xml @@ -2946,7 +2946,7 @@ We slaan geen locatiegegevens, zoektermen of andere gebruikersgegevens op. Donkergeel From 8c76608930ca7cec8e3c2f33ea4789b35b96e443 Mon Sep 17 00:00:00 2001 From: Dmitriy Prodchenko Date: Wed, 18 Oct 2017 16:33:15 +0300 Subject: [PATCH 12/17] Change URL for new release. --- OsmAnd/src/net/osmand/plus/AppInitializer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/AppInitializer.java b/OsmAnd/src/net/osmand/plus/AppInitializer.java index 0dc3cc726a..53fb922d9f 100644 --- a/OsmAnd/src/net/osmand/plus/AppInitializer.java +++ b/OsmAnd/src/net/osmand/plus/AppInitializer.java @@ -87,7 +87,7 @@ public class AppInitializer implements IProgress { private static final String VERSION_INSTALLED = "VERSION_INSTALLED"; //$NON-NLS-1$ private static final String EXCEPTION_FILE_SIZE = "EXCEPTION_FS"; //$NON-NLS-1$ - public static final String LATEST_CHANGES_URL = "https://osmand.net/blog?id=osmand-2-7-released"; + public static final String LATEST_CHANGES_URL = "https://osmand.net/blog?id=osmand-2-8-released"; // public static final String LATEST_CHANGES_URL = null; // not enough to read public static final int APP_EXIT_CODE = 4; public static final String APP_EXIT_KEY = "APP_EXIT_KEY"; From b9dbb786b889b9d3e1e2dc636e8d6a1872c4e84c Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Wed, 18 Oct 2017 18:20:45 +0300 Subject: [PATCH 13/17] Added tap on empty place feature --- .../osmand/plus/activities/MapActivity.java | 2 ++ .../osmand/plus/dashboard/DashboardOnMap.java | 4 +-- .../plus/mapcontextmenu/MapContextMenu.java | 19 ++++++++---- .../MapContextMenuFragment.java | 1 + .../other/MapRouteInfoMenuFragment.java | 1 + .../plus/mapmarkers/PlanRouteFragment.java | 1 + .../MeasurementToolFragment.java | 6 ++++ .../osmand/plus/views/ContextMenuLayer.java | 11 +++++-- .../osmand/plus/views/MapControlsLayer.java | 30 +++++++++++++++++++ 9 files changed, 64 insertions(+), 11 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index 4e4f9dc846..4aa1980093 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -913,6 +913,8 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven } public void readLocationToShow() { + mapLayers.getMapControlsLayer().showMapControls(); + LatLon cur = new LatLon(mapView.getLatitude(), mapView.getLongitude()); LatLon latLonToShow = settings.getAndClearMapLocationToShow(); PointDescription mapLabelToShow = settings.getAndClearMapLabelToShow(latLonToShow); diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java index 3aec39ede8..8438311687 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java @@ -851,7 +851,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis } } mapActivity.findViewById(R.id.toolbar_back).setVisibility(isBackButtonVisible() ? View.VISIBLE : View.GONE); - mapActivity.findViewById(R.id.MapHudButtonsOverlay).setVisibility(View.INVISIBLE); + mapActivity.getMapLayers().getMapControlsLayer().hideMapControls(); boolean portrait = AndroidUiHelper.isOrientationPortrait(mapActivity); if (!portrait) { AndroidUiHelper.updateVisibility(mapActivity.findViewById(R.id.map_route_land_left_margin_external), true); @@ -875,7 +875,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis mapActivity.getMapView().refreshMap(); } - mapActivity.findViewById(R.id.MapHudButtonsOverlay).setVisibility(View.VISIBLE); + mapActivity.getMapLayers().getMapControlsLayer().showMapControls(); hideActionButton(); for (WeakReference df : fragList) { if (df.get() != null) { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java index d6528205f0..916fb34fb6 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java @@ -413,7 +413,8 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL init(latLon, pointDescription, object); } - public void close() { + public boolean close() { + boolean result = false; if (active) { active = false; if (object instanceof MapMarker) { @@ -428,15 +429,17 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL if (this.object != null) { clearSelectedObject(this.object); } - hide(); + result = hide(); if (menuController != null) { menuController.setActive(false); } mapActivity.refreshMap(); } + return result; } - public void hide() { + public boolean hide() { + boolean result = false; if (mapPosition != 0) { mapActivity.getMapView().setMapPosition(mapPosition); mapPosition = 0; @@ -447,7 +450,9 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL WeakReference fragmentRef = findMenuFragment(); if (fragmentRef != null) { fragmentRef.get().dismissMenu(); + result = true; } + return result; } public void updateControlsVisibility(boolean menuVisible) { @@ -642,18 +647,20 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL } } - public void onSingleTapOnMap() { + public boolean onSingleTapOnMap() { + boolean result = false; if (menuController == null || !menuController.handleSingleTapOnMap()) { if (menuController != null && !menuController.isClosable()) { - hide(); + result = hide(); } else { updateMapCenter(null); - close(); + result = close(); } if (mapActivity.getMapLayers().getMapQuickActionLayer().isLayerOn()) { mapActivity.getMapLayers().getMapQuickActionLayer().refreshLayer(); } } + return result; } @Override diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java index 02422e6039..b181e47f40 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java @@ -853,6 +853,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents { ((View) parent).addOnLayoutChangeListener(containerLayoutListener); } menu.updateControlsVisibility(true); + getMapActivity().getMapLayers().getMapControlsLayer().showMapControls(); } @Override diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapRouteInfoMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapRouteInfoMenuFragment.java index 6ebf0ee420..1ceedaa33c 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapRouteInfoMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapRouteInfoMenuFragment.java @@ -55,6 +55,7 @@ public class MapRouteInfoMenuFragment extends Fragment { if (menu == null) { dismiss(); } + getMapActivity().getMapLayers().getMapControlsLayer().showMapControls(); } @Override diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteFragment.java index 434792feef..b55066047c 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteFragment.java @@ -365,6 +365,7 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene if (mapActivity != null) { mapActivity.getMyApplication().getLocationProvider().addLocationListener(this); } + getMapActivity().getMapLayers().getMapControlsLayer().showMapControls(); } @Override diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java index cc65e048fe..3345225bae 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java @@ -457,6 +457,12 @@ public class MeasurementToolFragment extends Fragment { return view; } + @Override + public void onResume() { + super.onResume(); + getMapActivity().getMapLayers().getMapControlsLayer().showMapControls(); + } + @Override public void onDestroyView() { super.onDestroyView(); diff --git a/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java b/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java index 7740d4e12b..350c284eb4 100644 --- a/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java @@ -809,8 +809,11 @@ public class ContextMenuLayer extends OsmandMapLayer { } } - hideVisibleMenues(); - menu.onSingleTapOnMap(); + boolean processed = hideVisibleMenues(); + processed |= menu.onSingleTapOnMap(); + if (!processed) { + activity.getMapLayers().getMapControlsLayer().switchMapControlsVisibility(); + } return false; } @@ -854,10 +857,12 @@ public class ContextMenuLayer extends OsmandMapLayer { return res; } - private void hideVisibleMenues() { + private boolean hideVisibleMenues() { if (multiSelectionMenu.isVisible()) { multiSelectionMenu.hide(); + return true; } + return false; } private void showContextMenuForSelectedObjects(final LatLon latLon, final Map selectedObjects) { diff --git a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java index 9d4d5e82e1..4895eaa881 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java @@ -48,6 +48,7 @@ import net.osmand.plus.dialogs.DirectionsDialogs; import net.osmand.plus.mapcontextmenu.MapContextMenu; import net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenu; import net.osmand.plus.mapcontextmenu.other.TrackDetailsMenu; +import net.osmand.plus.measurementtool.MeasurementToolFragment; import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.views.corenative.NativeCoreContext; @@ -656,6 +657,35 @@ public class MapControlsLayer extends OsmandMapLayer { zoomOutButton.setOnLongClickListener(listener); } + public void showMapControls() { + mapActivity.findViewById(R.id.MapHudButtonsOverlay).setVisibility(View.VISIBLE); + } + public void hideMapControls() { + mapActivity.findViewById(R.id.MapHudButtonsOverlay).setVisibility(View.INVISIBLE); + } + + public void setMapControlsVisibility(boolean visible) { + View mapHudButtonsOverlay = mapActivity.findViewById(R.id.MapHudButtonsOverlay); + mapHudButtonsOverlay.setVisibility(visible ? View.VISIBLE : View.INVISIBLE); + } + + public boolean isMapControlsVisible() { + return mapActivity.findViewById(R.id.MapHudButtonsOverlay).getVisibility() == View.VISIBLE; + } + + public void switchMapControlsVisibility() { + if (app.getRoutingHelper().isFollowingMode() || app.getRoutingHelper().isPauseNavigation() + || mapActivity.getMeasurementToolFragment() != null + || mapActivity.getPlanRouteFragment() != null) { + return; + } + if (isMapControlsVisible()) { + hideMapControls(); + } else { + showMapControls(); + } + } + public void startNavigation() { OsmandApplication app = mapActivity.getMyApplication(); RoutingHelper routingHelper = app.getRoutingHelper(); From 8ac26dc3228dfd9b15cbf8f3bf532c4bdf31417b Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Wed, 18 Oct 2017 13:29:54 +0300 Subject: [PATCH 14/17] Add show direction menu to configure screen (cherry picked from commit f9bf198) --- ...howDirectionBottomSheetDialogFragment.java | 6 +++- .../views/mapwidgets/MapWidgetRegistry.java | 29 +++++-------------- 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/ShowDirectionBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/ShowDirectionBottomSheetDialogFragment.java index 1b1a59ee83..dacf153f6c 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/ShowDirectionBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/ShowDirectionBottomSheetDialogFragment.java @@ -282,6 +282,10 @@ public class ShowDirectionBottomSheetDialogFragment extends BottomSheetDialogFra showDirectionEnabled = false; break; } + MapActivity mapActivity = getMapActivity(); + if (mapActivity != null) { + mapActivity.refreshMap(); + } if (listener != null) { listener.onMapMarkersModeChanged(showDirectionEnabled); } @@ -289,7 +293,7 @@ public class ShowDirectionBottomSheetDialogFragment extends BottomSheetDialogFra } }; - interface ShowDirectionFragmentListener { + public interface ShowDirectionFragmentListener { void onMapMarkersModeChanged(boolean showDirectionEnabled); } } diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java index 0735984144..b95c2d5289 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java @@ -1,11 +1,9 @@ package net.osmand.plus.views.mapwidgets; import android.content.Context; -import android.content.DialogInterface; import android.support.annotation.DrawableRes; import android.support.annotation.NonNull; import android.support.annotation.StringRes; -import android.support.v7.app.AlertDialog; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; @@ -19,16 +17,15 @@ import net.osmand.plus.ContextMenuItem; import net.osmand.plus.IconsCache; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandSettings; -import net.osmand.plus.OsmandSettings.MapMarkersMode; import net.osmand.plus.OsmandSettings.OsmandPreference; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.dialogs.ConfigureMapMenu; +import net.osmand.plus.mapmarkers.ShowDirectionBottomSheetDialogFragment; import net.osmand.plus.quickaction.QuickActionListFragment; import net.osmand.plus.views.MapInfoLayer; import net.osmand.plus.views.MapQuickActionLayer; import net.osmand.plus.views.OsmandMapLayer.DrawSettings; -import net.osmand.plus.views.OsmandMapTileView; import net.osmand.plus.widgets.IconPopupMenu; import java.util.Collections; @@ -329,27 +326,17 @@ public class MapWidgetRegistry { .setDescription(settings.MAP_MARKERS_MODE.get().toHumanString(map)) .setListener(new ContextMenuAdapter.ItemClickListener() { @Override - public boolean onContextMenuClick(final ArrayAdapter ad, - int itemId, final int pos, boolean isChecked) { - final OsmandMapTileView view = map.getMapView(); - AlertDialog.Builder bld = new AlertDialog.Builder(view.getContext()); - bld.setTitle(R.string.map_markers); - final String[] items = new String[MapMarkersMode.values().length]; - for (int i = 0; i < items.length; i++) { - items[i] = MapMarkersMode.values()[i].toHumanString(map); - } - int i = settings.MAP_MARKERS_MODE.get().ordinal(); - bld.setSingleChoiceItems(items, i, new DialogInterface.OnClickListener() { + public boolean onContextMenuClick(final ArrayAdapter adapter, int itemId, final int position, boolean isChecked) { + ShowDirectionBottomSheetDialogFragment fragment = new ShowDirectionBottomSheetDialogFragment(); + fragment.setListener(new ShowDirectionBottomSheetDialogFragment.ShowDirectionFragmentListener() { @Override - public void onClick(DialogInterface dialog, int which) { - settings.MAP_MARKERS_MODE.set(MapMarkersMode.values()[which]); + public void onMapMarkersModeChanged(boolean showDirectionEnabled) { updateMapMarkersMode(map); - dialog.dismiss(); - cm.getItem(pos).setDescription(settings.MAP_MARKERS_MODE.get().toHumanString(map)); - ad.notifyDataSetChanged(); + cm.getItem(position).setDescription(settings.MAP_MARKERS_MODE.get().toHumanString(map)); + adapter.notifyDataSetChanged(); } }); - bld.show(); + fragment.show(map.getSupportFragmentManager(), ShowDirectionBottomSheetDialogFragment.TAG); return false; } }).setLayout(R.layout.list_item_text_button).createItem()); From 7713dbcc99766f3a3bbee85303e1988c09b4e973 Mon Sep 17 00:00:00 2001 From: PavelRatushnyi Date: Wed, 18 Oct 2017 08:54:11 +0300 Subject: [PATCH 15/17] Fix activity not found (cherry picked from commit b1f4da2) --- OsmAnd/src/net/osmand/plus/Version.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/Version.java b/OsmAnd/src/net/osmand/plus/Version.java index 5600d8c073..bfc4fbfd31 100644 --- a/OsmAnd/src/net/osmand/plus/Version.java +++ b/OsmAnd/src/net/osmand/plus/Version.java @@ -26,11 +26,20 @@ public class Version { public static boolean isMarketEnabled(OsmandApplication ctx) { return isGooglePlayEnabled(ctx) || isAmazonEnabled(ctx); } + + public static boolean isGooglePlayInstalled(OsmandApplication ctx) { + try { + ctx.getPackageManager().getPackageInfo("com.android.vending", 0); + } catch (PackageManager.NameNotFoundException e) { + return false; + } + return true; + } public static String marketPrefix(OsmandApplication ctx) { if (isAmazonEnabled(ctx)) { return "amzn://apps/android?p="; - } else if (isGooglePlayEnabled(ctx)) { + } else if (isGooglePlayEnabled(ctx) && isGooglePlayInstalled(ctx)) { return "market://details?id="; } return "https://osmand.net/apps?id="; From d21efe39ca26becffeb3707eec7b41ac1c2f8997 Mon Sep 17 00:00:00 2001 From: Tobias Zwick Date: Fri, 13 Oct 2017 22:24:55 +0300 Subject: [PATCH 16/17] less greedy intent-filter for www.openstreetmap.org (fixes #4440) Registering an intent filter for all of openstreetmap breaks the OAuth process for other Android apps, trying to access www.openstreetmap.org/oauth (cherry picked from commit f9e42fc) --- OsmAnd/AndroidManifest.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/OsmAnd/AndroidManifest.xml b/OsmAnd/AndroidManifest.xml index fdfd8c2bde..af7edc7f44 100644 --- a/OsmAnd/AndroidManifest.xml +++ b/OsmAnd/AndroidManifest.xml @@ -229,7 +229,9 @@ - + + + From 2e04ccc98ee24cbd8034d497ea1985c157b5d2bd Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Wed, 18 Oct 2017 14:47:47 +0300 Subject: [PATCH 17/17] Add search prefix and change openstreetmap correspondingly (cherry picked from commit 334ef11) --- OsmAnd/AndroidManifest.xml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/OsmAnd/AndroidManifest.xml b/OsmAnd/AndroidManifest.xml index af7edc7f44..145d61cedf 100644 --- a/OsmAnd/AndroidManifest.xml +++ b/OsmAnd/AndroidManifest.xml @@ -232,7 +232,11 @@ - + + + + +