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();
}
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());
}
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;
}
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();
}
}
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();
}
}
Aggregations