Search in sources :

Example 71 with OsmandSettings

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

the class SearchPOIActivity method onItemClick.

@Override
public void onItemClick(AdapterView<?> parent, final View view, int position, long id) {
    final Amenity amenity = ((AmenityAdapter) getListAdapter()).getItem(position);
    final OsmandSettings settings = app.getSettings();
    String poiSimpleFormat = OsmAndFormatter.getPoiStringWithoutType(amenity, app.getSettings().MAP_PREFERRED_LOCALE.get(), app.getSettings().MAP_TRANSLITERATE_NAMES.get());
    PointDescription name = new PointDescription(PointDescription.POINT_TYPE_POI, poiSimpleFormat);
    int z = Math.max(16, settings.getLastKnownMapZoom());
    LatLon location = amenity.getLocation();
    settings.setMapLocationToShow(location.getLatitude(), location.getLongitude(), z, name, true, // $NON-NLS-1$
    amenity);
    MapActivity.launchMapActivityMoveToTop(this);
}
Also used : Amenity(net.osmand.data.Amenity) LatLon(net.osmand.data.LatLon) PointDescription(net.osmand.data.PointDescription) OsmandSettings(net.osmand.plus.OsmandSettings)

Example 72 with OsmandSettings

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

the class TrackActivity method addNewGpxData.

public void addNewGpxData(NewGpxData.ActionType actionType, TrkSegment segment) {
    GPXFile gpxFile = getGpx();
    QuadRect rect = getRect();
    NewGpxData newGpxData = new NewGpxData(gpxFile, rect, actionType, segment);
    WptPt pointToShow = gpxFile != null ? gpxFile.findPointToShow() : null;
    if (pointToShow != null) {
        LatLon location = new LatLon(pointToShow.getLatitude(), pointToShow.getLongitude());
        final OsmandSettings settings = app.getSettings();
        settings.setMapLocationToShow(location.getLatitude(), location.getLongitude(), settings.getLastKnownMapZoom(), new PointDescription(PointDescription.POINT_TYPE_WPT, getString(R.string.add_line)), false, newGpxData);
        MapActivity.launchMapActivityMoveToTop(this);
    }
}
Also used : WptPt(net.osmand.plus.GPXUtilities.WptPt) LatLon(net.osmand.data.LatLon) PointDescription(net.osmand.data.PointDescription) NewGpxData(net.osmand.plus.measurementtool.NewGpxData) GPXFile(net.osmand.plus.GPXUtilities.GPXFile) QuadRect(net.osmand.data.QuadRect) OsmandSettings(net.osmand.plus.OsmandSettings)

Example 73 with OsmandSettings

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

the class SearchHistoryFragment method selectModel.

private void selectModel(final HistoryEntry model) {
    PointDescription name = model.getName();
    OsmandSettings settings = ((OsmandApplication) getActivity().getApplication()).getSettings();
    LatLon location = new LatLon(model.getLat(), model.getLon());
    settings.setMapLocationToShow(location.getLatitude(), location.getLongitude(), settings.getLastKnownMapZoom(), name, true, // $NON-NLS-1$
    model);
    MapActivity.launchMapActivityMoveToTop(getActivity());
}
Also used : LatLon(net.osmand.data.LatLon) OsmandApplication(net.osmand.plus.OsmandApplication) PointDescription(net.osmand.data.PointDescription) OsmandSettings(net.osmand.plus.OsmandSettings)

Example 74 with OsmandSettings

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

the class BottomSheetDialogFragment method onCreateDialog.

@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    OsmandSettings settings = getMyApplication().getSettings();
    int themeId = settings.isLightContent() ? R.style.OsmandLightTheme_BottomSheet : R.style.OsmandDarkTheme_BottomSheet;
    BottomSheetDialog dialog = new BottomSheetDialog(getContext(), themeId);
    dialog.setCanceledOnTouchOutside(true);
    Window window = dialog.getWindow();
    if (!settings.DO_NOT_USE_ANIMATIONS.get() && window != null) {
        window.getAttributes().windowAnimations = R.style.Animations_PopUpMenu_Bottom;
    }
    return dialog;
}
Also used : Window(android.view.Window) OsmandSettings(net.osmand.plus.OsmandSettings) NonNull(android.support.annotation.NonNull)

Example 75 with OsmandSettings

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

the class MapActivityLayers method selectMapLayer.

public void selectMapLayer(final OsmandMapTileView mapView, final ContextMenuItem it, final ArrayAdapter<ContextMenuItem> adapter) {
    if (OsmandPlugin.getEnabledPlugin(OsmandRasterMapsPlugin.class) == null) {
        Toast.makeText(activity, R.string.map_online_plugin_is_not_installed, Toast.LENGTH_LONG).show();
        return;
    }
    final OsmandSettings settings = getApplication().getSettings();
    final LinkedHashMap<String, String> entriesMap = new LinkedHashMap<>();
    final String layerOsmVector = "LAYER_OSM_VECTOR";
    final String layerInstallMore = "LAYER_INSTALL_MORE";
    final String layerEditInstall = "LAYER_EDIT";
    entriesMap.put(layerOsmVector, getString(R.string.vector_data));
    entriesMap.putAll(settings.getTileSourceEntries());
    entriesMap.put(layerInstallMore, getString(R.string.install_more));
    entriesMap.put(layerEditInstall, getString(R.string.maps_define_edit));
    final List<Entry<String, String>> entriesMapList = new ArrayList<>(entriesMap.entrySet());
    AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    String selectedTileSourceKey = settings.MAP_TILE_SOURCES.get();
    int selectedItem = -1;
    if (!settings.MAP_ONLINE_DATA.get()) {
        selectedItem = 0;
    } else {
        Entry<String, String> selectedEntry = null;
        for (Entry<String, String> entry : entriesMap.entrySet()) {
            if (entry.getKey().equals(selectedTileSourceKey)) {
                selectedEntry = entry;
                break;
            }
        }
        if (selectedEntry != null) {
            selectedItem = 0;
            entriesMapList.remove(selectedEntry);
            entriesMapList.add(0, selectedEntry);
        }
    }
    final String[] items = new String[entriesMapList.size()];
    int i = 0;
    for (Entry<String, String> entry : entriesMapList) {
        items[i++] = entry.getValue();
    }
    builder.setSingleChoiceItems(items, selectedItem, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            String layerKey = entriesMapList.get(which).getKey();
            switch(layerKey) {
                case layerOsmVector:
                    settings.MAP_ONLINE_DATA.set(false);
                    updateMapSource(mapView, null);
                    it.setDescription(null);
                    adapter.notifyDataSetChanged();
                    break;
                case layerEditInstall:
                    OsmandRasterMapsPlugin.defineNewEditLayer(activity, new ResultMatcher<TileSourceTemplate>() {

                        @Override
                        public boolean publish(TileSourceTemplate object) {
                            settings.MAP_TILE_SOURCES.set(object.getName());
                            settings.MAP_ONLINE_DATA.set(true);
                            if (it != null) {
                                it.setDescription(object.getName());
                            }
                            updateMapSource(mapView, settings.MAP_TILE_SOURCES);
                            return true;
                        }

                        @Override
                        public boolean isCancelled() {
                            return false;
                        }
                    });
                    break;
                case layerInstallMore:
                    OsmandRasterMapsPlugin.installMapLayers(activity, new ResultMatcher<TileSourceTemplate>() {

                        TileSourceTemplate template = null;

                        int count = 0;

                        @Override
                        public boolean publish(TileSourceTemplate object) {
                            if (object == null) {
                                if (count == 1) {
                                    settings.MAP_TILE_SOURCES.set(template.getName());
                                    settings.MAP_ONLINE_DATA.set(true);
                                    it.setDescription(template.getName());
                                    adapter.notifyDataSetChanged();
                                    updateMapSource(mapView, settings.MAP_TILE_SOURCES);
                                } else {
                                    selectMapLayer(mapView, it, adapter);
                                }
                            } else {
                                count++;
                                template = object;
                            }
                            return false;
                        }

                        @Override
                        public boolean isCancelled() {
                            return false;
                        }
                    });
                    break;
                default:
                    settings.MAP_TILE_SOURCES.set(layerKey);
                    settings.MAP_ONLINE_DATA.set(true);
                    it.setDescription(layerKey);
                    adapter.notifyDataSetChanged();
                    updateMapSource(mapView, settings.MAP_TILE_SOURCES);
                    break;
            }
            dialog.dismiss();
        }
    });
    builder.setNegativeButton(R.string.shared_string_dismiss, null);
    builder.show();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) TileSourceTemplate(net.osmand.map.TileSourceManager.TileSourceTemplate) DialogInterface(android.content.DialogInterface) ArrayList(java.util.ArrayList) ResultMatcher(net.osmand.ResultMatcher) OsmandSettings(net.osmand.plus.OsmandSettings) LinkedHashMap(java.util.LinkedHashMap) Entry(java.util.Map.Entry) OsmandRasterMapsPlugin(net.osmand.plus.rastermaps.OsmandRasterMapsPlugin)

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