Make map movable when context menu is open

This commit is contained in:
Alexey Kulish 2018-10-19 14:12:57 +03:00
parent a7f2a3104a
commit c3ac67aa00
4 changed files with 21 additions and 15 deletions

View file

@ -96,6 +96,8 @@ import net.osmand.plus.helpers.ImportHelper.ImportGpxBottomSheetDialogFragment;
import net.osmand.plus.helpers.WakeLockHelper;
import net.osmand.plus.mapcontextmenu.AdditionalActionsBottomSheetDialogFragment;
import net.osmand.plus.mapcontextmenu.MapContextMenu;
import net.osmand.plus.mapcontextmenu.MenuController;
import net.osmand.plus.mapcontextmenu.MenuController.MenuState;
import net.osmand.plus.mapcontextmenu.builders.cards.dialogs.ContextMenuCardDialogFragment;
import net.osmand.plus.mapcontextmenu.other.DestinationReachedMenu;
import net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenu;
@ -589,7 +591,11 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
return;
}
if (mapContextMenu.isVisible() && mapContextMenu.isClosable()) {
mapContextMenu.close();
if (mapContextMenu.getCurrentMenuState() != MenuState.HEADER_ONLY) {
mapContextMenu.openMenuHeaderOnly();
} else {
mapContextMenu.close();
}
return;
}
if (getMapLayers().getContextMenuLayer().isInAddGpxPointMode()) {

View file

@ -1128,6 +1128,18 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
}
}
public void openMenuHeaderOnly() {
WeakReference<MapContextMenuFragment> fragmentRef = findMenuFragment();
if (fragmentRef != null)
fragmentRef.get().openMenuHeaderOnly();
}
public void openMenuHalfScreen() {
WeakReference<MapContextMenuFragment> fragmentRef = findMenuFragment();
if (fragmentRef != null)
fragmentRef.get().openMenuHalfScreen();
}
public void openMenuFullScreen() {
WeakReference<MapContextMenuFragment> fragmentRef = findMenuFragment();
if (fragmentRef != null)

View file

@ -1265,12 +1265,6 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
@Override
public void onDestroyView() {
super.onDestroyView();
if (!menu.isActive()) {
if (mapCenter != null) {
AnimateDraggingMapThread thread = map.getAnimatedDraggingThread();
thread.startMoving(mapCenter.getLatitude(), mapCenter.getLongitude(), map.getZoom(), true);
}
}
menu.setMapCenter(null);
menu.setMapZoom(0);
}

View file

@ -55,6 +55,8 @@ import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.MapActivityActions;
import net.osmand.plus.mapcontextmenu.MapContextMenu;
import net.osmand.plus.mapcontextmenu.MenuController;
import net.osmand.plus.mapcontextmenu.MenuController.MenuState;
import net.osmand.plus.mapcontextmenu.other.MapMultiSelectionMenu;
import net.osmand.plus.render.MapRenderRepositories;
import net.osmand.plus.render.NativeOsmandLibrary;
@ -1028,14 +1030,6 @@ 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();
}
}
if (multiSelectionMenu.isVisible()) {
multiSelectionMenu.hide();
}