use of net.osmand.plus.ApplicationMode in project Osmand by osmandapp.
the class AvoidSpecificRoads method replaceImpassableRoad.
public void replaceImpassableRoad(final MapActivity activity, final RouteDataObject currentObject, final LatLon loc, final boolean showDialog, final AvoidSpecificRoadsCallback callback) {
LatLon latLon = getLocation(currentObject);
app.getSettings().moveImpassableRoad(latLon, loc);
final Location ll = new Location("");
ll.setLatitude(loc.getLatitude());
ll.setLongitude(loc.getLongitude());
ApplicationMode appMode = app.getRoutingHelper().getAppMode();
app.getLocationProvider().getRouteSegment(ll, appMode, new ResultMatcher<RouteDataObject>() {
@Override
public boolean publish(RouteDataObject object) {
if (object == null) {
Toast.makeText(activity, R.string.error_avoid_specific_road, Toast.LENGTH_LONG).show();
if (callback != null) {
callback.onAddImpassableRoad(false, null);
}
} else {
app.getDefaultRoutingConfig().removeImpassableRoad(currentObject);
addImpassableRoadInternal(object, ll, showDialog, activity, loc);
if (callback != null) {
callback.onAddImpassableRoad(true, object);
}
}
return true;
}
@Override
public boolean isCancelled() {
return callback != null && callback.isCancelled();
}
});
}
use of net.osmand.plus.ApplicationMode in project Osmand by osmandapp.
the class SettingsGeneralActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
((OsmandApplication) getApplication()).applyTheme(this);
super.onCreate(savedInstanceState);
getToolbar().setTitle(R.string.global_app_settings);
addPreferencesFromResource(R.xml.general_settings);
String[] entries;
String[] entrieValues;
PreferenceScreen screen = getPreferenceScreen();
settings = getMyApplication().getSettings();
ApplicationMode[] appModes = ApplicationMode.values(settings).toArray(new ApplicationMode[0]);
entries = new String[appModes.length];
for (int i = 0; i < entries.length; i++) {
entries[i] = appModes[i].toHumanString(getMyApplication());
}
registerListPreference(settings.APPLICATION_MODE, screen, entries, appModes);
// List preferences
registerListPreference(settings.ROTATE_MAP, screen, new String[] { getString(R.string.rotate_map_none_opt), getString(R.string.rotate_map_bearing_opt), getString(R.string.rotate_map_compass_opt) }, new Integer[] { OsmandSettings.ROTATE_MAP_NONE, OsmandSettings.ROTATE_MAP_BEARING, OsmandSettings.ROTATE_MAP_COMPASS });
registerListPreference(settings.MAP_SCREEN_ORIENTATION, screen, new String[] { getString(R.string.map_orientation_portrait), getString(R.string.map_orientation_landscape), getString(R.string.map_orientation_default) }, new Integer[] { ActivityInfo.SCREEN_ORIENTATION_PORTRAIT, ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE, ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED });
drivingRegionPreference = screen.findPreference(settings.DRIVING_REGION.getId());
addLocalPrefs((PreferenceGroup) screen.findPreference("localization"));
addProxyPrefs((PreferenceGroup) screen.findPreference("proxy"));
addMiscPreferences((PreferenceGroup) screen.findPreference("misc"));
applicationModePreference = (ListPreference) screen.findPreference(settings.APPLICATION_MODE.getId());
applicationModePreference.setOnPreferenceChangeListener(this);
}
use of net.osmand.plus.ApplicationMode in project Osmand by osmandapp.
the class SettingsBaseActivity method onCreate.
@SuppressWarnings("deprecation")
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
settings = getMyApplication().getSettings();
getToolbar().setTitle(R.string.shared_string_settings);
if (profileSettings) {
modes.clear();
for (ApplicationMode a : ApplicationMode.values(settings)) {
if (a != ApplicationMode.DEFAULT) {
modes.add(a);
}
}
List<String> s = new ArrayList<String>();
for (ApplicationMode a : modes) {
s.add(a.toHumanString(getMyApplication()));
}
SpinnerAdapter spinnerAdapter = new SpinnerAdapter(this, R.layout.spinner_item, s);
// android.R.layout.simple_spinner_dropdown_item
spinnerAdapter.setDropDownViewResource(R.layout.spinner_dropdown_item);
getSpinner().setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
settings.APPLICATION_MODE.set(modes.get(position));
updateAllSettings();
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
getSpinner().setAdapter(spinnerAdapter);
getSpinner().setVisibility(View.VISIBLE);
}
setPreferenceScreen(getPreferenceManager().createPreferenceScreen(this));
}
use of net.osmand.plus.ApplicationMode in project Osmand by osmandapp.
the class SettingsBaseActivity method setSelectedAppMode.
protected boolean setSelectedAppMode(ApplicationMode am) {
int ind = 0;
boolean found = false;
for (ApplicationMode a : modes) {
if (am == a) {
getSpinner().setSelection(ind);
found = true;
break;
}
ind++;
}
return found;
}
use of net.osmand.plus.ApplicationMode in project Osmand by osmandapp.
the class SettingsBaseActivity method onResume.
@Override
protected void onResume() {
super.onResume();
if (profileSettings) {
previousAppMode = settings.getApplicationMode();
boolean found;
if (getIntent() != null && getIntent().hasExtra(INTENT_APP_MODE)) {
String modeStr = getIntent().getStringExtra(INTENT_APP_MODE);
ApplicationMode mode = ApplicationMode.valueOfStringKey(modeStr, previousAppMode);
found = setSelectedAppMode(mode);
} else {
found = setSelectedAppMode(previousAppMode);
}
if (!found) {
getSpinner().setSelection(0);
}
} else {
updateAllSettings();
}
}
Aggregations