Search in sources :

Example 56 with OsmandSettings

use of net.osmand.plus.settings.backend.OsmandSettings in project Osmand by osmandapp.

the class DirectionIndicationDialogFragment method updateSelection.

private void updateSelection(boolean notifyListener) {
    OsmandSettings settings = getSettings();
    MapMarkersMode mode = settings.MAP_MARKERS_MODE.get();
    boolean distIndEnabled = settings.MARKERS_DISTANCE_INDICATION_ENABLED.get();
    int count = settings.DISPLAYED_MARKERS_WIDGETS_COUNT.get();
    int topBarIconId = count == 1 ? R.drawable.ic_action_device_topbar : R.drawable.ic_action_device_topbar_two;
    int widgetIconId = count == 1 ? R.drawable.ic_action_device_widget : R.drawable.ic_action_device_widget_two;
    updateIcon(R.id.top_bar_icon, topBarIconId, mode.isToolbar() && distIndEnabled);
    updateIcon(R.id.widget_icon, widgetIconId, mode.isWidgets() && distIndEnabled);
    updateMarkerModeRow(R.id.top_bar_row, R.id.top_bar_radio_button, mode.isToolbar(), distIndEnabled);
    updateMarkerModeRow(R.id.widget_row, R.id.widget_radio_button, mode.isWidgets(), distIndEnabled);
    if (notifyListener) {
        notifyListener();
    }
    updateHelpImage();
}
Also used : OsmandSettings(net.osmand.plus.settings.backend.OsmandSettings) Paint(android.graphics.Paint)

Example 57 with OsmandSettings

use of net.osmand.plus.settings.backend.OsmandSettings in project Osmand by osmandapp.

the class OsmNotesMenu method createLayersItems.

private static void createLayersItems(@NonNull final ContextMenuAdapter adapter, @NonNull final MapActivity mapActivity) {
    final OsmandApplication app = mapActivity.getMyApplication();
    final OsmandSettings settings = app.getSettings();
    final OsmEditingPlugin plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
    if (plugin == null) {
        return;
    }
    final boolean nightMode = isNightMode(app);
    final int themeRes = getThemeRes(app);
    final int selectedModeColor = settings.getApplicationMode().getProfileColor(nightMode);
    final int osmNotesStringId = R.string.layer_osm_bugs;
    final int showZoomLevelStringId = R.string.show_from_zoom_level;
    final int showClosedNotesStringId = R.string.show_closed_notes;
    final String[] zoomStrings = getZoomStrings(mapActivity);
    OnRowItemClick l = new OnRowItemClick() {

        @Override
        public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> adapter, int itemId, final int position, boolean isChecked, int[] viewCoordinates) {
            if (itemId == osmNotesStringId) {
                plugin.SHOW_OSM_BUGS.set(isChecked);
                plugin.updateLayers(mapActivity, mapActivity);
                mapActivity.refreshMap();
                mapActivity.getDashboard().refreshContent(true);
            } else if (itemId == showZoomLevelStringId) {
                int checked = Arrays.asList(zoomIntValues).indexOf(plugin.SHOW_OSM_BUGS_MIN_ZOOM.get());
                DialogListItemAdapter dialogAdapter = DialogListItemAdapter.createSingleChoiceAdapter(zoomStrings, nightMode, checked, app, selectedModeColor, themeRes, v -> {
                    int which = (int) v.getTag();
                    plugin.SHOW_OSM_BUGS_MIN_ZOOM.set(zoomIntValues[which]);
                    ContextMenuItem item = adapter.getItem(position);
                    if (item != null) {
                        item.setDescription(zoomStrings[which]);
                        adapter.notifyDataSetChanged();
                    }
                    mapActivity.refreshMap();
                });
                AlertDialog.Builder b = new AlertDialog.Builder(new ContextThemeWrapper(mapActivity, themeRes)).setTitle(R.string.show_from_zoom_level).setAdapter(dialogAdapter, null).setNegativeButton(R.string.shared_string_dismiss, null);
                dialogAdapter.setDialog(b.show());
            } else if (itemId == showClosedNotesStringId) {
                plugin.SHOW_CLOSED_OSM_BUGS.set(isChecked);
                mapActivity.refreshMap();
            }
            return false;
        }
    };
    boolean showOsmBugs = plugin.SHOW_OSM_BUGS.get();
    int toggleIconColorId;
    if (showOsmBugs) {
        toggleIconColorId = ColorUtilities.getActiveColorId(nightMode);
    } else {
        toggleIconColorId = ContextMenuItem.INVALID_ID;
    }
    adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(osmNotesStringId, mapActivity).setDescription(mapActivity.getString(R.string.switch_osm_notes_visibility_desc)).setIcon(R.drawable.ic_action_osm_note).setColor(app, toggleIconColorId).setListener(l).setSelected(showOsmBugs).createItem());
    adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(showZoomLevelStringId, mapActivity).setDescription(zoomStrings[Arrays.asList(zoomIntValues).indexOf(plugin.SHOW_OSM_BUGS_MIN_ZOOM.get())]).setLayout(R.layout.list_item_single_line_descrition_narrow).setIcon(R.drawable.ic_action_map_magnifier).setListener(l).setClickable(showOsmBugs).createItem());
    adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(showClosedNotesStringId, mapActivity).setIcon(R.drawable.ic_action_note_dark).setListener(l).setSelected(plugin.SHOW_CLOSED_OSM_BUGS.get()).setClickable(showOsmBugs).hideDivider(true).createItem());
    adapter.addItem(new ContextMenuItem.ItemBuilder().setLayout(R.layout.card_bottom_divider).setClickable(false).createItem());
}
Also used : Context(android.content.Context) Arrays(java.util.Arrays) AlertDialog(androidx.appcompat.app.AlertDialog) OsmandSettings(net.osmand.plus.settings.backend.OsmandSettings) ColorUtilities(net.osmand.plus.utils.ColorUtilities) NonNull(androidx.annotation.NonNull) R(net.osmand.plus.R) OnRowItemClick(net.osmand.plus.ContextMenuAdapter.OnRowItemClick) OsmandApplication(net.osmand.plus.OsmandApplication) ArrayAdapter(android.widget.ArrayAdapter) OsmandPlugin(net.osmand.plus.plugins.OsmandPlugin) ContextThemeWrapper(android.view.ContextThemeWrapper) ContextMenuAdapter(net.osmand.plus.ContextMenuAdapter) ContextMenuItem(net.osmand.plus.ContextMenuItem) OsmEditingPlugin(net.osmand.plus.plugins.osmedit.OsmEditingPlugin) DialogListItemAdapter(net.osmand.plus.DialogListItemAdapter) MapActivity(net.osmand.plus.activities.MapActivity) OsmandApplication(net.osmand.plus.OsmandApplication) ContextMenuItem(net.osmand.plus.ContextMenuItem) OnRowItemClick(net.osmand.plus.ContextMenuAdapter.OnRowItemClick) OsmandSettings(net.osmand.plus.settings.backend.OsmandSettings) OsmEditingPlugin(net.osmand.plus.plugins.osmedit.OsmEditingPlugin) ContextThemeWrapper(android.view.ContextThemeWrapper) DialogListItemAdapter(net.osmand.plus.DialogListItemAdapter) ArrayAdapter(android.widget.ArrayAdapter)

Example 58 with OsmandSettings

use of net.osmand.plus.settings.backend.OsmandSettings in project Osmand by osmandapp.

the class SRTMPlugin method init.

@Override
public boolean init(@NonNull final OsmandApplication app, Activity activity) {
    OsmandSettings settings = app.getSettings();
    CommonPreference<String> pref = settings.getCustomRenderProperty("contourLines");
    if (pref.get().isEmpty()) {
        for (ApplicationMode m : ApplicationMode.allPossibleValues()) {
            if (pref.getModeValue(m).isEmpty()) {
                pref.setModeValue(m, "13");
            }
        }
    }
    return true;
}
Also used : ApplicationMode(net.osmand.plus.settings.backend.ApplicationMode) OsmandSettings(net.osmand.plus.settings.backend.OsmandSettings)

Example 59 with OsmandSettings

use of net.osmand.plus.settings.backend.OsmandSettings in project Osmand by osmandapp.

the class MapUnderlayAction method executeWithParams.

@Override
public void executeWithParams(@NonNull MapActivity mapActivity, String params) {
    OsmandRasterMapsPlugin plugin = OsmandPlugin.getActivePlugin(OsmandRasterMapsPlugin.class);
    if (plugin != null) {
        OsmandSettings settings = mapActivity.getMyApplication().getSettings();
        boolean hasUnderlay = !params.equals(KEY_NO_UNDERLAY);
        if (hasUnderlay) {
            settings.MAP_UNDERLAY.set(params);
            settings.MAP_UNDERLAY_PREVIOUS.set(params);
            if (settings.LAYER_TRANSPARENCY_SEEKBAR_MODE.get() == LayerTransparencySeekbarMode.UNDEFINED) {
                settings.LAYER_TRANSPARENCY_SEEKBAR_MODE.set(LayerTransparencySeekbarMode.UNDERLAY);
            }
            if (settings.LAYER_TRANSPARENCY_SEEKBAR_MODE.get() == LayerTransparencySeekbarMode.UNDERLAY) {
                mapActivity.getMapLayers().getMapControlsLayer().showTransparencyBar(settings.MAP_TRANSPARENCY);
            }
        } else {
            settings.MAP_UNDERLAY.set(null);
            mapActivity.getMapLayers().getMapControlsLayer().hideTransparencyBar();
            settings.MAP_UNDERLAY_PREVIOUS.set(null);
        }
        plugin.updateMapLayers(mapActivity, mapActivity, settings.MAP_UNDERLAY);
        mapActivity.refreshMapComplete();
        Toast.makeText(mapActivity, mapActivity.getString(R.string.quick_action_map_underlay_switch, getTranslatedItemName(mapActivity, params)), Toast.LENGTH_SHORT).show();
    }
}
Also used : OsmandSettings(net.osmand.plus.settings.backend.OsmandSettings)

Example 60 with OsmandSettings

use of net.osmand.plus.settings.backend.OsmandSettings in project Osmand by osmandapp.

the class MapOverlayAction method executeWithParams.

@Override
public void executeWithParams(@NonNull MapActivity mapActivity, String params) {
    OsmandRasterMapsPlugin plugin = OsmandPlugin.getActivePlugin(OsmandRasterMapsPlugin.class);
    if (plugin != null) {
        OsmandSettings settings = mapActivity.getMyApplication().getSettings();
        boolean hasOverlay = !params.equals(KEY_NO_OVERLAY);
        if (hasOverlay) {
            settings.MAP_OVERLAY.set(params);
            settings.MAP_OVERLAY_PREVIOUS.set(params);
            if (settings.LAYER_TRANSPARENCY_SEEKBAR_MODE.get() == LayerTransparencySeekbarMode.UNDEFINED) {
                settings.LAYER_TRANSPARENCY_SEEKBAR_MODE.set(LayerTransparencySeekbarMode.OVERLAY);
            }
            if (settings.LAYER_TRANSPARENCY_SEEKBAR_MODE.get() == LayerTransparencySeekbarMode.OVERLAY) {
                mapActivity.getMapLayers().getMapControlsLayer().showTransparencyBar(settings.MAP_OVERLAY_TRANSPARENCY);
            }
        } else {
            settings.MAP_OVERLAY.set(null);
            mapActivity.getMapLayers().getMapControlsLayer().hideTransparencyBar();
            settings.MAP_OVERLAY_PREVIOUS.set(null);
        }
        plugin.updateMapLayers(mapActivity, mapActivity, settings.MAP_OVERLAY);
        Toast.makeText(mapActivity, mapActivity.getString(R.string.quick_action_map_overlay_switch, getTranslatedItemName(mapActivity, params)), Toast.LENGTH_SHORT).show();
    }
}
Also used : OsmandSettings(net.osmand.plus.settings.backend.OsmandSettings)

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