Map widgets visibility refactoring, part 2

This commit is contained in:
nazar-kutz 2021-03-29 23:09:02 +03:00
parent dacbc9b4cf
commit 3dff56da46
2 changed files with 21 additions and 17 deletions

View file

@ -858,30 +858,25 @@ public class MapControlsLayer extends OsmandMapLayer {
boolean routePlanningMode = isInRoutePlanningMode(); boolean routePlanningMode = isInRoutePlanningMode();
boolean routeFollowingMode = !routePlanningMode && rh.isFollowingMode(); boolean routeFollowingMode = !routePlanningMode && rh.isFollowingMode();
boolean trackDialogOpened = mapActivity.getTrackDetailsMenu().isVisible(); boolean timeToShowButtons = System.currentTimeMillis() - touchEvent < TIMEOUT_TO_SHOW_BUTTONS;
boolean shouldHideTopControls = mapActivity.shouldHideTopControls(); boolean showRouteCalculationControls = routePlanningMode || ((app.accessibilityEnabled() || timeToShowButtons) && routeFollowingMode);
boolean showRouteCalculationControls = routePlanningMode ||
((app.accessibilityEnabled() || (System.currentTimeMillis() - touchEvent < TIMEOUT_TO_SHOW_BUTTONS)) && routeFollowingMode);
boolean routeDialogOpened = mapRouteInfoMenu.isVisible() || (showRouteCalculationControls && mapRouteInfoMenu.needShowMenu()); boolean routeDialogOpened = mapRouteInfoMenu.isVisible() || (showRouteCalculationControls && mapRouteInfoMenu.needShowMenu());
boolean dialogOpened = routeDialogOpened || shouldHideTopControls; boolean showBackToLocation = !routeDialogOpened && mapActivity.getWidgetsVisibilityHelper().shouldShowBackToLocationButton();
boolean showBackToLocation = mapActivity.getWidgetsVisibilityHelper().shouldShowBackToLocationButton(); backToLocationControl.updateVisibility(showBackToLocation);
backToLocationControl.updateVisibility(!dialogOpened && showBackToLocation);
//routePlanningBtn.setIconResId(routeFollowingMode ? R.drawable.ic_action_info_dark : R.drawable.ic_action_gdirections_dark); //routePlanningBtn.setIconResId(routeFollowingMode ? R.drawable.ic_action_info_dark : R.drawable.ic_action_gdirections_dark);
updateRoutePlaningButton(rh, routePlanningMode); updateRoutePlaningButton(rh, routePlanningMode);
boolean showBottomMenuButtons = boolean showBottomMenuButtons = (showRouteCalculationControls || !routeFollowingMode) && vh.shouldShowBottomMenuButtons();
(showRouteCalculationControls || !routeFollowingMode) && vh.shouldShowBottomMenuButtons();
routePlanningBtn.updateVisibility(showBottomMenuButtons); routePlanningBtn.updateVisibility(showBottomMenuButtons);
menuControl.updateVisibility(showBottomMenuButtons); menuControl.updateVisibility(showBottomMenuButtons);
boolean showZoomButtons = !routeDialogOpened && vh.shouldShowZoomButtons();
boolean showZoomButtons = !routeDialogOpened && !shouldHideTopControls && vh.shouldShowZoomButtons();
mapZoomIn.updateVisibility(showZoomButtons); mapZoomIn.updateVisibility(showZoomButtons);
mapZoomOut.updateVisibility(showZoomButtons); mapZoomOut.updateVisibility(showZoomButtons);
boolean forceHideCompass = routeDialogOpened || trackDialogOpened || vh.shouldHideCompass(); boolean forceHideCompass = routeDialogOpened || vh.shouldHideCompass();
compassHud.forceHideCompass = forceHideCompass; compassHud.forceHideCompass = forceHideCompass;
compassHud.updateVisibility(!forceHideCompass && shouldShowCompass()); compassHud.updateVisibility(!forceHideCompass && shouldShowCompass());
@ -890,8 +885,7 @@ public class MapControlsLayer extends OsmandMapLayer {
if (layersHud.setIconResId(appMode.getIconRes())) { if (layersHud.setIconResId(appMode.getIconRes())) {
layersHud.update(app, isNight); layersHud.update(app, isNight);
} }
boolean showTopButtons = !routeDialogOpened && !trackDialogOpened boolean showTopButtons = !routeDialogOpened && vh.shouldShowTopButtons();
&& !shouldHideTopControls && vh.shouldShowTopButtons();
layersHud.updateVisibility(showTopButtons); layersHud.updateVisibility(showTopButtons);
quickSearchHud.updateVisibility(showTopButtons); quickSearchHud.updateVisibility(showTopButtons);

View file

@ -93,11 +93,14 @@ public class WidgetsVisibilityHelper {
&& !isInChoosingRoutesMode() && !isInChoosingRoutesMode()
&& !isInWaypointsChoosingMode() && !isInWaypointsChoosingMode()
&& !isInRouteLineAppearanceMode(); && !isInRouteLineAppearanceMode();
return !isInFollowTrackMode() && (additionalDialogsHide || !isPortrait()); return !mapActivity.shouldHideTopControls()
&& !isInFollowTrackMode()
&& (additionalDialogsHide || !isPortrait());
} }
public boolean shouldHideCompass() { public boolean shouldHideCompass() {
return mapActivity.shouldHideTopControls() return mapActivity.shouldHideTopControls()
|| isTrackDetailsMenuOpened()
|| isInMeasurementToolMode() || isInMeasurementToolMode()
|| isInPlanRouteMode() || isInPlanRouteMode()
|| isInChoosingRoutesMode() || isInChoosingRoutesMode()
@ -108,7 +111,9 @@ public class WidgetsVisibilityHelper {
} }
public boolean shouldShowTopButtons() { public boolean shouldShowTopButtons() {
return !isInMeasurementToolMode() return !mapActivity.shouldHideTopControls()
&& !isTrackDetailsMenuOpened()
&& !isInMeasurementToolMode()
&& !isInPlanRouteMode() && !isInPlanRouteMode()
&& !isInChoosingRoutesMode() && !isInChoosingRoutesMode()
&& !isInTrackAppearanceMode() && !isInTrackAppearanceMode()
@ -124,7 +129,8 @@ public class WidgetsVisibilityHelper {
&& !isInWaypointsChoosingMode() && !isInWaypointsChoosingMode()
&& !isInFollowTrackMode() && !isInFollowTrackMode()
&& !isInRouteLineAppearanceMode(); && !isInRouteLineAppearanceMode();
return !isInPlanRouteMode() return !mapActivity.shouldHideTopControls()
&& !isInPlanRouteMode()
&& !(isMapLinkedToLocation() && routingHelper.isFollowingMode()) && !(isMapLinkedToLocation() && routingHelper.isFollowingMode())
&& (additionalDialogsHide || !isPortrait()); && (additionalDialogsHide || !isPortrait());
} }
@ -215,6 +221,10 @@ public class WidgetsVisibilityHelper {
return mapActivity.getMapViewTrackingUtilities().isMapLinkedToLocation(); return mapActivity.getMapViewTrackingUtilities().isMapLinkedToLocation();
} }
private boolean isTrackDetailsMenuOpened() {
return mapActivity.getTrackDetailsMenu().isVisible();
}
private boolean isPortrait() { private boolean isPortrait() {
return AndroidUiHelper.isOrientationPortrait(mapActivity); return AndroidUiHelper.isOrientationPortrait(mapActivity);
} }