Merge pull request #7950 from osmandapp/Fix_7682

Fix 7682
This commit is contained in:
max-klaus 2019-11-20 12:04:41 +03:00 committed by GitHub
commit 67669eb859
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 33 additions and 16 deletions

View file

@ -496,6 +496,10 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
public void start() {
setupRouteCalculationProgressBar(pb);
mapRouteInfoMenu.routeCalculationStarted();
RoutingHelper routingHelper = getRoutingHelper();
if (routingHelper.isPublicTransportMode() || !routingHelper.isOsmandRouting()) {
dashboardOnMap.updateRouteCalculationProgress(0);
}
}
@Override
@ -588,8 +592,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);
}
@ -843,8 +848,9 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
}
if (intent.hasExtra(EditProfileFragment.OPEN_SETTINGS)) {
String settingsType = intent.getStringExtra(EditProfileFragment.OPEN_SETTINGS);
String appMode = intent.getStringExtra(EditProfileFragment.SELECTED_ITEM);
if (EditProfileFragment.OPEN_CONFIG_PROFILE.equals(settingsType)) {
BaseSettingsFragment.showInstance(this, SettingsScreenType.CONFIGURE_PROFILE);
BaseSettingsFragment.showInstance(this, SettingsScreenType.CONFIGURE_PROFILE, ApplicationMode.valueOfStringKey(appMode, null));
}
setIntent(null);
}

View file

@ -369,16 +369,13 @@ public class EditProfileFragment extends BaseOsmAndFragment {
if (dataChanged) {
needSaveDialog();
} else if (getSettings() != null) {
activateMode(mode);
getSettings().APPLICATION_MODE.set(mode);
if (activity instanceof EditProfileActivity) {
Intent i = new Intent(getActivity(), MapActivity.class);
i.putExtra(OPEN_SETTINGS, OPEN_CONFIG_PROFILE);
i.putExtra(SELECTED_ITEM, profile.stringKey);
startActivity(i);
} else {
BaseSettingsFragment.showInstance(activity, SettingsScreenType.CONFIGURE_PROFILE);
BaseSettingsFragment.showInstance(activity, SettingsScreenType.CONFIGURE_PROFILE, ApplicationMode.valueOfStringKey(profile.stringKey, null));
}
}
}

View file

@ -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();
}

View file

@ -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;
}

View file

@ -304,7 +304,11 @@ public class ConfigureProfileFragment extends BaseSettingsFragment {
try {
FragmentManager fragmentManager = activity.getSupportFragmentManager();
if (fragmentManager != null) {
settings.APPLICATION_MODE.set(getSelectedAppMode());
ApplicationMode selectedMode = getSelectedAppMode();
if (!ApplicationMode.values(app).contains(selectedMode)) {
ApplicationMode.changeProfileAvailability(selectedMode, true, app);
}
settings.APPLICATION_MODE.set(selectedMode);
fragmentManager.beginTransaction()
.remove(this)
.addToBackStack(TAG)

View file

@ -98,8 +98,6 @@ public class GlobalSettingsFragment extends BaseSettingsFragment implements Send
if (app == null) {
return;
}
ApplicationMode selectedMode = getSelectedAppMode();
ApplicationMode[] appModes = ApplicationMode.values(app).toArray(new ApplicationMode[0]);
String[] entries = new String[appModes.length];
String[] entryValues = new String[appModes.length];
@ -109,7 +107,7 @@ public class GlobalSettingsFragment extends BaseSettingsFragment implements Send
}
ListPreferenceEx defaultApplicationMode = (ListPreferenceEx) findPreference(settings.DEFAULT_APPLICATION_MODE.getId());
defaultApplicationMode.setIcon(getContentIcon(selectedMode.getIconRes()));
defaultApplicationMode.setIcon(getContentIcon(settings.DEFAULT_APPLICATION_MODE.get().getIconRes()));
defaultApplicationMode.setEntries(entries);
defaultApplicationMode.setEntryValues(entryValues);
}