From 3dff56da46836947ecb01ef905d9b84590be9ef1 Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Mon, 29 Mar 2021 23:09:02 +0300 Subject: [PATCH] Map widgets visibility refactoring, part 2 --- .../plus/views/layers/MapControlsLayer.java | 22 +++++++------------ .../mapwidgets/WidgetsVisibilityHelper.java | 16 +++++++++++--- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/views/layers/MapControlsLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/MapControlsLayer.java index 6eaf25b608..614ecce575 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/MapControlsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/MapControlsLayer.java @@ -858,30 +858,25 @@ public class MapControlsLayer extends OsmandMapLayer { boolean routePlanningMode = isInRoutePlanningMode(); boolean routeFollowingMode = !routePlanningMode && rh.isFollowingMode(); - boolean trackDialogOpened = mapActivity.getTrackDetailsMenu().isVisible(); - boolean shouldHideTopControls = mapActivity.shouldHideTopControls(); - boolean showRouteCalculationControls = routePlanningMode || - ((app.accessibilityEnabled() || (System.currentTimeMillis() - touchEvent < TIMEOUT_TO_SHOW_BUTTONS)) && routeFollowingMode); + boolean timeToShowButtons = System.currentTimeMillis() - touchEvent < TIMEOUT_TO_SHOW_BUTTONS; + boolean showRouteCalculationControls = routePlanningMode || ((app.accessibilityEnabled() || timeToShowButtons) && routeFollowingMode); boolean routeDialogOpened = mapRouteInfoMenu.isVisible() || (showRouteCalculationControls && mapRouteInfoMenu.needShowMenu()); - boolean dialogOpened = routeDialogOpened || shouldHideTopControls; - boolean showBackToLocation = mapActivity.getWidgetsVisibilityHelper().shouldShowBackToLocationButton(); - backToLocationControl.updateVisibility(!dialogOpened && showBackToLocation); + boolean showBackToLocation = !routeDialogOpened && mapActivity.getWidgetsVisibilityHelper().shouldShowBackToLocationButton(); + backToLocationControl.updateVisibility(showBackToLocation); //routePlanningBtn.setIconResId(routeFollowingMode ? R.drawable.ic_action_info_dark : R.drawable.ic_action_gdirections_dark); updateRoutePlaningButton(rh, routePlanningMode); - boolean showBottomMenuButtons = - (showRouteCalculationControls || !routeFollowingMode) && vh.shouldShowBottomMenuButtons(); + boolean showBottomMenuButtons = (showRouteCalculationControls || !routeFollowingMode) && vh.shouldShowBottomMenuButtons(); routePlanningBtn.updateVisibility(showBottomMenuButtons); menuControl.updateVisibility(showBottomMenuButtons); - - boolean showZoomButtons = !routeDialogOpened && !shouldHideTopControls && vh.shouldShowZoomButtons(); + boolean showZoomButtons = !routeDialogOpened && vh.shouldShowZoomButtons(); mapZoomIn.updateVisibility(showZoomButtons); mapZoomOut.updateVisibility(showZoomButtons); - boolean forceHideCompass = routeDialogOpened || trackDialogOpened || vh.shouldHideCompass(); + boolean forceHideCompass = routeDialogOpened || vh.shouldHideCompass(); compassHud.forceHideCompass = forceHideCompass; compassHud.updateVisibility(!forceHideCompass && shouldShowCompass()); @@ -890,8 +885,7 @@ public class MapControlsLayer extends OsmandMapLayer { if (layersHud.setIconResId(appMode.getIconRes())) { layersHud.update(app, isNight); } - boolean showTopButtons = !routeDialogOpened && !trackDialogOpened - && !shouldHideTopControls && vh.shouldShowTopButtons(); + boolean showTopButtons = !routeDialogOpened && vh.shouldShowTopButtons(); layersHud.updateVisibility(showTopButtons); quickSearchHud.updateVisibility(showTopButtons); diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/WidgetsVisibilityHelper.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/WidgetsVisibilityHelper.java index b0b13b346e..7cc747c1b6 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/WidgetsVisibilityHelper.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/WidgetsVisibilityHelper.java @@ -93,11 +93,14 @@ public class WidgetsVisibilityHelper { && !isInChoosingRoutesMode() && !isInWaypointsChoosingMode() && !isInRouteLineAppearanceMode(); - return !isInFollowTrackMode() && (additionalDialogsHide || !isPortrait()); + return !mapActivity.shouldHideTopControls() + && !isInFollowTrackMode() + && (additionalDialogsHide || !isPortrait()); } public boolean shouldHideCompass() { return mapActivity.shouldHideTopControls() + || isTrackDetailsMenuOpened() || isInMeasurementToolMode() || isInPlanRouteMode() || isInChoosingRoutesMode() @@ -108,7 +111,9 @@ public class WidgetsVisibilityHelper { } public boolean shouldShowTopButtons() { - return !isInMeasurementToolMode() + return !mapActivity.shouldHideTopControls() + && !isTrackDetailsMenuOpened() + && !isInMeasurementToolMode() && !isInPlanRouteMode() && !isInChoosingRoutesMode() && !isInTrackAppearanceMode() @@ -124,7 +129,8 @@ public class WidgetsVisibilityHelper { && !isInWaypointsChoosingMode() && !isInFollowTrackMode() && !isInRouteLineAppearanceMode(); - return !isInPlanRouteMode() + return !mapActivity.shouldHideTopControls() + && !isInPlanRouteMode() && !(isMapLinkedToLocation() && routingHelper.isFollowingMode()) && (additionalDialogsHide || !isPortrait()); } @@ -215,6 +221,10 @@ public class WidgetsVisibilityHelper { return mapActivity.getMapViewTrackingUtilities().isMapLinkedToLocation(); } + private boolean isTrackDetailsMenuOpened() { + return mapActivity.getTrackDetailsMenu().isVisible(); + } + private boolean isPortrait() { return AndroidUiHelper.isOrientationPortrait(mapActivity); }