Fix transport context menu

This commit is contained in:
Alexey Kulish 2017-08-04 16:03:24 +03:00
parent edb25fbd95
commit 4757fbe427
5 changed files with 44 additions and 11 deletions

View file

@ -609,8 +609,12 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
public void onSingleTapOnMap() {
if (menuController == null || !menuController.handleSingleTapOnMap()) {
updateMapCenter(null);
close();
if (menuController != null && !menuController.isClosable()) {
hide();
} else {
updateMapCenter(null);
close();
}
if (mapActivity.getMapLayers().getMapQuickActionLayer().isLayerOn()) {
mapActivity.getMapLayers().getMapQuickActionLayer().refreshLayer();
}
@ -994,6 +998,10 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
return menuController == null || menuController.fabVisible();
}
public boolean isClosable() {
return menuController == null || menuController.isClosable();
}
public boolean buttonsVisible() {
return menuController == null || menuController.buttonsVisible();
}

View file

@ -69,6 +69,7 @@ public class MenuBuilder {
private LatLon latLon;
private boolean hidden;
private boolean showNearestWiki = false;
private boolean showOnlinePhotos = true;
protected List<Amenity> nearestWiki = new ArrayList<>();
private List<OsmandPlugin> menuPlugins = new ArrayList<>();
private CardsRowBuilder onlinePhotoCardsRow;
@ -207,6 +208,14 @@ public class MenuBuilder {
this.showNearestWiki = showNearestWiki;
}
public boolean isShowOnlinePhotos() {
return showOnlinePhotos;
}
public void setShowOnlinePhotos(boolean showOnlinePhotos) {
this.showOnlinePhotos = showOnlinePhotos;
}
public void setShowNearestWiki(boolean showNearestWiki, long objectId) {
this.objectId = objectId;
this.showNearestWiki = showNearestWiki;
@ -228,7 +237,9 @@ public class MenuBuilder {
buildPlainMenuItems(view);
}
buildInternal(view);
buildNearestPhotosRow(view);
if (showOnlinePhotos) {
buildNearestPhotosRow(view);
}
buildPluginRows(view);
buildAfter(view);
}

View file

@ -348,6 +348,10 @@ public abstract class MenuController extends BaseMenuController {
return false;
}
public boolean isClosable() {
return true;
}
public boolean needStreetName() {
return !displayDistanceDirection();
}

View file

@ -27,6 +27,7 @@ public class TransportRouteController extends MenuController {
final TransportStopRoute transportRoute) {
super(new MenuBuilder(mapActivity), pointDescription, mapActivity);
this.transportRoute = transportRoute;
builder.setShowOnlinePhotos(false);
toolbarController = new ContextMenuToolbarController(this);
toolbarController.setTitle(getNameStr());
toolbarController.setOnBackButtonClickListener(new OnClickListener() {
@ -83,6 +84,10 @@ public class TransportRouteController extends MenuController {
return false;
}
@Override
public boolean isClosable() {
return false;
}
@Override
public boolean buttonsVisible() {
@ -157,12 +162,13 @@ public class TransportRouteController extends MenuController {
MapContextMenu menu = getMapActivity().getContextMenu();
PointDescription pd = new PointDescription(PointDescription.POINT_TYPE_TRANSPORT_STOP,
getMapActivity().getString(R.string.transport_Stop), name);
resetRoute();
menu.show(stop.getLocation(), pd, stop);
WeakReference<MapContextMenuFragment> rr = menu.findMenuFragment();
if (rr != null && rr.get() != null) {
rr.get().centerMarkerLocation();
}
//resetRoute();
LatLon stopLocation = stop.getLocation();
getMapActivity().getMyApplication().getSettings()
.setMapLocationToShow(stopLocation.getLatitude(), stopLocation.getLongitude(),
15, pd, false, stop);
MapActivity.launchMapActivityMoveToTop(getMapActivity());
}
});
}

View file

@ -854,8 +854,12 @@ public class ContextMenuLayer extends OsmandMapLayer {
if (movementListener.onTouchEvent(event)) {
if (menu.isVisible()) {
menu.updateMapCenter(null);
menu.close();
if (!menu.isClosable()) {
menu.hide();
} else {
menu.updateMapCenter(null);
menu.close();
}
}
if (multiSelectionMenu.isVisible()) {
multiSelectionMenu.hide();