Merge pull request #10673 from osmandapp/points_fixes

GPX menu fixes second part
This commit is contained in:
vshcherb 2021-01-27 12:57:50 +01:00 committed by GitHub
commit 22f49928da
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 111 additions and 115 deletions

View file

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/map_controls_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
tools:visibility="invisible">
<include
layout="@layout/map_ruler"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start|bottom"
android:layout_marginStart="@dimen/fab_margin_right"
android:layout_marginLeft="@dimen/fab_margin_right"
android:layout_marginEnd="@dimen/fab_margin_right"
android:layout_marginRight="@dimen/fab_margin_right" />
<include
layout="@layout/map_hud_controls"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_marginStart="@dimen/fab_margin_right"
android:layout_marginLeft="@dimen/fab_margin_right"
android:layout_marginEnd="@dimen/fab_margin_right"
android:layout_marginRight="@dimen/fab_margin_right" />
</FrameLayout>

View file

@ -99,34 +99,7 @@
</LinearLayout>
<FrameLayout
android:id="@+id/map_controls_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
tools:visibility="invisible">
<include
layout="@layout/map_ruler"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start|bottom"
android:layout_marginStart="@dimen/fab_margin_right"
android:layout_marginLeft="@dimen/fab_margin_right"
android:layout_marginEnd="@dimen/fab_margin_right"
android:layout_marginRight="@dimen/fab_margin_right" />
<include
layout="@layout/map_hud_controls"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_marginStart="@dimen/fab_margin_right"
android:layout_marginLeft="@dimen/fab_margin_right"
android:layout_marginEnd="@dimen/fab_margin_right"
android:layout_marginRight="@dimen/fab_margin_right" />
</FrameLayout>
<include layout="@layout/context_menu_controls" />
<LinearLayout
android:id="@+id/control_buttons"

View file

@ -90,34 +90,7 @@
</LinearLayout>
<FrameLayout
android:id="@+id/map_controls_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
tools:visibility="invisible">
<include
layout="@layout/map_ruler"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start|bottom"
android:layout_marginStart="@dimen/fab_margin_right"
android:layout_marginLeft="@dimen/fab_margin_right"
android:layout_marginEnd="@dimen/fab_margin_right"
android:layout_marginRight="@dimen/fab_margin_right" />
<include
layout="@layout/map_hud_controls"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_marginStart="@dimen/fab_margin_right"
android:layout_marginLeft="@dimen/fab_margin_right"
android:layout_marginEnd="@dimen/fab_margin_right"
android:layout_marginRight="@dimen/fab_margin_right" />
</FrameLayout>
<include layout="@layout/context_menu_controls" />
<LinearLayout
android:id="@+id/control_buttons"

View file

@ -191,6 +191,8 @@
</com.google.android.material.appbar.AppBarLayout>
<include layout="@layout/context_menu_controls" />
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"

View file

@ -70,7 +70,6 @@ import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
import net.osmand.plus.OnDismissDialogFragmentListener;
import net.osmand.plus.OsmAndConstants;
import net.osmand.plus.OsmAndLocationProvider;
import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener;
import net.osmand.plus.OsmAndLocationSimulation;
import net.osmand.plus.OsmandApplication;
@ -1568,6 +1567,17 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
}
}
public boolean shouldHideTopControls() {
boolean hideTopControls = !mapContextMenu.shouldShowTopControls();
TrackMenuFragment fragment = getTrackMenuFragment();
if (fragment != null) {
hideTopControls = hideTopControls || !fragment.shouldShowTopControls();
}
return hideTopControls;
}
public OsmandMapTileView getMapView() {
return mapView;
}

View file

@ -103,7 +103,7 @@ public abstract class ContextMenuFragment extends BaseOsmAndFragment
public interface ContextMenuFragmentListener {
void onContextMenuYPosChanged(@NonNull ContextMenuFragment fragment, int y, boolean needMapAdjust, boolean animated);
void onContextMenuStateChanged(@NonNull ContextMenuFragment fragment, int menuState);
void onContextMenuStateChanged(@NonNull ContextMenuFragment fragment, int menuState, int previousMenuState);
void onContextMenuDismiss(@NonNull ContextMenuFragment fragment);
}
@ -815,7 +815,7 @@ public abstract class ContextMenuFragment extends BaseOsmAndFragment
ContextMenuFragmentListener listener = this.listener;
if (listener != null) {
listener.onContextMenuStateChanged(this, newMenuState);
listener.onContextMenuStateChanged(this, newMenuState, currentMenuState);
}
}
@ -971,7 +971,8 @@ public abstract class ContextMenuFragment extends BaseOsmAndFragment
ContextMenuFragmentListener listener = ContextMenuFragment.this.listener;
if (listener != null) {
listener.onContextMenuStateChanged(ContextMenuFragment.this, getCurrentMenuState());
int menuState = getCurrentMenuState();
listener.onContextMenuStateChanged(ContextMenuFragment.this, menuState, menuState);
}
}
}

View file

@ -82,7 +82,7 @@ public abstract class ContextMenuScrollFragment extends ContextMenuFragment impl
}
@Override
public void onContextMenuStateChanged(@NonNull ContextMenuFragment fragment, int menuState) {
public void onContextMenuStateChanged(@NonNull ContextMenuFragment fragment, int menuState, int previousMenuState) {
updateMapControlsVisibility(menuState);
}

View file

@ -22,18 +22,17 @@ import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.data.TransportStop;
import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
import net.osmand.plus.mapmarkers.MapMarker;
import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarkerChangedListener;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper.TargetPoint;
import net.osmand.plus.TargetPointsHelper.TargetPointChangedListener;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.helpers.GpxUiHelper;
import net.osmand.plus.mapcontextmenu.AdditionalActionsBottomSheetDialogFragment.ContextMenuItemClickListener;
import net.osmand.plus.mapcontextmenu.MenuController.ContextMenuToolbarController;
import net.osmand.plus.mapcontextmenu.MenuController.MenuState;
import net.osmand.plus.mapcontextmenu.MenuController.MenuType;
@ -47,12 +46,14 @@ import net.osmand.plus.mapcontextmenu.editors.RtePtEditor;
import net.osmand.plus.mapcontextmenu.editors.WptPtEditor;
import net.osmand.plus.mapcontextmenu.other.MapMultiSelectionMenu;
import net.osmand.plus.mapcontextmenu.other.ShareMenu;
import net.osmand.plus.mapcontextmenu.AdditionalActionsBottomSheetDialogFragment.ContextMenuItemClickListener;
import net.osmand.plus.mapmarkers.MapMarker;
import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarkerChangedListener;
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.transport.TransportStopRoute;
import net.osmand.plus.views.layers.ContextMenuLayer;
import net.osmand.plus.views.OsmandMapLayer;
import net.osmand.plus.views.layers.ContextMenuLayer;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarControllerType;
import net.osmand.util.Algorithms;
@ -570,18 +571,21 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
public void updateControlsVisibility(boolean menuVisible) {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
int topControlsVisibility = shouldShowTopControls(menuVisible) ? View.VISIBLE : View.GONE;
mapActivity.findViewById(R.id.map_center_info).setVisibility(topControlsVisibility);
mapActivity.findViewById(R.id.map_left_widgets_panel).setVisibility(topControlsVisibility);
mapActivity.findViewById(R.id.map_right_widgets_panel).setVisibility(topControlsVisibility);
int bottomControlsVisibility = shouldShowBottomControls(menuVisible) ? View.VISIBLE : View.GONE;
mapActivity.findViewById(R.id.bottom_controls_container).setVisibility(bottomControlsVisibility);
mapActivity.refreshMap();
boolean topControlsVisible = shouldShowTopControls(menuVisible);
boolean bottomControlsVisible = shouldShowBottomControls(menuVisible);
updateControlsVisibility(mapActivity, topControlsVisible, bottomControlsVisible);
}
}
public static void updateControlsVisibility(@NonNull MapActivity mapActivity, boolean topControlsVisible, boolean bottomControlsVisible) {
AndroidUiHelper.updateVisibility(mapActivity.findViewById(R.id.map_center_info), topControlsVisible);
AndroidUiHelper.updateVisibility(mapActivity.findViewById(R.id.map_left_widgets_panel), topControlsVisible);
AndroidUiHelper.updateVisibility(mapActivity.findViewById(R.id.map_right_widgets_panel), topControlsVisible);
AndroidUiHelper.updateVisibility(mapActivity.findViewById(R.id.bottom_controls_container), bottomControlsVisible);
mapActivity.refreshMap();
}
public boolean shouldShowTopControls() {
return shouldShowTopControls(isVisible());
}

View file

@ -815,7 +815,7 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
}
@Override
public void onContextMenuStateChanged(@NonNull ContextMenuFragment fragment, int menuState) {
public void onContextMenuStateChanged(@NonNull ContextMenuFragment fragment, int menuState, int previousMenuState) {
LockableViewPager viewPager = this.viewPager;
RouteDetailsFragment current = getCurrentFragment();
if (viewPager != null && fragment == current) {

View file

@ -74,7 +74,9 @@ public class OptionsCard extends BaseCard {
items.add(createDirectionsItem());
}
items.add(createDividerItem());
items.add(createJoinGapsItem());
if (gpxFile.getGeneralTrack() != null) {
items.add(createJoinGapsItem());
}
items.add(createAnalyzeOnMapItem());
items.add(createAnalyzeByIntervalsItem());

View file

@ -152,6 +152,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
private int menuTitleHeight;
private int toolbarHeightPx;
private boolean mapPositionAdjusted;
public enum TrackMenuType {
OVERVIEW(R.id.action_overview, R.string.shared_string_overview),
@ -258,6 +259,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
if (isPortrait()) {
AndroidUiHelper.updateVisibility(getTopShadow(), true);
AndroidUiHelper.updateVisibility(view.findViewById(R.id.map_my_location_button), false);
} else {
int widthNoShadow = getLandscapeNoShadowWidth();
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(widthNoShadow, ViewGroup.LayoutParams.WRAP_CONTENT);
@ -269,7 +271,6 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
setupToolbar();
updateHeader();
setupButtons(view);
enterTrackAppearanceMode();
runLayoutListener();
}
return view;
@ -455,15 +456,21 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
adjustMapPosition(getHeight());
public void onContextMenuStateChanged(@NonNull ContextMenuFragment fragment, int currentMenuState, int previousMenuState) {
super.onContextMenuStateChanged(fragment, currentMenuState, previousMenuState);
boolean changed = currentMenuState != previousMenuState;
if (changed) {
updateControlsVisibility(true);
}
if (currentMenuState != MenuState.FULL_SCREEN && (changed || !mapPositionAdjusted)) {
adjustMapPosition(getViewY());
}
}
@Override
public void onDestroyView() {
super.onDestroyView();
exitTrackAppearanceMode();
updateStatusBarColor();
}
@ -474,6 +481,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
if (mapActivity != null && trackChartPoints != null) {
mapActivity.getMapLayers().getGpxLayer().setTrackChartPoints(trackChartPoints);
}
updateControlsVisibility(true);
startLocationUpdate();
}
@ -484,6 +492,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
if (mapActivity != null) {
mapActivity.getMapLayers().getGpxLayer().setTrackChartPoints(null);
}
updateControlsVisibility(false);
stopLocationUpdate();
}
@ -569,26 +578,25 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
updateContent();
}
private void enterTrackAppearanceMode() {
public void updateControlsVisibility(boolean menuVisible) {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
boolean portrait = AndroidUiHelper.isOrientationPortrait(mapActivity);
AndroidUiHelper.setVisibility(mapActivity, portrait ? View.INVISIBLE : View.GONE,
R.id.map_left_widgets_panel,
R.id.map_right_widgets_panel,
R.id.map_center_info);
boolean topControlsVisible = shouldShowTopControls(menuVisible);
boolean bottomControlsVisible = shouldShowBottomControls(menuVisible);
MapContextMenu.updateControlsVisibility(mapActivity, topControlsVisible, bottomControlsVisible);
}
}
private void exitTrackAppearanceMode() {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
AndroidUiHelper.setVisibility(mapActivity, View.VISIBLE,
R.id.map_left_widgets_panel,
R.id.map_right_widgets_panel,
R.id.map_center_info,
R.id.map_search_button);
}
public boolean shouldShowTopControls() {
return shouldShowTopControls(isVisible());
}
public boolean shouldShowTopControls(boolean menuVisible) {
return !menuVisible || !isPortrait() || getCurrentMenuState() == MenuState.HEADER_ONLY;
}
public boolean shouldShowBottomControls(boolean menuVisible) {
return !menuVisible || !isPortrait();
}
@Override
@ -760,15 +768,6 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
}
}
@Override
protected int applyPosY(int currentY, boolean needCloseMenu, boolean needMapAdjust, int previousMenuState, int newMenuState, int dZoom, boolean animated) {
int y = super.applyPosY(currentY, needCloseMenu, needMapAdjust, previousMenuState, newMenuState, dZoom, animated);
if (needMapAdjust) {
adjustMapPosition(y);
}
return y;
}
public void updateToolbar(int y, boolean animated) {
final MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
@ -821,6 +820,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
if (r.left != 0 && r.right != 0) {
mapActivity.getMapView().fitRectToMap(r.left, r.right, r.top, r.bottom, tileBoxWidthPx, tileBoxHeightPx, 0);
}
mapPositionAdjusted = true;
}
}

View file

@ -859,30 +859,30 @@ public class MapControlsLayer extends OsmandMapLayer {
}
boolean routeFollowingMode = !routePlanningMode && rh.isFollowingMode();
boolean trackDialogOpened = mapActivity.getTrackDetailsMenu().isVisible();
boolean contextMenuOpened = !mapActivity.getContextMenu().shouldShowTopControls();
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 || contextMenuOpened);
updateMyLocationVisibility(backToLocationControl, rh, routeDialogOpened || shouldHideTopControls);
//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() && !contextMenuOpened && !isInChoosingRoutesMode()
&& !isInPlanRouteMode() && !shouldHideTopControls && !isInChoosingRoutesMode()
&& !isInWaypointsChoosingMode() && !isInFollowTrackMode() && !isInTrackAppearanceMode();
routePlanningBtn.updateVisibility(showBottomMenuButtons);
menuControl.updateVisibility(showBottomMenuButtons);
boolean showZoomButtons = !routeDialogOpened && !contextMenuOpened && !isInTrackAppearanceMode()
boolean showZoomButtons = !routeDialogOpened && !shouldHideTopControls && !isInTrackAppearanceMode()
&& (!isInGpxApproximationMode() || !isPotrait())
&& !isInFollowTrackMode() && (!isInChoosingRoutesMode() || !isInWaypointsChoosingMode() || !portrait);
mapZoomIn.updateVisibility(showZoomButtons);
mapZoomOut.updateVisibility(showZoomButtons);
boolean forceHideCompass = routeDialogOpened || trackDialogOpened || isInMeasurementToolMode()
|| isInPlanRouteMode() || contextMenuOpened || isInChoosingRoutesMode()
|| isInPlanRouteMode() || shouldHideTopControls || isInChoosingRoutesMode()
|| isInTrackAppearanceMode() || isInWaypointsChoosingMode() || isInFollowTrackMode();
compassHud.forceHideCompass = forceHideCompass;
compassHud.updateVisibility(!forceHideCompass && shouldShowCompass());
@ -892,7 +892,7 @@ public class MapControlsLayer extends OsmandMapLayer {
if (layersHud.setIconResId(appMode.getIconRes())) {
layersHud.update(app, isNight);
}
boolean showTopButtons = !routeDialogOpened && !trackDialogOpened && !contextMenuOpened
boolean showTopButtons = !routeDialogOpened && !trackDialogOpened && !shouldHideTopControls
&& !isInMeasurementToolMode() && !isInPlanRouteMode() && !isInChoosingRoutesMode()
&& !isInTrackAppearanceMode() && !isInWaypointsChoosingMode() && !isInFollowTrackMode();
layersHud.updateVisibility(showTopButtons);

View file

@ -425,6 +425,7 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
measurementToolLayer.isInMeasurementMode() ||
mapMarkersLayer.isInPlanRouteMode() ||
gpxLayer.isInTrackAppearanceMode() ||
mapControlsLayer.isInTrackMenuMode() ||
mapRouteInfoMenu.isVisible() ||
MapRouteInfoMenu.chooseRoutesVisible ||
MapRouteInfoMenu.waypointsVisible ||

View file

@ -974,7 +974,7 @@ public class MapInfoWidgetsFactory {
}
}
}
if (map.isTopToolbarActive() || !map.getContextMenu().shouldShowTopControls() || MapRouteInfoMenu.chooseRoutesVisible || MapRouteInfoMenu.waypointsVisible) {
if (map.isTopToolbarActive() || map.shouldHideTopControls() || MapRouteInfoMenu.chooseRoutesVisible || MapRouteInfoMenu.waypointsVisible) {
updateVisibility(false);
} else if (showClosestWaypointFirstInAddress && updateWaypoint()) {
updateVisibility(true);
@ -1232,7 +1232,7 @@ public class MapInfoWidgetsFactory {
@SuppressLint("SetTextI18n")
public boolean updateInfo() {
boolean visible = settings.SHOW_COORDINATES_WIDGET.get() && map.getContextMenu().shouldShowTopControls()
boolean visible = settings.SHOW_COORDINATES_WIDGET.get() && !map.shouldHideTopControls()
&& map.getMapRouteInfoMenu().shouldShowTopControls() && !map.isTopToolbarActive()
&& !map.getMapLayers().getGpxLayer().isInTrackAppearanceMode()
&& !MapRouteInfoMenu.chooseRoutesVisible && !MapRouteInfoMenu.waypointsVisible

View file

@ -191,7 +191,7 @@ public class MapMarkersWidgetsFactory {
|| map.getMapRouteInfoMenu().isVisible()
|| addressTopBar.getVisibility() == View.VISIBLE
|| map.isTopToolbarActive()
|| !map.getContextMenu().shouldShowTopControls()
|| map.shouldHideTopControls()
|| map.getMapLayers().getGpxLayer().isInTrackAppearanceMode()
|| map.getMapLayers().getMapMarkersLayer().isInPlanRouteMode()) {
updateVisibility(false);