Merge branch 'master' of github.com:osmandapp/Osmand

This commit is contained in:
Victor Shcherb 2016-02-19 18:56:43 +02:00
commit c94c75de60
9 changed files with 94 additions and 51 deletions

View file

@ -4,54 +4,91 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:text="@string/upload_osm_note_description"
android:textSize="@dimen/default_desc_text_size"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/upload_anonymously"
android:textSize="@dimen/default_desc_text_size"/>
<android.support.v7.widget.SwitchCompat
android:id="@+id/upload_anonymously_switch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/divider_color"/>
<TextView <TextView
android:id="@+id/messageEditTextLabel" android:id="@+id/messageEditTextLabel"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:layout_marginLeft="16dp"
android:text="@string/osb_comment_dialog_message" /> android:layout_marginRight="16dp"
android:layout_marginTop="16dp"
android:text="@string/osb_comment_dialog_message"/>
<EditText <EditText
android:id="@+id/messageEditText" android:id="@+id/messageEditText"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:layout_marginLeft="16dp"
android:layout_marginRight="5dp" android:layout_marginRight="16dp"
android:inputType="textMultiLine" android:inputType="textMultiLine"
android:minLines="1" /> android:minLines="1"/>
<CheckBox <CheckBox
android:id="@+id/closeChangeSetCheckBox" android:id="@+id/closeChangeSetCheckBox"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:layout_marginLeft="16dp"
android:text="@string/close_changeset" /> android:layout_marginRight="16dp"
android:text="@string/close_changeset"/>
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:layout_marginLeft="16dp"
android:text="@string/user_name" /> android:layout_marginRight="16dp"
android:text="@string/user_name"/>
<EditText <EditText
android:id="@+id/userNameEditText" android:id="@+id/userNameEditText"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:layout_marginLeft="16dp"
android:layout_marginRight="5dp" /> android:layout_marginRight="16dp"/>
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:layout_marginLeft="16dp"
android:text="@string/user_password" /> android:layout_marginRight="16dp"
android:text="@string/user_password"/>
<EditText <EditText
android:id="@+id/passwordEditText" android:id="@+id/passwordEditText"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:layout_marginBottom="16dp"
android:layout_marginRight="5dp" android:layout_marginLeft="16dp"
android:inputType="textPassword" /> android:layout_marginRight="16dp"
android:inputType="textPassword"/>
</LinearLayout> </LinearLayout>

View file

@ -18,6 +18,8 @@
<string name="download_files_question_space">Really download {0} file(s)? <string name="download_files_question_space">Really download {0} file(s)?
This needs {1} MB permanently? This needs {1} MB permanently?
Currently, there are {2} MB available.</string> Currently, there are {2} MB available.</string>
<string name="upload_osm_note_description">You can upload your OSM Note anonymously of youse your OpenStreetMap.org profile.</string>
<string name="upload_osm_note">Upload OSM Note</string>
<string name="show_map_markers_topbar">Show Map markers topbar</string> <string name="show_map_markers_topbar">Show Map markers topbar</string>
<string name="map_marker_1st">First Map marker</string> <string name="map_marker_1st">First Map marker</string>
<string name="map_marker_2nd">Second Map marker</string> <string name="map_marker_2nd">Second Map marker</string>
@ -2235,4 +2237,5 @@ If you need help with OsmAnd application, please contact our support team: suppo
<string name="number_of_contributors">Number of contributors</string> <string name="number_of_contributors">Number of contributors</string>
<string name="number_of_edits">Number of edits</string> <string name="number_of_edits">Number of edits</string>
<string name="reports_for">Report for</string> <string name="reports_for">Report for</string>
<string name="upload_anonymously">Upload anonymously</string>
</resources> </resources>

View file

@ -80,6 +80,7 @@ public class DashOsmEditsFragment extends DashBaseFragment
private void setupEditings() { private void setupEditings() {
View mainView = getView(); View mainView = getView();
assert mainView != null;
if (plugin == null) { if (plugin == null) {
mainView.setVisibility(View.GONE); mainView.setVisibility(View.GONE);
return; return;
@ -144,14 +145,15 @@ public class DashOsmEditsFragment extends DashBaseFragment
b.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() { b.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { 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.setNegativeButton(R.string.shared_string_cancel, null);
b.show(); b.show();
} }
public void showProgressDialog(OsmPoint[] points, boolean closeChangeSet) { @Override
public void showProgressDialog(OsmPoint[] points, boolean closeChangeSet, boolean anonymously) {
OsmPoint[] toUpload = points; OsmPoint[] toUpload = points;
ProgressDialogFragment dialog = ProgressDialogFragment.createInstance(R.string.uploading, ProgressDialogFragment dialog = ProgressDialogFragment.createInstance(R.string.uploading,
R.string.local_openstreetmap_uploading, ProgressDialog.STYLE_HORIZONTAL); R.string.local_openstreetmap_uploading, ProgressDialog.STYLE_HORIZONTAL);
@ -175,7 +177,7 @@ public class DashOsmEditsFragment extends DashBaseFragment
}; };
dialog.show(getChildFragmentManager(), ProgressDialogFragment.TAG); dialog.show(getChildFragmentManager(), ProgressDialogFragment.TAG);
UploadOpenstreetmapPointAsyncTask uploadTask = new UploadOpenstreetmapPointAsyncTask(dialog, UploadOpenstreetmapPointAsyncTask uploadTask = new UploadOpenstreetmapPointAsyncTask(dialog,
listener, plugin, toUpload.length, closeChangeSet); listener, plugin, toUpload.length, closeChangeSet, anonymously);
uploadTask.execute(toUpload); uploadTask.execute(toUpload);
} }

View file

@ -33,7 +33,7 @@ public class EditPOIMenuController extends MenuController {
poiUploader = new ProgressDialogPoiUploader() { poiUploader = new ProgressDialogPoiUploader() {
@Override @Override
public void showProgressDialog(OsmPoint[] points, boolean closeChangeSet) { public void showProgressDialog(OsmPoint[] points, boolean closeChangeSet, boolean anonymously) {
ProgressDialogFragment dialog = ProgressDialogFragment.createInstance( ProgressDialogFragment dialog = ProgressDialogFragment.createInstance(
R.string.uploading, R.string.uploading,
R.string.local_openstreetmap_uploading, R.string.local_openstreetmap_uploading,
@ -53,7 +53,7 @@ public class EditPOIMenuController extends MenuController {
}; };
dialog.show(mapActivity.getSupportFragmentManager(), ProgressDialogFragment.TAG); dialog.show(mapActivity.getSupportFragmentManager(), ProgressDialogFragment.TAG);
UploadOpenstreetmapPointAsyncTask uploadTask = new UploadOpenstreetmapPointAsyncTask( UploadOpenstreetmapPointAsyncTask uploadTask = new UploadOpenstreetmapPointAsyncTask(
dialog, listener, plugin, points.length, closeChangeSet); dialog, listener, plugin, points.length, closeChangeSet, anonymously);
uploadTask.execute(points); uploadTask.execute(points);
} }
}; };

View file

@ -58,7 +58,7 @@ public class OsmBugsRemoteUtil implements OsmBugsUtil {
@Override @Override
public OsmBugResult commit(OsmNotesPoint point, String text, Action action) { 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) { public OsmBugResult commit(OsmNotesPoint point, String text, Action action, boolean anonymous) {

View file

@ -99,7 +99,7 @@ public class OsmEditsFragment extends OsmAndListFragment
public android.widget.ArrayAdapter<?> getAdapter() { public android.widget.ArrayAdapter<?> getAdapter() {
return listAdapter; return listAdapter;
}; }
private void selectAll() { private void selectAll() {
for (int i = 0; i < listAdapter.getCount(); i++) { for (int i = 0; i < listAdapter.getCount(); i++) {
@ -143,7 +143,7 @@ public class OsmEditsFragment extends OsmAndListFragment
@Override @Override
public boolean onMenuItemClick(MenuItem item) { public boolean onMenuItemClick(MenuItem item) {
new BackupOpenstreetmapPointAsyncTask().execute( new BackupOpenstreetmapPointAsyncTask().execute(
listAdapter.dataPoints.toArray(new OsmPoint[0])); listAdapter.dataPoints.toArray(new OsmPoint[listAdapter.dataPoints.size()]));
return true; return true;
} }
}); });
@ -170,7 +170,7 @@ public class OsmEditsFragment extends OsmAndListFragment
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override @Override
public boolean onMenuItemClick(MenuItem item) { public boolean onMenuItemClick(MenuItem item) {
uploadItems(osmEditsSelected.toArray(new OsmPoint[0])); uploadItems(osmEditsSelected.toArray(new OsmPoint[osmEditsSelected.size()]));
mode.finish(); mode.finish();
return true; return true;
} }
@ -285,6 +285,7 @@ public class OsmEditsFragment extends OsmAndListFragment
private void enableSelectionMode(boolean selectionMode) { private void enableSelectionMode(boolean selectionMode) {
this.selectionMode = selectionMode; this.selectionMode = selectionMode;
//noinspection ConstantConditions
getView().findViewById(R.id.select_all).setVisibility(selectionMode ? View.VISIBLE : View.GONE); getView().findViewById(R.id.select_all).setVisibility(selectionMode ? View.VISIBLE : View.GONE);
((FavoritesActivity) getActivity()).setToolbarVisibility(!selectionMode && ((FavoritesActivity) getActivity()).setToolbarVisibility(!selectionMode &&
AndroidUiHelper.isOrientationPortrait(getActivity())); AndroidUiHelper.isOrientationPortrait(getActivity()));
@ -485,9 +486,9 @@ public class OsmEditsFragment extends OsmAndListFragment
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override @Override
public boolean onMenuItemClick(MenuItem item) { public boolean onMenuItemClick(MenuItem item) {
ArrayList<OsmPoint> points = new ArrayList<OsmPoint>(); ArrayList<OsmPoint> points = new ArrayList<>();
points.add(info); points.add(info);
deleteItems(new ArrayList<OsmPoint>(points)); deleteItems(new ArrayList<>(points));
return true; return true;
} }
@ -527,7 +528,7 @@ public class OsmEditsFragment extends OsmAndListFragment
// UploadOsmEditsConfirmDialogFragment.TAG); // UploadOsmEditsConfirmDialogFragment.TAG);
} }
public void showProgressDialog(OsmPoint[] points, boolean closeChangeSet) { public void showProgressDialog(OsmPoint[] points, boolean closeChangeSet, boolean anonymously) {
ProgressDialogFragment dialog = ProgressDialogFragment.createInstance( ProgressDialogFragment dialog = ProgressDialogFragment.createInstance(
R.string.uploading, R.string.uploading,
R.string.local_openstreetmap_uploading, R.string.local_openstreetmap_uploading,
@ -547,7 +548,7 @@ public class OsmEditsFragment extends OsmAndListFragment
}; };
dialog.show(getActivity().getSupportFragmentManager(), ProgressDialogFragment.TAG); dialog.show(getActivity().getSupportFragmentManager(), ProgressDialogFragment.TAG);
UploadOpenstreetmapPointAsyncTask uploadTask = new UploadOpenstreetmapPointAsyncTask( UploadOpenstreetmapPointAsyncTask uploadTask = new UploadOpenstreetmapPointAsyncTask(
dialog, listener, plugin, points.length, closeChangeSet); dialog, listener, plugin, points.length, closeChangeSet, anonymously);
uploadTask.execute(points); uploadTask.execute(points);
} }
@ -687,10 +688,12 @@ public class OsmEditsFragment extends OsmAndListFragment
public Dialog onCreateDialog(Bundle savedInstanceState) { public Dialog onCreateDialog(Bundle savedInstanceState) {
final OsmEditsFragment parentFragment = (OsmEditsFragment) getParentFragment(); final OsmEditsFragment parentFragment = (OsmEditsFragment) getParentFragment();
final OsmEditingPlugin plugin = OsmandPlugin.getEnabledPlugin(OsmEditingPlugin.class); final OsmEditingPlugin plugin = OsmandPlugin.getEnabledPlugin(OsmEditingPlugin.class);
@SuppressWarnings("unchecked")
final ArrayList<OsmPoint> points = final ArrayList<OsmPoint> points =
(ArrayList<OsmPoint>) getArguments().getSerializable(POINTS_LIST); (ArrayList<OsmPoint>) getArguments().getSerializable(POINTS_LIST);
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
assert points != null;
builder.setMessage(getString(R.string.local_osm_changes_delete_all_confirm, builder.setMessage(getString(R.string.local_osm_changes_delete_all_confirm,
points.size())); points.size()));
builder.setPositiveButton(R.string.shared_string_delete, new DialogInterface.OnClickListener() { builder.setPositiveButton(R.string.shared_string_delete, new DialogInterface.OnClickListener() {
@ -699,6 +702,7 @@ public class OsmEditsFragment extends OsmAndListFragment
Iterator<OsmPoint> it = points.iterator(); Iterator<OsmPoint> it = points.iterator();
while (it.hasNext()) { while (it.hasNext()) {
OsmPoint osmPoint = it.next(); OsmPoint osmPoint = it.next();
assert plugin != null;
if (osmPoint.getGroup() == OsmPoint.Group.POI) { if (osmPoint.getGroup() == OsmPoint.Group.POI) {
plugin.getDBPOI().deletePOI((OpenstreetmapPoint) osmPoint); plugin.getDBPOI().deletePOI((OpenstreetmapPoint) osmPoint);
} else if (osmPoint.getGroup() == OsmPoint.Group.BUG) { } else if (osmPoint.getGroup() == OsmPoint.Group.BUG) {

View file

@ -91,7 +91,7 @@ public class OsmEditsUploadListenerHelper implements OsmEditsUploadListener {
ProgressDialog.STYLE_HORIZONTAL); ProgressDialog.STYLE_HORIZONTAL);
dialog.show(activity.getSupportFragmentManager(), ProgressDialogFragment.TAG); dialog.show(activity.getSupportFragmentManager(), ProgressDialogFragment.TAG);
UploadOpenstreetmapPointAsyncTask uploadTask = new UploadOpenstreetmapPointAsyncTask( UploadOpenstreetmapPointAsyncTask uploadTask = new UploadOpenstreetmapPointAsyncTask(
dialog, helper, plugin, toUpload.length, false); dialog, helper, plugin, toUpload.length, false, false);
uploadTask.execute(toUpload); uploadTask.execute(toUpload);
} }
@ -115,6 +115,8 @@ public class OsmEditsUploadListenerHelper implements OsmEditsUploadListener {
public void onClick(@Nullable DialogInterface dialog, int id) { public void onClick(@Nullable DialogInterface dialog, int id) {
OsmEditingPlugin plugin = OsmEditingPlugin plugin =
OsmandPlugin.getEnabledPlugin(OsmEditingPlugin.class); OsmandPlugin.getEnabledPlugin(OsmEditingPlugin.class);
assert point != null;
assert plugin != null;
if (point.getGroup() == OsmPoint.Group.BUG) { if (point.getGroup() == OsmPoint.Group.BUG) {
plugin.getDBBug().deleteAllBugModifications( plugin.getDBBug().deleteAllBugModifications(
(OsmNotesPoint) point); (OsmNotesPoint) point);
@ -150,6 +152,7 @@ public class OsmEditsUploadListenerHelper implements OsmEditsUploadListener {
boolean[] hasErrors = arguments.getBooleanArray(HAS_ERROR); boolean[] hasErrors = arguments.getBooleanArray(HAS_ERROR);
final OsmPoint[] points = (OsmPoint[]) arguments.getSerializable(POINTS_WITH_ERRORS); final OsmPoint[] points = (OsmPoint[]) arguments.getSerializable(POINTS_WITH_ERRORS);
int successfulUploads = 0; int successfulUploads = 0;
assert hasErrors != null;
for (boolean hasError : hasErrors) { for (boolean hasError : hasErrors) {
if (!hasError) { if (!hasError) {
successfulUploads++; successfulUploads++;
@ -237,7 +240,7 @@ public class OsmEditsUploadListenerHelper implements OsmEditsUploadListener {
@Override @Override
public View getView(int position, View convertView, @NonNull ViewGroup parent) { public View getView(int position, View convertView, @NonNull ViewGroup parent) {
View row = convertView; View row = convertView;
PointHolder holder = null; PointHolder holder;
if (row == null) { if (row == null) {
LayoutInflater inflater = context.getLayoutInflater(); LayoutInflater inflater = context.getLayoutInflater();

View file

@ -24,14 +24,6 @@ public class UploadOpenstreetmapPointAsyncTask
private final boolean closeChangeSet; private final boolean closeChangeSet;
private final boolean loadAnonymous; 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, public UploadOpenstreetmapPointAsyncTask(ProgressDialogFragment progress,
OsmEditsUploadListener listener, OsmEditsUploadListener listener,
OsmEditingPlugin plugin, OsmEditingPlugin plugin,

View file

@ -6,6 +6,7 @@ import android.os.Bundle;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment; import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.support.v7.widget.SwitchCompat;
import android.view.View; import android.view.View;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.EditText; import android.widget.EditText;
@ -33,6 +34,7 @@ public class SendPoiDialogFragment extends DialogFragment {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
View view = getActivity().getLayoutInflater().inflate(R.layout.send_poi_dialog, null); View view = getActivity().getLayoutInflater().inflate(R.layout.send_poi_dialog, null);
final View messageEditTextLabel = view.findViewById(R.id.messageEditTextLabel); 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 messageEditText = (EditText) view.findViewById(R.id.messageEditText);
final EditText userNameEditText = (EditText) view.findViewById(R.id.userNameEditText); final EditText userNameEditText = (EditText) view.findViewById(R.id.userNameEditText);
final EditText passwordEditText = (EditText) view.findViewById(R.id.passwordEditText); final EditText passwordEditText = (EditText) view.findViewById(R.id.passwordEditText);
@ -44,15 +46,16 @@ public class SendPoiDialogFragment extends DialogFragment {
userNameEditText.setText(settings.USER_NAME.get()); userNameEditText.setText(settings.USER_NAME.get());
passwordEditText.setText(settings.USER_PASSWORD.get()); passwordEditText.setText(settings.USER_PASSWORD.get());
boolean hasOsmPOI = false; boolean hasOsmPOI = false;
for(OsmPoint p : poi) { assert poi != null;
for (OsmPoint p : poi) {
if (p.getGroup() == OsmPoint.Group.POI) { if (p.getGroup() == OsmPoint.Group.POI) {
hasOsmPOI = true; hasOsmPOI = true;
break; break;
} }
} }
messageEditTextLabel.setVisibility(hasOsmPOI ? View.VISIBLE :View.GONE); messageEditTextLabel.setVisibility(hasOsmPOI ? View.VISIBLE : View.GONE);
messageEditText.setVisibility(hasOsmPOI ? View.VISIBLE :View.GONE); messageEditText.setVisibility(hasOsmPOI ? View.VISIBLE : View.GONE);
closeChangeSetCheckBox.setVisibility(hasOsmPOI ? View.VISIBLE :View.GONE); closeChangeSetCheckBox.setVisibility(hasOsmPOI ? View.VISIBLE : View.GONE);
final ProgressDialogPoiUploader progressDialogPoiUploader; final ProgressDialogPoiUploader progressDialogPoiUploader;
if (poiUploader != null) { if (poiUploader != null) {
@ -61,7 +64,7 @@ public class SendPoiDialogFragment extends DialogFragment {
progressDialogPoiUploader = (ProgressDialogPoiUploader) getParentFragment(); progressDialogPoiUploader = (ProgressDialogPoiUploader) getParentFragment();
} }
builder.setTitle(R.string.shared_string_commit) builder.setTitle(R.string.upload_osm_note)
.setView(view) .setView(view)
.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() { .setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
@Override @Override
@ -78,7 +81,8 @@ public class SendPoiDialogFragment extends DialogFragment {
} }
} }
progressDialogPoiUploader.showProgressDialog(poi, progressDialogPoiUploader.showProgressDialog(poi,
closeChangeSetCheckBox.isChecked()); closeChangeSetCheckBox.isChecked(),
uploadAnonymously.isChecked());
} }
}) })
.setNegativeButton(R.string.shared_string_cancel, null); .setNegativeButton(R.string.shared_string_cancel, null);
@ -94,8 +98,6 @@ public class SendPoiDialogFragment extends DialogFragment {
} }
public interface ProgressDialogPoiUploader { public interface ProgressDialogPoiUploader {
void showProgressDialog(OsmPoint[] points, boolean closeChangeSet, boolean anonymously);
void showProgressDialog(OsmPoint[] points, boolean closeChangeSet);
} }
} }