Merge pull request #6709 from osmandapp/RouteMenuImprovements
Route menu improvements
This commit is contained in:
commit
2d30e44152
7 changed files with 69 additions and 25 deletions
|
@ -443,6 +443,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
@Override
|
||||
public void start() {
|
||||
setupRouteCalculationProgressBar(pb);
|
||||
mapRouteInfoMenu.routeCalculationStarted();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -704,11 +704,12 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
|
|||
}
|
||||
|
||||
private List<TransportStopRoute> filterNearbyTransportRoutes(List<TransportStopRoute> routes, List<TransportStopRoute> filterFromRoutes) {
|
||||
if (filterFromRoutes == null) {
|
||||
return routes;
|
||||
List<TransportStopRoute> nearbyFilteredTransportStopRoutes = filterTransportRoutes(routes);
|
||||
if (filterFromRoutes == null || filterFromRoutes.isEmpty()) {
|
||||
return nearbyFilteredTransportStopRoutes;
|
||||
}
|
||||
List<TransportStopRoute> filteredRoutes = new ArrayList<>();
|
||||
for (TransportStopRoute route : routes) {
|
||||
for (TransportStopRoute route : nearbyFilteredTransportStopRoutes) {
|
||||
if (!containsRef(filterFromRoutes, route.route)) {
|
||||
filteredRoutes.add(route);
|
||||
}
|
||||
|
|
|
@ -55,7 +55,6 @@ import net.osmand.plus.activities.MapActivity;
|
|||
import net.osmand.plus.activities.SettingsBaseActivity;
|
||||
import net.osmand.plus.activities.actions.AppModeDialog;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
import net.osmand.plus.helpers.AvoidSpecificRoads;
|
||||
import net.osmand.plus.helpers.GpxUiHelper;
|
||||
import net.osmand.plus.helpers.WaypointHelper;
|
||||
import net.osmand.plus.mapmarkers.MapMarkerSelectionFragment;
|
||||
|
@ -388,6 +387,16 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
|||
}
|
||||
}
|
||||
|
||||
public void routeCalculationStarted() {
|
||||
WeakReference<MapRouteInfoMenuFragment> fragmentRef = findMenuFragment();
|
||||
MapRouteInfoMenuFragment fragment = fragmentRef != null ? fragmentRef.get() : null;
|
||||
if (fragmentRef != null && fragment.isVisible()) {
|
||||
fragment.updateRouteCalculationProgress(0);
|
||||
fragment.updateControlButtons();
|
||||
fragment.updateInfo();
|
||||
}
|
||||
}
|
||||
|
||||
public void updateRouteCalculationProgress(int progress) {
|
||||
WeakReference<MapRouteInfoMenuFragment> fragmentRef = findMenuFragment();
|
||||
MapRouteInfoMenuFragment fragment = fragmentRef != null ? fragmentRef.get() : null;
|
||||
|
@ -403,12 +412,17 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
|||
public void routeCalculationFinished() {
|
||||
WeakReference<MapRouteInfoMenuFragment> fragmentRef = findMenuFragment();
|
||||
MapRouteInfoMenuFragment fragment = fragmentRef != null ? fragmentRef.get() : null;
|
||||
if (fragmentRef != null && fragment.isVisible()) {
|
||||
setRouteCalculationInProgress(false);
|
||||
fragment.hideRouteCalculationProgressBar();
|
||||
fragment.updateControlButtons();
|
||||
fragment.updateInfo();
|
||||
fragment.openMenuHalfScreen();
|
||||
OsmandApplication app = getApp();
|
||||
if (app != null && fragmentRef != null && fragment.isVisible()) {
|
||||
boolean routeCalculating = app.getRoutingHelper().isRouteBeingCalculated() || app.getTransportRoutingHelper().isRouteBeingCalculated();
|
||||
if (setRouteCalculationInProgress(routeCalculating)) {
|
||||
fragment.updateControlButtons();
|
||||
fragment.updateInfo();
|
||||
if (!routeCalculationInProgress) {
|
||||
fragment.hideRouteCalculationProgressBar();
|
||||
fragment.openMenuHalfScreen();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -466,7 +480,6 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
|||
mainView = main;
|
||||
OsmandApplication app = mapActivity.getMyApplication();
|
||||
nightMode = app.getDaynightHelper().isNightModeForMapControls();
|
||||
TargetPointsHelper targetPointsHelper = app.getTargetPointsHelper();
|
||||
|
||||
updateStartPointView();
|
||||
updateWaypointsView();
|
||||
|
@ -476,11 +489,26 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
|||
updateApplicationModesOptions();
|
||||
updateOptionsButtons();
|
||||
|
||||
updateCards();
|
||||
}
|
||||
|
||||
private void updateCards() {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
OsmandApplication app = mapActivity.getMyApplication();
|
||||
nightMode = app.getDaynightHelper().isNightModeForMapControls();
|
||||
|
||||
TargetPointsHelper targetPointsHelper = app.getTargetPointsHelper();
|
||||
RoutingHelper routingHelper = app.getRoutingHelper();
|
||||
|
||||
menuCards.clear();
|
||||
|
||||
boolean bottomShadowVisible = true;
|
||||
if (isBasicRouteCalculated()) {
|
||||
GPXFile gpx = GpxUiHelper.makeGpxFromRoute(app.getRoutingHelper().getRoute(), app);
|
||||
GPXFile gpx = GpxUiHelper.makeGpxFromRoute(routingHelper.getRoute(), app);
|
||||
if (gpx != null) {
|
||||
menuCards.add(new SimpleRouteCard(mapActivity, gpx));
|
||||
}
|
||||
|
@ -498,8 +526,11 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
|||
}
|
||||
bottomShadowVisible = routes.size() == 0;
|
||||
} else if (routeCalculationInProgress) {
|
||||
WarningCard warningCard = new WarningCard(mapActivity);
|
||||
menuCards.add(warningCard);
|
||||
if (app.getTargetPointsHelper().hasTooLongDistanceToNavigate() || routingHelper.isPublicTransportMode()) {
|
||||
// WarningCard card
|
||||
WarningCard warningCard = new WarningCard(mapActivity);
|
||||
menuCards.add(warningCard);
|
||||
}
|
||||
} else {
|
||||
// Home/work card
|
||||
HomeWorkCard homeWorkCard = new HomeWorkCard(mapActivity);
|
||||
|
|
|
@ -32,12 +32,10 @@ import net.osmand.AndroidUtils;
|
|||
import net.osmand.Location;
|
||||
import net.osmand.data.QuadRect;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.osm.edit.Node;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.LockableScrollView;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.TargetPointsHelper;
|
||||
import net.osmand.plus.TargetPointsHelper.TargetPoint;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.base.BaseOsmAndFragment;
|
||||
|
@ -46,7 +44,6 @@ import net.osmand.plus.mapcontextmenu.InterceptorLinearLayout;
|
|||
import net.osmand.plus.routing.RoutingHelper;
|
||||
import net.osmand.plus.routing.TransportRoutingHelper;
|
||||
import net.osmand.plus.views.controls.HorizontalSwipeConfirm;
|
||||
import net.osmand.plus.widgets.ImageViewExProgress;
|
||||
import net.osmand.plus.widgets.TextViewExProgress;
|
||||
import net.osmand.router.TransportRoutePlanner.TransportRouteResult;
|
||||
import net.osmand.util.MapUtils;
|
||||
|
@ -629,6 +626,11 @@ public class MapRouteInfoMenuFragment extends BaseOsmAndFragment {
|
|||
|
||||
boolean canceled = false;
|
||||
|
||||
@Override
|
||||
public void onAnimationStart(Animator animation) {
|
||||
moving = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationCancel(Animator animation) {
|
||||
canceled = true;
|
||||
|
@ -636,6 +638,7 @@ public class MapRouteInfoMenuFragment extends BaseOsmAndFragment {
|
|||
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
moving = false;
|
||||
if (!canceled) {
|
||||
if (needCloseMenu) {
|
||||
menu.hide();
|
||||
|
@ -798,7 +801,9 @@ public class MapRouteInfoMenuFragment extends BaseOsmAndFragment {
|
|||
if (menu != null) {
|
||||
menu.updateInfo(view);
|
||||
applyDayNightMode();
|
||||
runLayoutListener();
|
||||
if (!moving) {
|
||||
runLayoutListener();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -836,9 +841,6 @@ public class MapRouteInfoMenuFragment extends BaseOsmAndFragment {
|
|||
}
|
||||
TextViewExProgress textViewExProgress = (TextViewExProgress) view.findViewById(R.id.start_button_descr);
|
||||
textViewExProgress.percent = progress / 100f;
|
||||
int color = nightMode ? R.color.main_font_dark : R.color.card_and_list_background_light;
|
||||
textViewExProgress.color1 = ContextCompat.getColor(mapActivity, color);
|
||||
textViewExProgress.color2 = ContextCompat.getColor(mapActivity, R.color.description_font_and_bottom_sheet_icons);
|
||||
textViewExProgress.invalidate();
|
||||
}
|
||||
|
||||
|
|
|
@ -1901,7 +1901,10 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment implements P
|
|||
|
||||
public CumulativeInfo getRouteDirectionCumulativeInfo(int position, List<RouteDirectionInfo> routeDirections) {
|
||||
CumulativeInfo cumulativeInfo = new CumulativeInfo();
|
||||
for (int i = position; i < routeDirections.size(); i++) {
|
||||
if (position >= routeDirections.size()) {
|
||||
return cumulativeInfo;
|
||||
}
|
||||
for (int i = 0; i < position; i++) {
|
||||
RouteDirectionInfo routeDirectionInfo = routeDirections.get(i);
|
||||
cumulativeInfo.time += routeDirectionInfo.getExpectedTime();
|
||||
cumulativeInfo.distance += routeDirectionInfo.distance;
|
||||
|
|
|
@ -64,6 +64,7 @@ public class RoutingHelper {
|
|||
private String lastRouteCalcErrorShort;
|
||||
private long recalculateCountInInterval = 0;
|
||||
private int evalWaitInterval = 0;
|
||||
private boolean waitingNextJob;
|
||||
|
||||
private ApplicationMode mode;
|
||||
private OsmandSettings settings;
|
||||
|
@ -872,6 +873,7 @@ public class RoutingHelper {
|
|||
public void run() {
|
||||
synchronized (RoutingHelper.this) {
|
||||
currentRunningJob = this;
|
||||
waitingNextJob = prevRunningJob != null;
|
||||
}
|
||||
if(prevRunningJob != null) {
|
||||
while(prevRunningJob.isAlive()){
|
||||
|
@ -883,6 +885,7 @@ public class RoutingHelper {
|
|||
}
|
||||
synchronized (RoutingHelper.this) {
|
||||
currentRunningJob = this;
|
||||
waitingNextJob = false;
|
||||
}
|
||||
}
|
||||
lastRouteCalcError = null;
|
||||
|
@ -1086,8 +1089,8 @@ public class RoutingHelper {
|
|||
return mode == ApplicationMode.PUBLIC_TRANSPORT;
|
||||
}
|
||||
|
||||
public boolean isRouteBeingCalculated(){
|
||||
return currentRunningJob instanceof RouteRecalculationThread;
|
||||
public boolean isRouteBeingCalculated() {
|
||||
return currentRunningJob instanceof RouteRecalculationThread || waitingNextJob;
|
||||
}
|
||||
|
||||
private void showMessage(final String msg){
|
||||
|
|
|
@ -63,6 +63,7 @@ public class TransportRoutingHelper {
|
|||
private String lastRouteCalcError;
|
||||
private String lastRouteCalcErrorShort;
|
||||
private long lastTimeEvaluatedRoute = 0;
|
||||
private boolean waitingNextJob;
|
||||
|
||||
private TransportRouteCalculationProgressCallback progressRoute;
|
||||
|
||||
|
@ -253,7 +254,7 @@ public class TransportRoutingHelper {
|
|||
}
|
||||
|
||||
public boolean isRouteBeingCalculated() {
|
||||
return currentRunningJob instanceof RouteRecalculationThread;
|
||||
return currentRunningJob instanceof RouteRecalculationThread || waitingNextJob;
|
||||
}
|
||||
|
||||
private void setNewRoute(final List<TransportRouteResult> res) {
|
||||
|
@ -584,6 +585,7 @@ public class TransportRoutingHelper {
|
|||
public void run() {
|
||||
synchronized (TransportRoutingHelper.this) {
|
||||
currentRunningJob = this;
|
||||
waitingNextJob = prevRunningJob != null;
|
||||
}
|
||||
if (prevRunningJob != null) {
|
||||
while (prevRunningJob.isAlive()) {
|
||||
|
@ -595,6 +597,7 @@ public class TransportRoutingHelper {
|
|||
}
|
||||
synchronized (TransportRoutingHelper.this) {
|
||||
currentRunningJob = this;
|
||||
waitingNextJob = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue