From 73fee0b0bd170ed773fa2e7ed3ad0f3ea2d9c239 Mon Sep 17 00:00:00 2001 From: Chumva Date: Thu, 14 Nov 2019 19:02:49 +0200 Subject: [PATCH] Make voice provider dialog from route preparation change all modes prefs --- OsmAnd/src/net/osmand/plus/OsmandApplication.java | 12 +++++++++--- .../osmand/plus/activities/MapActivityActions.java | 2 +- .../plus/activities/SettingsNavigationActivity.java | 4 ++-- .../src/net/osmand/plus/base/FailSafeFuntions.java | 2 +- .../osmand/plus/development/TestVoiceActivity.java | 2 +- .../mapcontextmenu/other/RoutePreferencesMenu.java | 2 +- .../plus/routepreparationmenu/MapRouteInfoMenu.java | 2 +- .../routepreparationmenu/RoutingOptionsHelper.java | 12 +++++++++--- .../osmand/plus/settings/VoiceAnnouncesFragment.java | 2 +- 9 files changed, 26 insertions(+), 14 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/OsmandApplication.java b/OsmAnd/src/net/osmand/plus/OsmandApplication.java index e2d8ddf7e0..5fc477f84a 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandApplication.java +++ b/OsmAnd/src/net/osmand/plus/OsmandApplication.java @@ -450,7 +450,7 @@ public class OsmandApplication extends MultiDexApplication { } public void initVoiceCommandPlayer(final Activity uiContext, final ApplicationMode applicationMode, - boolean warningNoneProvider, Runnable run, boolean showDialog, boolean force) { + boolean warningNoneProvider, Runnable run, boolean showDialog, boolean force, final boolean applyAllModes) { String voiceProvider = osmandSettings.VOICE_PROVIDER.getModeValue(applicationMode); if (voiceProvider == null || OsmandSettings.VOICE_PROVIDER_NOT_USE.equals(voiceProvider)) { if (warningNoneProvider && voiceProvider == null) { @@ -489,14 +489,20 @@ public class OsmandApplication extends MultiDexApplication { @Override public void onClick(DialogInterface dialog, int which) { if (!Algorithms.isEmpty(firstSelectedVoiceProvider)) { - routingOptionsHelper.applyVoiceProvider((MapActivity) uiContext, firstSelectedVoiceProvider); + routingOptionsHelper.applyVoiceProvider((MapActivity) uiContext, firstSelectedVoiceProvider, applyAllModes); } } }); builder.setNeutralButton(R.string.shared_string_do_not_use, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { - osmandSettings.VOICE_PROVIDER.setModeValue(applicationMode, OsmandSettings.VOICE_PROVIDER_NOT_USE); + if (applyAllModes) { + for (ApplicationMode mode : ApplicationMode.allPossibleValues()) { + osmandSettings.VOICE_PROVIDER.setModeValue(mode, OsmandSettings.VOICE_PROVIDER_NOT_USE); + } + } else { + osmandSettings.VOICE_PROVIDER.setModeValue(applicationMode, OsmandSettings.VOICE_PROVIDER_NOT_USE); + } } }); diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index 463fe6a259..6430a68197 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -495,7 +495,7 @@ public class MapActivityActions implements DialogProvider { ApplicationMode mode = getRouteMode(from); //app.getSettings().APPLICATION_MODE.set(mode); app.getRoutingHelper().setAppMode(mode); - app.initVoiceCommandPlayer(mapActivity, mode, true, null, false, false); + app.initVoiceCommandPlayer(mapActivity, mode, true, null, false, false, showMenu); // save application mode controls settings.FOLLOW_THE_ROUTE.set(false); app.getRoutingHelper().setFollowingMode(false); diff --git a/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java b/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java index 882f2d0df7..ec9239f8f1 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java @@ -456,8 +456,8 @@ public class SettingsNavigationActivity extends SettingsBaseActivity { startActivity(intent); } else { super.onPreferenceChange(preference, newValue); - getMyApplication().initVoiceCommandPlayer( - this, settings.APPLICATION_MODE.get(), false, null, true, false); + getMyApplication().initVoiceCommandPlayer(this, settings.APPLICATION_MODE.get(), + false, null, true, false, false); } return true; } diff --git a/OsmAnd/src/net/osmand/plus/base/FailSafeFuntions.java b/OsmAnd/src/net/osmand/plus/base/FailSafeFuntions.java index 6e5bb8adf1..a45b2a2e42 100644 --- a/OsmAnd/src/net/osmand/plus/base/FailSafeFuntions.java +++ b/OsmAnd/src/net/osmand/plus/base/FailSafeFuntions.java @@ -173,7 +173,7 @@ public class FailSafeFuntions { app.getSettings().FOLLOW_THE_ROUTE.set(true); routingHelper.setFollowingMode(true); app.getTargetPointsHelper().updateRouteAndRefresh(true); - app.initVoiceCommandPlayer(ma, routingHelper.getAppMode(), true, null, false, false); + app.initVoiceCommandPlayer(ma, routingHelper.getAppMode(), true, null, false, false, false); if(ma.getDashboard().isVisible()) { ma.getDashboard().hideDashboard(); } diff --git a/OsmAnd/src/net/osmand/plus/development/TestVoiceActivity.java b/OsmAnd/src/net/osmand/plus/development/TestVoiceActivity.java index 61777cd33c..68a7ab97f9 100644 --- a/OsmAnd/src/net/osmand/plus/development/TestVoiceActivity.java +++ b/OsmAnd/src/net/osmand/plus/development/TestVoiceActivity.java @@ -113,7 +113,7 @@ public class TestVoiceActivity extends OsmandActionBarActivity { addButtons(ll, p); } } - }, true, true); + }, true, true, false); dialog.dismiss(); } }); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/RoutePreferencesMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/RoutePreferencesMenu.java index 7f0826304e..27037ed092 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/RoutePreferencesMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/RoutePreferencesMenu.java @@ -69,7 +69,7 @@ public class RoutePreferencesMenu { routingOptionsHelper.selectVoiceGuidance(mapActivity, new CallbackWithObject() { @Override public boolean processResult(String result) { - routingOptionsHelper.applyVoiceProvider(mapActivity, result); + routingOptionsHelper.applyVoiceProvider(mapActivity, result, false); updateParameters(); return true; } diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java index 95f428ad51..9e2113d18a 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java @@ -813,7 +813,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener appMode.set(next); } routingHelper.setAppMode(next); - app.initVoiceCommandPlayer(mapActivity, next, true, null, false, false); + app.initVoiceCommandPlayer(mapActivity, next, true, null, false, false, true); routingHelper.recalculateRouteDueToSettingsChange(); } } diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/RoutingOptionsHelper.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/RoutingOptionsHelper.java index fb6c8ba307..bc1cda9b6f 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/RoutingOptionsHelper.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/RoutingOptionsHelper.java @@ -175,11 +175,17 @@ public class RoutingOptionsHelper { } } - public void applyVoiceProvider(MapActivity mapActivity, String provider) { + public void applyVoiceProvider(MapActivity mapActivity, String provider, boolean applyAllModes) { OsmandApplication app = mapActivity.getMyApplication(); ApplicationMode selectedAppMode = app.getRoutingHelper().getAppMode(); - app.getSettings().VOICE_PROVIDER.setModeValue(selectedAppMode, provider); - app.initVoiceCommandPlayer(mapActivity, selectedAppMode, false, null, true, false); + if (applyAllModes) { + for (ApplicationMode mode : ApplicationMode.allPossibleValues()) { + app.getSettings().VOICE_PROVIDER.setModeValue(mode, provider); + } + } else { + app.getSettings().VOICE_PROVIDER.setModeValue(selectedAppMode, provider); + } + app.initVoiceCommandPlayer(mapActivity, selectedAppMode, false, null, true, false, applyAllModes); } public Set getVoiceFiles(Activity activity) { diff --git a/OsmAnd/src/net/osmand/plus/settings/VoiceAnnouncesFragment.java b/OsmAnd/src/net/osmand/plus/settings/VoiceAnnouncesFragment.java index e2b0d41128..48869a4aa1 100644 --- a/OsmAnd/src/net/osmand/plus/settings/VoiceAnnouncesFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/VoiceAnnouncesFragment.java @@ -230,7 +230,7 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment { startActivity(intent); } else if (newValue instanceof String) { settings.VOICE_PROVIDER.set((String) newValue); - app.initVoiceCommandPlayer(getActivity(), getSelectedAppMode(), false, null, true, false); + app.initVoiceCommandPlayer(getActivity(), getSelectedAppMode(), false, null, true, false, false); } return true; }