diff --git a/OsmAnd/res/layout/send_poi_dialog.xml b/OsmAnd/res/layout/send_poi_dialog.xml index f1389f7140..620009d0d6 100644 --- a/OsmAnd/res/layout/send_poi_dialog.xml +++ b/OsmAnd/res/layout/send_poi_dialog.xml @@ -1,57 +1,94 @@ + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:orientation="vertical"> + + + + + + + + + + + + android:layout_marginLeft="16dp" + android:layout_marginRight="16dp" + android:layout_marginTop="16dp" + android:text="@string/osb_comment_dialog_message"/> + android:minLines="1"/> + android:layout_marginLeft="16dp" + android:layout_marginRight="16dp" + android:text="@string/close_changeset"/> + android:layout_marginLeft="16dp" + android:layout_marginRight="16dp" + android:text="@string/user_name"/> + android:layout_marginLeft="16dp" + android:layout_marginRight="16dp"/> + android:layout_marginLeft="16dp" + android:layout_marginRight="16dp" + android:text="@string/user_password"/> + android:layout_marginBottom="16dp" + android:layout_marginLeft="16dp" + android:layout_marginRight="16dp" + android:inputType="textPassword"/> diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 9fe8064bea..9be58cf443 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -18,6 +18,8 @@ Really download {0} file(s)? This needs {1} MB permanently? Currently, there are {2} MB available. + You can upload your OSM Note anonymously of youse your OpenStreetMap.org profile. + Upload OSM Note Show Map markers topbar First Map marker Second Map marker @@ -2235,4 +2237,5 @@ If you need help with OsmAnd application, please contact our support team: suppo Number of contributors Number of edits Report for + Upload anonymously diff --git a/OsmAnd/src/net/osmand/plus/osmedit/DashOsmEditsFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/DashOsmEditsFragment.java index a133db2e89..d62eede901 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/DashOsmEditsFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/DashOsmEditsFragment.java @@ -80,6 +80,7 @@ public class DashOsmEditsFragment extends DashBaseFragment private void setupEditings() { View mainView = getView(); + assert mainView != null; if (plugin == null) { mainView.setVisibility(View.GONE); return; @@ -144,14 +145,15 @@ public class DashOsmEditsFragment extends DashBaseFragment b.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - showProgressDialog(new OsmPoint[] {point}, false); + showProgressDialog(new OsmPoint[] {point}, false, false); } }); b.setNegativeButton(R.string.shared_string_cancel, null); b.show(); } - public void showProgressDialog(OsmPoint[] points, boolean closeChangeSet) { + @Override + public void showProgressDialog(OsmPoint[] points, boolean closeChangeSet, boolean anonymously) { OsmPoint[] toUpload = points; ProgressDialogFragment dialog = ProgressDialogFragment.createInstance(R.string.uploading, R.string.local_openstreetmap_uploading, ProgressDialog.STYLE_HORIZONTAL); @@ -175,7 +177,7 @@ public class DashOsmEditsFragment extends DashBaseFragment }; dialog.show(getChildFragmentManager(), ProgressDialogFragment.TAG); UploadOpenstreetmapPointAsyncTask uploadTask = new UploadOpenstreetmapPointAsyncTask(dialog, - listener, plugin, toUpload.length, closeChangeSet); + listener, plugin, toUpload.length, closeChangeSet, anonymously); uploadTask.execute(toUpload); } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuController.java b/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuController.java index 222d591fc2..24a962bb12 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuController.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuController.java @@ -33,7 +33,7 @@ public class EditPOIMenuController extends MenuController { poiUploader = new ProgressDialogPoiUploader() { @Override - public void showProgressDialog(OsmPoint[] points, boolean closeChangeSet) { + public void showProgressDialog(OsmPoint[] points, boolean closeChangeSet, boolean anonymously) { ProgressDialogFragment dialog = ProgressDialogFragment.createInstance( R.string.uploading, R.string.local_openstreetmap_uploading, @@ -53,7 +53,7 @@ public class EditPOIMenuController extends MenuController { }; dialog.show(mapActivity.getSupportFragmentManager(), ProgressDialogFragment.TAG); UploadOpenstreetmapPointAsyncTask uploadTask = new UploadOpenstreetmapPointAsyncTask( - dialog, listener, plugin, points.length, closeChangeSet); + dialog, listener, plugin, points.length, closeChangeSet, anonymously); uploadTask.execute(points); } }; diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsRemoteUtil.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsRemoteUtil.java index cfc9f90127..c478670155 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsRemoteUtil.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsRemoteUtil.java @@ -58,7 +58,7 @@ public class OsmBugsRemoteUtil implements OsmBugsUtil { @Override public OsmBugResult commit(OsmNotesPoint point, String text, Action action) { - return commit(point, text, action, true); + return commit(point, text, action, false); } public OsmBugResult commit(OsmNotesPoint point, String text, Action action, boolean anonymous) { diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsFragment.java index 45361d54b0..e6f867faa7 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsFragment.java @@ -99,7 +99,7 @@ public class OsmEditsFragment extends OsmAndListFragment public android.widget.ArrayAdapter getAdapter() { return listAdapter; - }; + } private void selectAll() { for (int i = 0; i < listAdapter.getCount(); i++) { @@ -143,7 +143,7 @@ public class OsmEditsFragment extends OsmAndListFragment @Override public boolean onMenuItemClick(MenuItem item) { new BackupOpenstreetmapPointAsyncTask().execute( - listAdapter.dataPoints.toArray(new OsmPoint[0])); + listAdapter.dataPoints.toArray(new OsmPoint[listAdapter.dataPoints.size()])); return true; } }); @@ -170,7 +170,7 @@ public class OsmEditsFragment extends OsmAndListFragment item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { - uploadItems(osmEditsSelected.toArray(new OsmPoint[0])); + uploadItems(osmEditsSelected.toArray(new OsmPoint[osmEditsSelected.size()])); mode.finish(); return true; } @@ -285,6 +285,7 @@ public class OsmEditsFragment extends OsmAndListFragment private void enableSelectionMode(boolean selectionMode) { this.selectionMode = selectionMode; + //noinspection ConstantConditions getView().findViewById(R.id.select_all).setVisibility(selectionMode ? View.VISIBLE : View.GONE); ((FavoritesActivity) getActivity()).setToolbarVisibility(!selectionMode && AndroidUiHelper.isOrientationPortrait(getActivity())); @@ -485,9 +486,9 @@ public class OsmEditsFragment extends OsmAndListFragment item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { - ArrayList points = new ArrayList(); + ArrayList points = new ArrayList<>(); points.add(info); - deleteItems(new ArrayList(points)); + deleteItems(new ArrayList<>(points)); return true; } @@ -527,7 +528,7 @@ public class OsmEditsFragment extends OsmAndListFragment // UploadOsmEditsConfirmDialogFragment.TAG); } - public void showProgressDialog(OsmPoint[] points, boolean closeChangeSet) { + public void showProgressDialog(OsmPoint[] points, boolean closeChangeSet, boolean anonymously) { ProgressDialogFragment dialog = ProgressDialogFragment.createInstance( R.string.uploading, R.string.local_openstreetmap_uploading, @@ -547,7 +548,7 @@ public class OsmEditsFragment extends OsmAndListFragment }; dialog.show(getActivity().getSupportFragmentManager(), ProgressDialogFragment.TAG); UploadOpenstreetmapPointAsyncTask uploadTask = new UploadOpenstreetmapPointAsyncTask( - dialog, listener, plugin, points.length, closeChangeSet); + dialog, listener, plugin, points.length, closeChangeSet, anonymously); uploadTask.execute(points); } @@ -687,10 +688,12 @@ public class OsmEditsFragment extends OsmAndListFragment public Dialog onCreateDialog(Bundle savedInstanceState) { final OsmEditsFragment parentFragment = (OsmEditsFragment) getParentFragment(); final OsmEditingPlugin plugin = OsmandPlugin.getEnabledPlugin(OsmEditingPlugin.class); + @SuppressWarnings("unchecked") final ArrayList points = (ArrayList) getArguments().getSerializable(POINTS_LIST); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); + assert points != null; builder.setMessage(getString(R.string.local_osm_changes_delete_all_confirm, points.size())); builder.setPositiveButton(R.string.shared_string_delete, new DialogInterface.OnClickListener() { @@ -699,6 +702,7 @@ public class OsmEditsFragment extends OsmAndListFragment Iterator it = points.iterator(); while (it.hasNext()) { OsmPoint osmPoint = it.next(); + assert plugin != null; if (osmPoint.getGroup() == OsmPoint.Group.POI) { plugin.getDBPOI().deletePOI((OpenstreetmapPoint) osmPoint); } else if (osmPoint.getGroup() == OsmPoint.Group.BUG) { diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsUploadListenerHelper.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsUploadListenerHelper.java index 35b3321d65..44c1c6f050 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsUploadListenerHelper.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsUploadListenerHelper.java @@ -91,7 +91,7 @@ public class OsmEditsUploadListenerHelper implements OsmEditsUploadListener { ProgressDialog.STYLE_HORIZONTAL); dialog.show(activity.getSupportFragmentManager(), ProgressDialogFragment.TAG); UploadOpenstreetmapPointAsyncTask uploadTask = new UploadOpenstreetmapPointAsyncTask( - dialog, helper, plugin, toUpload.length, false); + dialog, helper, plugin, toUpload.length, false, false); uploadTask.execute(toUpload); } @@ -115,6 +115,8 @@ public class OsmEditsUploadListenerHelper implements OsmEditsUploadListener { public void onClick(@Nullable DialogInterface dialog, int id) { OsmEditingPlugin plugin = OsmandPlugin.getEnabledPlugin(OsmEditingPlugin.class); + assert point != null; + assert plugin != null; if (point.getGroup() == OsmPoint.Group.BUG) { plugin.getDBBug().deleteAllBugModifications( (OsmNotesPoint) point); @@ -150,6 +152,7 @@ public class OsmEditsUploadListenerHelper implements OsmEditsUploadListener { boolean[] hasErrors = arguments.getBooleanArray(HAS_ERROR); final OsmPoint[] points = (OsmPoint[]) arguments.getSerializable(POINTS_WITH_ERRORS); int successfulUploads = 0; + assert hasErrors != null; for (boolean hasError : hasErrors) { if (!hasError) { successfulUploads++; @@ -237,7 +240,7 @@ public class OsmEditsUploadListenerHelper implements OsmEditsUploadListener { @Override public View getView(int position, View convertView, @NonNull ViewGroup parent) { View row = convertView; - PointHolder holder = null; + PointHolder holder; if (row == null) { LayoutInflater inflater = context.getLayoutInflater(); diff --git a/OsmAnd/src/net/osmand/plus/osmedit/UploadOpenstreetmapPointAsyncTask.java b/OsmAnd/src/net/osmand/plus/osmedit/UploadOpenstreetmapPointAsyncTask.java index 3fd50618da..9477428426 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/UploadOpenstreetmapPointAsyncTask.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/UploadOpenstreetmapPointAsyncTask.java @@ -24,14 +24,6 @@ public class UploadOpenstreetmapPointAsyncTask private final boolean closeChangeSet; private final boolean loadAnonymous; - public UploadOpenstreetmapPointAsyncTask(ProgressDialogFragment progress, - OsmEditsUploadListener listener, - OsmEditingPlugin plugin, - int listSize, - boolean closeChangeSet) { - this(progress, listener, plugin, listSize, closeChangeSet, false); - } - public UploadOpenstreetmapPointAsyncTask(ProgressDialogFragment progress, OsmEditsUploadListener listener, OsmEditingPlugin plugin, diff --git a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendPoiDialogFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendPoiDialogFragment.java index 5420afbed4..8c638474e9 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendPoiDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendPoiDialogFragment.java @@ -6,6 +6,7 @@ import android.os.Bundle; import android.support.annotation.NonNull; import android.support.v4.app.DialogFragment; import android.support.v7.app.AlertDialog; +import android.support.v7.widget.SwitchCompat; import android.view.View; import android.widget.CheckBox; import android.widget.EditText; @@ -33,6 +34,7 @@ public class SendPoiDialogFragment extends DialogFragment { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); View view = getActivity().getLayoutInflater().inflate(R.layout.send_poi_dialog, null); final View messageEditTextLabel = view.findViewById(R.id.messageEditTextLabel); + final SwitchCompat uploadAnonymously = (SwitchCompat) view.findViewById(R.id.upload_anonymously_switch); final EditText messageEditText = (EditText) view.findViewById(R.id.messageEditText); final EditText userNameEditText = (EditText) view.findViewById(R.id.userNameEditText); final EditText passwordEditText = (EditText) view.findViewById(R.id.passwordEditText); @@ -44,15 +46,16 @@ public class SendPoiDialogFragment extends DialogFragment { userNameEditText.setText(settings.USER_NAME.get()); passwordEditText.setText(settings.USER_PASSWORD.get()); boolean hasOsmPOI = false; - for(OsmPoint p : poi) { + assert poi != null; + for (OsmPoint p : poi) { if (p.getGroup() == OsmPoint.Group.POI) { hasOsmPOI = true; break; } } - messageEditTextLabel.setVisibility(hasOsmPOI ? View.VISIBLE :View.GONE); - messageEditText.setVisibility(hasOsmPOI ? View.VISIBLE :View.GONE); - closeChangeSetCheckBox.setVisibility(hasOsmPOI ? View.VISIBLE :View.GONE); + messageEditTextLabel.setVisibility(hasOsmPOI ? View.VISIBLE : View.GONE); + messageEditText.setVisibility(hasOsmPOI ? View.VISIBLE : View.GONE); + closeChangeSetCheckBox.setVisibility(hasOsmPOI ? View.VISIBLE : View.GONE); final ProgressDialogPoiUploader progressDialogPoiUploader; if (poiUploader != null) { @@ -61,7 +64,7 @@ public class SendPoiDialogFragment extends DialogFragment { progressDialogPoiUploader = (ProgressDialogPoiUploader) getParentFragment(); } - builder.setTitle(R.string.shared_string_commit) + builder.setTitle(R.string.upload_osm_note) .setView(view) .setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() { @Override @@ -78,7 +81,8 @@ public class SendPoiDialogFragment extends DialogFragment { } } progressDialogPoiUploader.showProgressDialog(poi, - closeChangeSetCheckBox.isChecked()); + closeChangeSetCheckBox.isChecked(), + uploadAnonymously.isChecked()); } }) .setNegativeButton(R.string.shared_string_cancel, null); @@ -94,8 +98,6 @@ public class SendPoiDialogFragment extends DialogFragment { } public interface ProgressDialogPoiUploader { - - void showProgressDialog(OsmPoint[] points, boolean closeChangeSet); - + void showProgressDialog(OsmPoint[] points, boolean closeChangeSet, boolean anonymously); } }