Search in sources :

Example 81 with OsmandSettings

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();
}
Also used : OsmandApplication(net.osmand.plus.OsmandApplication) OsmandSettings(net.osmand.plus.settings.backend.OsmandSettings)

Example 82 with OsmandSettings

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);
    }
}
Also used : OsmandSettings(net.osmand.plus.settings.backend.OsmandSettings) TextPaint(android.text.TextPaint)

Example 83 with OsmandSettings

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;
}
Also used : ContextMenuItem(net.osmand.plus.ContextMenuItem) PoiFiltersHelper(net.osmand.plus.poi.PoiFiltersHelper) GpxSelectionHelper(net.osmand.plus.track.helpers.GpxSelectionHelper) OsmandRasterMapsPlugin(net.osmand.plus.plugins.rastermaps.OsmandRasterMapsPlugin) OsmandSettings(net.osmand.plus.settings.backend.OsmandSettings) PoiUIFilter(net.osmand.plus.poi.PoiUIFilter)

Example 84 with OsmandSettings

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;
    }
}
Also used : OsmandApplication(net.osmand.plus.OsmandApplication) Bundle(android.os.Bundle) Intent(android.content.Intent) OsmandSettings(net.osmand.plus.settings.backend.OsmandSettings) MapActivity(net.osmand.plus.activities.MapActivity)

Example 85 with OsmandSettings

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();
    }
}
Also used : TargetPoint(net.osmand.plus.helpers.TargetPointsHelper.TargetPoint) OsmandSettings(net.osmand.plus.settings.backend.OsmandSettings) MapActivity(net.osmand.plus.activities.MapActivity)

Aggregations

OsmandSettings (net.osmand.plus.settings.backend.OsmandSettings)154 OsmandApplication (net.osmand.plus.OsmandApplication)52 View (android.view.View)25 ArrayList (java.util.ArrayList)23 LatLon (net.osmand.data.LatLon)17 MapActivity (net.osmand.plus.activities.MapActivity)17 TextView (android.widget.TextView)16 NonNull (androidx.annotation.NonNull)16 AlertDialog (androidx.appcompat.app.AlertDialog)15 ApplicationMode (net.osmand.plus.settings.backend.ApplicationMode)15 ArrayAdapter (android.widget.ArrayAdapter)13 ContextMenuItem (net.osmand.plus.ContextMenuItem)13 TargetPoint (net.osmand.plus.helpers.TargetPointsHelper.TargetPoint)12 OsmandMapTileView (net.osmand.plus.views.OsmandMapTileView)12 Context (android.content.Context)11 ImageView (android.widget.ImageView)11 Intent (android.content.Intent)8 List (java.util.List)8 PointDescription (net.osmand.data.PointDescription)8 DialogInterface (android.content.DialogInterface)7