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