Fix context menu

This commit is contained in:
Alexey Kulish 2018-02-01 16:49:45 +03:00
parent f14a84dc19
commit 09e4e6bba8
2 changed files with 34 additions and 16 deletions

View file

@ -94,6 +94,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
private int menuTopShadowAllHeight;
private int menuTitleHeight;
private int menuBottomViewHeight;
private int menuButtonsHeight;
private int menuFullHeight;
private int menuFullHeightMax;
private int menuTopViewHeightExcludingTitle;
@ -606,8 +607,8 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
private float getToolbarAlpha(int y) {
float a = 0;
if (menu != null && !menu.isLandscapeLayout()) {
if (y < minHalfY) {
a = 1f - (y - bottomToolbarPosY) * (1f / (minHalfY - bottomToolbarPosY));
if (y < bottomToolbarPosY) {
a = 1f - (y - topScreenPosY) * (1f / (bottomToolbarPosY - topScreenPosY));
}
if (a < 0) {
a = 0;
@ -714,7 +715,8 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
int oldMenuState = menu.getCurrentMenuState();
if (!menu.isLandscapeLayout()) {
if (slidingDown && !skipScreenState && oldMenuState == MenuState.FULL_SCREEN && currentY < topScreenPosY) {
if (slidingDown && !skipScreenState && oldMenuState == MenuState.FULL_SCREEN
&& currentY < (-menuTitleHeight + menuButtonsHeight)) {
slidingDown = false;
}
if (menuBottomViewHeight > 0 && slidingUp) {
@ -1198,6 +1200,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
menuTopShadowAllHeight = newMenuTopShadowAllHeight;
menuTitleHeight = menuTopShadowAllHeight + dy;
menuBottomViewHeight = view.findViewById(R.id.context_menu_bottom_view).getHeight();
menuButtonsHeight = view.findViewById(R.id.context_menu_bottom_buttons).getHeight() + view.findViewById(R.id.buttons_bottom_border).getHeight() + view.findViewById(R.id.context_menu_buttons).getHeight();
menuFullHeightMax = menuTitleHeight + menuBottomViewHeight;
@ -1416,7 +1419,12 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
case MenuState.FULL_SCREEN:
if (currentY != CURRENT_Y_UNDEFINED) {
int maxPosY = viewHeight - menuFullHeightMax;
int minPosY = topScreenPosY;
int minPosY;
if (menu.isLandscapeLayout()) {
minPosY = topScreenPosY;
} else {
minPosY = -menuTitleHeight + menuButtonsHeight + bottomToolbarPosY;
}
if (maxPosY > minPosY) {
maxPosY = minPosY;
}
@ -1428,7 +1436,11 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
posY = currentY;
}
} else {
posY = topScreenPosY;
if (menu.isLandscapeLayout()) {
posY = topScreenPosY;
} else {
posY = -menuTitleHeight + menuButtonsHeight + bottomToolbarPosY;
}
}
break;
default:

View file

@ -806,12 +806,12 @@ public class MapControlsLayer extends OsmandMapLayer {
boolean routeFollowingMode = !routePlanningMode && rh.isFollowingMode();
boolean routeDialogOpened = MapRouteInfoMenu.isVisible();
boolean trackDialogOpened = TrackDetailsMenu.isVisible();
boolean contextMenuOpened = mapActivity.getContextMenu().shouldShowTopControls();
boolean contextMenuOpened = !mapActivity.getContextMenu().shouldShowTopControls();
boolean showRouteCalculationControls = routePlanningMode ||
((app.accessibilityEnabled() || (System.currentTimeMillis() - touchEvent < TIMEOUT_TO_SHOW_BUTTONS)) && routeFollowingMode);
updateMyLocation(rh, routeDialogOpened || trackDialogOpened || !contextMenuOpened);
updateMyLocation(rh, routeDialogOpened || trackDialogOpened || contextMenuOpened);
boolean showButtons = (showRouteCalculationControls || !routeFollowingMode)
&& !isInMovingMarkerMode() && !isInGpxDetailsMode() && !isInMeasurementToolMode() && !isInPlanRouteMode() && contextMenuOpened;
&& !isInMovingMarkerMode() && !isInGpxDetailsMode() && !isInMeasurementToolMode() && !isInPlanRouteMode() && !contextMenuOpened;
//routePlanningBtn.setIconResId(routeFollowingMode ? R.drawable.ic_action_gabout_dark : R.drawable.map_directions);
if (rh.isFollowingMode()) {
routePlanningBtn.setIconResId(R.drawable.map_start_navigation);
@ -826,18 +826,20 @@ public class MapControlsLayer extends OsmandMapLayer {
routePlanningBtn.updateVisibility(showButtons);
menuControl.updateVisibility(showButtons);
mapZoomIn.updateVisibility(!routeDialogOpened && contextMenuOpened);
mapZoomOut.updateVisibility(!routeDialogOpened && contextMenuOpened);
compassHud.updateVisibility(!routeDialogOpened && !trackDialogOpened && shouldShowCompass()
&& !isInMeasurementToolMode() && !isInPlanRouteMode() && contextMenuOpened);
mapZoomIn.updateVisibility(!routeDialogOpened && !contextMenuOpened);
mapZoomOut.updateVisibility(!routeDialogOpened && !contextMenuOpened);
boolean forceHideCompass = routeDialogOpened || trackDialogOpened
|| isInMeasurementToolMode() || isInPlanRouteMode() || contextMenuOpened;
compassHud.forceHideCompass = forceHideCompass;
compassHud.updateVisibility(!forceHideCompass && shouldShowCompass());
if (layersHud.setIconResId(settings.getApplicationMode().getMapIconId())) {
layersHud.update(app, isNight);
}
layersHud.updateVisibility(!routeDialogOpened && !trackDialogOpened && !isInMeasurementToolMode() && !isInPlanRouteMode()
&& contextMenuOpened);
&& !contextMenuOpened);
quickSearchHud.updateVisibility(!routeDialogOpened && !trackDialogOpened && !isInMeasurementToolMode() && !isInPlanRouteMode()
&& contextMenuOpened);
&& !contextMenuOpened);
if (!routePlanningMode && !routeFollowingMode) {
if (mapView.isZooming()) {
@ -854,7 +856,9 @@ public class MapControlsLayer extends OsmandMapLayer {
}
mapRouteInfoMenu.setVisible(showRouteCalculationControls);
updateCompass(isNight);
if (!forceHideCompass) {
updateCompass(isNight);
}
for (MapHudButton mc : controls) {
mc.update(mapActivity.getMyApplication(), isNight);
@ -1027,6 +1031,7 @@ public class MapControlsLayer extends OsmandMapLayer {
boolean f = true;
boolean compass;
boolean compassOutside;
boolean forceHideCompass;
ViewPropertyAnimatorCompat hideAnimator;
public MapHudButton setRoundTransparent() {
@ -1088,9 +1093,10 @@ public class MapControlsLayer extends OsmandMapLayer {
iv.setVisibility(View.VISIBLE);
iv.invalidate();
} else if (hideAnimator == null) {
if (compass) {
if (compass && !forceHideCompass) {
hideDelayed(5000);
} else {
forceHideCompass = false;
iv.setVisibility(View.GONE);
iv.invalidate();
}