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

@ -1,57 +1,94 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
android:layout_width="fill_parent"
android:layout_height="wrap_content"
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
android:id="@+id/messageEditTextLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="@string/osb_comment_dialog_message" />
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="16dp"
android:text="@string/osb_comment_dialog_message"/>
<EditText
android:id="@+id/messageEditText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:inputType="textMultiLine"
android:minLines="1" />
android:minLines="1"/>
<CheckBox
android:id="@+id/closeChangeSetCheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="@string/close_changeset" />
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:text="@string/close_changeset"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="@string/user_name" />
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:text="@string/user_name"/>
<EditText
android:id="@+id/userNameEditText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp" />
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="@string/user_password" />
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:text="@string/user_password"/>
<EditText
android:id="@+id/passwordEditText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:inputType="textPassword" />
android:layout_marginBottom="16dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:inputType="textPassword"/>
</LinearLayout>

View file

@ -18,6 +18,8 @@
<string name="download_files_question_space">Really download {0} file(s)?
This needs {1} MB permanently?
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="map_marker_1st">First 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_edits">Number of edits</string>
<string name="reports_for">Report for</string>
<string name="upload_anonymously">Upload anonymously</string>
</resources>

View file

@ -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);
}

View file

@ -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);
}
};

View file

@ -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) {

View file

@ -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<OsmPoint> points = new ArrayList<OsmPoint>();
ArrayList<OsmPoint> points = new ArrayList<>();
points.add(info);
deleteItems(new ArrayList<OsmPoint>(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<OsmPoint> points =
(ArrayList<OsmPoint>) 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<OsmPoint> 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) {

View file

@ -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();

View file

@ -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,

View file

@ -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);
}
}