Fix backstack of RP/RD/TD
This commit is contained in:
parent
e34c7ba29b
commit
67ff4adf74
11 changed files with 212 additions and 98 deletions
|
@ -362,7 +362,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
app.getMapMarkersHelper().getPlanRouteContext().setFragmentVisible(true);
|
||||
}
|
||||
if (trackDetailsMenu.isVisible()) {
|
||||
trackDetailsMenu.dismiss();
|
||||
trackDetailsMenu.dismiss(false);
|
||||
}
|
||||
removeFragment(ImportGpxBottomSheetDialogFragment.TAG);
|
||||
removeFragment(AdditionalActionsBottomSheetDialogFragment.TAG);
|
||||
|
@ -606,7 +606,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
return;
|
||||
}
|
||||
if (trackDetailsMenu.isVisible()) {
|
||||
trackDetailsMenu.hide();
|
||||
trackDetailsMenu.hide(true);
|
||||
if (prevActivityIntent == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -625,7 +625,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
}
|
||||
ChooseRouteFragment chooseRouteFragment = getChooseRouteFragment();
|
||||
if (chooseRouteFragment != null) {
|
||||
chooseRouteFragment.dismiss();
|
||||
chooseRouteFragment.dismiss(true);
|
||||
return;
|
||||
}
|
||||
if (mapContextMenu.isVisible() && mapContextMenu.isClosable()) {
|
||||
|
|
|
@ -4,6 +4,7 @@ import android.app.Activity;
|
|||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
@ -41,9 +42,10 @@ public class DashNavigationFragment extends DashBaseFragment {
|
|||
(view.findViewById(R.id.show_all)).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Activity activity = getActivity();
|
||||
if (activity instanceof MapActivity) {
|
||||
ChooseRouteFragment.showInstance(((MapActivity) activity).getSupportFragmentManager());
|
||||
FragmentActivity activity = getActivity();
|
||||
if (activity != null) {
|
||||
closeDashboard();
|
||||
ChooseRouteFragment.showInstance(activity.getSupportFragmentManager());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1311,10 +1311,13 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
|
|||
super.onResume();
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
if (!menu.isActive() || (mapActivity.getMapRouteInfoMenu().isVisible()) || MapRouteInfoMenu.chooseRoutesVisible || MapRouteInfoMenu.waypointsVisible) {
|
||||
if (!menu.isActive() || (mapActivity.getMapRouteInfoMenu().isVisible()) || MapRouteInfoMenu.waypointsVisible) {
|
||||
dismissMenu();
|
||||
return;
|
||||
}
|
||||
if (MapRouteInfoMenu.chooseRoutesVisible) {
|
||||
mapActivity.getChooseRouteFragment().dismiss();
|
||||
}
|
||||
updateLocationViewCache = mapActivity.getMyApplication().getUIUtilities().getUpdateLocationViewCache();
|
||||
mapActivity.getMapViewTrackingUtilities().setContextMenu(menu);
|
||||
mapActivity.getMapViewTrackingUtilities().setMapLinkedToLocation(false);
|
||||
|
@ -1465,7 +1468,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
dismissMenu();
|
||||
ChooseRouteFragment.showFromRouteInfo(requireMyActivity().getSupportFragmentManager(),
|
||||
ChooseRouteFragment.showInstance(requireMyActivity().getSupportFragmentManager(),
|
||||
requireMyApplication().getRoutingHelper().getTransportRoutingHelper().getCurrentRoute(),
|
||||
ContextMenuFragment.MenuState.FULL_SCREEN);
|
||||
/* fit route segment on map
|
||||
|
|
|
@ -104,18 +104,18 @@ public class TrackDetailsMenu {
|
|||
}
|
||||
}
|
||||
|
||||
public void dismiss() {
|
||||
public void dismiss(boolean backPressed) {
|
||||
TrackDetailsMenuFragment fragment = getMenuFragment();
|
||||
if (fragment != null) {
|
||||
fragment.dismiss();
|
||||
fragment.dismiss(backPressed);
|
||||
}
|
||||
}
|
||||
|
||||
public void hide() {
|
||||
public void hide(boolean backPressed) {
|
||||
TrackDetailsMenuFragment fragment = getMenuFragment();
|
||||
if (fragment != null) {
|
||||
hidding = true;
|
||||
fragment.dismiss();
|
||||
fragment.dismiss(backPressed);
|
||||
} else {
|
||||
segment = null;
|
||||
trackChartPoints = null;
|
||||
|
@ -174,7 +174,7 @@ public class TrackDetailsMenu {
|
|||
toolbarController.setOnCloseButtonClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
hide();
|
||||
hide(false);
|
||||
}
|
||||
});
|
||||
mapActivity.showTopToolbar(toolbarController);
|
||||
|
|
|
@ -82,7 +82,7 @@ public class TrackDetailsMenuFragment extends BaseOsmAndFragment {
|
|||
closeButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
menu.hide();
|
||||
menu.hide(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ public class TrackDetailsMenuFragment extends BaseOsmAndFragment {
|
|||
public void onResume() {
|
||||
super.onResume();
|
||||
if (menu == null || menu.getGpxItem() == null) {
|
||||
dismiss();
|
||||
dismiss(false);
|
||||
} else {
|
||||
menu.onShow();
|
||||
}
|
||||
|
@ -172,11 +172,12 @@ public class TrackDetailsMenuFragment extends BaseOsmAndFragment {
|
|||
.commitAllowingStateLoss();
|
||||
}
|
||||
|
||||
public void dismiss() {
|
||||
FragmentActivity activity = getActivity();
|
||||
if (activity != null) {
|
||||
public void dismiss(boolean backPressed) {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
try {
|
||||
activity.getSupportFragmentManager().popBackStackImmediate(TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
||||
mapActivity.getSupportFragmentManager().popBackStackImmediate(TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
||||
mapActivity.getMapRouteInfoMenu().onDismiss(this, 0, null, backPressed);
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
|
|
|
@ -78,7 +78,6 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
|
|||
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 INITIAL_MENU_STATE_KEY = "initial_menu_state_key";
|
||||
public static final String USE_ROUTE_INFO_MENU_KEY = "use_route_info_menu_key";
|
||||
public static final String ADJUST_MAP_KEY = "adjust_map_key";
|
||||
|
||||
@Nullable
|
||||
|
@ -102,8 +101,6 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
|
|||
private int routesCount;
|
||||
|
||||
private boolean publicTransportMode;
|
||||
private boolean useRouteInfoMenu;
|
||||
private boolean openingAnalyseOnMap = false;
|
||||
private boolean needAdjustMap;
|
||||
|
||||
@Nullable
|
||||
|
@ -123,7 +120,6 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
|
|||
}
|
||||
if (args != null) {
|
||||
routeIndex = args.getInt(ROUTE_INDEX_KEY);
|
||||
useRouteInfoMenu = args.getBoolean(USE_ROUTE_INFO_MENU_KEY, false);
|
||||
needAdjustMap = args.getBoolean(ADJUST_MAP_KEY, false);
|
||||
initialMenuState = args.getInt(INITIAL_MENU_STATE_KEY, initialMenuState);
|
||||
}
|
||||
|
@ -221,7 +217,7 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
|
|||
if (!wasDrawerDisabled) {
|
||||
mapActivity.disableDrawer();
|
||||
}
|
||||
updateControlsVisibility(false, false);
|
||||
updateControlsVisibility(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -233,16 +229,10 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
|
|||
if (!wasDrawerDisabled) {
|
||||
mapActivity.enableDrawer();
|
||||
}
|
||||
updateControlsVisibility(true, useRouteInfoMenu);
|
||||
updateControlsVisibility(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(@NonNull Bundle outState) {
|
||||
outState.putBoolean(USE_ROUTE_INFO_MENU_KEY, useRouteInfoMenu);
|
||||
super.onSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStatusBarColorId() {
|
||||
View view = getView();
|
||||
|
@ -273,7 +263,6 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
|
|||
}
|
||||
|
||||
public void analyseOnMap(LatLon location, GpxDisplayItem gpxItem) {
|
||||
openingAnalyseOnMap = true;
|
||||
OsmandApplication app = requireMyApplication();
|
||||
final OsmandSettings settings = app.getSettings();
|
||||
settings.setMapLocationToShow(location.getLatitude(), location.getLongitude(),
|
||||
|
@ -287,13 +276,23 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
|
|||
}
|
||||
|
||||
public void dismiss() {
|
||||
dismiss(false);
|
||||
}
|
||||
|
||||
public void dismiss(boolean backPressed) {
|
||||
try {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
LockableViewPager viewPager = this.viewPager;
|
||||
if (mapActivity != null && viewPager != null) {
|
||||
mapActivity.getSupportFragmentManager().beginTransaction().remove(this).commitAllowingStateLoss();
|
||||
if (useRouteInfoMenu && !openingAnalyseOnMap) {
|
||||
mapActivity.getMapLayers().getMapControlsLayer().showRouteInfoControlDialog();
|
||||
Bundle args = getArguments();
|
||||
if (args == null) {
|
||||
args = new Bundle();
|
||||
}
|
||||
args.putInt(ROUTE_INDEX_KEY, viewPager.getCurrentItem());
|
||||
args.putInt(INITIAL_MENU_STATE_KEY, currentMenuState);
|
||||
args.putBoolean(ADJUST_MAP_KEY, false);
|
||||
mapActivity.getMapRouteInfoMenu().onDismiss(this, currentMenuState, args, backPressed);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
|
@ -445,10 +444,16 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
|
|||
|
||||
private void updatePagesViewVisibility(int menuState) {
|
||||
View pagesView = this.pagesView;
|
||||
if (portrait && routesCount > 1 && pagesView != null) {
|
||||
if (menuState != MenuState.FULL_SCREEN) {
|
||||
if (pagesView.getVisibility() != View.VISIBLE) {
|
||||
pagesView.setVisibility(View.VISIBLE);
|
||||
if (pagesView != null) {
|
||||
if (portrait && routesCount > 1) {
|
||||
if (menuState != MenuState.FULL_SCREEN) {
|
||||
if (pagesView.getVisibility() != View.VISIBLE) {
|
||||
pagesView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
} else {
|
||||
if (pagesView.getVisibility() == View.VISIBLE) {
|
||||
pagesView.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (pagesView.getVisibility() == View.VISIBLE) {
|
||||
|
@ -474,7 +479,7 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
|
|||
OnClickListener backOnClick = new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
dismiss();
|
||||
dismiss(true);
|
||||
}
|
||||
};
|
||||
backButton.setOnClickListener(backOnClick);
|
||||
|
@ -783,16 +788,16 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
|
|||
}
|
||||
}
|
||||
|
||||
public void updateControlsVisibility(boolean visible, boolean openingRouteInfo) {
|
||||
public void updateControlsVisibility(boolean visible) {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
int visibility = visible ? View.VISIBLE : View.GONE;
|
||||
mapActivity.findViewById(R.id.map_center_info).setVisibility(visibility);
|
||||
mapActivity.findViewById(R.id.map_left_widgets_panel).setVisibility(visibility);
|
||||
if (!openingRouteInfo) {
|
||||
if (!visible) {
|
||||
mapActivity.findViewById(R.id.map_right_widgets_panel).setVisibility(visibility);
|
||||
if (!portrait) {
|
||||
mapActivity.getMapView().setMapPositionX(visible ? 0 : 1);
|
||||
mapActivity.getMapView().setMapPositionX(1);
|
||||
}
|
||||
}
|
||||
mapActivity.updateStatusBarColor();
|
||||
|
@ -861,14 +866,17 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
|
|||
}
|
||||
}
|
||||
|
||||
public static boolean showFromRouteInfo(FragmentManager fragmentManager, int routeIndex, int initialMenuState) {
|
||||
public static boolean showInstance(FragmentManager fragmentManager, int routeIndex, int initialMenuState) {
|
||||
Bundle args = new Bundle();
|
||||
args.putInt(ROUTE_INDEX_KEY, routeIndex);
|
||||
args.putInt(INITIAL_MENU_STATE_KEY, initialMenuState);
|
||||
args.putBoolean(ADJUST_MAP_KEY, initialMenuState != MenuState.FULL_SCREEN);
|
||||
return showInstance(fragmentManager, args);
|
||||
}
|
||||
|
||||
public static boolean showInstance(FragmentManager fragmentManager, Bundle args) {
|
||||
try {
|
||||
ChooseRouteFragment fragment = new ChooseRouteFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putInt(ROUTE_INDEX_KEY, routeIndex);
|
||||
args.putBoolean(USE_ROUTE_INFO_MENU_KEY, true);
|
||||
args.putInt(INITIAL_MENU_STATE_KEY, initialMenuState);
|
||||
args.putBoolean(ADJUST_MAP_KEY, initialMenuState != MenuState.FULL_SCREEN);
|
||||
fragment.setArguments(args);
|
||||
fragmentManager.beginTransaction()
|
||||
.add(R.id.routeMenuContainer, fragment, TAG)
|
||||
|
@ -883,8 +891,7 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
|
|||
public void onNavigationRequested() {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
useRouteInfoMenu = false;
|
||||
dismiss();
|
||||
dismiss(false);
|
||||
if (!mapActivity.getMyApplication().getRoutingHelper().isPublicTransportMode()) {
|
||||
mapActivity.getMapLayers().getMapControlsLayer().startNavigation();
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import android.graphics.PointF;
|
|||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Build.VERSION_CODES;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.annotation.ColorRes;
|
||||
import android.support.annotation.DrawableRes;
|
||||
|
@ -62,6 +63,7 @@ import net.osmand.plus.base.ContextMenuFragment.MenuState;
|
|||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
import net.osmand.plus.helpers.GpxUiHelper;
|
||||
import net.osmand.plus.helpers.WaypointHelper;
|
||||
import net.osmand.plus.mapcontextmenu.other.TrackDetailsMenuFragment;
|
||||
import net.osmand.plus.mapmarkers.MapMarkerSelectionFragment;
|
||||
import net.osmand.plus.poi.PoiUIFilter;
|
||||
import net.osmand.plus.profiles.AppModesBottomSheetDialogFragment;
|
||||
|
@ -109,6 +111,7 @@ import java.util.Iterator;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Stack;
|
||||
import java.util.TreeMap;
|
||||
|
||||
public class MapRouteInfoMenu implements IRouteInformationListener, CardListener {
|
||||
|
@ -123,6 +126,8 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
|||
public static boolean chooseRoutesVisible = false;
|
||||
public static boolean waypointsVisible = false;
|
||||
|
||||
private Stack<MapRouteMenuStateHolder> menuBackStack = new Stack<>();
|
||||
|
||||
private boolean routeCalculationInProgress;
|
||||
|
||||
private boolean selectFromMapTouch;
|
||||
|
@ -132,7 +137,6 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
|||
|
||||
private boolean showMenu = false;
|
||||
private int showMenuState = DEFAULT_MENU_STATE;
|
||||
private int lastMenuState = MenuState.HEADER_ONLY;
|
||||
|
||||
@Nullable
|
||||
private MapActivity mapActivity;
|
||||
|
@ -348,7 +352,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
|||
if (fragmentRef != null) {
|
||||
return fragmentRef.get().getCurrentMenuState();
|
||||
}
|
||||
return lastMenuState;
|
||||
return getInitialMenuState();
|
||||
}
|
||||
|
||||
public int getSupportedMenuStates() {
|
||||
|
@ -368,15 +372,11 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
|||
}
|
||||
|
||||
public void showHideMenu() {
|
||||
showHideMenu(lastMenuState);
|
||||
}
|
||||
|
||||
public void showHideMenu(int menuState) {
|
||||
intermediateRequestsLatLon.clear();
|
||||
if (isVisible()) {
|
||||
hide();
|
||||
} else {
|
||||
show(menuState);
|
||||
show();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -648,7 +648,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
|||
if (mapActivity != null) {
|
||||
if (card instanceof SimpleRouteCard) {
|
||||
hide();
|
||||
ChooseRouteFragment.showFromRouteInfo(mapActivity.getSupportFragmentManager(), 0, MenuState.FULL_SCREEN);
|
||||
ChooseRouteFragment.showInstance(mapActivity.getSupportFragmentManager(), 0, MenuState.FULL_SCREEN);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -672,14 +672,14 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
|||
} else if (card instanceof PublicTransportCard) {
|
||||
if (buttonIndex == PublicTransportCard.DETAILS_BUTTON_INDEX) {
|
||||
hide();
|
||||
ChooseRouteFragment.showFromRouteInfo(mapActivity.getSupportFragmentManager(),
|
||||
ChooseRouteFragment.showInstance(mapActivity.getSupportFragmentManager(),
|
||||
((PublicTransportCard) card).getRouteId(), MenuState.FULL_SCREEN);
|
||||
} else if (buttonIndex == PublicTransportCard.SHOW_BUTTON_INDEX) {
|
||||
showRouteOnMap(mapActivity, ((PublicTransportCard) card).getRouteId());
|
||||
}
|
||||
} else if (card instanceof SimpleRouteCard) {
|
||||
hide();
|
||||
ChooseRouteFragment.showFromRouteInfo(mapActivity.getSupportFragmentManager(), 0, MenuState.FULL_SCREEN);
|
||||
ChooseRouteFragment.showInstance(mapActivity.getSupportFragmentManager(), 0, MenuState.FULL_SCREEN);
|
||||
} else if (card instanceof PublicTransportNotFoundWarningCard) {
|
||||
updateApplicationMode(null, ApplicationMode.PEDESTRIAN);
|
||||
} else if (card instanceof PublicTransportNotFoundSettingsWarningCard) {
|
||||
|
@ -1407,8 +1407,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
|||
if (mapActivity.getPointToNavigate() != null) {
|
||||
hide();
|
||||
}
|
||||
ChooseRouteFragment.showFromRouteInfo(mapActivity.getSupportFragmentManager(),
|
||||
routeIndex, MenuState.HEADER_ONLY);
|
||||
ChooseRouteFragment.showInstance(mapActivity.getSupportFragmentManager(), routeIndex, MenuState.HEADER_ONLY);
|
||||
}
|
||||
|
||||
private void clickRouteCancel() {
|
||||
|
@ -2042,34 +2041,72 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
|||
public void routeWasFinished() {
|
||||
}
|
||||
|
||||
public void onDismiss(int currentMenuState) {
|
||||
cancelButtonsAnimations();
|
||||
public void onDismiss(Fragment fragment, int currentMenuState, Bundle arguments, boolean backPressed) {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
lastMenuState = currentMenuState;
|
||||
mapActivity.getMapView().setMapPositionX(0);
|
||||
mapActivity.getMapView().refreshMap();
|
||||
AndroidUiHelper.updateVisibility(mapActivity.findViewById(R.id.map_route_land_left_margin), false);
|
||||
AndroidUiHelper.updateVisibility(mapActivity.findViewById(R.id.map_right_widgets_panel), true);
|
||||
if (switched) {
|
||||
mapActivity.getMapLayers().getMapControlsLayer().switchToRouteFollowingLayout();
|
||||
if (fragment instanceof MapRouteInfoMenuFragment) {
|
||||
cancelButtonsAnimations();
|
||||
mapActivity.getMapView().setMapPositionX(0);
|
||||
mapActivity.getMapView().refreshMap();
|
||||
AndroidUiHelper.updateVisibility(mapActivity.findViewById(R.id.map_route_land_left_margin), false);
|
||||
AndroidUiHelper.updateVisibility(mapActivity.findViewById(R.id.map_right_widgets_panel), true);
|
||||
if (switched) {
|
||||
mapActivity.getMapLayers().getMapControlsLayer().switchToRouteFollowingLayout();
|
||||
}
|
||||
if (mapActivity.getPointToNavigate() == null && !selectFromMapTouch) {
|
||||
mapActivity.getMapActions().stopNavigationWithoutConfirm();
|
||||
}
|
||||
mapActivity.updateStatusBarColor();
|
||||
RoutingHelper routingHelper = mapActivity.getMyApplication().getRoutingHelper();
|
||||
menuBackStack.clear();
|
||||
if (routingHelper.isRoutePlanningMode() || routingHelper.isFollowingMode()) {
|
||||
menuBackStack.push(new MapRouteMenuStateHolder(MapRouteMenuType.ROUTE_INFO, currentMenuState, fragment.getArguments()));
|
||||
}
|
||||
if (onDismissListener != null) {
|
||||
onDismissListener.onDismiss(null);
|
||||
}
|
||||
removeTargetPointListener();
|
||||
} else if (fragment instanceof ChooseRouteFragment) {
|
||||
MapRouteMenuStateHolder holder = new MapRouteMenuStateHolder(MapRouteMenuType.ROUTE_DETAILS, currentMenuState, fragment.getArguments());
|
||||
if (!menuBackStack.empty() && menuBackStack.peek().type == holder.type) {
|
||||
menuBackStack.pop();
|
||||
}
|
||||
if (backPressed) {
|
||||
holder.onDismiss(onBackPressed());
|
||||
} else {
|
||||
menuBackStack.push(holder);
|
||||
holder.onDismiss(null);
|
||||
}
|
||||
} else if (fragment instanceof TrackDetailsMenuFragment) {
|
||||
if (backPressed) {
|
||||
onBackPressed();
|
||||
}
|
||||
}
|
||||
if (mapActivity.getPointToNavigate() == null && !selectFromMapTouch) {
|
||||
mapActivity.getMapActions().stopNavigationWithoutConfirm();
|
||||
}
|
||||
mapActivity.updateStatusBarColor();
|
||||
}
|
||||
if (onDismissListener != null) {
|
||||
onDismissListener.onDismiss(null);
|
||||
}
|
||||
removeTargetPointListener();
|
||||
}
|
||||
|
||||
public void show() {
|
||||
show(getInitialMenuState());
|
||||
}
|
||||
|
||||
public void show(int menuState) {
|
||||
private void show(int menuState) {
|
||||
MapRouteMenuStateHolder holder = !menuBackStack.empty() ? menuBackStack.pop() : null;
|
||||
if (holder != null) {
|
||||
holder.showMenu();
|
||||
} else {
|
||||
showInternal(menuState);
|
||||
}
|
||||
}
|
||||
|
||||
public MapRouteMenuStateHolder onBackPressed() {
|
||||
MapRouteMenuStateHolder holder = !menuBackStack.empty() ? menuBackStack.pop() : null;
|
||||
if (holder != null) {
|
||||
holder.showMenu();
|
||||
}
|
||||
return holder;
|
||||
}
|
||||
|
||||
private void showInternal(int menuState) {
|
||||
if (menuState == DEFAULT_MENU_STATE) {
|
||||
menuState = getInitialMenuState();
|
||||
}
|
||||
|
@ -2121,4 +2158,76 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
|||
showMenu = true;
|
||||
showMenuState = menuState;
|
||||
}
|
||||
|
||||
@DrawableRes
|
||||
public int getRoutePlanningBtnImage() {
|
||||
return menuBackStack.empty() ? 0 : menuBackStack.peek().getButtonImage();
|
||||
}
|
||||
|
||||
public enum MapRouteMenuType {
|
||||
ROUTE_INFO,
|
||||
ROUTE_DETAILS
|
||||
}
|
||||
|
||||
private class MapRouteMenuStateHolder {
|
||||
|
||||
private MapRouteMenuType type;
|
||||
private int menuState;
|
||||
private Bundle arguments;
|
||||
|
||||
MapRouteMenuStateHolder(MapRouteMenuType type, int menuState, Bundle arguments) {
|
||||
this.type = type;
|
||||
this.menuState = menuState;
|
||||
this.arguments = arguments;
|
||||
}
|
||||
|
||||
@DrawableRes
|
||||
int getButtonImage() {
|
||||
OsmandApplication app = getApp();
|
||||
switch (type) {
|
||||
case ROUTE_INFO:
|
||||
return 0;
|
||||
case ROUTE_DETAILS:
|
||||
return app != null ? app.getRoutingHelper().getAppMode().getMapIconRes() : R.drawable.map_directions;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void showMenu() {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
switch (type) {
|
||||
case ROUTE_INFO:
|
||||
showInternal(menuState);
|
||||
break;
|
||||
case ROUTE_DETAILS:
|
||||
ChooseRouteFragment.showInstance(mapActivity.getSupportFragmentManager(), arguments);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void onDismiss(@Nullable MapRouteMenuStateHolder openingMenuStateHolder) {
|
||||
boolean openingRouteInfo = openingMenuStateHolder != null && openingMenuStateHolder.type == MapRouteMenuType.ROUTE_INFO;
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
if (!openingRouteInfo) {
|
||||
switch (type) {
|
||||
case ROUTE_INFO:
|
||||
break;
|
||||
case ROUTE_DETAILS:
|
||||
mapActivity.findViewById(R.id.map_right_widgets_panel).setVisibility(View.VISIBLE);
|
||||
if (!portraitMode) {
|
||||
mapActivity.getMapView().setMapPositionX(0);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -169,7 +169,7 @@ public class MapRouteInfoMenuFragment extends ContextMenuFragment {
|
|||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
if (menu != null) {
|
||||
menu.onDismiss(getCurrentMenuState());
|
||||
menu.onDismiss(this, getCurrentMenuState(), null, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -187,6 +187,7 @@ public class RouteDetailsFragment extends ContextMenuFragment implements PublicT
|
|||
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) cardsContainer.getLayoutParams();
|
||||
layoutParams.setMargins(pageMarginPx, 0, pageMarginPx, 0);
|
||||
cardsContainer.setLayoutParams(layoutParams);
|
||||
updateCardsLayout();
|
||||
}
|
||||
updateCards();
|
||||
runLayoutListener();
|
||||
|
|
|
@ -814,7 +814,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
}
|
||||
|
||||
public boolean disableSingleTap() {
|
||||
if (activity.getMapRouteInfoMenu().isVisible() || MapRouteInfoMenu.chooseRoutesVisible || MapRouteInfoMenu.waypointsVisible) {
|
||||
if (activity.getMapRouteInfoMenu().isVisible() || MapRouteInfoMenu.waypointsVisible) {
|
||||
return true;
|
||||
}
|
||||
boolean res = false;
|
||||
|
@ -831,7 +831,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
|
||||
public boolean disableLongPressOnMap() {
|
||||
if (mInChangeMarkerPositionMode || mInGpxDetailsMode || mInAddGpxPointMode ||
|
||||
activity.getMapRouteInfoMenu().isVisible() || MapRouteInfoMenu.chooseRoutesVisible || MapRouteInfoMenu.waypointsVisible) {
|
||||
activity.getMapRouteInfoMenu().isVisible() || MapRouteInfoMenu.waypointsVisible) {
|
||||
return true;
|
||||
}
|
||||
boolean res = false;
|
||||
|
|
|
@ -340,10 +340,6 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
mapRouteInfoMenu.showHideMenu();
|
||||
}
|
||||
|
||||
public void showRouteInfoControlDialog(int menuState) {
|
||||
mapRouteInfoMenu.showHideMenu(menuState);
|
||||
}
|
||||
|
||||
public void showRouteInfoMenu() {
|
||||
mapRouteInfoMenu.setShowMenu(MapRouteInfoMenu.DEFAULT_MENU_STATE);
|
||||
}
|
||||
|
@ -398,13 +394,7 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
mapActivity.dismissCardDialog();
|
||||
RoutingHelper routingHelper = mapActivity.getRoutingHelper();
|
||||
TransportRoutingHelper transportRoutingHelper = routingHelper.getTransportRoutingHelper();
|
||||
if (transportRoutingHelper.hasActiveRoute()) {
|
||||
ChooseRouteFragment.showFromRouteInfo(mapActivity.getSupportFragmentManager(), transportRoutingHelper.getCurrentRoute(), MenuState.FULL_SCREEN);
|
||||
} else {
|
||||
doRoute(false);
|
||||
}
|
||||
doRoute(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -434,7 +424,7 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
mapActivity.getMapActions().enterRoutePlanningMode(null, null);
|
||||
}
|
||||
} else {
|
||||
showRouteInfoControlDialog(MenuState.HEADER_ONLY);
|
||||
showRouteInfoControlDialog();
|
||||
}
|
||||
hasTargets = false;
|
||||
}
|
||||
|
@ -782,8 +772,9 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
boolean showButtons = (showRouteCalculationControls || !routeFollowingMode)
|
||||
&& !isInMovingMarkerMode() && !isInGpxDetailsMode() && !isInMeasurementToolMode() && !isInPlanRouteMode() && !contextMenuOpened && !isInChoosingRoutesMode() && !isInWaypointsChoosingMode();
|
||||
//routePlanningBtn.setIconResId(routeFollowingMode ? R.drawable.ic_action_gabout_dark : R.drawable.map_directions);
|
||||
if (trh.hasActiveRoute()) {
|
||||
routePlanningBtn.setIconResId(R.drawable.map_action_bus_dark);
|
||||
int routePlanningBtnImage = mapRouteInfoMenu.getRoutePlanningBtnImage();
|
||||
if (routePlanningBtnImage != 0) {
|
||||
routePlanningBtn.setIconResId(routePlanningBtnImage);
|
||||
routePlanningBtn.setIconColorId(R.color.color_myloc_distance);
|
||||
} else if (rh.isFollowingMode()) {
|
||||
routePlanningBtn.setIconResId(R.drawable.map_start_navigation);
|
||||
|
|
Loading…
Reference in a new issue