From b3fe91019357d9fcf7616b12fd8d46e9b3c5661f Mon Sep 17 00:00:00 2001 From: Chumva Date: Mon, 18 Nov 2019 18:26:28 +0200 Subject: [PATCH 1/3] Fix enabling edited profile as current app mode --- OsmAnd/src/net/osmand/plus/activities/MapActivity.java | 3 ++- .../src/net/osmand/plus/profiles/EditProfileFragment.java | 5 +---- .../net/osmand/plus/settings/ConfigureProfileFragment.java | 6 +++++- .../net/osmand/plus/settings/GlobalSettingsFragment.java | 4 +--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index 08fdbd3758..eec1aaff56 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -843,8 +843,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); } diff --git a/OsmAnd/src/net/osmand/plus/profiles/EditProfileFragment.java b/OsmAnd/src/net/osmand/plus/profiles/EditProfileFragment.java index 36fcf7ba64..e529e5fc74 100644 --- a/OsmAnd/src/net/osmand/plus/profiles/EditProfileFragment.java +++ b/OsmAnd/src/net/osmand/plus/profiles/EditProfileFragment.java @@ -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)); } } } diff --git a/OsmAnd/src/net/osmand/plus/settings/ConfigureProfileFragment.java b/OsmAnd/src/net/osmand/plus/settings/ConfigureProfileFragment.java index 361da5a374..89abd68987 100644 --- a/OsmAnd/src/net/osmand/plus/settings/ConfigureProfileFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/ConfigureProfileFragment.java @@ -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) diff --git a/OsmAnd/src/net/osmand/plus/settings/GlobalSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/GlobalSettingsFragment.java index cd07a69928..2058f32bdd 100644 --- a/OsmAnd/src/net/osmand/plus/settings/GlobalSettingsFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/GlobalSettingsFragment.java @@ -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); } From 25bdbfc502409d5e3bad98d300d333b8ae326c7b Mon Sep 17 00:00:00 2001 From: Chumva Date: Mon, 18 Nov 2019 18:59:56 +0200 Subject: [PATCH 2/3] 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; } From b20899e1a4d0b8bc2ef0be71537546a9cb44ce82 Mon Sep 17 00:00:00 2001 From: Chumva Date: Tue, 19 Nov 2019 10:10:28 +0200 Subject: [PATCH 3/3] Fix progress for dashboard --- OsmAnd/src/net/osmand/plus/activities/MapActivity.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index 7f61a91924..b344304e6a 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -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