From 25bdbfc502409d5e3bad98d300d333b8ae326c7b Mon Sep 17 00:00:00 2001 From: Chumva Date: Mon, 18 Nov 2019 18:59:56 +0200 Subject: [PATCH] Show indeterminate progress for not osmand routing --- .../osmand/plus/activities/MapActivity.java | 3 ++- .../MapRouteInfoMenuFragment.java | 18 +++++++++++++----- .../net/osmand/plus/routing/RoutingHelper.java | 6 +++++- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index eec1aaff56..7f61a91924 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -588,8 +588,9 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven ? mapLayers.getRouteLayer().getRouteLineColor(nightMode) : ContextCompat.getColor(this, R.color.wikivoyage_active_light); + RoutingHelper routingHelper = getRoutingHelper(); pb.setProgressDrawable(AndroidUtils.createProgressDrawable(bgColor, progressColor)); - pb.setIndeterminate(getRoutingHelper().isPublicTransportMode()); + pb.setIndeterminate(routingHelper.isPublicTransportMode() || !routingHelper.isOsmandRouting()); pb.getIndeterminateDrawable().setColorFilter(progressColor, android.graphics.PorterDuff.Mode.SRC_IN); } diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenuFragment.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenuFragment.java index 810ea4ad6e..b975e04f15 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenuFragment.java @@ -149,11 +149,14 @@ public class MapRouteInfoMenuFragment extends ContextMenuFragment { View mainView = getMainView(); if (mainView != null) { View progressBar = mainView.findViewById(R.id.progress_bar); + RoutingHelper routingHelper = app.getRoutingHelper(); boolean progressVisible = progressBar != null && progressBar.getVisibility() == View.VISIBLE; - boolean routeCalculating = app.getRoutingHelper().isRouteBeingCalculated() || app.getTransportRoutingHelper().isRouteBeingCalculated(); + boolean routeCalculating = routingHelper.isRouteBeingCalculated() || app.getTransportRoutingHelper().isRouteBeingCalculated(); if (progressVisible && !routeCalculating) { hideRouteCalculationProgressBar(); openMenuHalfScreen(); + } else if (!progressVisible && routeCalculating && !routingHelper.isOsmandRouting()) { + updateRouteCalculationProgress(0); } } menu.addTargetPointListener(); @@ -359,6 +362,11 @@ public class MapRouteInfoMenuFragment extends ContextMenuFragment { OsmandApplication app = getMyApplication(); return app != null && app.getRoutingHelper().isPublicTransportMode(); } + + private boolean isOsmandRouting() { + OsmandApplication app = getMyApplication(); + return app != null && app.getRoutingHelper().isOsmandRouting(); + } public void updateRouteCalculationProgress(int progress) { MapActivity mapActivity = getMapActivity(); @@ -367,11 +375,11 @@ public class MapRouteInfoMenuFragment extends ContextMenuFragment { if (mapActivity == null || mainView == null || view == null) { return; } - boolean publicTransportMode = isPublicTransportMode(); + boolean indeterminate = isPublicTransportMode() || !isOsmandRouting(); ProgressBar progressBar = (ProgressBar) mainView.findViewById(R.id.progress_bar); if (progressBar != null) { if (progress == 0) { - progressBar.setIndeterminate(publicTransportMode); + progressBar.setIndeterminate(indeterminate); } if (progressBar.getVisibility() != View.VISIBLE) { progressBar.setVisibility(View.VISIBLE); @@ -383,10 +391,10 @@ public class MapRouteInfoMenuFragment extends ContextMenuFragment { if (progressBarButton.getVisibility() != View.VISIBLE) { progressBarButton.setVisibility(View.VISIBLE); } - progressBarButton.setProgress(publicTransportMode ? 0 : progress); + progressBarButton.setProgress(indeterminate ? 0 : progress); } TextViewExProgress textViewExProgress = (TextViewExProgress) view.findViewById(R.id.start_button_descr); - textViewExProgress.percent = publicTransportMode ? 0 : progress / 100f; + textViewExProgress.percent = indeterminate ? 0 : progress / 100f; textViewExProgress.invalidate(); } diff --git a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java index d16628b632..ce4a7861ec 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java +++ b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java @@ -1073,8 +1073,8 @@ public class RoutingHelper { RouteRecalculationThread newThread = new RouteRecalculationThread( "Calculating route", params, paramsChanged); //$NON-NLS-1$ currentRunningJob = newThread; + startProgress(params); if (updateProgress) { - startProgress(params); updateProgress(params); } if (prevRunningJob != null) { @@ -1165,6 +1165,10 @@ public class RoutingHelper { return mode.isDerivedRoutingFrom(ApplicationMode.PUBLIC_TRANSPORT); } + public boolean isOsmandRouting() { + return mode.getRouteService() == RouteService.OSMAND; + } + public boolean isRouteBeingCalculated() { return currentRunningJob instanceof RouteRecalculationThread || waitingNextJob; }