Merge branch 'r3.3'

This commit is contained in:
crimean 2019-03-23 18:17:40 +03:00
commit aee93525a9
9 changed files with 101 additions and 51 deletions

View file

@ -509,6 +509,10 @@ public class TransportRoutePlanner {
return cfg.getChangeTime(); return cfg.getChangeTime();
} }
public double getBoardingTime() {
return cfg.getBoardingTime();
}
public int getChanges() { public int getChanges() {
return segments.size() - 1; return segments.size() - 1;
} }

View file

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/color_transparent"> android:background="@color/color_transparent">

View file

@ -106,6 +106,7 @@ import net.osmand.plus.measurementtool.MeasurementToolFragment;
import net.osmand.plus.measurementtool.NewGpxData; import net.osmand.plus.measurementtool.NewGpxData;
import net.osmand.plus.render.RendererRegistry; import net.osmand.plus.render.RendererRegistry;
import net.osmand.plus.resources.ResourceManager; import net.osmand.plus.resources.ResourceManager;
import net.osmand.plus.routepreparationmenu.ChooseRouteFragment;
import net.osmand.plus.routepreparationmenu.MapRouteInfoMenu; import net.osmand.plus.routepreparationmenu.MapRouteInfoMenu;
import net.osmand.plus.routepreparationmenu.MapRouteInfoMenuFragment; import net.osmand.plus.routepreparationmenu.MapRouteInfoMenuFragment;
import net.osmand.plus.routing.IRouteInformationListener; import net.osmand.plus.routing.IRouteInformationListener;
@ -592,14 +593,21 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
return; return;
} }
} }
if (getPlanRouteFragment() != null) { PlanRouteFragment planRouteFragment = getPlanRouteFragment();
if (getPlanRouteFragment().quit(true)) { if (planRouteFragment != null) {
if (planRouteFragment.quit(true)) {
MapMarkersDialogFragment.showInstance(this); MapMarkersDialogFragment.showInstance(this);
} }
return; return;
} }
if (getMeasurementToolFragment() != null) { MeasurementToolFragment measurementToolFragment = getMeasurementToolFragment();
getMeasurementToolFragment().quit(true); if (measurementToolFragment != null) {
measurementToolFragment.quit(true);
return;
}
ChooseRouteFragment chooseRouteFragment = getChooseRouteFragment();
if (chooseRouteFragment != null) {
chooseRouteFragment.dismiss();
return; return;
} }
if (mapContextMenu.isVisible() && mapContextMenu.isClosable()) { if (mapContextMenu.isVisible() && mapContextMenu.isClosable()) {
@ -629,7 +637,6 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
return; return;
super.onBackPressed(); super.onBackPressed();
} }
private void quitAddGpxPointMode() { private void quitAddGpxPointMode() {
@ -2007,6 +2014,11 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
return fragment != null && !fragment.isDetached() && !fragment.isRemoving() ? (MeasurementToolFragment) fragment : null; return fragment != null && !fragment.isDetached() && !fragment.isRemoving() ? (MeasurementToolFragment) fragment : null;
} }
public ChooseRouteFragment getChooseRouteFragment() {
Fragment fragment = getSupportFragmentManager().findFragmentByTag(ChooseRouteFragment.TAG);
return fragment != null && !fragment.isDetached() && !fragment.isRemoving() ? (ChooseRouteFragment) fragment : null;
}
public boolean isTopToolbarActive() { public boolean isTopToolbarActive() {
MapInfoLayer mapInfoLayer = getMapLayers().getMapInfoLayer(); MapInfoLayer mapInfoLayer = getMapLayers().getMapInfoLayer();
return mapInfoLayer.hasTopToolbar(); return mapInfoLayer.hasTopToolbar();

View file

@ -17,7 +17,6 @@ import android.support.v7.view.ContextThemeWrapper;
import android.text.ClipboardManager; import android.text.ClipboardManager;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.GestureDetector; import android.view.GestureDetector;
import android.view.Gravity;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.VelocityTracker; import android.view.VelocityTracker;
@ -74,6 +73,7 @@ public abstract class ContextMenuFragment extends BaseOsmAndFragment {
private int minHalfY; private int minHalfY;
private int topScreenPosY; private int topScreenPosY;
private int topPadding;
private int menuFullHeightMax; private int menuFullHeightMax;
private int menuBottomViewHeight; private int menuBottomViewHeight;
private int menuFullHeight; private int menuFullHeight;
@ -82,7 +82,6 @@ public abstract class ContextMenuFragment extends BaseOsmAndFragment {
private int topShadowMargin; private int topShadowMargin;
private int currentMenuState; private int currentMenuState;
private int shadowHeight; private int shadowHeight;
private int toolbarHeight;
private int statusBarHeight; private int statusBarHeight;
private String preferredMapLang; private String preferredMapLang;
@ -107,6 +106,8 @@ public abstract class ContextMenuFragment extends BaseOsmAndFragment {
public abstract int getHeaderViewHeight(); public abstract int getHeaderViewHeight();
public abstract int getToolbarHeight();
public boolean isSingleFragment() { public boolean isSingleFragment() {
return true; return true;
} }
@ -192,31 +193,26 @@ public abstract class ContextMenuFragment extends BaseOsmAndFragment {
shadowHeight = AndroidUtils.dpToPx(mapActivity, SHADOW_HEIGHT_TOP_DP); shadowHeight = AndroidUtils.dpToPx(mapActivity, SHADOW_HEIGHT_TOP_DP);
topScreenPosY = addStatusBarHeightIfNeeded(-shadowHeight); topScreenPosY = addStatusBarHeightIfNeeded(-shadowHeight);
toolbarHeight = app.getResources().getDimensionPixelSize(R.dimen.dashboard_map_toolbar);
mainView = view.findViewById(getMainViewId()); mainView = view.findViewById(getMainViewId());
nightMode = app.getDaynightHelper().isNightModeForMapControls(); nightMode = app.getDaynightHelper().isNightModeForMapControls();
processScreenHeight(container);
minHalfY = viewHeight - (int) (viewHeight * .75f);
LockableScrollView bottomScrollView = (LockableScrollView) view.findViewById(getBottomScrollViewId()); LockableScrollView bottomScrollView = (LockableScrollView) view.findViewById(getBottomScrollViewId());
bottomScrollView.setScrollingEnabled(false); bottomScrollView.setScrollingEnabled(false);
AndroidUtils.setBackground(app, bottomScrollView, nightMode, R.color.route_info_bg_light, R.color.route_info_bg_dark); AndroidUtils.setBackground(app, bottomScrollView, nightMode, R.color.route_info_bg_light, R.color.route_info_bg_dark);
AndroidUtils.setBackground(app, mainView, nightMode, R.drawable.bg_map_context_menu_light, R.drawable.bg_map_context_menu_dark); AndroidUtils.setBackground(app, mainView, nightMode, R.drawable.bg_map_context_menu_light, R.drawable.bg_map_context_menu_dark);
if (!portrait) { if (!portrait) {
topPadding = getToolbarHeight() - topScreenPosY;
bottomScrollView.setPadding(0, topPadding, 0, 0);
final TypedValue typedValueAttr = new TypedValue(); final TypedValue typedValueAttr = new TypedValue();
mapActivity.getTheme().resolveAttribute(R.attr.left_menu_view_bg, typedValueAttr, true); mapActivity.getTheme().resolveAttribute(R.attr.left_menu_view_bg, typedValueAttr, true);
mainView.setBackgroundResource(typedValueAttr.resourceId); mainView.setBackgroundResource(typedValueAttr.resourceId);
mainView.setLayoutParams(new FrameLayout.LayoutParams(getResources().getDimensionPixelSize(R.dimen.dashboard_land_width), ViewGroup.LayoutParams.MATCH_PARENT)); mainView.setLayoutParams(new FrameLayout.LayoutParams(getResources().getDimensionPixelSize(R.dimen.dashboard_land_width), ViewGroup.LayoutParams.MATCH_PARENT));
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(AndroidUtils.dpToPx(mapActivity, 345f), ViewGroup.LayoutParams.WRAP_CONTENT);
params.gravity = Gravity.BOTTOM;
} }
processScreenHeight(container);
minHalfY = viewHeight - (int) (viewHeight * .75f);
final GestureDetector swipeDetector = new GestureDetector(app, new HorizontalSwipeConfirm(true)); final GestureDetector swipeDetector = new GestureDetector(app, new HorizontalSwipeConfirm(true));
final OnTouchListener slideTouchListener = new OnTouchListener() { final OnTouchListener slideTouchListener = new OnTouchListener() {
@ -293,16 +289,14 @@ public abstract class ContextMenuFragment extends BaseOsmAndFragment {
if (moving) { if (moving) {
moving = false; moving = false;
int currentY = getViewY(); int currentY = getViewY();
int fullScreenTopPosY = getMenuStatePosY(MenuState.FULL_SCREEN);
final VelocityTracker velocityTracker = this.velocityTracker; final VelocityTracker velocityTracker = this.velocityTracker;
velocityTracker.computeCurrentVelocity(1000, maximumVelocity); velocityTracker.computeCurrentVelocity(1000, maximumVelocity);
int initialVelocity = (int) velocityTracker.getYVelocity(); int initialVelocity = (int) velocityTracker.getYVelocity();
if ((Math.abs(initialVelocity) > minimumVelocity) && currentY != fullScreenTopPosY) {
if ((Math.abs(initialVelocity) > minimumVelocity)) {
scroller.abortAnimation(); scroller.abortAnimation();
scroller.fling(0, currentY, 0, initialVelocity, 0, 0, scroller.fling(0, currentY, 0, initialVelocity, 0, 0,
Math.min(viewHeight - menuFullHeightMax, getFullScreenTopPosY()), Math.min(viewHeight - menuFullHeightMax, fullScreenTopPosY),
screenHeight, screenHeight,
0, 0); 0, 0);
currentY = scroller.getFinalY(); currentY = scroller.getFinalY();
@ -480,7 +474,7 @@ public abstract class ContextMenuFragment extends BaseOsmAndFragment {
MapActivity mapActivity = getMapActivity(); MapActivity mapActivity = getMapActivity();
if (mapActivity != null) { if (mapActivity != null) {
screenHeight = container.getHeight() + statusBarHeight; screenHeight = container.getHeight() + statusBarHeight;
viewHeight = screenHeight - statusBarHeight; viewHeight = screenHeight - statusBarHeight - topPadding;
minHalfY = viewHeight - (int) (viewHeight * .75f); minHalfY = viewHeight - (int) (viewHeight * .75f);
} }
} }
@ -488,7 +482,7 @@ public abstract class ContextMenuFragment extends BaseOsmAndFragment {
private int getFullScreenTopPosY() { private int getFullScreenTopPosY() {
MapActivity mapActivity = getMapActivity(); MapActivity mapActivity = getMapActivity();
if (mapActivity != null) { if (mapActivity != null) {
int res = topShadowMargin + toolbarHeight; int res = topShadowMargin + getToolbarHeight();
if (Build.VERSION.SDK_INT >= 21 && !isSingleFragment()) { if (Build.VERSION.SDK_INT >= 21 && !isSingleFragment()) {
res -= statusBarHeight; res -= statusBarHeight;
} }
@ -833,15 +827,13 @@ public abstract class ContextMenuFragment extends BaseOsmAndFragment {
RotatedTileBox tb = mapActivity.getMapView().getCurrentRotatedTileBox().copy(); RotatedTileBox tb = mapActivity.getMapView().getCurrentRotatedTileBox().copy();
int tileBoxWidthPx = 0; int tileBoxWidthPx = 0;
int tileBoxHeightPx = 0; int tileBoxHeightPx = 0;
boolean portrait = AndroidUiHelper.isOrientationPortrait(mapActivity);
if (!portrait) { if (!portrait) {
tileBoxWidthPx = tb.getPixWidth() - view.getWidth(); tileBoxWidthPx = tb.getPixWidth() - view.getWidth();
} else { } else {
tileBoxHeightPx = getHeaderOnlyTopY(); tileBoxHeightPx = getHeaderOnlyTopY();
} }
if (tileBoxHeightPx > 0) { if (tileBoxHeightPx > 0 || tileBoxWidthPx > 0) {
int topMarginPx = toolbarHeight; int topMarginPx = getToolbarHeight();
mapActivity.getMapView().fitRectToMap(rect.left, rect.right, rect.top, rect.bottom, mapActivity.getMapView().fitRectToMap(rect.left, rect.right, rect.top, rect.bottom,
tileBoxWidthPx, tileBoxHeightPx, topMarginPx); tileBoxWidthPx, tileBoxHeightPx, topMarginPx);
} }

View file

@ -21,6 +21,7 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageButton; import android.widget.ImageButton;
import net.osmand.AndroidUtils; import net.osmand.AndroidUtils;
@ -64,6 +65,7 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
public static final String TAG = "ChooseRouteFragment"; public static final String TAG = "ChooseRouteFragment";
public static final String ROUTE_INDEX_KEY = "route_index_key"; public static final String ROUTE_INDEX_KEY = "route_index_key";
public static final String ROUTE_INFO_STATE_KEY = "route_info_state_key"; public static final String ROUTE_INFO_STATE_KEY = "route_info_state_key";
public static final String INITIAL_MENU_STATE_KEY = "initial_menu_state_key";
@Nullable @Nullable
private LockableViewPager viewPager; private LockableViewPager viewPager;
@ -94,10 +96,12 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
TransportRoutingHelper transportRoutingHelper = app.getTransportRoutingHelper(); TransportRoutingHelper transportRoutingHelper = app.getTransportRoutingHelper();
List<TransportRouteResult> routes = transportRoutingHelper.getRoutes(); List<TransportRouteResult> routes = transportRoutingHelper.getRoutes();
int routeIndex = 0; int routeIndex = 0;
int initialMenuState = MenuState.HEADER_ONLY;
Bundle args = getArguments(); Bundle args = getArguments();
if (args != null) { if (args != null) {
routeIndex = args.getInt(ROUTE_INDEX_KEY); routeIndex = args.getInt(ROUTE_INDEX_KEY);
routeInfoMenuState = args.getInt(ROUTE_INFO_STATE_KEY, -1); routeInfoMenuState = args.getInt(ROUTE_INFO_STATE_KEY, -1);
initialMenuState = args.getInt(INITIAL_MENU_STATE_KEY, initialMenuState);
} }
if (routes != null && !routes.isEmpty()) { if (routes != null && !routes.isEmpty()) {
publicTransportMode = true; publicTransportMode = true;
@ -106,13 +110,19 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
new ContextThemeWrapper(mapActivity, !nightMode ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme); new ContextThemeWrapper(mapActivity, !nightMode ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme);
View view = LayoutInflater.from(context).inflate(R.layout.fragment_show_all_routes, null); View view = LayoutInflater.from(context).inflate(R.layout.fragment_show_all_routes, null);
AndroidUtils.addStatusBarPadding21v(mapActivity, view); AndroidUtils.addStatusBarPadding21v(mapActivity, view);
solidToolbarView = view.findViewById(R.id.toolbar_layout); View solidToolbarView = view.findViewById(R.id.toolbar_layout);
this.solidToolbarView = solidToolbarView;
solidToolbarHeight = getResources().getDimensionPixelSize(R.dimen.dashboard_map_toolbar); solidToolbarHeight = getResources().getDimensionPixelSize(R.dimen.dashboard_map_toolbar);
LockableViewPager viewPager = view.findViewById(R.id.pager); LockableViewPager viewPager = view.findViewById(R.id.pager);
this.viewPager = viewPager; this.viewPager = viewPager;
if (!portrait) {
initialMenuState = MenuState.FULL_SCREEN;
solidToolbarView.setLayoutParams(new FrameLayout.LayoutParams(AndroidUtils.dpToPx(mapActivity, 345f), ViewGroup.LayoutParams.WRAP_CONTENT));
view.setLayoutParams(new FrameLayout.LayoutParams(getResources().getDimensionPixelSize(R.dimen.dashboard_land_width), ViewGroup.LayoutParams.MATCH_PARENT));
}
viewPager.setClipToPadding(false); viewPager.setClipToPadding(false);
//viewPager.setPageMargin(-60); //viewPager.setPageMargin(-60);
final RoutesPagerAdapter pagerAdapter = new RoutesPagerAdapter(getChildFragmentManager(), publicTransportMode ? routes.size() : 1); final RoutesPagerAdapter pagerAdapter = new RoutesPagerAdapter(getChildFragmentManager(), publicTransportMode ? routes.size() : 1, initialMenuState);
viewPager.setAdapter(pagerAdapter); viewPager.setAdapter(pagerAdapter);
viewPager.setCurrentItem(routeIndex); viewPager.setCurrentItem(routeIndex);
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@ -165,7 +175,7 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
if (!wasDrawerDisabled) { if (!wasDrawerDisabled) {
mapActivity.disableDrawer(); mapActivity.disableDrawer();
} }
updateControlsVisibility(false); updateControlsVisibility(false, false);
} }
} }
@ -177,7 +187,7 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
if (!wasDrawerDisabled) { if (!wasDrawerDisabled) {
mapActivity.enableDrawer(); mapActivity.enableDrawer();
} }
updateControlsVisibility(true); updateControlsVisibility(true, routeInfoMenuState != -1);
} }
} }
@ -210,7 +220,7 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
return getIcon(id, nightMode ? R.color.ctx_menu_info_text_dark : R.color.icon_color); return getIcon(id, nightMode ? R.color.ctx_menu_info_text_dark : R.color.icon_color);
} }
private void dismiss() { public void dismiss() {
try { try {
MapActivity mapActivity = getMapActivity(); MapActivity mapActivity = getMapActivity();
if (mapActivity != null) { if (mapActivity != null) {
@ -419,6 +429,8 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
if (publicTransportMode) { if (publicTransportMode) {
view.findViewById(R.id.toolbar_options).setVisibility(View.GONE); view.findViewById(R.id.toolbar_options).setVisibility(View.GONE);
}
if (publicTransportMode || !portrait) {
view.findViewById(R.id.toolbar_options_flow).setVisibility(View.GONE); view.findViewById(R.id.toolbar_options_flow).setVisibility(View.GONE);
view.findViewById(R.id.toolbar_options_flow_bg).setVisibility(View.GONE); view.findViewById(R.id.toolbar_options_flow_bg).setVisibility(View.GONE);
} }
@ -575,9 +587,11 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
if (viewPager != null) { if (viewPager != null) {
int currentItem = viewPager.getCurrentItem(); int currentItem = viewPager.getCurrentItem();
List<WeakReference<RouteDetailsFragment>> routeDetailsFragments = this.routeDetailsFragments; List<WeakReference<RouteDetailsFragment>> routeDetailsFragments = this.routeDetailsFragments;
if (routeDetailsFragments.size() > currentItem) { for (WeakReference<RouteDetailsFragment> ref : routeDetailsFragments) {
WeakReference<RouteDetailsFragment> ref = routeDetailsFragments.get(currentItem); RouteDetailsFragment f = ref.get();
return ref.get(); if (f != null && f.getRouteId() == currentItem) {
return f;
}
} }
} }
return null; return null;
@ -617,13 +631,18 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
} }
} }
public void updateControlsVisibility(boolean visible) { public void updateControlsVisibility(boolean visible, boolean openingRouteInfo) {
MapActivity mapActivity = getMapActivity(); MapActivity mapActivity = getMapActivity();
if (mapActivity != null) { if (mapActivity != null) {
int visibility = visible ? View.VISIBLE : View.GONE; int visibility = visible ? View.VISIBLE : View.GONE;
mapActivity.findViewById(R.id.map_center_info).setVisibility(visibility); mapActivity.findViewById(R.id.map_center_info).setVisibility(visibility);
mapActivity.findViewById(R.id.map_left_widgets_panel).setVisibility(visibility); mapActivity.findViewById(R.id.map_left_widgets_panel).setVisibility(visibility);
mapActivity.findViewById(R.id.map_right_widgets_panel).setVisibility(visibility); if (!openingRouteInfo) {
mapActivity.findViewById(R.id.map_right_widgets_panel).setVisibility(visibility);
if (!portrait) {
mapActivity.getMapView().setMapPositionX(visible ? 0 : 1);
}
}
mapActivity.findViewById(R.id.bottom_controls_container).setVisibility(visibility); mapActivity.findViewById(R.id.bottom_controls_container).setVisibility(visibility);
mapActivity.refreshMap(); mapActivity.refreshMap();
} }
@ -646,9 +665,9 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
int i = 0; int i = 0;
List<WeakReference<RouteDetailsFragment>> routeDetailsFragments = this.routeDetailsFragments; List<WeakReference<RouteDetailsFragment>> routeDetailsFragments = this.routeDetailsFragments;
for (WeakReference<RouteDetailsFragment> ref : routeDetailsFragments) { for (WeakReference<RouteDetailsFragment> ref : routeDetailsFragments) {
boolean current = i == currentItem;
RouteDetailsFragment f = ref.get(); RouteDetailsFragment f = ref.get();
if (f != null) { if (f != null) {
boolean current = f.getRouteId() == currentItem;
if (!current && f.getCurrentMenuState() != menuState) { if (!current && f.getCurrentMenuState() != menuState) {
f.openMenuScreen(menuState, false); f.openMenuScreen(menuState, false);
} }
@ -686,12 +705,14 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
} }
} }
static boolean showFromRouteInfo(FragmentManager fragmentManager, int routeIndex, int routeInfoState) { static boolean showFromRouteInfo(FragmentManager fragmentManager, int routeIndex,
int routeInfoState, int initialMenuState) {
try { try {
ChooseRouteFragment fragment = new ChooseRouteFragment(); ChooseRouteFragment fragment = new ChooseRouteFragment();
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putInt(ROUTE_INDEX_KEY, routeIndex); args.putInt(ROUTE_INDEX_KEY, routeIndex);
args.putInt(ROUTE_INFO_STATE_KEY, routeInfoState); args.putInt(ROUTE_INFO_STATE_KEY, routeInfoState);
args.putInt(INITIAL_MENU_STATE_KEY, initialMenuState);
fragment.setArguments(args); fragment.setArguments(args);
fragmentManager.beginTransaction() fragmentManager.beginTransaction()
.add(R.id.routeMenuContainer, fragment, TAG) .add(R.id.routeMenuContainer, fragment, TAG)
@ -704,10 +725,12 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
public class RoutesPagerAdapter extends FragmentPagerAdapter { public class RoutesPagerAdapter extends FragmentPagerAdapter {
private int routesCount; private int routesCount;
private int initialMenuState;
RoutesPagerAdapter(FragmentManager fm, int routesCount) { RoutesPagerAdapter(FragmentManager fm, int routesCount, int initialMenuState) {
super(fm); super(fm);
this.routesCount = routesCount; this.routesCount = routesCount;
this.initialMenuState = initialMenuState;
} }
@Override @Override
@ -718,7 +741,7 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
@Override @Override
public Fragment getItem(int position) { public Fragment getItem(int position) {
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putInt(ContextMenuFragment.MENU_STATE_KEY, MenuState.HEADER_ONLY); args.putInt(ContextMenuFragment.MENU_STATE_KEY, initialMenuState);
args.putInt(RouteDetailsFragment.ROUTE_ID_KEY, position); args.putInt(RouteDetailsFragment.ROUTE_ID_KEY, position);
return Fragment.instantiate(ChooseRouteFragment.this.getContext(), RouteDetailsFragment.class.getName(), args); return Fragment.instantiate(ChooseRouteFragment.this.getContext(), RouteDetailsFragment.class.getName(), args);
} }

View file

@ -609,7 +609,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
if (mapActivity != null) { if (mapActivity != null) {
if (card instanceof SimpleRouteCard) { if (card instanceof SimpleRouteCard) {
hide(); hide();
ChooseRouteFragment.showFromRouteInfo(mapActivity.getSupportFragmentManager(), 0, getCurrentMenuState()); ChooseRouteFragment.showFromRouteInfo(mapActivity.getSupportFragmentManager(), 0, getCurrentMenuState(), MenuState.FULL_SCREEN);
} }
} }
} }
@ -634,14 +634,15 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
if (buttonIndex == PublicTransportCard.DETAILS_BUTTON_INDEX) { if (buttonIndex == PublicTransportCard.DETAILS_BUTTON_INDEX) {
hide(); hide();
ChooseRouteFragment.showFromRouteInfo(mapActivity.getSupportFragmentManager(), ChooseRouteFragment.showFromRouteInfo(mapActivity.getSupportFragmentManager(),
((PublicTransportCard) card).getRouteId(), getCurrentMenuState()); ((PublicTransportCard) card).getRouteId(), getCurrentMenuState(), MenuState.FULL_SCREEN);
} else if (buttonIndex == PublicTransportCard.SHOW_BUTTON_INDEX) { } else if (buttonIndex == PublicTransportCard.SHOW_BUTTON_INDEX) {
setupCards(); setupCards();
openMenuHeaderOnly(); openMenuHeaderOnly();
} }
} else if (card instanceof SimpleRouteCard) { } else if (card instanceof SimpleRouteCard) {
hide(); hide();
ChooseRouteFragment.showFromRouteInfo(mapActivity.getSupportFragmentManager(), 0, getCurrentMenuState()); ChooseRouteFragment.showFromRouteInfo(mapActivity.getSupportFragmentManager(), 0,
getCurrentMenuState(), MenuState.FULL_SCREEN);
} }
} }
} }
@ -1263,7 +1264,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
if (app.getRoutingHelper().isPublicTransportMode()) { if (app.getRoutingHelper().isPublicTransportMode()) {
if (isTransportRouteCalculated()) { if (isTransportRouteCalculated()) {
ChooseRouteFragment.showFromRouteInfo(mapActivity.getSupportFragmentManager(), ChooseRouteFragment.showFromRouteInfo(mapActivity.getSupportFragmentManager(),
app.getTransportRoutingHelper().getCurrentRoute(), getCurrentMenuState()); app.getTransportRoutingHelper().getCurrentRoute(), getCurrentMenuState(), MenuState.HEADER_ONLY);
} }
} else { } else {
mapActivity.getMapLayers().getMapControlsLayer().startNavigation(); mapActivity.getMapLayers().getMapControlsLayer().startNavigation();
@ -1901,6 +1902,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
boolean refreshMap = !switched; boolean refreshMap = !switched;
boolean portrait = AndroidUiHelper.isOrientationPortrait(mapActivity); boolean portrait = AndroidUiHelper.isOrientationPortrait(mapActivity);
if (!portrait) { if (!portrait) {
currentMenuState = MenuState.FULL_SCREEN;
mapActivity.getMapView().setMapPositionX(1); mapActivity.getMapView().setMapPositionX(1);
refreshMap = true; refreshMap = true;
} }
@ -1933,6 +1935,10 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
removeTargetPointListener(); removeTargetPointListener();
} }
public boolean needShowMenu() {
return showMenu;
}
public void setShowMenu(int menuState) { public void setShowMenu(int menuState) {
showMenu = true; showMenu = true;
showMenuState = menuState; showMenuState = menuState;

View file

@ -125,11 +125,20 @@ public class RouteDetailsFragment extends ContextMenuFragment implements PublicT
return !menuCards.isEmpty() ? menuCards.get(0).getViewHeight() : 0; return !menuCards.isEmpty() ? menuCards.get(0).getViewHeight() : 0;
} }
@Override
public int getToolbarHeight() {
return getResources().getDimensionPixelSize(R.dimen.dashboard_map_toolbar);
}
@Override @Override
public boolean isSingleFragment() { public boolean isSingleFragment() {
return false; return false;
} }
public int getRouteId() {
return routeId;
}
@Override @Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
@ -292,7 +301,7 @@ public class RouteDetailsFragment extends ContextMenuFragment implements PublicT
} }
private void buildSegmentItem(View view, final TransportRouteResultSegment segment, private void buildSegmentItem(View view, final TransportRouteResultSegment segment,
final TransportRouteResultSegment nextSegment, int[] startTime, double walkSpeed, double changeTime) { final TransportRouteResultSegment nextSegment, int[] startTime, double walkSpeed, double boardingTime) {
OsmandApplication app = requireMyApplication(); OsmandApplication app = requireMyApplication();
TransportRoute transportRoute = segment.route; TransportRoute transportRoute = segment.route;
List<TransportStop> stops = segment.getTravelStops(); List<TransportStop> stops = segment.getTravelStops();
@ -318,6 +327,7 @@ public class RouteDetailsFragment extends ContextMenuFragment implements PublicT
Drawable icon = getContentIcon(drawableResId); Drawable icon = getContentIcon(drawableResId);
Typeface typeface = FontCache.getRobotoMedium(app); Typeface typeface = FontCache.getRobotoMedium(app);
startTime[0] += (int) boardingTime;
String timeText = OsmAndFormatter.getFormattedDurationShortMinutes(startTime[0]); String timeText = OsmAndFormatter.getFormattedDurationShortMinutes(startTime[0]);
SpannableString secondaryText = new SpannableString(getString(R.string.sit_on_the_stop)); SpannableString secondaryText = new SpannableString(getString(R.string.sit_on_the_stop));
@ -386,7 +396,7 @@ public class RouteDetailsFragment extends ContextMenuFragment implements PublicT
depTime = startTime[0] + arrivalTime; depTime = startTime[0] + arrivalTime;
} }
// TODO: fix later for schedule // TODO: fix later for schedule
startTime[0] += (int) segment.travelTime + (nextSegment != null ? changeTime / 2 : 0); startTime[0] += (int) segment.getTravelTime();
String textTime = OsmAndFormatter.getFormattedDurationShortMinutes(startTime[0]); String textTime = OsmAndFormatter.getFormattedDurationShortMinutes(startTime[0]);
secondaryText = new SpannableString(getString(R.string.exit_at)); secondaryText = new SpannableString(getString(R.string.exit_at));
@ -467,7 +477,7 @@ public class RouteDetailsFragment extends ContextMenuFragment implements PublicT
if (first) { if (first) {
buildStartItem(parent, startPoint, startTime, segment, routeResult.getWalkSpeed()); buildStartItem(parent, startPoint, startTime, segment, routeResult.getWalkSpeed());
} }
buildSegmentItem(parent, segment, !last ? segments.get(i + 1) : null, startTime, routeResult.getWalkSpeed(), routeResult.getChangeTime()); buildSegmentItem(parent, segment, !last ? segments.get(i + 1) : null, startTime, routeResult.getWalkSpeed(), routeResult.getBoardingTime());
if (last) { if (last) {
buildDestinationItem(parent, endPoint, startTime, segment, routeResult.getWalkSpeed()); buildDestinationItem(parent, endPoint, startTime, segment, routeResult.getWalkSpeed());
} }

View file

@ -747,11 +747,11 @@ public class MapControlsLayer extends OsmandMapLayer {
routePlanningMode = true; routePlanningMode = true;
} }
boolean routeFollowingMode = !routePlanningMode && rh.isFollowingMode(); boolean routeFollowingMode = !routePlanningMode && rh.isFollowingMode();
boolean routeDialogOpened = mapRouteInfoMenu.isVisible();
boolean trackDialogOpened = TrackDetailsMenu.isVisible(); boolean trackDialogOpened = TrackDetailsMenu.isVisible();
boolean contextMenuOpened = !mapActivity.getContextMenu().shouldShowTopControls(); boolean contextMenuOpened = !mapActivity.getContextMenu().shouldShowTopControls();
boolean showRouteCalculationControls = routePlanningMode || boolean showRouteCalculationControls = routePlanningMode ||
((app.accessibilityEnabled() || (System.currentTimeMillis() - touchEvent < TIMEOUT_TO_SHOW_BUTTONS)) && routeFollowingMode); ((app.accessibilityEnabled() || (System.currentTimeMillis() - touchEvent < TIMEOUT_TO_SHOW_BUTTONS)) && routeFollowingMode);
boolean routeDialogOpened = mapRouteInfoMenu.isVisible() || (showRouteCalculationControls && mapRouteInfoMenu.needShowMenu());
updateMyLocation(rh, routeDialogOpened || trackDialogOpened || contextMenuOpened); updateMyLocation(rh, routeDialogOpened || trackDialogOpened || contextMenuOpened);
boolean showButtons = (showRouteCalculationControls || !routeFollowingMode) boolean showButtons = (showRouteCalculationControls || !routeFollowingMode)
&& !isInMovingMarkerMode() && !isInGpxDetailsMode() && !isInMeasurementToolMode() && !isInPlanRouteMode() && !contextMenuOpened && !isInChoosingRoutesMode(); && !isInMovingMarkerMode() && !isInGpxDetailsMode() && !isInMeasurementToolMode() && !isInPlanRouteMode() && !contextMenuOpened && !isInChoosingRoutesMode();

View file

@ -40,6 +40,7 @@ import net.osmand.plus.quickaction.QuickAction;
import net.osmand.plus.quickaction.QuickActionFactory; import net.osmand.plus.quickaction.QuickActionFactory;
import net.osmand.plus.quickaction.QuickActionRegistry; import net.osmand.plus.quickaction.QuickActionRegistry;
import net.osmand.plus.quickaction.QuickActionsWidget; import net.osmand.plus.quickaction.QuickActionsWidget;
import net.osmand.plus.routepreparationmenu.MapRouteInfoMenu;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.util.ArrayList; import java.util.ArrayList;
@ -388,6 +389,7 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
private void setupQuickActionBtnVisibility() { private void setupQuickActionBtnVisibility() {
MapContextMenu contextMenu = mapActivity.getContextMenu(); MapContextMenu contextMenu = mapActivity.getContextMenu();
MapRouteInfoMenu mapRouteInfoMenu = mapActivity.getMapRouteInfoMenu();
MapMultiSelectionMenu multiSelectionMenu = contextMenu.getMultiSelectionMenu(); MapMultiSelectionMenu multiSelectionMenu = contextMenu.getMultiSelectionMenu();
WeakReference<MapContextMenuFragment> contextMenuMenuFragmentRef = contextMenu.findMenuFragment(); WeakReference<MapContextMenuFragment> contextMenuMenuFragmentRef = contextMenu.findMenuFragment();
MapContextMenuFragment contextMenuMenuFragment = contextMenuMenuFragmentRef != null ? contextMenuMenuFragmentRef.get() : null; MapContextMenuFragment contextMenuMenuFragment = contextMenuMenuFragmentRef != null ? contextMenuMenuFragmentRef.get() : null;
@ -397,6 +399,8 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
contextMenuLayer.isInGpxDetailsMode() || contextMenuLayer.isInGpxDetailsMode() ||
measurementToolLayer.isInMeasurementMode() || measurementToolLayer.isInMeasurementMode() ||
mapMarkersLayer.isInPlanRouteMode() || mapMarkersLayer.isInPlanRouteMode() ||
mapRouteInfoMenu.isVisible() ||
MapRouteInfoMenu.chooseRoutesVisible ||
contextMenu.isVisible() && contextMenuMenuFragment != null && !contextMenuMenuFragment.isRemoving() || contextMenu.isVisible() && contextMenuMenuFragment != null && !contextMenuMenuFragment.isRemoving() ||
contextMenu.isVisible() && contextMenuMenuFragment != null && contextMenuMenuFragment.isAdded() || contextMenu.isVisible() && contextMenuMenuFragment != null && contextMenuMenuFragment.isAdded() ||
multiSelectionMenu.isVisible() && multiMenuFragment != null && multiMenuFragment.isAdded() || multiSelectionMenu.isVisible() && multiMenuFragment != null && multiMenuFragment.isAdded() ||