Make voice provider dialog from route preparation change all modes prefs

This commit is contained in:
Chumva 2019-11-14 19:02:49 +02:00
parent e4228387ab
commit 73fee0b0bd
9 changed files with 26 additions and 14 deletions

View file

@ -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,15 +489,21 @@ 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) {
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);
}
}
});
builder.setView(view);

View file

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

View file

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

View file

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

View file

@ -113,7 +113,7 @@ public class TestVoiceActivity extends OsmandActionBarActivity {
addButtons(ll, p);
}
}
}, true, true);
}, true, true, false);
dialog.dismiss();
}
});

View file

@ -69,7 +69,7 @@ public class RoutePreferencesMenu {
routingOptionsHelper.selectVoiceGuidance(mapActivity, new CallbackWithObject<String>() {
@Override
public boolean processResult(String result) {
routingOptionsHelper.applyVoiceProvider(mapActivity, result);
routingOptionsHelper.applyVoiceProvider(mapActivity, result, false);
updateParameters();
return true;
}

View file

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

View file

@ -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();
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);
}
app.initVoiceCommandPlayer(mapActivity, selectedAppMode, false, null, true, false, applyAllModes);
}
public Set<String> getVoiceFiles(Activity activity) {

View file

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