Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
1d5f8cb44b
10 changed files with 174 additions and 144 deletions
|
@ -5,46 +5,52 @@
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_marginLeft="5dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:text="@string/osb_comment_dialog_message" />
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="5dp"
|
||||||
|
android:text="@string/osb_comment_dialog_message"/>
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/messageEditText"
|
android:id="@+id/messageEditText"
|
||||||
android:minLines="1"
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="5dp"
|
android:layout_marginLeft="5dp"
|
||||||
android:layout_marginRight="5dp"
|
android:layout_marginRight="5dp"
|
||||||
android:layout_height="wrap_content"
|
android:inputType="textMultiLine"
|
||||||
android:layout_width="fill_parent"
|
android:minLines="1"/>
|
||||||
android:inputType="textMultiLine" />
|
|
||||||
|
|
||||||
|
<CheckBox
|
||||||
|
android:id="@+id/closeChangeSetCheckBox"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="5dp"
|
||||||
|
android:text="@string/close_changeset"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_marginLeft="5dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:text="@string/user_name" />
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="5dp"
|
||||||
|
android:text="@string/user_name"/>
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/userNameEditText"
|
android:id="@+id/userNameEditText"
|
||||||
android:layout_marginLeft="5dp"
|
android:layout_width="fill_parent"
|
||||||
android:layout_marginRight="5dp"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="fill_parent" />
|
android:layout_marginLeft="5dp"
|
||||||
|
android:layout_marginRight="5dp"/>
|
||||||
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_marginLeft="5dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:text="@string/user_password" />
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="5dp"
|
||||||
|
android:text="@string/user_password"/>
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/passwordEditText"
|
android:id="@+id/passwordEditText"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="5dp"
|
android:layout_marginLeft="5dp"
|
||||||
android:layout_marginRight="5dp"
|
android:layout_marginRight="5dp"
|
||||||
android:layout_height="wrap_content"
|
android:inputType="textPassword"/>
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:inputType="textPassword" />
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
@ -2190,6 +2190,7 @@ Afghanistan, Albania, Algeria, Andorra, Angola, Anguilla, Antigua and Barbuda, A
|
||||||
<string name="poi_remove_success">POI was successfully deleted</string>
|
<string name="poi_remove_success">POI was successfully deleted</string>
|
||||||
<string name="poi_action_add">add</string>
|
<string name="poi_action_add">add</string>
|
||||||
<string name="poi_action_change">change</string>
|
<string name="poi_action_change">change</string>
|
||||||
|
<string name="poi_action_delete">delete</string>
|
||||||
<string name="poi_action_succeded_template">Action {0} completed successfully.</string>
|
<string name="poi_action_succeded_template">Action {0} completed successfully.</string>
|
||||||
<string name="poi_error_unexpected_template">Unexpected error occurred while performing action {0}.</string>
|
<string name="poi_error_unexpected_template">Unexpected error occurred while performing action {0}.</string>
|
||||||
<string name="poi_error_io_error_template">I/O error occurred while performing action {0}.</string>
|
<string name="poi_error_io_error_template">I/O error occurred while performing action {0}.</string>
|
||||||
|
|
|
@ -1,28 +1,24 @@
|
||||||
package net.osmand.plus.osmedit;
|
package net.osmand.plus.osmedit;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.Dialog;
|
|
||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
|
||||||
import android.support.v4.app.DialogFragment;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import net.osmand.data.PointDescription;
|
import net.osmand.data.PointDescription;
|
||||||
import net.osmand.plus.OsmandPlugin;
|
import net.osmand.plus.OsmandPlugin;
|
||||||
import net.osmand.plus.OsmandSettings;
|
|
||||||
import net.osmand.plus.ProgressImplementation;
|
import net.osmand.plus.ProgressImplementation;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.dashboard.DashBaseFragment;
|
import net.osmand.plus.dashboard.DashBaseFragment;
|
||||||
|
import net.osmand.plus.osmedit.dialogs.SendPoiDialogFragment;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -32,7 +28,8 @@ import java.util.Map;
|
||||||
* Created by Denis
|
* Created by Denis
|
||||||
* on 20.01.2015.
|
* on 20.01.2015.
|
||||||
*/
|
*/
|
||||||
public class DashOsmEditsFragment extends DashBaseFragment {
|
public class DashOsmEditsFragment extends DashBaseFragment
|
||||||
|
implements SendPoiDialogFragment.ProgressDialogPoiUploader {
|
||||||
public static final String TAG = "DASH_OSM_EDITS_FRAGMENT";
|
public static final String TAG = "DASH_OSM_EDITS_FRAGMENT";
|
||||||
|
|
||||||
OsmEditingPlugin plugin;
|
OsmEditingPlugin plugin;
|
||||||
|
@ -96,7 +93,7 @@ public class DashOsmEditsFragment extends DashBaseFragment {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (point.getGroup() == OsmPoint.Group.POI) {
|
if (point.getGroup() == OsmPoint.Group.POI) {
|
||||||
SendPoiDialogFragment.createInstance((OpenstreetmapPoint) point)
|
SendPoiDialogFragment.createInstance(new OsmPoint[] {point})
|
||||||
.show(getChildFragmentManager(), "SendPoiDialogFragment");
|
.show(getChildFragmentManager(), "SendPoiDialogFragment");
|
||||||
} else {
|
} else {
|
||||||
uploadItem(point);
|
uploadItem(point);
|
||||||
|
@ -123,22 +120,23 @@ public class DashOsmEditsFragment extends DashBaseFragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: 9/7/15 Redesign osm notes.
|
||||||
private void uploadItem(final OsmPoint point) {
|
private void uploadItem(final OsmPoint point) {
|
||||||
AlertDialog.Builder b = new AlertDialog.Builder(getActivity());
|
AlertDialog.Builder b = new AlertDialog.Builder(getActivity());
|
||||||
b.setMessage(getString(R.string.local_osm_changes_upload_all_confirm, 1));
|
b.setMessage(getString(R.string.local_osm_changes_upload_all_confirm, 1));
|
||||||
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(point);
|
showProgressDialog(new OsmPoint[] {point}, false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
b.setNegativeButton(R.string.shared_string_cancel, null);
|
b.setNegativeButton(R.string.shared_string_cancel, null);
|
||||||
b.show();
|
b.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showProgressDialog(OsmPoint point) {
|
public void showProgressDialog(OsmPoint[] points, boolean closeChangeSet) {
|
||||||
OpenstreetmapRemoteUtil remotepoi = new OpenstreetmapRemoteUtil(getActivity());
|
OpenstreetmapRemoteUtil remotepoi = new OpenstreetmapRemoteUtil(getActivity());
|
||||||
OsmPoint[] toUpload = new OsmPoint[]{point};
|
OsmPoint[] toUpload = points;
|
||||||
OsmBugsRemoteUtil remotebug = new OsmBugsRemoteUtil(getMyApplication());
|
OsmBugsRemoteUtil remotebug = new OsmBugsRemoteUtil(getMyApplication());
|
||||||
ProgressDialog dialog = ProgressImplementation.createProgressDialog(getActivity(),
|
ProgressDialog dialog = ProgressImplementation.createProgressDialog(getActivity(),
|
||||||
getString(R.string.uploading), getString(R.string.local_openstreetmap_uploading),
|
getString(R.string.uploading), getString(R.string.local_openstreetmap_uploading),
|
||||||
|
@ -162,7 +160,7 @@ public class DashOsmEditsFragment extends DashBaseFragment {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
UploadOpenstreetmapPointAsyncTask uploadTask = new UploadOpenstreetmapPointAsyncTask(dialog,
|
UploadOpenstreetmapPointAsyncTask uploadTask = new UploadOpenstreetmapPointAsyncTask(dialog,
|
||||||
listener, plugin, remotepoi, remotebug, toUpload.length);
|
listener, plugin, remotepoi, remotebug, toUpload.length, closeChangeSet);
|
||||||
uploadTask.execute(toUpload);
|
uploadTask.execute(toUpload);
|
||||||
dialog.show();
|
dialog.show();
|
||||||
}
|
}
|
||||||
|
@ -199,43 +197,4 @@ public class DashOsmEditsFragment extends DashBaseFragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class SendPoiDialogFragment extends DialogFragment {
|
|
||||||
public static final String OPENSTREETMAP_POINT = "openstreetmap_point";
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
|
||||||
final OpenstreetmapPoint poi = (OpenstreetmapPoint) getArguments().getSerializable(OPENSTREETMAP_POINT);
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
|
||||||
View view = getActivity().getLayoutInflater().inflate(R.layout.send_poi_dialog, null);
|
|
||||||
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);
|
|
||||||
|
|
||||||
final OsmandSettings settings = ((MapActivity) getActivity()).getMyApplication().getSettings();
|
|
||||||
userNameEditText.setText(settings.USER_NAME.get());
|
|
||||||
passwordEditText.setText(settings.USER_PASSWORD.get());
|
|
||||||
builder.setTitle(R.string.commit_poi)
|
|
||||||
.setView(view)
|
|
||||||
.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
settings.USER_NAME.set(userNameEditText.getText().toString());
|
|
||||||
settings.USER_PASSWORD.set(passwordEditText.getText().toString());
|
|
||||||
poi.setComment(messageEditText.getText().toString());
|
|
||||||
((DashOsmEditsFragment) getParentFragment()).showProgressDialog(poi);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.setNegativeButton(R.string.shared_string_cancel, null);
|
|
||||||
return builder.create();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static SendPoiDialogFragment createInstance(OpenstreetmapPoint poi) {
|
|
||||||
SendPoiDialogFragment fragment = new SendPoiDialogFragment();
|
|
||||||
Bundle bundle = new Bundle();
|
|
||||||
bundle.putSerializable(OPENSTREETMAP_POINT, poi);
|
|
||||||
fragment.setArguments(bundle);
|
|
||||||
return fragment;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -419,7 +419,12 @@ public class EditPoiFragment extends DialogFragment {
|
||||||
final Runnable successAction,
|
final Runnable successAction,
|
||||||
final Activity activity,
|
final Activity activity,
|
||||||
final OpenstreetmapUtil openstreetmapUtil) {
|
final OpenstreetmapUtil openstreetmapUtil) {
|
||||||
|
LOG.debug("commitNode(" + "action=" + action + ", n=" + n + ", info=" + info
|
||||||
|
+ ", comment=" + comment + ", closeChangeSet=" + closeChangeSet
|
||||||
|
+ ", successAction=" + successAction + ", activity=" + activity
|
||||||
|
+ ", openstreetmapUtil=" + openstreetmapUtil + ")");
|
||||||
if (info == null && OsmPoint.Action.CREATE != action) {
|
if (info == null && OsmPoint.Action.CREATE != action) {
|
||||||
|
|
||||||
AccessibleToast.makeText(activity, activity.getResources().getString(R.string.poi_error_info_not_loaded), Toast.LENGTH_LONG).show();
|
AccessibleToast.makeText(activity, activity.getResources().getString(R.string.poi_error_info_not_loaded), Toast.LENGTH_LONG).show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,5 +13,4 @@ public interface OpenstreetmapUtil {
|
||||||
public void closeChangeSet();
|
public void closeChangeSet();
|
||||||
|
|
||||||
public Node loadNode(Amenity n);
|
public Node loadNode(Amenity n);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@ import net.osmand.plus.activities.OsmandActionBarActivity;
|
||||||
import net.osmand.plus.dialogs.DirectionsDialogs;
|
import net.osmand.plus.dialogs.DirectionsDialogs;
|
||||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||||
import net.osmand.plus.myplaces.FavoritesActivity;
|
import net.osmand.plus.myplaces.FavoritesActivity;
|
||||||
|
import net.osmand.plus.osmedit.dialogs.SendPoiDialogFragment;
|
||||||
|
|
||||||
import org.xmlpull.v1.XmlSerializer;
|
import org.xmlpull.v1.XmlSerializer;
|
||||||
|
|
||||||
|
@ -56,7 +57,8 @@ import java.util.List;
|
||||||
* Created by Denis
|
* Created by Denis
|
||||||
* on 06.03.2015.
|
* on 06.03.2015.
|
||||||
*/
|
*/
|
||||||
public class OsmEditsFragment extends OsmAndListFragment {
|
public class OsmEditsFragment extends OsmAndListFragment
|
||||||
|
implements SendPoiDialogFragment.ProgressDialogPoiUploader {
|
||||||
OsmEditingPlugin plugin;
|
OsmEditingPlugin plugin;
|
||||||
|
|
||||||
private OsmEditsAdapter listAdapter;
|
private OsmEditsAdapter listAdapter;
|
||||||
|
@ -488,11 +490,13 @@ public class OsmEditsFragment extends OsmAndListFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void uploadItems(final OsmPoint[] items) {
|
private void uploadItems(final OsmPoint[] items) {
|
||||||
UploadOsmEditsConfirmDialogFragment.createInstance(items).show(getChildFragmentManager(),
|
SendPoiDialogFragment.createInstance(items).show(getChildFragmentManager(),
|
||||||
UploadOsmEditsConfirmDialogFragment.TAG);
|
SendPoiDialogFragment.TAG);
|
||||||
|
// UploadOsmEditsConfirmDialogFragment.createInstancee(items).show(getChildFragmentManager(),
|
||||||
|
// UploadOsmEditsConfirmDialogFragment.TAG);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showUploadItemsProgressDialog(OsmPoint[] toUpload) {
|
public void showProgressDialog(OsmPoint[] points, boolean closeChangeSet) {
|
||||||
ProgressDialog dialog = ProgressImplementation.createProgressDialog(
|
ProgressDialog dialog = ProgressImplementation.createProgressDialog(
|
||||||
getActivity(),
|
getActivity(),
|
||||||
getString(R.string.uploading),
|
getString(R.string.uploading),
|
||||||
|
@ -501,8 +505,8 @@ public class OsmEditsFragment extends OsmAndListFragment {
|
||||||
OsmEditsUploadListener listener = new OsmEditsUploadListenerHelper(getActivity(),
|
OsmEditsUploadListener listener = new OsmEditsUploadListenerHelper(getActivity(),
|
||||||
getString(R.string.local_openstreetmap_were_uploaded));
|
getString(R.string.local_openstreetmap_were_uploaded));
|
||||||
UploadOpenstreetmapPointAsyncTask uploadTask = new UploadOpenstreetmapPointAsyncTask(
|
UploadOpenstreetmapPointAsyncTask uploadTask = new UploadOpenstreetmapPointAsyncTask(
|
||||||
dialog, listener, plugin, remotepoi, remotebug, toUpload.length);
|
dialog, listener, plugin, remotepoi, remotebug, points.length, closeChangeSet);
|
||||||
uploadTask.execute(toUpload);
|
uploadTask.execute(points);
|
||||||
|
|
||||||
dialog.show();
|
dialog.show();
|
||||||
}
|
}
|
||||||
|
@ -676,36 +680,36 @@ public class OsmEditsFragment extends OsmAndListFragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class UploadOsmEditsConfirmDialogFragment extends DialogFragment {
|
// public static class UploadOsmEditsConfirmDialogFragment extends DialogFragment {
|
||||||
public static final String TAG = "UploadOsmEditsConfirmDialogFragment";
|
// public static final String TAG = "UploadOsmEditsConfirmDialogFragment";
|
||||||
private static final String POINTS_ARRAY = "points_list";
|
// private static final String POINTS_ARRAY = "points_list";
|
||||||
|
//
|
||||||
@NonNull
|
// @NonNull
|
||||||
@Override
|
// @Override
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
// public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
final OsmPoint[] points = (OsmPoint[]) getArguments().getSerializable(POINTS_ARRAY);
|
// final OsmPoint[] points = (OsmPoint[]) getArguments().getSerializable(POINTS_ARRAY);
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
// AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||||
builder.setMessage(
|
// builder.setMessage(
|
||||||
getString(R.string.local_osm_changes_upload_all_confirm, points.length));
|
// getString(R.string.local_osm_changes_upload_all_confirm, points.length));
|
||||||
builder.setPositiveButton(R.string.shared_string_yes,
|
// builder.setPositiveButton(R.string.shared_string_yes,
|
||||||
new DialogInterface.OnClickListener() {
|
// new DialogInterface.OnClickListener() {
|
||||||
@Override
|
// @Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
// public void onClick(DialogInterface dialog, int which) {
|
||||||
((OsmEditsFragment) getParentFragment())
|
// ((OsmEditsFragment) getParentFragment())
|
||||||
.showUploadItemsProgressDialog(points);
|
// .showUploadItemsProgressDialog(points);
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
builder.setNegativeButton(R.string.shared_string_cancel, null);
|
// builder.setNegativeButton(R.string.shared_string_cancel, null);
|
||||||
return builder.create();
|
// return builder.create();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public static UploadOsmEditsConfirmDialogFragment createInstance(OsmPoint[] points) {
|
// public static UploadOsmEditsConfirmDialogFragment createInstance(OsmPoint[] points) {
|
||||||
UploadOsmEditsConfirmDialogFragment fragment =
|
// UploadOsmEditsConfirmDialogFragment fragment =
|
||||||
new UploadOsmEditsConfirmDialogFragment();
|
// new UploadOsmEditsConfirmDialogFragment();
|
||||||
Bundle args = new Bundle();
|
// Bundle args = new Bundle();
|
||||||
args.putSerializable(POINTS_ARRAY, points);
|
// args.putSerializable(POINTS_ARRAY, points);
|
||||||
fragment.setArguments(args);
|
// fragment.setArguments(args);
|
||||||
return fragment;
|
// return fragment;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,7 +94,7 @@ public class OsmEditsUploadListenerHelper implements OsmEditsUploadListener {
|
||||||
resources.getString(R.string.local_openstreetmap_uploading),
|
resources.getString(R.string.local_openstreetmap_uploading),
|
||||||
ProgressDialog.STYLE_HORIZONTAL).getDialog();
|
ProgressDialog.STYLE_HORIZONTAL).getDialog();
|
||||||
UploadOpenstreetmapPointAsyncTask uploadTask = new UploadOpenstreetmapPointAsyncTask(
|
UploadOpenstreetmapPointAsyncTask uploadTask = new UploadOpenstreetmapPointAsyncTask(
|
||||||
dialog, helper, plugin, remotepoi, remotebug, toUpload.length);
|
dialog, helper, plugin, remotepoi, remotebug, toUpload.length, false);
|
||||||
uploadTask.execute(toUpload);
|
uploadTask.execute(toUpload);
|
||||||
|
|
||||||
dialog.show();
|
dialog.show();
|
||||||
|
|
|
@ -23,19 +23,22 @@ public class UploadOpenstreetmapPointAsyncTask
|
||||||
private boolean interruptUploading = false;
|
private boolean interruptUploading = false;
|
||||||
private OsmEditsUploadListener listener;
|
private OsmEditsUploadListener listener;
|
||||||
private OsmEditingPlugin plugin;
|
private OsmEditingPlugin plugin;
|
||||||
|
private final boolean closeChangeSet;
|
||||||
|
|
||||||
public UploadOpenstreetmapPointAsyncTask(ProgressDialog progress,
|
public UploadOpenstreetmapPointAsyncTask(ProgressDialog progress,
|
||||||
OsmEditsUploadListener listener,
|
OsmEditsUploadListener listener,
|
||||||
OsmEditingPlugin plugin,
|
OsmEditingPlugin plugin,
|
||||||
OpenstreetmapRemoteUtil remotepoi,
|
OpenstreetmapRemoteUtil remotepoi,
|
||||||
OsmBugsRemoteUtil remotebug,
|
OsmBugsRemoteUtil remotebug,
|
||||||
int listSize) {
|
int listSize,
|
||||||
|
boolean closeChangeSet) {
|
||||||
this.progress = progress;
|
this.progress = progress;
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.remotepoi = remotepoi;
|
this.remotepoi = remotepoi;
|
||||||
this.remotebug = remotebug;
|
this.remotebug = remotebug;
|
||||||
this.listSize = listSize;
|
this.listSize = listSize;
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
|
this.closeChangeSet = closeChangeSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -52,7 +55,8 @@ public class UploadOpenstreetmapPointAsyncTask
|
||||||
if (OsmPoint.Action.CREATE != p.getAction()) {
|
if (OsmPoint.Action.CREATE != p.getAction()) {
|
||||||
entityInfo = remotepoi.loadNode(p.getEntity());
|
entityInfo = remotepoi.loadNode(p.getEntity());
|
||||||
}
|
}
|
||||||
Node n = remotepoi.commitNodeImpl(p.getAction(), p.getEntity(), entityInfo, p.getComment(), false);
|
Node n = remotepoi.commitNodeImpl(p.getAction(), p.getEntity(), entityInfo,
|
||||||
|
p.getComment(), closeChangeSet);
|
||||||
if (n != null) {
|
if (n != null) {
|
||||||
plugin.getDBPOI().deletePOI(p);
|
plugin.getDBPOI().deletePOI(p);
|
||||||
publishProgress(p);
|
publishProgress(p);
|
||||||
|
|
|
@ -7,22 +7,15 @@ 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.widget.CheckBox;
|
|
||||||
import android.widget.EditText;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import net.osmand.access.AccessibleToast;
|
import net.osmand.access.AccessibleToast;
|
||||||
import net.osmand.data.Amenity;
|
|
||||||
import net.osmand.osm.edit.Node;
|
import net.osmand.osm.edit.Node;
|
||||||
import net.osmand.plus.OsmandApplication;
|
|
||||||
import net.osmand.plus.OsmandPlugin;
|
import net.osmand.plus.OsmandPlugin;
|
||||||
import net.osmand.plus.OsmandSettings;
|
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.osmedit.EditPoiFragment;
|
import net.osmand.plus.osmedit.EditPoiFragment;
|
||||||
import net.osmand.plus.osmedit.OpenstreetmapLocalUtil;
|
import net.osmand.plus.osmedit.OpenstreetmapLocalUtil;
|
||||||
import net.osmand.plus.osmedit.OpenstreetmapRemoteUtil;
|
|
||||||
import net.osmand.plus.osmedit.OpenstreetmapUtil;
|
import net.osmand.plus.osmedit.OpenstreetmapUtil;
|
||||||
import net.osmand.plus.osmedit.OsmEditingPlugin;
|
import net.osmand.plus.osmedit.OsmEditingPlugin;
|
||||||
import net.osmand.plus.osmedit.OsmPoint;
|
import net.osmand.plus.osmedit.OsmPoint;
|
||||||
|
@ -38,47 +31,31 @@ public class DeletePoiDialogFragment extends DialogFragment {
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
final Activity activity = getActivity();
|
final Activity activity = getActivity();
|
||||||
|
|
||||||
OsmandSettings settings = ((OsmandApplication) activity.getApplication()).getSettings();
|
|
||||||
OsmEditingPlugin plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
|
OsmEditingPlugin plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
|
||||||
final OpenstreetmapUtil mOpenstreetmapUtil;
|
final OpenstreetmapUtil mOpenstreetmapUtil;
|
||||||
if (settings.OFFLINE_EDITION.get() || !settings.isInternetConnectionAvailable(true)) {
|
mOpenstreetmapUtil = new OpenstreetmapLocalUtil(plugin, activity);
|
||||||
mOpenstreetmapUtil = new OpenstreetmapLocalUtil(plugin, activity);
|
|
||||||
} else if (!settings.isInternetConnectionAvailable(true)) {
|
|
||||||
mOpenstreetmapUtil = new OpenstreetmapLocalUtil(plugin, activity);
|
|
||||||
} else {
|
|
||||||
mOpenstreetmapUtil = new OpenstreetmapRemoteUtil(activity);
|
|
||||||
}
|
|
||||||
|
|
||||||
final Bundle args = getArguments();
|
final Bundle args = getArguments();
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||||
builder.setTitle(R.string.poi_remove_title);
|
builder.setTitle(R.string.poi_remove_title);;
|
||||||
LinearLayout ll = new LinearLayout(activity);
|
|
||||||
ll.setPadding(4, 2, 4, 0);
|
|
||||||
ll.setOrientation(LinearLayout.VERTICAL);
|
|
||||||
final EditText comment = new EditText(activity);
|
|
||||||
comment.setText(R.string.poi_remove_title);
|
|
||||||
ll.addView(comment);
|
|
||||||
final CheckBox closeChangeset;
|
|
||||||
closeChangeset = new CheckBox(activity);
|
|
||||||
closeChangeset.setText(R.string.close_changeset);
|
|
||||||
ll.addView(closeChangeset);
|
|
||||||
builder.setView(ll);
|
|
||||||
builder.setNegativeButton(R.string.shared_string_cancel, null);
|
builder.setNegativeButton(R.string.shared_string_cancel, null);
|
||||||
builder.setPositiveButton(R.string.shared_string_delete, new DialogInterface.OnClickListener() {
|
builder.setPositiveButton(R.string.shared_string_delete, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
Node n = (Node) args.getSerializable(KEY_AMENITY_NODE);
|
Node node = (Node) args.getSerializable(KEY_AMENITY_NODE);
|
||||||
String c = comment.getText().toString();
|
EditPoiFragment.commitNode(OsmPoint.Action.DELETE, node,
|
||||||
EditPoiFragment.commitNode(OsmPoint.Action.DELETE, n, mOpenstreetmapUtil.getEntityInfo(), c,
|
mOpenstreetmapUtil.getEntityInfo(), null, false,
|
||||||
closeChangeset == null ? false : closeChangeset.isSelected(), new Runnable() {
|
new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
AccessibleToast.makeText(activity, R.string.poi_remove_success, Toast.LENGTH_LONG).show();
|
AccessibleToast.makeText(activity, R.string.poi_remove_success,
|
||||||
|
Toast.LENGTH_LONG).show();
|
||||||
if (activity instanceof MapActivity) {
|
if (activity instanceof MapActivity) {
|
||||||
((MapActivity) activity).getMapView().refreshMap(true);
|
((MapActivity) activity).getMapView().refreshMap(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, getActivity(), mOpenstreetmapUtil);
|
},
|
||||||
|
getActivity(), mOpenstreetmapUtil);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return builder.create();
|
return builder.create();
|
||||||
|
|
|
@ -0,0 +1,75 @@
|
||||||
|
package net.osmand.plus.osmedit.dialogs;
|
||||||
|
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.v4.app.DialogFragment;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.CheckBox;
|
||||||
|
import android.widget.EditText;
|
||||||
|
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
import net.osmand.plus.OsmandSettings;
|
||||||
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.osmedit.OpenstreetmapPoint;
|
||||||
|
import net.osmand.plus.osmedit.OsmPoint;
|
||||||
|
|
||||||
|
public class SendPoiDialogFragment extends DialogFragment {
|
||||||
|
public static final String TAG = "SendPoiDialogFragment";
|
||||||
|
public static final String OPENSTREETMAP_POINT = "openstreetmap_point";
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
|
final OsmPoint[] poi = (OsmPoint[]) getArguments().getSerializable(OPENSTREETMAP_POINT);
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||||
|
View view = getActivity().getLayoutInflater().inflate(R.layout.send_poi_dialog, null);
|
||||||
|
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);
|
||||||
|
final CheckBox closeChangeSetCheckBox =
|
||||||
|
(CheckBox) view.findViewById(R.id.closeChangeSetCheckBox);
|
||||||
|
final OsmandSettings settings = ((OsmandApplication) getActivity().getApplication())
|
||||||
|
.getSettings();
|
||||||
|
userNameEditText.setText(settings.USER_NAME.get());
|
||||||
|
passwordEditText.setText(settings.USER_PASSWORD.get());
|
||||||
|
|
||||||
|
final ProgressDialogPoiUploader progressDialogPoiUploader =
|
||||||
|
(ProgressDialogPoiUploader) getParentFragment();
|
||||||
|
|
||||||
|
builder.setTitle(R.string.commit_poi)
|
||||||
|
.setView(view)
|
||||||
|
.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
settings.USER_NAME.set(userNameEditText.getText().toString());
|
||||||
|
settings.USER_PASSWORD.set(passwordEditText.getText().toString());
|
||||||
|
for (OsmPoint osmPoint : poi) {
|
||||||
|
if (osmPoint.getGroup() == OsmPoint.Group.POI) {
|
||||||
|
((OpenstreetmapPoint) osmPoint)
|
||||||
|
.setComment(messageEditText.getText().toString());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
progressDialogPoiUploader.showProgressDialog(poi,
|
||||||
|
closeChangeSetCheckBox.isChecked());
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setNegativeButton(R.string.shared_string_cancel, null);
|
||||||
|
return builder.create();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SendPoiDialogFragment createInstance(OsmPoint[] points) {
|
||||||
|
SendPoiDialogFragment fragment = new SendPoiDialogFragment();
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putSerializable(OPENSTREETMAP_POINT, points);
|
||||||
|
fragment.setArguments(bundle);
|
||||||
|
return fragment;
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface ProgressDialogPoiUploader {
|
||||||
|
void showProgressDialog(OsmPoint[] points, boolean closeChangeSet);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue