Search in sources :

Example 41 with OsmandSettings

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

the class OsmEditsFragment method createOsmEditOptionsFragmentListener.

private OsmEditOptionsFragmentListener createOsmEditOptionsFragmentListener() {
    return new OsmEditOptionsFragmentListener() {

        @Override
        public void onUploadClick(OsmPoint osmPoint) {
            uploadItems(new OsmPoint[] { getPointAfterModify(osmPoint) });
        }

        @Override
        public void onShowOnMapClick(OsmPoint osmPoint) {
            OsmandSettings settings = getMyApplication().getSettings();
            settings.setMapLocationToShow(osmPoint.getLatitude(), osmPoint.getLongitude(), settings.getLastKnownMapZoom());
            MapActivity.launchMapActivityMoveToTop(getActivity());
        }

        @Override
        public void onModifyOsmChangeClick(OsmPoint osmPoint) {
            OpenstreetmapPoint i = (OpenstreetmapPoint) getPointAfterModify(osmPoint);
            final Node entity = i.getEntity();
            refreshId = entity.getId();
            EditPoiDialogFragment.createInstance(entity, false).show(getActivity().getSupportFragmentManager(), "edit_poi");
        }

        @Override
        public void onModifyOsmNoteClick(OsmPoint osmPoint) {
            showBugDialog((OsmNotesPoint) osmPoint);
        }

        @Override
        public void onDeleteClick(OsmPoint osmPoint) {
            ArrayList<OsmPoint> points = new ArrayList<>();
            points.add(osmPoint);
            deleteItems(new ArrayList<>(points));
        }
    };
}
Also used : OsmEditOptionsFragmentListener(net.osmand.plus.osmedit.OsmEditOptionsBottomSheetDialogFragment.OsmEditOptionsFragmentListener) Node(net.osmand.osm.edit.Node) ArrayList(java.util.ArrayList) OsmandSettings(net.osmand.plus.OsmandSettings)

Example 42 with OsmandSettings

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

the class OsmNotesMenu method createLayersItems.

private static void createLayersItems(final ContextMenuAdapter adapter, final MapActivity mapActivity) {
    final OsmandSettings settings = mapActivity.getMyApplication().getSettings();
    final OsmEditingPlugin plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
    if (plugin == null) {
        return;
    }
    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 OsmandPreference<Boolean> showOsmBugsPref = settings.SHOW_OSM_BUGS;
    final CommonPreference<Boolean> showClosedOsmBugsPref = settings.SHOW_CLOSED_OSM_BUGS;
    final CommonPreference<Integer> showOsmBugsZoomPref = settings.SHOW_OSM_BUGS_MIN_ZOOM;
    final String[] zoomStrings = getZoomStrings(mapActivity);
    ContextMenuAdapter.OnRowItemClick l = new ContextMenuAdapter.OnRowItemClick() {

        @Override
        public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> adapter, int itemId, final int position, boolean isChecked, int[] viewCoordinates) {
            if (itemId == osmNotesStringId) {
                showOsmBugsPref.set(isChecked);
                plugin.updateLayers(mapActivity.getMapView(), mapActivity);
                mapActivity.refreshMap();
                mapActivity.getDashboard().refreshContent(true);
            } else if (itemId == showZoomLevelStringId) {
                int checked = Arrays.asList(zoomIntValues).indexOf(showOsmBugsZoomPref.get());
                new AlertDialog.Builder(mapActivity).setTitle(R.string.show_from_zoom_level).setSingleChoiceItems(zoomStrings, checked, new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        showOsmBugsZoomPref.set(zoomIntValues[which]);
                        ContextMenuItem item = adapter.getItem(position);
                        if (item != null) {
                            item.setDescription(zoomStrings[which]);
                            adapter.notifyDataSetChanged();
                        }
                        mapActivity.refreshMap();
                        dialog.dismiss();
                    }
                }).setNegativeButton(R.string.shared_string_dismiss, null).show();
            } else if (itemId == showClosedNotesStringId) {
                showClosedOsmBugsPref.set(isChecked);
                mapActivity.refreshMap();
            }
            return false;
        }
    };
    boolean showOsmBugs = showOsmBugsPref.get();
    boolean nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightModeForMapControls();
    int toggleIconColorId;
    if (showOsmBugs) {
        toggleIconColorId = nightMode ? R.color.color_dialog_buttons_dark : R.color.color_dialog_buttons_light;
    } else {
        toggleIconColorId = nightMode ? 0 : R.color.icon_color;
    }
    adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(osmNotesStringId, mapActivity).setDescription(mapActivity.getString(R.string.switch_osm_notes_visibility_desc)).setIcon(R.drawable.ic_action_bug_dark).setColor(toggleIconColorId).setListener(l).setSelected(showOsmBugs).createItem());
    adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(showZoomLevelStringId, mapActivity).setDescription(zoomStrings[Arrays.asList(zoomIntValues).indexOf(showOsmBugsZoomPref.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(showClosedOsmBugsPref.get()).setClickable(showOsmBugs).hideDivider(true).createItem());
    adapter.addItem(new ContextMenuItem.ItemBuilder().setLayout(R.layout.card_bottom_divider).setClickable(false).createItem());
}
Also used : AlertDialog(android.app.AlertDialog) ContextMenuItem(net.osmand.plus.ContextMenuItem) DialogInterface(android.content.DialogInterface) OsmandSettings(net.osmand.plus.OsmandSettings) ContextMenuAdapter(net.osmand.plus.ContextMenuAdapter) ArrayAdapter(android.widget.ArrayAdapter)

Example 43 with OsmandSettings

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

the class FavoritesActivity method setTabs.

private void setTabs(List<TabItem> mTabs) {
    PagerSlidingTabStrip mSlidingTabLayout = (PagerSlidingTabStrip) findViewById(R.id.sliding_tabs);
    OsmandSettings settings = ((OsmandApplication) getApplication()).getSettings();
    ViewPager mViewPager = (ViewPager) findViewById(R.id.pager);
    Integer tabId = settings.FAVORITES_TAB.get();
    int tab = 0;
    for (int i = 0; i < mTabs.size(); i++) {
        if (mTabs.get(i).resId == tabId) {
            tab = i;
        }
    }
    tabSize = mTabs.size();
    setViewPagerAdapter(mViewPager, mTabs);
    mSlidingTabLayout.setViewPager(mViewPager);
    mViewPager.setCurrentItem(tab);
}
Also used : PagerSlidingTabStrip(net.osmand.plus.views.controls.PagerSlidingTabStrip) OsmandApplication(net.osmand.plus.OsmandApplication) ViewPager(android.support.v4.view.ViewPager) OsmandSettings(net.osmand.plus.OsmandSettings)

Example 44 with OsmandSettings

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

the class TrackPointFragment method onChildClick.

@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
    if (selectionMode) {
        CheckBox ch = (CheckBox) v.findViewById(R.id.toggle_item);
        GpxDisplayItem item = adapter.getChild(groupPosition, childPosition);
        ch.setChecked(!ch.isChecked());
        if (ch.isChecked()) {
            Set<GpxDisplayItem> set = selectedItems.get(item.group.getType());
            if (set != null) {
                set.add(item);
            } else {
                set = new LinkedHashSet<>();
                set.add(item);
                selectedItems.put(item.group.getType(), set);
            }
        } else {
            Set<GpxDisplayItem> set = selectedItems.get(item.group.getType());
            if (set != null) {
                set.remove(item);
            }
        }
        updateSelectionMode(actionMode);
    } else {
        final GpxDisplayItem item = adapter.getChild(groupPosition, childPosition);
        if (item != null) {
            if (item.group.getGpx() != null) {
                app.getSelectedGpxHelper().setGpxFileToDisplay(item.group.getGpx());
            }
            final OsmandSettings settings = app.getSettings();
            LatLon location = new LatLon(item.locationStart.lat, item.locationStart.lon);
            settings.setMapLocationToShow(location.getLatitude(), location.getLongitude(), settings.getLastKnownMapZoom(), new PointDescription(PointDescription.POINT_TYPE_WPT, item.name), false, item.locationStart);
            MapActivity.launchMapActivityMoveToTop(getActivity());
        }
    }
    return true;
}
Also used : LatLon(net.osmand.data.LatLon) CheckBox(android.widget.CheckBox) PointDescription(net.osmand.data.PointDescription) GpxDisplayItem(net.osmand.plus.GpxSelectionHelper.GpxDisplayItem) OsmandSettings(net.osmand.plus.OsmandSettings)

Example 45 with OsmandSettings

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

the class DashTrackFragment method showOnMap.

private void showOnMap(GPXUtilities.GPXFile file) {
    if (file.isEmpty()) {
        Toast.makeText(getActivity(), R.string.gpx_file_is_empty, Toast.LENGTH_LONG).show();
        return;
    }
    OsmandSettings settings = getMyApplication().getSettings();
    if (file.getLastPoint() != null) {
        settings.setMapLocationToShow(file.getLastPoint().lat, file.getLastPoint().lon, settings.getLastKnownMapZoom());
    } else if (file.findPointToShow() != null) {
        settings.setMapLocationToShow(file.findPointToShow().lat, file.findPointToShow().lon, settings.getLastKnownMapZoom());
    }
    getMyApplication().getSelectedGpxHelper().setGpxFileToDisplay(file);
    MapActivity.launchMapActivityMoveToTop(getActivity());
}
Also used : OsmandSettings(net.osmand.plus.OsmandSettings)

Aggregations

OsmandSettings (net.osmand.plus.OsmandSettings)91 View (android.view.View)27 OsmandApplication (net.osmand.plus.OsmandApplication)25 ArrayList (java.util.ArrayList)20 LatLon (net.osmand.data.LatLon)17 DialogInterface (android.content.DialogInterface)14 ArrayAdapter (android.widget.ArrayAdapter)14 TextView (android.widget.TextView)14 AlertDialog (android.support.v7.app.AlertDialog)11 ImageView (android.widget.ImageView)11 PointDescription (net.osmand.data.PointDescription)10 AdapterView (android.widget.AdapterView)9 ContextMenuAdapter (net.osmand.plus.ContextMenuAdapter)8 ContextMenuItem (net.osmand.plus.ContextMenuItem)8 ApplicationMode (net.osmand.plus.ApplicationMode)7 Paint (android.graphics.Paint)6 Pair (android.support.v4.util.Pair)6 ListView (android.widget.ListView)6 SpannableString (android.text.SpannableString)5 CompoundButton (android.widget.CompoundButton)5