Added tap on empty place feature

This commit is contained in:
Alexey Kulish 2017-10-18 18:20:45 +03:00
parent 162605aa34
commit e09acfce48
9 changed files with 64 additions and 11 deletions

View file

@ -913,6 +913,8 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
}
public void readLocationToShow() {
mapLayers.getMapControlsLayer().showMapControls();
LatLon cur = new LatLon(mapView.getLatitude(), mapView.getLongitude());
LatLon latLonToShow = settings.getAndClearMapLocationToShow();
PointDescription mapLabelToShow = settings.getAndClearMapLabelToShow(latLonToShow);

View file

@ -851,7 +851,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
}
}
mapActivity.findViewById(R.id.toolbar_back).setVisibility(isBackButtonVisible() ? View.VISIBLE : View.GONE);
mapActivity.findViewById(R.id.MapHudButtonsOverlay).setVisibility(View.INVISIBLE);
mapActivity.getMapLayers().getMapControlsLayer().hideMapControls();
boolean portrait = AndroidUiHelper.isOrientationPortrait(mapActivity);
if (!portrait) {
AndroidUiHelper.updateVisibility(mapActivity.findViewById(R.id.map_route_land_left_margin_external), true);
@ -875,7 +875,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
mapActivity.getMapView().refreshMap();
}
mapActivity.findViewById(R.id.MapHudButtonsOverlay).setVisibility(View.VISIBLE);
mapActivity.getMapLayers().getMapControlsLayer().showMapControls();
hideActionButton();
for (WeakReference<DashBaseFragment> df : fragList) {
if (df.get() != null) {

View file

@ -413,7 +413,8 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
init(latLon, pointDescription, object);
}
public void close() {
public boolean close() {
boolean result = false;
if (active) {
active = false;
if (object instanceof MapMarker) {
@ -428,15 +429,17 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
if (this.object != null) {
clearSelectedObject(this.object);
}
hide();
result = hide();
if (menuController != null) {
menuController.setActive(false);
}
mapActivity.refreshMap();
}
return result;
}
public void hide() {
public boolean hide() {
boolean result = false;
if (mapPosition != 0) {
mapActivity.getMapView().setMapPosition(mapPosition);
mapPosition = 0;
@ -447,7 +450,9 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
WeakReference<MapContextMenuFragment> fragmentRef = findMenuFragment();
if (fragmentRef != null) {
fragmentRef.get().dismissMenu();
result = true;
}
return result;
}
public void updateControlsVisibility(boolean menuVisible) {
@ -642,18 +647,20 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
}
}
public void onSingleTapOnMap() {
public boolean onSingleTapOnMap() {
boolean result = false;
if (menuController == null || !menuController.handleSingleTapOnMap()) {
if (menuController != null && !menuController.isClosable()) {
hide();
result = hide();
} else {
updateMapCenter(null);
close();
result = close();
}
if (mapActivity.getMapLayers().getMapQuickActionLayer().isLayerOn()) {
mapActivity.getMapLayers().getMapQuickActionLayer().refreshLayer();
}
}
return result;
}
@Override

View file

@ -853,6 +853,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
((View) parent).addOnLayoutChangeListener(containerLayoutListener);
}
menu.updateControlsVisibility(true);
getMapActivity().getMapLayers().getMapControlsLayer().showMapControls();
}
@Override

View file

@ -55,6 +55,7 @@ public class MapRouteInfoMenuFragment extends Fragment {
if (menu == null) {
dismiss();
}
getMapActivity().getMapLayers().getMapControlsLayer().showMapControls();
}
@Override

View file

@ -365,6 +365,7 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
if (mapActivity != null) {
mapActivity.getMyApplication().getLocationProvider().addLocationListener(this);
}
getMapActivity().getMapLayers().getMapControlsLayer().showMapControls();
}
@Override

View file

@ -457,6 +457,12 @@ public class MeasurementToolFragment extends Fragment {
return view;
}
@Override
public void onResume() {
super.onResume();
getMapActivity().getMapLayers().getMapControlsLayer().showMapControls();
}
@Override
public void onDestroyView() {
super.onDestroyView();

View file

@ -809,8 +809,11 @@ public class ContextMenuLayer extends OsmandMapLayer {
}
}
hideVisibleMenues();
menu.onSingleTapOnMap();
boolean processed = hideVisibleMenues();
processed |= menu.onSingleTapOnMap();
if (!processed) {
activity.getMapLayers().getMapControlsLayer().switchMapControlsVisibility();
}
return false;
}
@ -854,10 +857,12 @@ public class ContextMenuLayer extends OsmandMapLayer {
return res;
}
private void hideVisibleMenues() {
private boolean hideVisibleMenues() {
if (multiSelectionMenu.isVisible()) {
multiSelectionMenu.hide();
return true;
}
return false;
}
private void showContextMenuForSelectedObjects(final LatLon latLon, final Map<Object, IContextMenuProvider> selectedObjects) {

View file

@ -48,6 +48,7 @@ import net.osmand.plus.dialogs.DirectionsDialogs;
import net.osmand.plus.mapcontextmenu.MapContextMenu;
import net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenu;
import net.osmand.plus.mapcontextmenu.other.TrackDetailsMenu;
import net.osmand.plus.measurementtool.MeasurementToolFragment;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.views.corenative.NativeCoreContext;
@ -656,6 +657,35 @@ public class MapControlsLayer extends OsmandMapLayer {
zoomOutButton.setOnLongClickListener(listener);
}
public void showMapControls() {
mapActivity.findViewById(R.id.MapHudButtonsOverlay).setVisibility(View.VISIBLE);
}
public void hideMapControls() {
mapActivity.findViewById(R.id.MapHudButtonsOverlay).setVisibility(View.INVISIBLE);
}
public void setMapControlsVisibility(boolean visible) {
View mapHudButtonsOverlay = mapActivity.findViewById(R.id.MapHudButtonsOverlay);
mapHudButtonsOverlay.setVisibility(visible ? View.VISIBLE : View.INVISIBLE);
}
public boolean isMapControlsVisible() {
return mapActivity.findViewById(R.id.MapHudButtonsOverlay).getVisibility() == View.VISIBLE;
}
public void switchMapControlsVisibility() {
if (app.getRoutingHelper().isFollowingMode() || app.getRoutingHelper().isPauseNavigation()
|| mapActivity.getMeasurementToolFragment() != null
|| mapActivity.getPlanRouteFragment() != null) {
return;
}
if (isMapControlsVisible()) {
hideMapControls();
} else {
showMapControls();
}
}
public void startNavigation() {
OsmandApplication app = mapActivity.getMyApplication();
RoutingHelper routingHelper = app.getRoutingHelper();