Map widgets visibility refactoring, part 1
This commit is contained in:
parent
372e4e7f49
commit
40b5220caa
7 changed files with 258 additions and 150 deletions
|
@ -140,6 +140,7 @@ import net.osmand.plus.views.layers.MapControlsLayer;
|
|||
import net.osmand.plus.views.layers.MapInfoLayer;
|
||||
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController;
|
||||
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarControllerType;
|
||||
import net.osmand.plus.views.mapwidgets.WidgetsVisibilityHelper;
|
||||
import net.osmand.render.RenderingRulesStorage;
|
||||
import net.osmand.router.GeneralRouter;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
@ -210,6 +211,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
|
||||
private MapActivityActions mapActions;
|
||||
private MapActivityLayers mapLayers;
|
||||
private WidgetsVisibilityHelper mapWidgetsVisibilityHelper;
|
||||
|
||||
// App variables
|
||||
private OsmandApplication app;
|
||||
|
@ -305,6 +307,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
}
|
||||
mapActions = new MapActivityActions(this);
|
||||
mapLayers = new MapActivityLayers(this);
|
||||
mapWidgetsVisibilityHelper = new WidgetsVisibilityHelper(this);
|
||||
dashboardOnMap.createDashboardView();
|
||||
checkAppInitialization();
|
||||
|
||||
|
@ -1597,6 +1600,10 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
return mapLayers;
|
||||
}
|
||||
|
||||
public WidgetsVisibilityHelper getWidgetsVisibilityHelper() {
|
||||
return mapWidgetsVisibilityHelper;
|
||||
}
|
||||
|
||||
public static void launchMapActivityMoveToTop(Context activity, Bundle prevIntentParams, Uri intentData, Bundle intentParams) {
|
||||
if (activity instanceof MapActivity) {
|
||||
if (((MapActivity) activity).getDashboard().isVisible()) {
|
||||
|
|
|
@ -13,7 +13,6 @@ import android.widget.Toast;
|
|||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.view.ContextThemeWrapper;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import net.osmand.CallbackWithObject;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
|
@ -184,7 +183,7 @@ public class MapActivityLayers {
|
|||
mapControlsLayer = new MapControlsLayer(activity);
|
||||
mapView.addLayer(mapControlsLayer, 11);
|
||||
// 12. quick actions layer
|
||||
mapQuickActionLayer = new MapQuickActionLayer(activity, contextMenuLayer);
|
||||
mapQuickActionLayer = new MapQuickActionLayer(activity);
|
||||
mapView.addLayer(mapQuickActionLayer, 12);
|
||||
contextMenuLayer.setMapQuickActionLayer(mapQuickActionLayer);
|
||||
mapControlsLayer.setMapQuickActionLayer(mapQuickActionLayer);
|
||||
|
|
|
@ -71,6 +71,7 @@ import net.osmand.plus.settings.backend.OsmandSettings;
|
|||
import net.osmand.plus.views.OsmandMapLayer;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
import net.osmand.plus.views.corenative.NativeCoreContext;
|
||||
import net.osmand.plus.views.mapwidgets.WidgetsVisibilityHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
|
@ -851,47 +852,36 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
// TODOnightMode
|
||||
// updatextColor(textColor, shadw, rulerControl, zoomControls, mapMenuControls);
|
||||
// default buttons
|
||||
boolean routePlanningMode = false;
|
||||
|
||||
RoutingHelper rh = mapActivity.getRoutingHelper();
|
||||
if (rh.isRoutePlanningMode()) {
|
||||
routePlanningMode = true;
|
||||
} else if ((rh.isRouteCalculated() || rh.isRouteBeingCalculated()) && !rh.isFollowingMode()) {
|
||||
routePlanningMode = true;
|
||||
}
|
||||
WidgetsVisibilityHelper vh = mapActivity.getWidgetsVisibilityHelper();
|
||||
|
||||
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 routeDialogOpened = mapRouteInfoMenu.isVisible() || (showRouteCalculationControls && mapRouteInfoMenu.needShowMenu());
|
||||
updateMyLocationVisibility(backToLocationControl, rh, routeDialogOpened || shouldHideTopControls);
|
||||
//routePlanningBtn.setIconResId(routeFollowingMode ? R.drawable.ic_action_info_dark : R.drawable.ic_action_gdirections_dark);
|
||||
|
||||
boolean dialogOpened = routeDialogOpened || shouldHideTopControls;
|
||||
boolean showBackToLocation = mapActivity.getWidgetsVisibilityHelper().shouldShowBackToLocationButton();
|
||||
backToLocationControl.updateVisibility(!dialogOpened && showBackToLocation);
|
||||
|
||||
//routePlanningBtn.setIconResId(routeFollowingMode ? R.drawable.ic_action_info_dark : R.drawable.ic_action_gdirections_dark);
|
||||
updateRoutePlaningButton(rh, routePlanningMode);
|
||||
|
||||
boolean showBottomMenuButtons = (showRouteCalculationControls || !routeFollowingMode)
|
||||
&& !isInMovingMarkerMode() && !isInGpxDetailsMode() && !isInMeasurementToolMode()
|
||||
&& !isInPlanRouteMode() && !shouldHideTopControls && !isInChoosingRoutesMode()
|
||||
&& !isInWaypointsChoosingMode() && !isInFollowTrackMode() && !isInTrackAppearanceMode()
|
||||
&& !isInRouteLineAppearanceMode();
|
||||
boolean showBottomMenuButtons =
|
||||
(showRouteCalculationControls || !routeFollowingMode) && vh.shouldShowBottomMenuButtons();
|
||||
routePlanningBtn.updateVisibility(showBottomMenuButtons);
|
||||
menuControl.updateVisibility(showBottomMenuButtons);
|
||||
|
||||
boolean additionalDialogsHide = !isInGpxApproximationMode()
|
||||
&& !isInTrackAppearanceMode()
|
||||
&& !isInChoosingRoutesMode()
|
||||
&& !isInWaypointsChoosingMode()
|
||||
&& !isInRouteLineAppearanceMode();
|
||||
boolean showZoomButtons = !routeDialogOpened && !shouldHideTopControls
|
||||
&& !isInFollowTrackMode()
|
||||
&& (additionalDialogsHide || !portrait);
|
||||
|
||||
boolean showZoomButtons = !routeDialogOpened && !shouldHideTopControls && vh.shouldShowZoomButtons();
|
||||
mapZoomIn.updateVisibility(showZoomButtons);
|
||||
mapZoomOut.updateVisibility(showZoomButtons);
|
||||
|
||||
boolean forceHideCompass = routeDialogOpened || trackDialogOpened || isInMeasurementToolMode()
|
||||
|| isInPlanRouteMode() || shouldHideTopControls || isInChoosingRoutesMode()
|
||||
|| isInTrackAppearanceMode() || isInWaypointsChoosingMode() || isInFollowTrackMode()
|
||||
|| isInRouteLineAppearanceMode();
|
||||
boolean forceHideCompass = routeDialogOpened || trackDialogOpened || vh.shouldHideCompass();
|
||||
compassHud.forceHideCompass = forceHideCompass;
|
||||
compassHud.updateVisibility(!forceHideCompass && shouldShowCompass());
|
||||
|
||||
|
@ -900,10 +890,8 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
if (layersHud.setIconResId(appMode.getIconRes())) {
|
||||
layersHud.update(app, isNight);
|
||||
}
|
||||
boolean showTopButtons = !routeDialogOpened && !trackDialogOpened && !shouldHideTopControls
|
||||
&& !isInMeasurementToolMode() && !isInPlanRouteMode() && !isInChoosingRoutesMode()
|
||||
&& !isInTrackAppearanceMode() && !isInWaypointsChoosingMode() && !isInFollowTrackMode()
|
||||
&& !isInRouteLineAppearanceMode();
|
||||
boolean showTopButtons = !routeDialogOpened && !trackDialogOpened
|
||||
&& !shouldHideTopControls && vh.shouldShowTopButtons();
|
||||
layersHud.updateVisibility(showTopButtons);
|
||||
quickSearchHud.updateVisibility(showTopButtons);
|
||||
|
||||
|
@ -1026,19 +1014,6 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
}
|
||||
}
|
||||
|
||||
public void updateMyLocationVisibility(MapHudButton backToLocationControl, RoutingHelper rh, boolean dialogOpened) {
|
||||
boolean tracked = mapActivity.getMapViewTrackingUtilities().isMapLinkedToLocation();
|
||||
boolean visible = !(tracked && rh.isFollowingMode());
|
||||
boolean additionalDialogsHide = !isInTrackAppearanceMode()
|
||||
&& !isInGpxApproximationMode()
|
||||
&& !isInChoosingRoutesMode()
|
||||
&& !isInWaypointsChoosingMode()
|
||||
&& !isInFollowTrackMode()
|
||||
&& !isInRouteLineAppearanceMode();
|
||||
backToLocationControl.updateVisibility(visible && !dialogOpened && !isInPlanRouteMode()
|
||||
&& (additionalDialogsHide || !isPotrait()));
|
||||
}
|
||||
|
||||
public boolean onSingleTap(PointF point, RotatedTileBox tileBox) {
|
||||
return mapRouteInfoMenu.onSingleTap(point, tileBox);
|
||||
}
|
||||
|
@ -1365,49 +1340,11 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
this.mapQuickActionLayer = mapQuickActionLayer;
|
||||
}
|
||||
|
||||
private boolean isInMovingMarkerMode() {
|
||||
return mapQuickActionLayer == null ? contextMenuLayer.isInChangeMarkerPositionMode() || contextMenuLayer.isInAddGpxPointMode() :
|
||||
mapQuickActionLayer.isInMovingMarkerMode() || contextMenuLayer.isInChangeMarkerPositionMode() || contextMenuLayer.isInAddGpxPointMode();
|
||||
}
|
||||
|
||||
private boolean isInGpxDetailsMode() {
|
||||
return contextMenuLayer.isInGpxDetailsMode();
|
||||
}
|
||||
|
||||
private boolean isInMeasurementToolMode() {
|
||||
return mapActivity.getMapLayers().getMeasurementToolLayer().isInMeasurementMode();
|
||||
}
|
||||
|
||||
private boolean isInPlanRouteMode() {
|
||||
return mapActivity.getMapLayers().getMapMarkersLayer().isInPlanRouteMode();
|
||||
}
|
||||
|
||||
private boolean isInTrackAppearanceMode() {
|
||||
return mapActivity.getMapLayers().getGpxLayer().isInTrackAppearanceMode();
|
||||
}
|
||||
|
||||
private boolean isInGpxApproximationMode() {
|
||||
return mapActivity.getMapLayers().getMeasurementToolLayer().isTapsDisabled();
|
||||
}
|
||||
|
||||
public boolean isInTrackMenuMode() {
|
||||
return mapActivity.getTrackMenuFragment() != null && mapActivity.getTrackMenuFragment().isVisible();
|
||||
}
|
||||
|
||||
private boolean isInChoosingRoutesMode() {
|
||||
return MapRouteInfoMenu.chooseRoutesVisible;
|
||||
}
|
||||
|
||||
private boolean isInWaypointsChoosingMode() {
|
||||
return MapRouteInfoMenu.waypointsVisible;
|
||||
}
|
||||
|
||||
private boolean isInRouteLineAppearanceMode() {
|
||||
return mapActivity.getMapLayers().getRouteLayer().isInRouteLineAppearanceMode();
|
||||
}
|
||||
|
||||
private boolean isInFollowTrackMode() {
|
||||
return MapRouteInfoMenu.followTrackVisible;
|
||||
private boolean isInRoutePlanningMode() {
|
||||
RoutingHelper routingHelper = mapActivity.getRoutingHelper();
|
||||
return routingHelper.isRoutePlanningMode()
|
||||
|| ((routingHelper.isRouteCalculated() || routingHelper.isRouteBeingCalculated())
|
||||
&& !routingHelper.isFollowingMode());
|
||||
}
|
||||
|
||||
public static View.OnLongClickListener getOnClickMagnifierListener(final OsmandMapTileView view) {
|
||||
|
|
|
@ -19,7 +19,6 @@ import android.widget.ImageView;
|
|||
import androidx.annotation.DimenRes;
|
||||
import androidx.appcompat.content.res.AppCompatResources;
|
||||
import androidx.core.util.Pair;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.getkeepsafe.taptargetview.TapTarget;
|
||||
import com.getkeepsafe.taptargetview.TapTargetView;
|
||||
|
@ -33,18 +32,13 @@ import net.osmand.plus.R;
|
|||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
||||
import net.osmand.plus.mapcontextmenu.MapContextMenuFragment;
|
||||
import net.osmand.plus.mapcontextmenu.other.MapMultiSelectionMenu;
|
||||
import net.osmand.plus.measurementtool.MeasurementToolLayer;
|
||||
import net.osmand.plus.quickaction.QuickAction;
|
||||
import net.osmand.plus.quickaction.QuickActionRegistry;
|
||||
import net.osmand.plus.quickaction.QuickActionsWidget;
|
||||
import net.osmand.plus.routepreparationmenu.MapRouteInfoMenu;
|
||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||
import net.osmand.plus.views.OsmandMapLayer;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -56,12 +50,6 @@ import static net.osmand.plus.views.layers.ContextMenuLayer.VIBRATE_SHORT;
|
|||
|
||||
public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRegistry.QuickActionUpdatesListener, QuickAction.QuickActionSelectionListener {
|
||||
|
||||
private final ContextMenuLayer contextMenuLayer;
|
||||
private final MeasurementToolLayer measurementToolLayer;
|
||||
private final MapMarkersLayer mapMarkersLayer;
|
||||
private final MapControlsLayer mapControlsLayer;
|
||||
private final GPXLayer gpxLayer;
|
||||
private final RouteLayer routeLayer;
|
||||
private ImageView contextMarker;
|
||||
private final MapActivity mapActivity;
|
||||
private final OsmandApplication app;
|
||||
|
@ -81,17 +69,11 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
|
|||
private boolean nightMode;
|
||||
private Boolean currentWidgetState;
|
||||
|
||||
public MapQuickActionLayer(MapActivity activity, ContextMenuLayer contextMenuLayer) {
|
||||
public MapQuickActionLayer(MapActivity activity) {
|
||||
this.mapActivity = activity;
|
||||
this.contextMenuLayer = contextMenuLayer;
|
||||
app = activity.getMyApplication();
|
||||
settings = activity.getMyApplication().getSettings();
|
||||
quickActionRegistry = app.getQuickActionRegistry();
|
||||
measurementToolLayer = mapActivity.getMapLayers().getMeasurementToolLayer();
|
||||
mapMarkersLayer = mapActivity.getMapLayers().getMapMarkersLayer();
|
||||
gpxLayer = mapActivity.getMapLayers().getGpxLayer();
|
||||
mapControlsLayer = mapActivity.getMapLayers().getMapControlsLayer();
|
||||
routeLayer = mapActivity.getMapLayers().getRouteLayer();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -415,29 +397,8 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
|
|||
}
|
||||
|
||||
private void setupQuickActionBtnVisibility() {
|
||||
MapContextMenu contextMenu = mapActivity.getContextMenu();
|
||||
MapRouteInfoMenu mapRouteInfoMenu = mapActivity.getMapRouteInfoMenu();
|
||||
MapMultiSelectionMenu multiSelectionMenu = contextMenu.getMultiSelectionMenu();
|
||||
WeakReference<MapContextMenuFragment> contextMenuMenuFragmentRef = contextMenu.findMenuFragment();
|
||||
MapContextMenuFragment contextMenuMenuFragment = contextMenuMenuFragmentRef != null ? contextMenuMenuFragmentRef.get() : null;
|
||||
Fragment multiMenuFragment = multiSelectionMenu.getFragmentByTag();
|
||||
boolean hideQuickButton = !isLayerOn ||
|
||||
contextMenuLayer.isInChangeMarkerPositionMode() ||
|
||||
contextMenuLayer.isInGpxDetailsMode() ||
|
||||
measurementToolLayer.isInMeasurementMode() ||
|
||||
mapMarkersLayer.isInPlanRouteMode() ||
|
||||
gpxLayer.isInTrackAppearanceMode() ||
|
||||
mapControlsLayer.isInTrackMenuMode() ||
|
||||
routeLayer.isInRouteLineAppearanceMode() ||
|
||||
mapRouteInfoMenu.isVisible() ||
|
||||
MapRouteInfoMenu.chooseRoutesVisible ||
|
||||
MapRouteInfoMenu.waypointsVisible ||
|
||||
MapRouteInfoMenu.followTrackVisible ||
|
||||
contextMenu.isVisible() && contextMenuMenuFragment != null && !contextMenuMenuFragment.isRemoving() ||
|
||||
contextMenu.isVisible() && contextMenuMenuFragment != null && contextMenuMenuFragment.isAdded() ||
|
||||
multiSelectionMenu.isVisible() && multiMenuFragment != null && multiMenuFragment.isAdded() ||
|
||||
multiSelectionMenu.isVisible() && multiMenuFragment != null && !multiMenuFragment.isRemoving();
|
||||
quickActionButton.setVisibility(hideQuickButton ? View.GONE : View.VISIBLE);
|
||||
boolean visible = mapActivity.getWidgetsVisibilityHelper().shouldShowQuickActionButton();
|
||||
quickActionButton.setVisibility(visible ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1204,13 +1204,7 @@ public class MapInfoWidgetsFactory {
|
|||
|
||||
@SuppressLint("SetTextI18n")
|
||||
public boolean updateInfo() {
|
||||
boolean visible = settings.SHOW_COORDINATES_WIDGET.get() && !map.shouldHideTopControls()
|
||||
&& map.getMapRouteInfoMenu().shouldShowTopControls() && !map.isTopToolbarActive()
|
||||
&& !map.getMapLayers().getGpxLayer().isInTrackAppearanceMode()
|
||||
&& !map.getMapLayers().getRouteLayer().isInRouteLineAppearanceMode()
|
||||
&& !MapRouteInfoMenu.chooseRoutesVisible && !MapRouteInfoMenu.waypointsVisible
|
||||
&& !MapRouteInfoMenu.followTrackVisible;
|
||||
|
||||
boolean visible = map.getWidgetsVisibilityHelper().shouldShowTopCoordinatesWidget();
|
||||
updateVisibility(visible);
|
||||
if (visible) {
|
||||
lastKnownLocation = locationProvider.getLastKnownLocation();
|
||||
|
|
|
@ -36,7 +36,6 @@ public class MapMarkersWidgetsFactory {
|
|||
private boolean portraitMode;
|
||||
|
||||
private View topBar;
|
||||
private View addressTopBar;
|
||||
private View topBar2nd;
|
||||
private View rowView;
|
||||
private View rowView2nd;
|
||||
|
@ -60,7 +59,6 @@ public class MapMarkersWidgetsFactory {
|
|||
helper = map.getMyApplication().getMapMarkersHelper();
|
||||
portraitMode = AndroidUiHelper.isOrientationPortrait(map);
|
||||
|
||||
addressTopBar = map.findViewById(R.id.map_top_bar);
|
||||
topBar = map.findViewById(R.id.map_markers_top_bar);
|
||||
topBar2nd = map.findViewById(R.id.map_markers_top_bar_2nd);
|
||||
rowView = map.findViewById(R.id.map_marker_row);
|
||||
|
@ -181,18 +179,8 @@ public class MapMarkersWidgetsFactory {
|
|||
}
|
||||
|
||||
List<MapMarker> markers = helper.getMapMarkers();
|
||||
if (zoom < 3 || markers.size() == 0
|
||||
|| !map.getMyApplication().getSettings().MARKERS_DISTANCE_INDICATION_ENABLED.get()
|
||||
|| !map.getMyApplication().getSettings().MAP_MARKERS_MODE.get().isToolbar()
|
||||
|| map.getMyApplication().getRoutingHelper().isFollowingMode()
|
||||
|| map.getMyApplication().getRoutingHelper().isRoutePlanningMode()
|
||||
|| map.getMapRouteInfoMenu().isVisible()
|
||||
|| addressTopBar.getVisibility() == View.VISIBLE
|
||||
|| map.isTopToolbarActive()
|
||||
|| map.shouldHideTopControls()
|
||||
|| map.getMapLayers().getGpxLayer().isInTrackAppearanceMode()
|
||||
|| map.getMapLayers().getMapMarkersLayer().isInPlanRouteMode()
|
||||
|| map.getMapLayers().getRouteLayer().isInRouteLineAppearanceMode()) {
|
||||
WidgetsVisibilityHelper vh = map.getWidgetsVisibilityHelper();
|
||||
if (zoom < 3 || markers.size() == 0 || vh.shouldHideMapMarkersWidget()) {
|
||||
updateVisibility(false);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,222 @@
|
|||
package net.osmand.plus.views.mapwidgets;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
||||
import net.osmand.plus.mapcontextmenu.MapContextMenuFragment;
|
||||
import net.osmand.plus.mapcontextmenu.other.MapMultiSelectionMenu;
|
||||
import net.osmand.plus.routepreparationmenu.MapRouteInfoMenu;
|
||||
import net.osmand.plus.routing.RoutingHelper;
|
||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||
import net.osmand.plus.views.layers.MapQuickActionLayer;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
public class WidgetsVisibilityHelper {
|
||||
|
||||
private MapActivity mapActivity;
|
||||
private OsmandSettings settings;
|
||||
private RoutingHelper routingHelper;
|
||||
|
||||
public WidgetsVisibilityHelper(@NonNull MapActivity mapActivity) {
|
||||
this.mapActivity = mapActivity;
|
||||
this.settings = mapActivity.getMyApplication().getSettings();
|
||||
this.routingHelper = mapActivity.getRoutingHelper();
|
||||
}
|
||||
|
||||
public boolean shouldShowQuickActionButton() {
|
||||
return isQuickActionLayerOn()
|
||||
&& !isInChangeMarkerPositionMode()
|
||||
&& !isInGpxDetailsMode()
|
||||
&& !isInMeasurementToolMode()
|
||||
&& !isInPlanRouteMode()
|
||||
&& !isInTrackAppearanceMode()
|
||||
&& !isInTrackMenuMode()
|
||||
&& !isInRouteLineAppearanceMode()
|
||||
&& !isMapRouteInfoMenuVisible()
|
||||
&& !isInChoosingRoutesMode()
|
||||
&& !isInWaypointsChoosingMode()
|
||||
&& !isInFollowTrackMode()
|
||||
&& !isContextMenuFragmentVisible()
|
||||
&& !isMultiSelectionMenuFragmentVisible();
|
||||
}
|
||||
|
||||
public boolean shouldShowTopCoordinatesWidget() {
|
||||
return settings.SHOW_COORDINATES_WIDGET.get()
|
||||
&& !mapActivity.shouldHideTopControls()
|
||||
&& mapActivity.getMapRouteInfoMenu().shouldShowTopControls()
|
||||
&& !mapActivity.isTopToolbarActive()
|
||||
&& !isInTrackAppearanceMode()
|
||||
&& !isInRouteLineAppearanceMode()
|
||||
&& !isInChoosingRoutesMode()
|
||||
&& !isInWaypointsChoosingMode()
|
||||
&& !isInFollowTrackMode();
|
||||
}
|
||||
|
||||
public boolean shouldHideMapMarkersWidget() {
|
||||
View addressTopBar = mapActivity.findViewById(R.id.map_top_bar);
|
||||
return !settings.MARKERS_DISTANCE_INDICATION_ENABLED.get()
|
||||
|| !settings.MAP_MARKERS_MODE.get().isToolbar()
|
||||
|| addressTopBar != null && addressTopBar.getVisibility() == View.VISIBLE
|
||||
|| routingHelper.isFollowingMode()
|
||||
|| routingHelper.isRoutePlanningMode()
|
||||
|| isMapRouteInfoMenuVisible()
|
||||
|| mapActivity.isTopToolbarActive()
|
||||
|| mapActivity.shouldHideTopControls()
|
||||
|| isInTrackAppearanceMode()
|
||||
|| isInPlanRouteMode()
|
||||
|| isInRouteLineAppearanceMode();
|
||||
}
|
||||
|
||||
public boolean shouldShowBottomMenuButtons() {
|
||||
return !mapActivity.shouldHideTopControls()
|
||||
&& !isInMovingMarkerMode()
|
||||
&& !isInGpxDetailsMode()
|
||||
&& !isInMeasurementToolMode()
|
||||
&& !isInPlanRouteMode()
|
||||
&& !isInChoosingRoutesMode()
|
||||
&& !isInWaypointsChoosingMode()
|
||||
&& !isInFollowTrackMode()
|
||||
&& !isInTrackAppearanceMode()
|
||||
&& !isInRouteLineAppearanceMode();
|
||||
}
|
||||
|
||||
public boolean shouldShowZoomButtons() {
|
||||
boolean additionalDialogsHide = !isInGpxApproximationMode()
|
||||
&& !isInTrackAppearanceMode()
|
||||
&& !isInChoosingRoutesMode()
|
||||
&& !isInWaypointsChoosingMode()
|
||||
&& !isInRouteLineAppearanceMode();
|
||||
return !isInFollowTrackMode() && (additionalDialogsHide || !isPortrait());
|
||||
}
|
||||
|
||||
public boolean shouldHideCompass() {
|
||||
return mapActivity.shouldHideTopControls()
|
||||
|| isInMeasurementToolMode()
|
||||
|| isInPlanRouteMode()
|
||||
|| isInChoosingRoutesMode()
|
||||
|| isInTrackAppearanceMode()
|
||||
|| isInWaypointsChoosingMode()
|
||||
|| isInFollowTrackMode()
|
||||
|| isInRouteLineAppearanceMode();
|
||||
}
|
||||
|
||||
public boolean shouldShowTopButtons() {
|
||||
return !isInMeasurementToolMode()
|
||||
&& !isInPlanRouteMode()
|
||||
&& !isInChoosingRoutesMode()
|
||||
&& !isInTrackAppearanceMode()
|
||||
&& !isInWaypointsChoosingMode()
|
||||
&& !isInFollowTrackMode()
|
||||
&& !isInRouteLineAppearanceMode();
|
||||
}
|
||||
|
||||
public boolean shouldShowBackToLocationButton() {
|
||||
boolean additionalDialogsHide = !isInTrackAppearanceMode()
|
||||
&& !isInGpxApproximationMode()
|
||||
&& !isInChoosingRoutesMode()
|
||||
&& !isInWaypointsChoosingMode()
|
||||
&& !isInFollowTrackMode()
|
||||
&& !isInRouteLineAppearanceMode();
|
||||
return !isInPlanRouteMode()
|
||||
&& !(isMapLinkedToLocation() && routingHelper.isFollowingMode())
|
||||
&& (additionalDialogsHide || !isPortrait());
|
||||
}
|
||||
|
||||
private boolean isQuickActionLayerOn() {
|
||||
return mapActivity.getMapLayers().getMapQuickActionLayer().isLayerOn();
|
||||
}
|
||||
|
||||
private boolean isMapRouteInfoMenuVisible() {
|
||||
return mapActivity.getMapRouteInfoMenu().isVisible();
|
||||
}
|
||||
|
||||
private boolean isInMovingMarkerMode() {
|
||||
MapQuickActionLayer quickActionLayer = mapActivity.getMapLayers().getMapQuickActionLayer();
|
||||
boolean isInMovingMarkerMode = quickActionLayer != null && quickActionLayer.isInMovingMarkerMode();
|
||||
return isInMovingMarkerMode || isInChangeMarkerPositionMode() || isInAddGpxPointMode();
|
||||
}
|
||||
|
||||
private boolean isInGpxDetailsMode() {
|
||||
return mapActivity.getMapLayers().getContextMenuLayer().isInGpxDetailsMode();
|
||||
}
|
||||
|
||||
private boolean isInAddGpxPointMode() {
|
||||
return mapActivity.getMapLayers().getContextMenuLayer().isInAddGpxPointMode();
|
||||
}
|
||||
|
||||
private boolean isInChangeMarkerPositionMode() {
|
||||
return mapActivity.getMapLayers().getContextMenuLayer().isInChangeMarkerPositionMode();
|
||||
}
|
||||
|
||||
private boolean isInMeasurementToolMode() {
|
||||
return mapActivity.getMapLayers().getMeasurementToolLayer().isInMeasurementMode();
|
||||
}
|
||||
|
||||
private boolean isInPlanRouteMode() {
|
||||
return mapActivity.getMapLayers().getMapMarkersLayer().isInPlanRouteMode();
|
||||
}
|
||||
|
||||
private boolean isInTrackAppearanceMode() {
|
||||
return mapActivity.getMapLayers().getGpxLayer().isInTrackAppearanceMode();
|
||||
}
|
||||
|
||||
private boolean isInGpxApproximationMode() {
|
||||
return mapActivity.getMapLayers().getMeasurementToolLayer().isTapsDisabled();
|
||||
}
|
||||
|
||||
public boolean isInTrackMenuMode() {
|
||||
return mapActivity.getTrackMenuFragment() != null && mapActivity.getTrackMenuFragment().isVisible();
|
||||
}
|
||||
|
||||
private boolean isInChoosingRoutesMode() {
|
||||
return MapRouteInfoMenu.chooseRoutesVisible;
|
||||
}
|
||||
|
||||
private boolean isInWaypointsChoosingMode() {
|
||||
return MapRouteInfoMenu.waypointsVisible;
|
||||
}
|
||||
|
||||
private boolean isInRouteLineAppearanceMode() {
|
||||
return mapActivity.getMapLayers().getRouteLayer().isInRouteLineAppearanceMode();
|
||||
}
|
||||
|
||||
private boolean isInFollowTrackMode() {
|
||||
return MapRouteInfoMenu.followTrackVisible;
|
||||
}
|
||||
|
||||
private boolean isContextMenuFragmentVisible() {
|
||||
MapContextMenu contextMenu = mapActivity.getContextMenu();
|
||||
WeakReference<MapContextMenuFragment> contextMenuMenuFragmentRef = contextMenu.findMenuFragment();
|
||||
MapContextMenuFragment contextMenuMenuFragment = contextMenuMenuFragmentRef != null ? contextMenuMenuFragmentRef.get() : null;
|
||||
if (contextMenuMenuFragment != null && contextMenu.isVisible()) {
|
||||
return !contextMenuMenuFragment.isRemoving() || contextMenuMenuFragment.isAdded();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isMultiSelectionMenuFragmentVisible() {
|
||||
MapContextMenu contextMenu = mapActivity.getContextMenu();
|
||||
MapMultiSelectionMenu multiSelectionMenu = contextMenu.getMultiSelectionMenu();
|
||||
Fragment multiMenuFragment = multiSelectionMenu.getFragmentByTag();
|
||||
if (multiMenuFragment != null && multiSelectionMenu.isVisible()) {
|
||||
return multiMenuFragment.isAdded() || !multiMenuFragment.isRemoving();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isMapLinkedToLocation() {
|
||||
return mapActivity.getMapViewTrackingUtilities().isMapLinkedToLocation();
|
||||
}
|
||||
|
||||
private boolean isPortrait() {
|
||||
return AndroidUiHelper.isOrientationPortrait(mapActivity);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue