Fix PT route details - added boarding time. Few UI fixes.
This commit is contained in:
parent
3051fb5069
commit
51be2bb3f8
4 changed files with 34 additions and 15 deletions
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,6 +64,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 +95,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;
|
||||||
|
@ -112,7 +115,7 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
|
||||||
this.viewPager = viewPager;
|
this.viewPager = viewPager;
|
||||||
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() {
|
||||||
|
@ -575,9 +578,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;
|
||||||
|
@ -646,9 +651,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 +691,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 +711,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 +727,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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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();
|
||||||
|
|
|
@ -130,6 +130,10 @@ public class RouteDetailsFragment extends ContextMenuFragment implements PublicT
|
||||||
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 +296,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 +322,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 +391,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 +472,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());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue