Don't show context menu on backToLocation button click on other screens

This commit is contained in:
Nazar-Kutz 2020-08-10 13:56:54 +03:00
parent 3d2a3e4160
commit eb2fb10386
3 changed files with 13 additions and 11 deletions

View file

@ -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);

View file

@ -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);
}

View file

@ -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,6 +409,7 @@ public class MapControlsLayer extends OsmandMapLayer {
}
});
if (showContextMenu) {
backToLocation.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
@ -416,6 +417,7 @@ public class MapControlsLayer extends OsmandMapLayer {
return false;
}
});
}
controls.add(backToLocationButton);