From f81673d047b496bb651c84ec6621f338edfb58bc Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Wed, 13 Jan 2021 17:11:46 +0200 Subject: [PATCH] My Place: GPX Context menu --- .../net/osmand/plus/activities/MapActivity.java | 6 ++++++ .../net/osmand/plus/track/TrackMenuFragment.java | 16 +++++++++++++++- .../plus/views/layers/ContextMenuLayer.java | 5 +++++ .../plus/views/layers/MapControlsLayer.java | 16 ++++++++++------ 4 files changed, 36 insertions(+), 7 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index e41792225b..be0d93dd8d 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -140,6 +140,7 @@ import net.osmand.plus.settings.fragments.BaseSettingsFragment.SettingsScreenTyp import net.osmand.plus.settings.fragments.ConfigureProfileFragment; import net.osmand.plus.settings.fragments.DataStorageFragment; import net.osmand.plus.track.TrackAppearanceFragment; +import net.osmand.plus.track.TrackMenuFragment; import net.osmand.plus.views.AddGpxPointBottomSheetHelper.NewGpxPoint; import net.osmand.plus.views.AnimateDraggingMapThread; import net.osmand.plus.views.OsmAndMapLayersView; @@ -2222,6 +2223,11 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven return getFragment(SnapTrackWarningFragment.TAG); } + @NonNull + public TrackMenuFragment getTrackMenuFragment() { + return getFragment(TrackMenuFragment.TAG); + } + public void backToConfigureProfileFragment() { FragmentManager fragmentManager = getSupportFragmentManager(); int backStackEntryCount = fragmentManager.getBackStackEntryCount(); diff --git a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java index 595c456858..2896eb48cd 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java @@ -58,6 +58,7 @@ import net.osmand.plus.myplaces.TrackActivityFragmentAdapter; import net.osmand.plus.routepreparationmenu.cards.BaseCard; import net.osmand.plus.routepreparationmenu.cards.BaseCard.CardListener; import net.osmand.plus.track.SaveGpxAsyncTask.SaveGpxListener; +import net.osmand.plus.views.layers.MapControlsLayer; import net.osmand.plus.widgets.IconPopupMenu; import net.osmand.util.Algorithms; @@ -84,6 +85,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card private BottomNavigationView bottomNav; private TrackMenuType menuType = TrackMenuType.TRACK; private SegmentsCard segmentsCard; + private MapControlsLayer.MapHudButton layersHud; private int menuTitleHeight; @@ -170,6 +172,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = super.onCreateView(inflater, container, savedInstanceState); if (view != null) { + view.setOnLongClickListener(closeOnLongTap); bottomNav = view.findViewById(R.id.bottom_navigation); routeMenuTopShadowAll = view.findViewById(R.id.route_menu_top_shadow_all); TextView title = view.findViewById(R.id.title); @@ -179,6 +182,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card if (isPortrait()) { updateCardsLayout(); } + setupCards(); setupButtons(view); enterTrackAppearanceMode(); @@ -187,6 +191,15 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card return view; } + private View.OnLongClickListener closeOnLongTap = new View.OnLongClickListener() { + + @Override + public boolean onLongClick(View view) { + dismiss(); + return true; + } + }; + private void setupCards() { MapActivity mapActivity = getMapActivity(); if (mapActivity != null) { @@ -237,6 +250,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card public void onDestroyView() { super.onDestroyView(); exitTrackAppearanceMode(); + updateStatusBarColor(); } private void enterTrackAppearanceMode() { @@ -550,7 +564,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card @Override public void gpxSavingFinished(Exception errorMessage) { if (selectedGpxFile != null) { - List groups = displayHelper.getDisplayGroups(new GpxDisplayItemType[] {GpxDisplayItemType.TRACK_SEGMENT}); + List groups = displayHelper.getDisplayGroups(new GpxDisplayItemType[]{GpxDisplayItemType.TRACK_SEGMENT}); if (groups != null) { selectedGpxFile.setDisplayGroups(groups, app); selectedGpxFile.processPoints(app); diff --git a/OsmAnd/src/net/osmand/plus/views/layers/ContextMenuLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/ContextMenuLayer.java index cc017d23ac..8236ac5651 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/ContextMenuLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/ContextMenuLayer.java @@ -805,6 +805,7 @@ public class ContextMenuLayer extends OsmandMapLayer { return true; } else if (selectedObjects.size() > 1) { + hideVisibleMenues(); selectedObjectContextMenuProvider = null; showContextMenuForSelectedObjects(pointLatLon, selectedObjects); return true; @@ -1036,6 +1037,10 @@ public class ContextMenuLayer extends OsmandMapLayer { } private boolean hideVisibleMenues() { + if (activity.getTrackMenuFragment() != null) { + activity.getTrackMenuFragment().dismiss(); + return true; + } if (multiSelectionMenu.isVisible()) { multiSelectionMenu.hide(); return true; diff --git a/OsmAnd/src/net/osmand/plus/views/layers/MapControlsLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/MapControlsLayer.java index b2697cecf2..a200d786fb 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/MapControlsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/MapControlsLayer.java @@ -44,10 +44,6 @@ import net.osmand.plus.OsmAndLocationProvider; import net.osmand.plus.OsmAndLocationSimulation; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; -import net.osmand.plus.settings.backend.OsmandPreference; -import net.osmand.plus.settings.backend.OsmandSettings; -import net.osmand.plus.settings.backend.CommonPreference; -import net.osmand.plus.rastermaps.LayerTransparencySeekbarMode; import net.osmand.plus.R; import net.osmand.plus.TargetPointsHelper; import net.osmand.plus.TargetPointsHelper.TargetPoint; @@ -60,13 +56,17 @@ import net.osmand.plus.dialogs.DirectionsDialogs; import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.mapcontextmenu.MapContextMenu; import net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController.SelectedGpxPoint; +import net.osmand.plus.rastermaps.LayerTransparencySeekbarMode; import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin; import net.osmand.plus.routepreparationmenu.MapRouteInfoMenu; import net.osmand.plus.routepreparationmenu.MapRouteInfoMenu.PointType; import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.search.QuickSearchDialogFragment.QuickSearchType; import net.osmand.plus.settings.backend.ApplicationMode; +import net.osmand.plus.settings.backend.CommonPreference; import net.osmand.plus.settings.backend.OsmAndAppCustomization; +import net.osmand.plus.settings.backend.OsmandPreference; +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; @@ -859,6 +859,10 @@ public class MapControlsLayer extends OsmandMapLayer { } boolean routeFollowingMode = !routePlanningMode && rh.isFollowingMode(); boolean trackDialogOpened = mapActivity.getTrackDetailsMenu().isVisible(); + boolean trackMenuFragmentOpened = false; + if (mapActivity.getTrackMenuFragment() != null && mapActivity.getTrackMenuFragment().isVisible()) { + trackMenuFragmentOpened = true; + } boolean contextMenuOpened = !mapActivity.getContextMenu().shouldShowTopControls(); boolean showRouteCalculationControls = routePlanningMode || ((app.accessibilityEnabled() || (System.currentTimeMillis() - touchEvent < TIMEOUT_TO_SHOW_BUTTONS)) && routeFollowingMode); @@ -881,7 +885,7 @@ public class MapControlsLayer extends OsmandMapLayer { mapZoomIn.updateVisibility(showZoomButtons); mapZoomOut.updateVisibility(showZoomButtons); - boolean forceHideCompass = routeDialogOpened || trackDialogOpened || isInMeasurementToolMode() + boolean forceHideCompass = routeDialogOpened || trackDialogOpened || trackMenuFragmentOpened || isInMeasurementToolMode() || isInPlanRouteMode() || contextMenuOpened || isInChoosingRoutesMode() || isInTrackAppearanceMode() || isInWaypointsChoosingMode() || isInFollowTrackMode(); compassHud.forceHideCompass = forceHideCompass; @@ -892,7 +896,7 @@ public class MapControlsLayer extends OsmandMapLayer { if (layersHud.setIconResId(appMode.getIconRes())) { layersHud.update(app, isNight); } - boolean showTopButtons = !routeDialogOpened && !trackDialogOpened && !contextMenuOpened + boolean showTopButtons = !routeDialogOpened && !trackDialogOpened && !trackMenuFragmentOpened && !contextMenuOpened && !isInMeasurementToolMode() && !isInPlanRouteMode() && !isInChoosingRoutesMode() && !isInTrackAppearanceMode() && !isInWaypointsChoosingMode() && !isInFollowTrackMode(); layersHud.updateVisibility(showTopButtons);