Search in sources :

Example 46 with OsmandSettings

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

the class AvailableGPXFragment method showGpxOnMap.

private void showGpxOnMap(GpxInfo info) {
    info.setGpx(GPXUtilities.loadGPXFile(app, info.file));
    boolean e = true;
    if (info.gpx != null) {
        WptPt loc = info.gpx.findPointToShow();
        OsmandSettings settings = getMyApplication().getSettings();
        if (loc != null) {
            settings.setMapLocationToShow(loc.lat, loc.lon, settings.getLastKnownMapZoom());
            e = false;
            getMyApplication().getSelectedGpxHelper().setGpxFileToDisplay(info.gpx);
            MapActivity.launchMapActivityMoveToTop(getActivity());
        }
    }
    if (e) {
        Toast.makeText(getActivity(), R.string.gpx_file_is_empty, Toast.LENGTH_LONG).show();
    }
}
Also used : WptPt(net.osmand.plus.GPXUtilities.WptPt) OsmandSettings(net.osmand.plus.OsmandSettings)

Example 47 with OsmandSettings

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

the class SendPoiDialogFragment method onCreateDialog.

@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    poi = (OsmPoint[]) getArguments().getSerializable(OPENSTREETMAP_POINT);
    final PoiUploaderType poiUploaderType = PoiUploaderType.valueOf(getArguments().getString(POI_UPLOADER_TYPE, PoiUploaderType.SIMPLE.name()));
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    View view = getActivity().getLayoutInflater().inflate(R.layout.send_poi_dialog, null);
    final SwitchCompat uploadAnonymously = (SwitchCompat) view.findViewById(R.id.upload_anonymously_switch);
    final EditText messageEditText = (EditText) view.findViewById(R.id.message_field);
    final EditText userNameEditText = (EditText) view.findViewById(R.id.user_name_field);
    final EditText passwordEditText = (EditText) view.findViewById(R.id.password_field);
    final View messageLabel = view.findViewById(R.id.message_label);
    final View userNameLabel = view.findViewById(R.id.osm_user_name_label);
    final View passwordLabel = view.findViewById(R.id.osm_user_password_label);
    final CheckBox closeChangeSetCheckBox = (CheckBox) view.findViewById(R.id.close_change_set_checkbox);
    final OsmandSettings settings = ((OsmandApplication) getActivity().getApplication()).getSettings();
    userNameEditText.setText(settings.USER_NAME.get());
    passwordEditText.setText(settings.USER_PASSWORD.get());
    boolean hasPoiGroup = false;
    assert poi != null;
    for (OsmPoint p : poi) {
        if (p.getGroup() == OsmPoint.Group.POI) {
            hasPoiGroup = true;
            break;
        }
    }
    String defaultChangeSet = createDefaultChangeSet();
    messageEditText.setText(defaultChangeSet);
    final boolean hasPOI = hasPoiGroup;
    messageLabel.setVisibility(hasPOI ? View.VISIBLE : View.GONE);
    messageEditText.setVisibility(hasPOI ? View.VISIBLE : View.GONE);
    closeChangeSetCheckBox.setVisibility(hasPOI ? View.VISIBLE : View.GONE);
    closeChangeSetCheckBox.setChecked(hasPOI && !defaultChangeSet.equals(""));
    view.findViewById(R.id.osm_note_header).setVisibility(hasPOI ? View.GONE : View.VISIBLE);
    uploadAnonymously.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            userNameLabel.setVisibility(isChecked ? View.GONE : View.VISIBLE);
            userNameEditText.setVisibility(isChecked ? View.GONE : View.VISIBLE);
            passwordLabel.setVisibility(isChecked ? View.GONE : View.VISIBLE);
            passwordEditText.setVisibility(isChecked ? View.GONE : View.VISIBLE);
        }
    });
    final ProgressDialogPoiUploader progressDialogPoiUploader;
    if (poiUploaderType == PoiUploaderType.SIMPLE && getActivity() instanceof MapActivity) {
        progressDialogPoiUploader = new SendPoiDialogFragment.SimpleProgressDialogPoiUploader((MapActivity) getActivity());
    } else {
        progressDialogPoiUploader = (ProgressDialogPoiUploader) getParentFragment();
    }
    builder.setTitle(hasPOI ? R.string.upload_poi : R.string.upload_osm_note).setView(view).setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (progressDialogPoiUploader != null) {
                settings.USER_NAME.set(userNameEditText.getText().toString());
                settings.USER_PASSWORD.set(passwordEditText.getText().toString());
                String comment = messageEditText.getText().toString();
                if (comment.length() > 0) {
                    for (OsmPoint osmPoint : poi) {
                        if (osmPoint.getGroup() == OsmPoint.Group.POI) {
                            ((OpenstreetmapPoint) osmPoint).setComment(comment);
                            break;
                        }
                    }
                }
                progressDialogPoiUploader.showProgressDialog(poi, closeChangeSetCheckBox.isChecked(), !hasPOI && uploadAnonymously.isChecked());
            }
        }
    }).setNegativeButton(R.string.shared_string_cancel, null);
    return builder.create();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) EditText(android.widget.EditText) OsmPoint(net.osmand.plus.osmedit.OsmPoint) OsmandApplication(net.osmand.plus.OsmandApplication) DialogInterface(android.content.DialogInterface) View(android.view.View) OsmandSettings(net.osmand.plus.OsmandSettings) OpenstreetmapPoint(net.osmand.plus.osmedit.OpenstreetmapPoint) CheckBox(android.widget.CheckBox) CompoundButton(android.widget.CompoundButton) SwitchCompat(android.support.v7.widget.SwitchCompat) MapActivity(net.osmand.plus.activities.MapActivity) NonNull(android.support.annotation.NonNull)

Example 48 with OsmandSettings

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

the class PlanRouteFragment method roundTripOnClick.

private void roundTripOnClick() {
    MapActivity mapActivity = getMapActivity();
    if (mapActivity != null) {
        OsmandSettings settings = mapActivity.getMyApplication().getSettings();
        settings.ROUTE_MAP_MARKERS_ROUND_TRIP.set(!settings.ROUTE_MAP_MARKERS_ROUND_TRIP.get());
        adapter.reloadData();
        adapter.notifyDataSetChanged();
        planRouteContext.recreateSnapTrkSegment(false);
    }
}
Also used : OsmandSettings(net.osmand.plus.OsmandSettings) MapActivity(net.osmand.plus.activities.MapActivity)

Example 49 with OsmandSettings

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

the class MapillaryAutoCompleteAdapter method getFilter.

@NonNull
@Override
public Filter getFilter() {
    return new Filter() {

        @Override
        protected FilterResults performFiltering(CharSequence constraint) {
            FilterResults filterResults = new FilterResults();
            if (constraint != null) {
                try {
                    OsmandSettings settings = app.getSettings();
                    names.clear();
                    if (!settings.isInternetConnectionAvailable()) {
                        names.add(NO_INTERNET_CONNECTION);
                        wrong = true;
                    } else {
                        Pair<String, String> user = new GetMapillaryUserAsyncTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, constraint.toString()).get();
                        if (user != null) {
                            settings.MAPILLARY_FILTER_USER_KEY.set(user.first);
                            settings.MAPILLARY_FILTER_USERNAME.set(user.second);
                            names.add(user.second);
                            wrong = false;
                        } else {
                            settings.MAPILLARY_FILTER_USER_KEY.set("");
                            settings.MAPILLARY_FILTER_USERNAME.set("");
                            names.add(WRONG_USER_NAME);
                            wrong = true;
                        }
                    }
                } catch (InterruptedException e) {
                    Log.e(TAG, e.toString());
                } catch (ExecutionException e) {
                    Log.e(TAG, e.toString());
                }
                filterResults.values = names;
                filterResults.count = names.size();
            }
            return filterResults;
        }

        @Override
        protected void publishResults(CharSequence constraint, FilterResults results) {
            if (results != null) {
                notifyDataSetChanged();
            } else {
                notifyDataSetInvalidated();
            }
        }
    };
}
Also used : Filter(android.widget.Filter) ExecutionException(java.util.concurrent.ExecutionException) OsmandSettings(net.osmand.plus.OsmandSettings) NonNull(android.support.annotation.NonNull)

Example 50 with OsmandSettings

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

the class DirectionIndicationDialogFragment method updateHelpImage.

private void updateHelpImage() {
    if (Build.VERSION.SDK_INT >= 18) {
        OsmandSettings settings = getSettings();
        int count = settings.DISPLAYED_MARKERS_WIDGETS_COUNT.get();
        LinkedList<Drawable> imgList = new LinkedList<>();
        imgList.add(getDeviceImg());
        if (settings.SHOW_LINES_TO_FIRST_MARKERS.get()) {
            imgList.add(getGuideLineOneImg());
            if (count == 2) {
                imgList.add(getGuideLineTwoImg());
            }
        }
        if (settings.SHOW_ARROWS_TO_FIRST_MARKERS.get()) {
            imgList.add(getArrowOneImg());
            if (count == 2) {
                imgList.add(getArrowTwoImg());
            }
        }
        if (settings.MARKERS_DISTANCE_INDICATION_ENABLED.get()) {
            if (settings.MAP_MARKERS_MODE.get().isWidgets()) {
                imgList.add(getWidget1Img());
                if (count == 2) {
                    imgList.add(getWidget2Img());
                }
            } else {
                imgList.add(getTopBar1Img());
                if (count == 2) {
                    imgList.add(getTopBar2Img());
                }
            }
        }
        ((ImageView) mainView.findViewById(R.id.action_bar_image)).setImageDrawable(new LayerDrawable(imgList.toArray(new Drawable[imgList.size()])));
    } else {
        mainView.findViewById(R.id.action_bar_image_container).setVisibility(View.GONE);
    }
}
Also used : LayerDrawable(android.graphics.drawable.LayerDrawable) LayerDrawable(android.graphics.drawable.LayerDrawable) Drawable(android.graphics.drawable.Drawable) ImageView(android.widget.ImageView) OsmandSettings(net.osmand.plus.OsmandSettings) Paint(android.graphics.Paint) LinkedList(java.util.LinkedList)

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