Hide context menu on map pan

This commit is contained in:
Alexey Kulish 2018-10-19 10:40:49 +03:00
parent 50643f3f85
commit 3cb6162e54
4 changed files with 57 additions and 11 deletions

View file

@ -862,9 +862,10 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
boolean night = app.getDaynightHelper().isNightModeForMapControls();
boolean quickSearchTopBar = getTopToolbarController(TopToolbarControllerType.QUICK_SEARCH) != null;
boolean contextMenuTopBar = getTopToolbarController(TopToolbarControllerType.CONTEXT_MENU) != null;
boolean contextTopBar = getTopToolbarController(TopToolbarControllerType.CONTEXT) != null;
boolean mapTopBar = findViewById(R.id.map_top_bar).getVisibility() == View.VISIBLE;
boolean markerTopBar = findViewById(R.id.map_markers_top_bar).getVisibility() == View.VISIBLE;
if (((quickSearchTopBar || mapTopBar) && mapControlsVisible) || contextMenuTopBar) {
if (((quickSearchTopBar || mapTopBar) && mapControlsVisible) || contextMenuTopBar || contextTopBar) {
colorId = night ? R.color.status_bar_route_dark : R.color.status_bar_route_light;
} else if (markerTopBar && mapControlsVisible) {
colorId = R.color.status_bar_dark;

View file

@ -76,6 +76,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
private PointDescription pointDescription;
private Object object;
private MenuController menuController;
private ContextToolbarController toolbarController;
private LatLon mapCenter;
private int mapPosition = 0;
@ -125,6 +126,25 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
}
public MapContextMenu() {
toolbarController = new ContextToolbarController();
toolbarController.setOnBackButtonClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
show();
}
});
toolbarController.setOnTitleClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
show();
}
});
toolbarController.setOnCloseButtonClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
close();
}
});
}
@Nullable
@ -444,6 +464,19 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
init(latLon, pointDescription, object);
}
private void showToolbar() {
if (mapActivity != null) {
toolbarController.setTitle(getTitleStr());
mapActivity.showTopToolbar(toolbarController);
}
}
private void hideToolbar() {
if (mapActivity != null) {
mapActivity.hideTopToolbar(toolbarController);
}
}
public void onFragmentResume() {
if (active && displayDistanceDirection()) {
updateLocation(false, true, false);
@ -478,6 +511,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
if (menuController != null) {
menuController.setActive(false);
}
hideToolbar();
mapActivity.refreshMap();
}
}
@ -502,6 +536,9 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
fragmentRef.get().dismissMenu();
result = true;
}
if (active) {
showToolbar();
}
}
return result;
}
@ -752,7 +789,6 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
if (fragmentRef != null) {
fragmentRef.get().refreshTitle();
}
if (searchDoneAction != null) {
if (searchDoneAction.dlg != null) {
try {
@ -766,6 +802,13 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
searchDoneAction.run();
searchDoneAction = null;
}
if (active) {
toolbarController.setTitle(getTitleStr());
if (mapActivity != null
&& mapActivity.getTopToolbarController(TopToolbarControllerType.CONTEXT) != null) {
mapActivity.refreshMap();
}
}
}
@Nullable
@ -1367,4 +1410,12 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
private abstract class MenuAction implements Runnable {
protected ProgressDialog dlg;
}
public static class ContextToolbarController extends TopToolbarController {
public ContextToolbarController() {
super(TopToolbarControllerType.CONTEXT);
}
}
}

View file

@ -1028,14 +1028,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
public boolean onTouchEvent(MotionEvent event, RotatedTileBox tileBox) {
if (movementListener.onTouchEvent(event)) {
if (menu.isVisible()) {
if (!menu.isClosable()) {
menu.hide();
} else {
menu.updateMapCenter(null);
menu.close();
}
}
menu.hide();
if (multiSelectionMenu.isVisible()) {
multiSelectionMenu.hide();
}

View file

@ -51,7 +51,8 @@ public class MapInfoWidgetsFactory {
CONTEXT_MENU,
TRACK_DETAILS,
DISCOUNT,
MEASUREMENT_TOOL
MEASUREMENT_TOOL,
CONTEXT
}
public TextInfoWidget createAltitudeControl(final MapActivity map) {