From b7063062f8a450aaf9063f0040610fe83bb74138 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Wed, 12 Feb 2020 20:13:41 +0100 Subject: [PATCH] Fix #8335 Expansion state of the route setup dialog #8335 --- OsmAnd/src/net/osmand/plus/OsmandSettings.java | 3 +++ .../net/osmand/plus/base/ContextMenuFragment.java | 5 +++++ .../plus/routepreparationmenu/MapRouteInfoMenu.java | 7 ++++++- .../MapRouteInfoMenuFragment.java | 12 ++++++++++++ 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java index 4a8540f633..90049786d8 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -3374,6 +3374,9 @@ public class OsmandSettings { public final CommonPreference OSMAND_THEME = new IntPreference("osmand_theme", OSMAND_LIGHT_THEME).makeProfile().cache(); + public final OsmandPreference OPEN_ONLY_HEADER_STATE_ROUTE_CALCULATED = + new BooleanPreference("open_only_header_route_calculated", false).makeProfile(); + public boolean isLightActionBar() { return isLightContent(); } diff --git a/OsmAnd/src/net/osmand/plus/base/ContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/base/ContextMenuFragment.java index ee371cc6c3..9bb13bd34c 100644 --- a/OsmAnd/src/net/osmand/plus/base/ContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/base/ContextMenuFragment.java @@ -742,6 +742,8 @@ public abstract class ContextMenuFragment extends BaseOsmAndFragment { int newMenuState = getCurrentMenuState(); boolean needMapAdjust = currentMenuState != newMenuState && newMenuState != MenuState.FULL_SCREEN; + updateMenuState(currentMenuState, newMenuState); + applyPosY(currentY, needCloseMenu, needMapAdjust, currentMenuState, newMenuState, 0, animated); ContextMenuFragmentListener listener = this.listener; @@ -750,6 +752,9 @@ public abstract class ContextMenuFragment extends BaseOsmAndFragment { } } + protected void updateMenuState(int currentMenuState, int newMenuState) { + } + private int getPosY(final int currentY, boolean needCloseMenu, int previousState) { if (needCloseMenu) { diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java index be4ce89b3a..a59fbe8a48 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java @@ -445,7 +445,12 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener fragment.updateInfo(); if (!routeCalculationInProgress) { fragment.hideRouteCalculationProgressBar(); - fragment.openMenuHalfScreen(); + if(!app.getSettings().OPEN_ONLY_HEADER_STATE_ROUTE_CALCULATED. + getModeValue(app.getRoutingHelper().getAppMode())) { + fragment.openMenuHalfScreen(); + } else { + fragment.openMenuHeaderOnly(); + } } } } diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenuFragment.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenuFragment.java index caa0ceeda1..3024b7f9f4 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenuFragment.java @@ -186,6 +186,18 @@ public class MapRouteInfoMenuFragment extends ContextMenuFragment { } } + @Override + protected void updateMenuState(int currentMenuState, int newMenuState) { + if(getMyApplication().getRoutingHelper().isRouteCalculated() ) { + ApplicationMode mV = getMyApplication().getRoutingHelper().getAppMode(); + if (newMenuState == MenuState.HEADER_ONLY && currentMenuState == MenuState.HALF_SCREEN) { + getSettings().OPEN_ONLY_HEADER_STATE_ROUTE_CALCULATED.setModeValue(mV,true); + } else if (currentMenuState == MenuState.HEADER_ONLY && newMenuState == MenuState.HALF_SCREEN) { + getSettings().OPEN_ONLY_HEADER_STATE_ROUTE_CALCULATED.resetModeToDefault(mV); + } + } + } + @Override protected void setViewY(int y, boolean animated, boolean adjustMapPos) { super.setViewY(y, animated, adjustMapPos);