From eb2fb10386b6accc3797cb7f95ddb3e194112e7c Mon Sep 17 00:00:00 2001 From: Nazar-Kutz Date: Mon, 10 Aug 2020 13:56:54 +0300 Subject: [PATCH] Don't show context menu on backToLocation button click on other screens --- .../plus/base/ContextMenuScrollFragment.java | 2 +- .../ChooseRouteFragment.java | 2 +- .../plus/views/layers/MapControlsLayer.java | 20 ++++++++++--------- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/base/ContextMenuScrollFragment.java b/OsmAnd/src/net/osmand/plus/base/ContextMenuScrollFragment.java index 571f478848..1314c08c6d 100644 --- a/OsmAnd/src/net/osmand/plus/base/ContextMenuScrollFragment.java +++ b/OsmAnd/src/net/osmand/plus/base/ContextMenuScrollFragment.java @@ -117,7 +117,7 @@ public abstract class ContextMenuScrollFragment extends ContextMenuFragment impl MapControlsLayer mapControlsLayer = mapLayers.getMapControlsLayer(); mapControlsLayer.setupZoomInButton(zoomInButtonView, longClickListener, ZOOM_IN_BUTTON_ID); mapControlsLayer.setupZoomOutButton(zoomOutButtonView, longClickListener, ZOOM_OUT_BUTTON_ID); - mapControlsLayer.setupBackToLocationButton(myLocButtonView, BACK_TO_LOC_BUTTON_ID); + mapControlsLayer.setupBackToLocationButton(myLocButtonView, false, BACK_TO_LOC_BUTTON_ID); MapInfoLayer mapInfoLayer = mapLayers.getMapInfoLayer(); rulerWidget = mapInfoLayer.setupRulerWidget(mapRulerView); diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/ChooseRouteFragment.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/ChooseRouteFragment.java index 8e46e3aa03..c046cca7f7 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/ChooseRouteFragment.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/ChooseRouteFragment.java @@ -376,7 +376,7 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe mapControlsLayer.setupZoomInButton(zoomInButton, longClickListener, ZOOM_IN_BUTTON_ID); mapControlsLayer.setupZoomOutButton(zoomOutButton, longClickListener, ZOOM_OUT_BUTTON_ID); - mapControlsLayer.setupBackToLocationButton(backToLocation, BACK_TO_LOC_BUTTON_ID); + mapControlsLayer.setupBackToLocationButton(backToLocation, false, BACK_TO_LOC_BUTTON_ID); AndroidUiHelper.updateVisibility(zoomButtonsView, true); } diff --git a/OsmAnd/src/net/osmand/plus/views/layers/MapControlsLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/MapControlsLayer.java index 929f3cd577..6d6c78fedb 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/MapControlsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/MapControlsLayer.java @@ -359,7 +359,7 @@ public class MapControlsLayer extends OsmandMapLayer { private void initControls() { View backToLocation = mapActivity.findViewById(R.id.map_my_location_button); - backToLocationControl = setupBackToLocationButton(backToLocation, BACK_TO_LOC_HUD_ID); + backToLocationControl = setupBackToLocationButton(backToLocation, true, BACK_TO_LOC_HUD_ID); View backToMenuButton = mapActivity.findViewById(R.id.map_menu_button); @@ -397,7 +397,7 @@ public class MapControlsLayer extends OsmandMapLayer { }); } - public MapHudButton setupBackToLocationButton(View backToLocation, String buttonId) { + public MapHudButton setupBackToLocationButton(View backToLocation, boolean showContextMenu, String buttonId) { MapHudButton backToLocationButton = createHudButton(backToLocation, R.drawable.ic_my_location, buttonId) .setIconColorId(R.color.map_button_icon_color_light, R.color.map_button_icon_color_dark) .setBg(R.drawable.btn_circle_blue); @@ -409,13 +409,15 @@ public class MapControlsLayer extends OsmandMapLayer { } }); - backToLocation.setOnLongClickListener(new View.OnLongClickListener() { - @Override - public boolean onLongClick(View v) { - onBackToLocationClick(true); - return false; - } - }); + if (showContextMenu) { + backToLocation.setOnLongClickListener(new View.OnLongClickListener() { + @Override + public boolean onLongClick(View v) { + onBackToLocationClick(true); + return false; + } + }); + } controls.add(backToLocationButton);