use of net.osmand.plus.settings.backend.OsmandSettings in project Osmand by osmandapp.
the class SendAnalyticsBottomSheetDialogFragment method onDismissButtonClickAction.
@Override
protected void onDismissButtonClickAction() {
OsmandApplication app = requiredMyApplication();
OsmandSettings settings = app.getSettings();
settings.SEND_ANONYMOUS_MAP_DOWNLOADS_DATA.set(false);
settings.SEND_ANONYMOUS_APP_USAGE_DATA.set(false);
settings.SEND_ANONYMOUS_DATA_REQUEST_PROCESSED.set(true);
informAnalyticsPrefsUpdate();
}
use of net.osmand.plus.settings.backend.OsmandSettings in project Osmand by osmandapp.
the class SendAnalyticsBottomSheetDialogFragment method showInstance.
public static void showInstance(@NonNull OsmandApplication app, @NonNull FragmentManager fm, @Nullable Fragment target) {
try {
if (fm.findFragmentByTag(SendAnalyticsBottomSheetDialogFragment.TAG) == null) {
SendAnalyticsBottomSheetDialogFragment fragment = new SendAnalyticsBottomSheetDialogFragment();
fragment.setTargetFragment(target, 0);
fragment.show(fm, SendAnalyticsBottomSheetDialogFragment.TAG);
OsmandSettings settings = app.getSettings();
int numberOfStarts = app.getAppInitializer().getNumberOfStarts();
OsmandPreference<Integer> lastRequestNS = settings.SEND_ANONYMOUS_DATA_LAST_REQUEST_NS;
if (numberOfStarts != lastRequestNS.get()) {
OsmandPreference<Integer> counter = settings.SEND_ANONYMOUS_DATA_REQUESTS_COUNT;
counter.set(counter.get() + 1);
lastRequestNS.set(numberOfStarts);
}
}
} catch (RuntimeException e) {
LOG.error("showInstance", e);
}
}
use of net.osmand.plus.settings.backend.OsmandSettings in project Osmand by osmandapp.
the class MapLayerMenuListener method onContextMenuClick.
@Override
public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> adapter, int itemId, final int pos, boolean isChecked, int[] viewCoordinates) {
final OsmandSettings settings = mapActivity.getMyApplication().getSettings();
final PoiFiltersHelper poiFiltersHelper = mapActivity.getMyApplication().getPoiFilters();
final ContextMenuItem item = menuAdapter.getItem(pos);
if (item.getSelected() != null) {
item.setColor(mapActivity, isChecked ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
}
if (itemId == R.string.layer_poi) {
PoiUIFilter wiki = poiFiltersHelper.getTopWikiPoiFilter();
poiFiltersHelper.clearSelectedPoiFilters(wiki);
if (isChecked) {
showPoiFilterDialog(adapter, adapter.getItem(pos));
} else {
adapter.getItem(pos).setDescription(poiFiltersHelper.getSelectedPoiFiltersName(wiki));
}
} else if (itemId == R.string.layer_amenity_label) {
settings.SHOW_POI_LABEL.set(isChecked);
} else if (itemId == R.string.shared_string_favorites) {
settings.SHOW_FAVORITES.set(isChecked);
} else if (itemId == R.string.layer_gpx_layer) {
final GpxSelectionHelper selectedGpxHelper = mapActivity.getMyApplication().getSelectedGpxHelper();
if (selectedGpxHelper.isShowingAnyGpxFiles()) {
selectedGpxHelper.clearAllGpxFilesToShow(true);
adapter.getItem(pos).setDescription(selectedGpxHelper.getGpxDescription());
} else {
showGpxSelectionDialog(adapter, adapter.getItem(pos));
}
} else if (itemId == R.string.rendering_category_transport) {
boolean selected = TransportLinesMenu.isShowLines(mapActivity.getMyApplication());
TransportLinesMenu.toggleTransportLines(mapActivity, !selected, result -> {
item.setSelected(result);
item.setColor(mapActivity, result ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
adapter.notifyDataSetChanged();
return true;
});
} else if (itemId == R.string.map_markers) {
settings.SHOW_MAP_MARKERS.set(isChecked);
} else if (itemId == R.string.layer_map) {
if (!OsmandPlugin.isActive(OsmandRasterMapsPlugin.class)) {
PluginsFragment.showInstance(mapActivity.getSupportFragmentManager());
} else {
ContextMenuItem it = adapter.getItem(pos);
mapActivity.getMapLayers().selectMapLayer(mapActivity, it, adapter);
}
return false;
}
adapter.notifyDataSetChanged();
mapActivity.updateLayers();
mapActivity.refreshMap();
return false;
}
use of net.osmand.plus.settings.backend.OsmandSettings in project Osmand by osmandapp.
the class ShareMenu method share.
public void share(ShareItem item) {
MapActivity mapActivity = getMapActivity();
if (mapActivity == null) {
return;
}
String lat = LocationConvert.convertLatitude(latLon.getLatitude(), LocationConvert.FORMAT_DEGREES, false);
String lon = LocationConvert.convertLongitude(latLon.getLongitude(), LocationConvert.FORMAT_DEGREES, false);
lat = lat.substring(0, lat.length() - 1);
lon = lon.substring(0, lon.length() - 1);
final int zoom = mapActivity.getMapView().getZoom();
final String geoUrl = MapUtils.buildGeoUrl(lat, lon, zoom);
final String httpUrl = "https://osmand.net/go?lat=" + lat + "&lon=" + lon + "&z=" + zoom;
StringBuilder sb = new StringBuilder();
if (!Algorithms.isEmpty(title)) {
sb.append(title).append("\n");
}
if (!Algorithms.isEmpty(address) && !address.equals(title) && !address.equals(mapActivity.getString(R.string.no_address_found))) {
sb.append(address).append("\n");
}
sb.append(mapActivity.getString(R.string.shared_string_location)).append(": ");
if (TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault()) == ViewCompat.LAYOUT_DIRECTION_RTL) {
sb.append("\n");
}
sb.append(geoUrl).append("\n").append(httpUrl);
String sms = sb.toString();
switch(item) {
case MESSAGE:
sendMessage(mapActivity, sms);
break;
case CLIPBOARD:
copyToClipboardWithToast(mapActivity, sms, Toast.LENGTH_LONG);
break;
case ADDRESS:
if (!Algorithms.isEmpty(address)) {
copyToClipboardWithToast(mapActivity, address, Toast.LENGTH_LONG);
} else {
Toast.makeText(mapActivity, R.string.no_address_found, Toast.LENGTH_LONG).show();
}
break;
case NAME:
if (!Algorithms.isEmpty(title)) {
copyToClipboardWithToast(mapActivity, title, Toast.LENGTH_LONG);
} else {
Toast.makeText(mapActivity, R.string.toast_empty_name_error, Toast.LENGTH_LONG).show();
}
break;
case COORDINATES:
OsmandSettings st = ((OsmandApplication) mapActivity.getApplicationContext()).getSettings();
int f = st.COORDINATES_FORMAT.get();
String coordinates = OsmAndFormatter.getFormattedCoordinates(latLon.getLatitude(), latLon.getLongitude(), f);
copyToClipboardWithToast(mapActivity, coordinates, Toast.LENGTH_LONG);
break;
case GEO:
Intent mapIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(geoUrl));
AndroidUtils.startActivityIfSafe(mapActivity, mapIntent);
break;
case QR_CODE:
Bundle bundle = new Bundle();
bundle.putFloat("LAT", (float) latLon.getLatitude());
bundle.putFloat("LONG", (float) latLon.getLongitude());
sendQRCode(mapActivity, "LOCATION_TYPE", bundle, null);
break;
}
}
use of net.osmand.plus.settings.backend.OsmandSettings in project Osmand by osmandapp.
the class DestinationReachedMenuFragment method finishNavigation.
private void finishNavigation() {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
mapActivity.getMyApplication().getTargetPointsHelper().removeWayPoint(true, -1);
Object contextMenuObj = mapActivity.getContextMenu().getObject();
if (mapActivity.getContextMenu().isActive() && contextMenuObj instanceof TargetPoint) {
TargetPoint targetPoint = (TargetPoint) contextMenuObj;
if (!targetPoint.start && !targetPoint.intermediate) {
mapActivity.getContextMenu().close();
}
}
OsmandSettings settings = mapActivity.getMyApplication().getSettings();
settings.setApplicationMode(settings.DEFAULT_APPLICATION_MODE.get());
mapActivity.getMapActions().stopNavigationWithoutConfirm();
dismissMenu();
}
}
Aggregations