use of net.osmand.plus.OsmandSettings in project Osmand by osmandapp.
the class SRTMPlugin method init.
@Override
public boolean init(final OsmandApplication app, Activity activity) {
OsmandSettings settings = app.getSettings();
CommonPreference<String> pref = settings.getCustomRenderProperty("contourLines");
if (pref.get().equals("")) {
for (ApplicationMode m : ApplicationMode.allPossibleValues()) {
if (pref.getModeValue(m).equals("")) {
pref.setModeValue(m, "13");
}
}
}
return true;
}
use of net.osmand.plus.OsmandSettings in project Osmand by osmandapp.
the class FavoritesSearchFragment method showOnMap.
public void showOnMap(final FavouritePoint point) {
getMyApplication().getSettings().FAVORITES_TAB.set(FavoritesActivity.FAV_TAB);
final OsmandSettings settings = getMyApplication().getSettings();
LatLon location = new LatLon(point.getLatitude(), point.getLongitude());
settings.setMapLocationToShow(location.getLatitude(), location.getLongitude(), settings.getLastKnownMapZoom(), new PointDescription(PointDescription.POINT_TYPE_FAVORITE, point.getName()), true, // $NON-NLS-1$
point);
MapActivity.launchMapActivityMoveToTop(getActivity());
}
use of net.osmand.plus.OsmandSettings in project Osmand by osmandapp.
the class SearchPOIActivity method onCreateOptionsMenu.
@Override
public boolean onCreateOptionsMenu(Menu omenu) {
Menu menu = getClearToolbar(true).getMenu();
searchPOILevel = menu.add(0, SEARCH_MORE, 0, R.string.search_POI_level_btn);
MenuItemCompat.setShowAsAction(searchPOILevel, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
searchPOILevel.setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
return search();
}
});
showFilterItem = menu.add(0, FILTER, 0, R.string.search_poi_filter);
MenuItemCompat.setShowAsAction(showFilterItem, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
showFilterItem = showFilterItem.setIcon(getMyApplication().getIconsCache().getIcon(R.drawable.ic_action_filter_dark));
showFilterItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
if (searchFilterLayout.getVisibility() == View.GONE) {
searchFilterLayout.setVisibility(View.VISIBLE);
searchFilter.requestFocus();
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(searchFilter, InputMethodManager.SHOW_IMPLICIT);
} else {
if (filter != null) {
searchFilter.setText(filter.getSavedFilterByName() == null ? "" : filter.getSavedFilterByName());
}
searchFilterLayout.setVisibility(View.GONE);
}
return true;
}
});
showOnMapItem = menu.add(0, SHOW_ON_MAP, 0, R.string.shared_string_show_on_map);
MenuItemCompat.setShowAsAction(showOnMapItem, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
showOnMapItem = showOnMapItem.setIcon(getMyApplication().getIconsCache().getIcon(R.drawable.ic_show_on_map));
showOnMapItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
OsmandSettings settings = app.getSettings();
filter.setFilterByName(searchFilter.getText().toString().trim());
app.getPoiFilters().addSelectedPoiFilter(filter);
if (location != null) {
settings.setMapLocationToShow(location.getLatitude(), location.getLongitude(), 15);
}
MapActivity.launchMapActivityMoveToTop(SearchPOIActivity.this);
return true;
}
});
showOnMapItem.setEnabled(!isNameSearch() || amenityAdapter.getCount() > 0);
if (filter != null && !isNameSearch()) {
createMenuItem(omenu, SAVE_FILTER, R.string.edit_filter_save_as_menu_item, R.drawable.ic_action_fav_dark, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
if (!filter.isStandardFilter()) {
createMenuItem(omenu, DELETE_FILTER, R.string.shared_string_delete, R.drawable.ic_action_delete_dark, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
}
}
updateButtonState(false);
return true;
}
use of net.osmand.plus.OsmandSettings in project Osmand by osmandapp.
the class TrackActivity method addPoint.
public void addPoint(PointDescription pointDescription) {
Intent currentIntent = getIntent();
if (currentIntent != null) {
currentIntent.putExtra(TrackActivity.OPEN_POINTS_TAB, true);
}
final OsmandSettings settings = app.getSettings();
GPXFile gpx = getGpx();
LatLon location = settings.getLastKnownMapLocation();
QuadRect rect = getRect();
NewGpxPoint newGpxPoint = new NewGpxPoint(gpx, pointDescription, rect);
if (gpx != null && location != null) {
settings.setMapLocationToShow(location.getLatitude(), location.getLongitude(), settings.getLastKnownMapZoom(), pointDescription, false, newGpxPoint);
MapActivity.launchMapActivityMoveToTop(this);
}
}
use of net.osmand.plus.OsmandSettings in project Osmand by osmandapp.
the class SavingTrackHelper method updateLocation.
public void updateLocation(net.osmand.Location location) {
// use because there is a bug on some devices with location.getTime()
long locationTime = System.currentTimeMillis();
OsmandSettings settings = ctx.getSettings();
boolean record = false;
if (OsmAndLocationProvider.isPointAccurateForRouting(location) && OsmAndLocationProvider.isNotSimulatedLocation(location)) {
if (OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class) != null) {
if (settings.SAVE_TRACK_TO_GPX.get() && locationTime - lastTimeUpdated > settings.SAVE_TRACK_INTERVAL.get() && ctx.getRoutingHelper().isFollowingMode()) {
record = true;
} else if (settings.SAVE_GLOBAL_TRACK_TO_GPX.get() && locationTime - lastTimeUpdated > settings.SAVE_GLOBAL_TRACK_INTERVAL.get()) {
record = true;
}
float minDistance = settings.SAVE_TRACK_MIN_DISTANCE.get();
if (minDistance > 0 && lastPoint != null && MapUtils.getDistance(lastPoint, location.getLatitude(), location.getLongitude()) < minDistance) {
record = false;
}
float precision = settings.SAVE_TRACK_PRECISION.get();
if (precision > 0 && (!location.hasAccuracy() || location.getAccuracy() > precision)) {
record = false;
}
float minSpeed = settings.SAVE_TRACK_MIN_SPEED.get();
if (minSpeed > 0 && (!location.hasSpeed() || location.getSpeed() < minSpeed)) {
record = false;
}
}
}
if (record) {
insertData(location.getLatitude(), location.getLongitude(), location.getAltitude(), location.getSpeed(), location.getAccuracy(), locationTime, settings);
ctx.getNotificationHelper().refreshNotification(NotificationType.GPX);
}
}
Aggregations