Make voice provider dialog from route preparation change all modes prefs
This commit is contained in:
parent
e4228387ab
commit
73fee0b0bd
9 changed files with 26 additions and 14 deletions
|
@ -450,7 +450,7 @@ public class OsmandApplication extends MultiDexApplication {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initVoiceCommandPlayer(final Activity uiContext, final ApplicationMode applicationMode,
|
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);
|
String voiceProvider = osmandSettings.VOICE_PROVIDER.getModeValue(applicationMode);
|
||||||
if (voiceProvider == null || OsmandSettings.VOICE_PROVIDER_NOT_USE.equals(voiceProvider)) {
|
if (voiceProvider == null || OsmandSettings.VOICE_PROVIDER_NOT_USE.equals(voiceProvider)) {
|
||||||
if (warningNoneProvider && voiceProvider == null) {
|
if (warningNoneProvider && voiceProvider == null) {
|
||||||
|
@ -489,14 +489,20 @@ public class OsmandApplication extends MultiDexApplication {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
if (!Algorithms.isEmpty(firstSelectedVoiceProvider)) {
|
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() {
|
builder.setNeutralButton(R.string.shared_string_do_not_use, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialogInterface, int i) {
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -495,7 +495,7 @@ public class MapActivityActions implements DialogProvider {
|
||||||
ApplicationMode mode = getRouteMode(from);
|
ApplicationMode mode = getRouteMode(from);
|
||||||
//app.getSettings().APPLICATION_MODE.set(mode);
|
//app.getSettings().APPLICATION_MODE.set(mode);
|
||||||
app.getRoutingHelper().setAppMode(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
|
// save application mode controls
|
||||||
settings.FOLLOW_THE_ROUTE.set(false);
|
settings.FOLLOW_THE_ROUTE.set(false);
|
||||||
app.getRoutingHelper().setFollowingMode(false);
|
app.getRoutingHelper().setFollowingMode(false);
|
||||||
|
|
|
@ -456,8 +456,8 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
} else {
|
} else {
|
||||||
super.onPreferenceChange(preference, newValue);
|
super.onPreferenceChange(preference, newValue);
|
||||||
getMyApplication().initVoiceCommandPlayer(
|
getMyApplication().initVoiceCommandPlayer(this, settings.APPLICATION_MODE.get(),
|
||||||
this, settings.APPLICATION_MODE.get(), false, null, true, false);
|
false, null, true, false, false);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,7 +173,7 @@ public class FailSafeFuntions {
|
||||||
app.getSettings().FOLLOW_THE_ROUTE.set(true);
|
app.getSettings().FOLLOW_THE_ROUTE.set(true);
|
||||||
routingHelper.setFollowingMode(true);
|
routingHelper.setFollowingMode(true);
|
||||||
app.getTargetPointsHelper().updateRouteAndRefresh(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()) {
|
if(ma.getDashboard().isVisible()) {
|
||||||
ma.getDashboard().hideDashboard();
|
ma.getDashboard().hideDashboard();
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,7 +113,7 @@ public class TestVoiceActivity extends OsmandActionBarActivity {
|
||||||
addButtons(ll, p);
|
addButtons(ll, p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, true, true);
|
}, true, true, false);
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class RoutePreferencesMenu {
|
||||||
routingOptionsHelper.selectVoiceGuidance(mapActivity, new CallbackWithObject<String>() {
|
routingOptionsHelper.selectVoiceGuidance(mapActivity, new CallbackWithObject<String>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean processResult(String result) {
|
public boolean processResult(String result) {
|
||||||
routingOptionsHelper.applyVoiceProvider(mapActivity, result);
|
routingOptionsHelper.applyVoiceProvider(mapActivity, result, false);
|
||||||
updateParameters();
|
updateParameters();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -813,7 +813,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
||||||
appMode.set(next);
|
appMode.set(next);
|
||||||
}
|
}
|
||||||
routingHelper.setAppMode(next);
|
routingHelper.setAppMode(next);
|
||||||
app.initVoiceCommandPlayer(mapActivity, next, true, null, false, false);
|
app.initVoiceCommandPlayer(mapActivity, next, true, null, false, false, true);
|
||||||
routingHelper.recalculateRouteDueToSettingsChange();
|
routingHelper.recalculateRouteDueToSettingsChange();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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();
|
OsmandApplication app = mapActivity.getMyApplication();
|
||||||
ApplicationMode selectedAppMode = app.getRoutingHelper().getAppMode();
|
ApplicationMode selectedAppMode = app.getRoutingHelper().getAppMode();
|
||||||
app.getSettings().VOICE_PROVIDER.setModeValue(selectedAppMode, provider);
|
if (applyAllModes) {
|
||||||
app.initVoiceCommandPlayer(mapActivity, selectedAppMode, false, null, true, false);
|
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<String> getVoiceFiles(Activity activity) {
|
public Set<String> getVoiceFiles(Activity activity) {
|
||||||
|
|
|
@ -230,7 +230,7 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment {
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
} else if (newValue instanceof String) {
|
} else if (newValue instanceof String) {
|
||||||
settings.VOICE_PROVIDER.set((String) newValue);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue