Search in sources :

Example 16 with OsmandSettings

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

the class SRTMPlugin method init.

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

Example 17 with OsmandSettings

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

the class FavoritesSearchFragment method showOnMap.

public void showOnMap(final FavouritePoint point) {
    getMyApplication().getSettings().FAVORITES_TAB.set(FavoritesActivity.FAV_TAB);
    final OsmandSettings settings = getMyApplication().getSettings();
    LatLon location = new LatLon(point.getLatitude(), point.getLongitude());
    settings.setMapLocationToShow(location.getLatitude(), location.getLongitude(), settings.getLastKnownMapZoom(), new PointDescription(PointDescription.POINT_TYPE_FAVORITE, point.getName()), true, // $NON-NLS-1$
    point);
    MapActivity.launchMapActivityMoveToTop(getActivity());
}
Also used : LatLon(net.osmand.data.LatLon) PointDescription(net.osmand.data.PointDescription) OsmandSettings(net.osmand.plus.OsmandSettings)

Example 18 with OsmandSettings

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

the class SearchPOIActivity method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu omenu) {
    Menu menu = getClearToolbar(true).getMenu();
    searchPOILevel = menu.add(0, SEARCH_MORE, 0, R.string.search_POI_level_btn);
    MenuItemCompat.setShowAsAction(searchPOILevel, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
    searchPOILevel.setOnMenuItemClickListener(new OnMenuItemClickListener() {

        @Override
        public boolean onMenuItemClick(MenuItem item) {
            return search();
        }
    });
    showFilterItem = menu.add(0, FILTER, 0, R.string.search_poi_filter);
    MenuItemCompat.setShowAsAction(showFilterItem, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
    showFilterItem = showFilterItem.setIcon(getMyApplication().getIconsCache().getIcon(R.drawable.ic_action_filter_dark));
    showFilterItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {

        @Override
        public boolean onMenuItemClick(MenuItem item) {
            if (searchFilterLayout.getVisibility() == View.GONE) {
                searchFilterLayout.setVisibility(View.VISIBLE);
                searchFilter.requestFocus();
                InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.showSoftInput(searchFilter, InputMethodManager.SHOW_IMPLICIT);
            } else {
                if (filter != null) {
                    searchFilter.setText(filter.getSavedFilterByName() == null ? "" : filter.getSavedFilterByName());
                }
                searchFilterLayout.setVisibility(View.GONE);
            }
            return true;
        }
    });
    showOnMapItem = menu.add(0, SHOW_ON_MAP, 0, R.string.shared_string_show_on_map);
    MenuItemCompat.setShowAsAction(showOnMapItem, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
    showOnMapItem = showOnMapItem.setIcon(getMyApplication().getIconsCache().getIcon(R.drawable.ic_show_on_map));
    showOnMapItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {

        @Override
        public boolean onMenuItemClick(MenuItem item) {
            OsmandSettings settings = app.getSettings();
            filter.setFilterByName(searchFilter.getText().toString().trim());
            app.getPoiFilters().addSelectedPoiFilter(filter);
            if (location != null) {
                settings.setMapLocationToShow(location.getLatitude(), location.getLongitude(), 15);
            }
            MapActivity.launchMapActivityMoveToTop(SearchPOIActivity.this);
            return true;
        }
    });
    showOnMapItem.setEnabled(!isNameSearch() || amenityAdapter.getCount() > 0);
    if (filter != null && !isNameSearch()) {
        createMenuItem(omenu, SAVE_FILTER, R.string.edit_filter_save_as_menu_item, R.drawable.ic_action_fav_dark, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
        if (!filter.isStandardFilter()) {
            createMenuItem(omenu, DELETE_FILTER, R.string.shared_string_delete, R.drawable.ic_action_delete_dark, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
        }
    }
    updateButtonState(false);
    return true;
}
Also used : OnMenuItemClickListener(android.view.MenuItem.OnMenuItemClickListener) MenuItem(android.view.MenuItem) InputMethodManager(android.view.inputmethod.InputMethodManager) PopupMenu(android.support.v7.widget.PopupMenu) Menu(android.view.Menu) OsmandSettings(net.osmand.plus.OsmandSettings)

Example 19 with OsmandSettings

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

the class TrackActivity method addPoint.

public void addPoint(PointDescription pointDescription) {
    Intent currentIntent = getIntent();
    if (currentIntent != null) {
        currentIntent.putExtra(TrackActivity.OPEN_POINTS_TAB, true);
    }
    final OsmandSettings settings = app.getSettings();
    GPXFile gpx = getGpx();
    LatLon location = settings.getLastKnownMapLocation();
    QuadRect rect = getRect();
    NewGpxPoint newGpxPoint = new NewGpxPoint(gpx, pointDescription, rect);
    if (gpx != null && location != null) {
        settings.setMapLocationToShow(location.getLatitude(), location.getLongitude(), settings.getLastKnownMapZoom(), pointDescription, false, newGpxPoint);
        MapActivity.launchMapActivityMoveToTop(this);
    }
}
Also used : LatLon(net.osmand.data.LatLon) NewGpxPoint(net.osmand.plus.views.AddGpxPointBottomSheetHelper.NewGpxPoint) Intent(android.content.Intent) GPXFile(net.osmand.plus.GPXUtilities.GPXFile) QuadRect(net.osmand.data.QuadRect) OsmandSettings(net.osmand.plus.OsmandSettings)

Example 20 with OsmandSettings

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

the class SavingTrackHelper method updateLocation.

public void updateLocation(net.osmand.Location location) {
    // use because there is a bug on some devices with location.getTime()
    long locationTime = System.currentTimeMillis();
    OsmandSettings settings = ctx.getSettings();
    boolean record = false;
    if (OsmAndLocationProvider.isPointAccurateForRouting(location) && OsmAndLocationProvider.isNotSimulatedLocation(location)) {
        if (OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class) != null) {
            if (settings.SAVE_TRACK_TO_GPX.get() && locationTime - lastTimeUpdated > settings.SAVE_TRACK_INTERVAL.get() && ctx.getRoutingHelper().isFollowingMode()) {
                record = true;
            } else if (settings.SAVE_GLOBAL_TRACK_TO_GPX.get() && locationTime - lastTimeUpdated > settings.SAVE_GLOBAL_TRACK_INTERVAL.get()) {
                record = true;
            }
            float minDistance = settings.SAVE_TRACK_MIN_DISTANCE.get();
            if (minDistance > 0 && lastPoint != null && MapUtils.getDistance(lastPoint, location.getLatitude(), location.getLongitude()) < minDistance) {
                record = false;
            }
            float precision = settings.SAVE_TRACK_PRECISION.get();
            if (precision > 0 && (!location.hasAccuracy() || location.getAccuracy() > precision)) {
                record = false;
            }
            float minSpeed = settings.SAVE_TRACK_MIN_SPEED.get();
            if (minSpeed > 0 && (!location.hasSpeed() || location.getSpeed() < minSpeed)) {
                record = false;
            }
        }
    }
    if (record) {
        insertData(location.getLatitude(), location.getLongitude(), location.getAltitude(), location.getSpeed(), location.getAccuracy(), locationTime, settings);
        ctx.getNotificationHelper().refreshNotification(NotificationType.GPX);
    }
}
Also used : OsmandSettings(net.osmand.plus.OsmandSettings) OsmandMonitoringPlugin(net.osmand.plus.monitoring.OsmandMonitoringPlugin)

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