quick action fab proper visibility with context menu; center map shift in quick action mode

This commit is contained in:
Korusn Oleksandr 2017-01-03 13:13:11 +02:00
parent 0bb62d6b9c
commit bbb35bc385
3 changed files with 26 additions and 5 deletions

View file

@ -587,6 +587,8 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
public void onSingleTapOnMap() { public void onSingleTapOnMap() {
if (menuController == null || !menuController.handleSingleTapOnMap()) { if (menuController == null || !menuController.handleSingleTapOnMap()) {
hide(); hide();
if (mapActivity.getMapLayers().getMapQuickActionLayer().isLayerOn())
mapActivity.getMapLayers().getMapQuickActionLayer().refreshLayer();
} }
} }

View file

@ -170,13 +170,17 @@ public class MapMultiSelectionMenu extends BaseMenuController {
} }
public boolean isVisible() { public boolean isVisible() {
Fragment fragment = getMapActivity().getSupportFragmentManager().findFragmentByTag(MapMultiSelectionMenuFragment.TAG); Fragment fragment = getFragmentByTag();
return fragment != null; return fragment != null;
} }
public Fragment getFragmentByTag() {
return getMapActivity().getSupportFragmentManager().findFragmentByTag(MapMultiSelectionMenuFragment.TAG);
}
public void hide() { public void hide() {
clearMenu(); clearMenu();
Fragment fragment = getMapActivity().getSupportFragmentManager().findFragmentByTag(MapMultiSelectionMenuFragment.TAG); Fragment fragment = getFragmentByTag();
if (fragment != null) { if (fragment != null) {
MapMultiSelectionMenuFragment menuFragment = (MapMultiSelectionMenuFragment) fragment; MapMultiSelectionMenuFragment menuFragment = (MapMultiSelectionMenuFragment) fragment;
menuFragment.dismissMenu(); menuFragment.dismissMenu();

View file

@ -46,6 +46,7 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
private OsmandMapTileView view; private OsmandMapTileView view;
private boolean wasCollapseButtonVisible; private boolean wasCollapseButtonVisible;
private int previousMapPosition;
private boolean inChangeMarkerPositionMode; private boolean inChangeMarkerPositionMode;
@ -102,6 +103,7 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
public void refreshLayer() { public void refreshLayer() {
setLayerState(true); setLayerState(true);
isLayerOn = quickActionRegistry.isQuickActionOn(); isLayerOn = quickActionRegistry.isQuickActionOn();
setUpQuickActionBtnVisibility();
} }
private void setQuickActionButtonMargin() { private void setQuickActionButtonMargin() {
@ -160,6 +162,8 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
} }
private void enterMovingMode(RotatedTileBox tileBox) { private void enterMovingMode(RotatedTileBox tileBox) {
previousMapPosition = view.getMapPosition();
view.setMapPosition( OsmandSettings.BOTTOM_CONSTANT);
MapContextMenu menu = mapActivity.getContextMenu(); MapContextMenu menu = mapActivity.getContextMenu();
LatLon ll = menu.isActive() && tileBox.containsLatLon(menu.getLatLon()) ? menu.getLatLon() : tileBox.getCenterLatLon(); LatLon ll = menu.isActive() && tileBox.containsLatLon(menu.getLatLon()) ? menu.getLatLon() : tileBox.getCenterLatLon();
@ -167,7 +171,7 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
menu.close(); menu.close();
RotatedTileBox rb = new RotatedTileBox(tileBox); RotatedTileBox rb = new RotatedTileBox(tileBox);
// rb.setCenterLocation(0.5f, 0.5f); // tileBox.setCenterLocation(0.5f, 0.75f);
rb.setLatLonCenter(ll.getLatitude(), ll.getLongitude()); rb.setLatLonCenter(ll.getLatitude(), ll.getLongitude());
double lat = rb.getLatFromPixel(tileBox.getCenterPixelX(), tileBox.getCenterPixelY()); double lat = rb.getLatFromPixel(tileBox.getCenterPixelX(), tileBox.getCenterPixelY());
double lon = rb.getLonFromPixel(tileBox.getCenterPixelX(), tileBox.getCenterPixelY()); double lon = rb.getLonFromPixel(tileBox.getCenterPixelX(), tileBox.getCenterPixelY());
@ -189,6 +193,7 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
} }
private void quitMovingMarker() { private void quitMovingMarker() {
view.setMapPosition(previousMapPosition);
inChangeMarkerPositionMode = false; inChangeMarkerPositionMode = false;
mark(View.VISIBLE, R.id.map_ruler_layout, mark(View.VISIBLE, R.id.map_ruler_layout,
R.id.map_left_widgets_panel, R.id.map_right_widgets_panel, R.id.map_center_info); R.id.map_left_widgets_panel, R.id.map_right_widgets_panel, R.id.map_center_info);
@ -228,10 +233,16 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
canvas.translate(box.getCenterPixelX() - contextMarker.getWidth() / 2, box.getCenterPixelY() - contextMarker.getHeight()); canvas.translate(box.getCenterPixelX() - contextMarker.getWidth() / 2, box.getCenterPixelY() - contextMarker.getHeight());
contextMarker.draw(canvas); contextMarker.draw(canvas);
} }
setUpQuickActionBtnVisibility();
}
private void setUpQuickActionBtnVisibility() {
boolean hideQuickButton = !isLayerOn || boolean hideQuickButton = !isLayerOn ||
contextMenuLayer.isInChangeMarkerPositionMode() || contextMenuLayer.isInChangeMarkerPositionMode() ||
mapActivity.getContextMenu().isVisible() || mapActivity.getContextMenu().isVisible() && !mapActivity.getContextMenu().findMenuFragment().get().isRemoving() ||
mapActivity.getContextMenu().getMultiSelectionMenu().isVisible(); mapActivity.getContextMenu().isVisible() && mapActivity.getContextMenu().findMenuFragment().get().isAdded() ||
mapActivity.getContextMenu().getMultiSelectionMenu().isVisible() && mapActivity.getContextMenu().getMultiSelectionMenu().getFragmentByTag().isAdded() ||
mapActivity.getContextMenu().getMultiSelectionMenu().isVisible() && !mapActivity.getContextMenu().getMultiSelectionMenu().getFragmentByTag().isRemoving();
quickActionButton.setVisibility(hideQuickButton ? View.GONE : View.VISIBLE); quickActionButton.setVisibility(hideQuickButton ? View.GONE : View.VISIBLE);
} }
@ -265,6 +276,10 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
return isLayerOn && inChangeMarkerPositionMode; return isLayerOn && inChangeMarkerPositionMode;
} }
public boolean isLayerOn() {
return isLayerOn;
}
public boolean onBackPressed() { public boolean onBackPressed() {
return setLayerState(true); return setLayerState(true);
} }