use of net.osmand.plus.routepreparationmenu.RoutingOptionsHelper in project Osmand by osmandapp.
the class OsmAndDialogs method showVoiceProviderDialog.
public static void showVoiceProviderDialog(final MapActivity activity, final ApplicationMode applicationMode, final boolean applyAllModes) {
OsmandApplication app = activity.getMyApplication();
final OsmandSettings settings = app.getSettings();
boolean nightMode = app.getDaynightHelper().isNightModeForMapControls();
final RoutingOptionsHelper routingOptionsHelper = app.getRoutingOptionsHelper();
final AlertDialog.Builder builder = new AlertDialog.Builder(UiUtilities.getThemedContext(activity, nightMode));
final String[] firstSelectedVoiceProvider = new String[1];
View view = UiUtilities.getInflater(activity, nightMode).inflate(R.layout.select_voice_first, null);
((ImageView) view.findViewById(R.id.icon)).setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_volume_up, settings.isLightContent()));
view.findViewById(R.id.spinner).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View v) {
routingOptionsHelper.selectVoiceGuidance(activity, new CallbackWithObject<String>() {
@Override
public boolean processResult(String result) {
boolean acceptableValue = !RoutePreferencesMenu.MORE_VALUE.equals(firstSelectedVoiceProvider[0]);
if (acceptableValue) {
((TextView) v.findViewById(R.id.selectText)).setText(routingOptionsHelper.getVoiceProviderName(v.getContext(), result));
firstSelectedVoiceProvider[0] = result;
}
return acceptableValue;
}
}, applicationMode);
}
});
((ImageView) view.findViewById(R.id.dropDownIcon)).setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_arrow_drop_down, settings.isLightContent()));
builder.setCancelable(true);
builder.setNegativeButton(R.string.shared_string_cancel, null);
builder.setPositiveButton(R.string.shared_string_apply, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (!Algorithms.isEmpty(firstSelectedVoiceProvider[0])) {
routingOptionsHelper.applyVoiceProvider(activity, firstSelectedVoiceProvider[0], applyAllModes);
if (OsmandSettings.VOICE_PROVIDER_NOT_USE.equals(firstSelectedVoiceProvider[0])) {
settings.VOICE_MUTE.setModeValue(applicationMode, true);
} else {
settings.VOICE_MUTE.setModeValue(applicationMode, false);
}
}
}
});
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()) {
// if (!settings.VOICE_PROVIDER.isSetForMode(mode)) {
settings.VOICE_PROVIDER.setModeValue(mode, OsmandSettings.VOICE_PROVIDER_NOT_USE);
settings.VOICE_MUTE.setModeValue(mode, true);
// }
}
}
settings.VOICE_PROVIDER.setModeValue(applicationMode, OsmandSettings.VOICE_PROVIDER_NOT_USE);
settings.VOICE_MUTE.setModeValue(applicationMode, true);
}
});
builder.setView(view);
builder.show();
}
use of net.osmand.plus.routepreparationmenu.RoutingOptionsHelper in project Osmand by osmandapp.
the class AppInitializer method onCreateApplication.
public void onCreateApplication() {
// always update application mode to default
OsmandSettings osmandSettings = app.getSettings();
if (osmandSettings.FOLLOW_THE_ROUTE.get()) {
ApplicationMode savedMode = osmandSettings.readApplicationMode();
if (!osmandSettings.APPLICATION_MODE.get().getStringKey().equals(savedMode.getStringKey())) {
osmandSettings.setApplicationMode(savedMode);
}
} else {
osmandSettings.setApplicationMode(osmandSettings.DEFAULT_APPLICATION_MODE.get());
}
startTime = System.currentTimeMillis();
getLazyRoutingConfig();
app.applyTheme(app);
startupInit(app.reconnectToBRouter(), IBRouterService.class);
app.backupHelper = startupInit(new BackupHelper(app), BackupHelper.class);
app.inAppPurchaseHelper = startupInit(new InAppPurchaseHelperImpl(app), InAppPurchaseHelperImpl.class);
app.poiTypes = startupInit(MapPoiTypes.getDefaultNoInit(), MapPoiTypes.class);
app.transportRoutingHelper = startupInit(new TransportRoutingHelper(app), TransportRoutingHelper.class);
app.routingHelper = startupInit(new RoutingHelper(app), RoutingHelper.class);
app.routingOptionsHelper = startupInit(new RoutingOptionsHelper(app), RoutingOptionsHelper.class);
app.resourceManager = startupInit(new ResourceManager(app), ResourceManager.class);
app.daynightHelper = startupInit(new DayNightHelper(app), DayNightHelper.class);
app.locationProvider = startupInit(new OsmAndLocationProvider(app), OsmAndLocationProvider.class);
app.avoidSpecificRoads = startupInit(new AvoidSpecificRoads(app), AvoidSpecificRoads.class);
app.avoidRoadsHelper = startupInit(new AvoidRoadsHelper(app), AvoidRoadsHelper.class);
app.savingTrackHelper = startupInit(new SavingTrackHelper(app), SavingTrackHelper.class);
app.analyticsHelper = startupInit(new AnalyticsHelper(app), AnalyticsHelper.class);
app.notificationHelper = startupInit(new NotificationHelper(app), NotificationHelper.class);
app.liveMonitoringHelper = startupInit(new LiveMonitoringHelper(app), LiveMonitoringHelper.class);
app.selectedGpxHelper = startupInit(new GpxSelectionHelper(app, app.savingTrackHelper), GpxSelectionHelper.class);
app.gpxDbHelper = startupInit(new GpxDbHelper(app), GpxDbHelper.class);
app.favoritesHelper = startupInit(new FavouritesHelper(app), FavouritesHelper.class);
app.waypointHelper = startupInit(new WaypointHelper(app), WaypointHelper.class);
app.aidlApi = startupInit(new OsmandAidlApi(app), OsmandAidlApi.class);
app.regions = startupInit(new OsmandRegions(), OsmandRegions.class);
updateRegionVars();
app.poiFilters = startupInit(new PoiFiltersHelper(app), PoiFiltersHelper.class);
app.rendererRegistry = startupInit(new RendererRegistry(app), RendererRegistry.class);
app.geocodingLookupService = startupInit(new GeocodingLookupService(app), GeocodingLookupService.class);
app.targetPointsHelper = startupInit(new TargetPointsHelper(app), TargetPointsHelper.class);
app.mapMarkersDbHelper = startupInit(new MapMarkersDbHelper(app), MapMarkersDbHelper.class);
app.mapMarkersHelper = startupInit(new MapMarkersHelper(app), MapMarkersHelper.class);
app.searchUICore = startupInit(new QuickSearchHelper(app), QuickSearchHelper.class);
app.mapViewTrackingUtilities = startupInit(new MapViewTrackingUtilities(app), MapViewTrackingUtilities.class);
app.osmandMap = startupInit(new OsmandMap(app), OsmandMap.class);
// TODO TRAVEL_OBF_HELPER check ResourceManager and use TravelObfHelper
TravelHelper travelHelper = !TravelDbHelper.checkIfDbFileExists(app) ? new TravelObfHelper(app) : new TravelDbHelper(app);
app.travelHelper = startupInit(travelHelper, TravelHelper.class);
app.travelRendererHelper = startupInit(new TravelRendererHelper(app), TravelRendererHelper.class);
app.lockHelper = startupInit(new LockHelper(app), LockHelper.class);
app.fileSettingsHelper = startupInit(new FileSettingsHelper(app), FileSettingsHelper.class);
app.networkSettingsHelper = startupInit(new NetworkSettingsHelper(app), NetworkSettingsHelper.class);
app.quickActionRegistry = startupInit(new QuickActionRegistry(app.getSettings()), QuickActionRegistry.class);
app.osmOAuthHelper = startupInit(new OsmOAuthHelper(app), OsmOAuthHelper.class);
app.oprAuthHelper = startupInit(new OprAuthHelper(app), OprAuthHelper.class);
app.onlineRoutingHelper = startupInit(new OnlineRoutingHelper(app), OnlineRoutingHelper.class);
app.launcherShortcutsHelper = startupInit(new LauncherShortcutsHelper(app), LauncherShortcutsHelper.class);
app.gpsFilterHelper = startupInit(new GpsFilterHelper(app), GpsFilterHelper.class);
app.downloadTilesHelper = startupInit(new DownloadTilesHelper(app), DownloadTilesHelper.class);
initOpeningHoursParser();
}
Aggregations