Delete dialog redesign in progress. Values are not deleted from local DB.
This commit is contained in:
parent
3a1c66c439
commit
aef0ba075e
6 changed files with 104 additions and 56 deletions
|
@ -5,46 +5,52 @@
|
|||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_height="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
|
||||
android:id="@+id/messageEditText"
|
||||
android:minLines="1"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginRight="5dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="fill_parent"
|
||||
android:inputType="textMultiLine" />
|
||||
android:inputType="textMultiLine"
|
||||
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"/>
|
||||
|
||||
<TextView
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_height="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
|
||||
android:id="@+id/userNameEditText"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginRight="5dp"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="fill_parent" />
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginRight="5dp"/>
|
||||
|
||||
|
||||
<TextView
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_height="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
|
||||
android:id="@+id/passwordEditText"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginRight="5dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="fill_parent"
|
||||
android:inputType="textPassword" />
|
||||
android:inputType="textPassword"/>
|
||||
</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_action_add">add</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_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>
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
package net.osmand.plus.osmedit;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
|
@ -11,12 +13,16 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import net.osmand.access.AccessibleToast;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.osm.edit.EntityInfo;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.ProgressImplementation;
|
||||
|
@ -24,6 +30,7 @@ import net.osmand.plus.R;
|
|||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.dashboard.DashBaseFragment;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -205,13 +212,15 @@ public class DashOsmEditsFragment extends DashBaseFragment {
|
|||
@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 CheckBox closeChangeSetCheckBox =
|
||||
(CheckBox) view.findViewById(R.id.closeChangeSetCheckBox);
|
||||
final OsmandSettings settings = ((MapActivity) getActivity()).getMyApplication().getSettings();
|
||||
userNameEditText.setText(settings.USER_NAME.get());
|
||||
passwordEditText.setText(settings.USER_PASSWORD.get());
|
||||
|
@ -220,10 +229,61 @@ public class DashOsmEditsFragment extends DashBaseFragment {
|
|||
.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
final OpenstreetmapRemoteUtil openstreetmapRemoteUtil
|
||||
= new OpenstreetmapRemoteUtil(getActivity());
|
||||
settings.USER_NAME.set(userNameEditText.getText().toString());
|
||||
settings.USER_PASSWORD.set(passwordEditText.getText().toString());
|
||||
poi.setComment(messageEditText.getText().toString());
|
||||
((DashOsmEditsFragment) getParentFragment()).showProgressDialog(poi);
|
||||
final String message = messageEditText.getText().toString();
|
||||
final boolean closeChangeSet = closeChangeSetCheckBox.isChecked();
|
||||
final Activity activity = getActivity();
|
||||
int actionTypeMessageId = -1;
|
||||
switch (poi.getAction()) {
|
||||
case CREATE: actionTypeMessageId = R.string.poi_action_add;
|
||||
break;
|
||||
case MODIFY: actionTypeMessageId = R.string.poi_action_change;
|
||||
break;
|
||||
case DELETE: actionTypeMessageId = R.string.poi_action_delete;
|
||||
break;
|
||||
}
|
||||
final String resultMessage =
|
||||
getResources().getString(actionTypeMessageId);
|
||||
final String successTemplate = getResources().getString(
|
||||
R.string.poi_action_succeded_template);
|
||||
|
||||
new AsyncTask<Void, Void, EntityInfo>() {
|
||||
|
||||
@Override
|
||||
protected EntityInfo doInBackground(Void... params) {
|
||||
return openstreetmapRemoteUtil.loadNode(poi.getEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(EntityInfo entityInfo) {
|
||||
EditPoiFragment.commitNode(poi.getAction(), poi.getEntity(),
|
||||
entityInfo,
|
||||
message,
|
||||
closeChangeSet,
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
AccessibleToast.makeText(
|
||||
activity,
|
||||
MessageFormat.format(
|
||||
successTemplate,
|
||||
resultMessage),
|
||||
Toast.LENGTH_LONG).show();
|
||||
|
||||
if (activity instanceof MapActivity) {
|
||||
((MapActivity) activity)
|
||||
.getMapView().refreshMap(true);
|
||||
}
|
||||
}
|
||||
},
|
||||
activity, openstreetmapRemoteUtil);
|
||||
}
|
||||
}.execute();
|
||||
// poi.setComment(messageEditText.getText().toString());
|
||||
// ((DashOsmEditsFragment) getParentFragment()).showProgressDialog(poi);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.shared_string_cancel, null);
|
||||
|
|
|
@ -419,7 +419,12 @@ public class EditPoiFragment extends DialogFragment {
|
|||
final Runnable successAction,
|
||||
final Activity activity,
|
||||
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) {
|
||||
|
||||
AccessibleToast.makeText(activity, activity.getResources().getString(R.string.poi_error_info_not_loaded), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -13,5 +13,4 @@ public interface OpenstreetmapUtil {
|
|||
public void closeChangeSet();
|
||||
|
||||
public Node loadNode(Amenity n);
|
||||
|
||||
}
|
||||
|
|
|
@ -7,22 +7,15 @@ import android.os.Bundle;
|
|||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Toast;
|
||||
|
||||
import net.osmand.access.AccessibleToast;
|
||||
import net.osmand.data.Amenity;
|
||||
import net.osmand.osm.edit.Node;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.osmedit.EditPoiFragment;
|
||||
import net.osmand.plus.osmedit.OpenstreetmapLocalUtil;
|
||||
import net.osmand.plus.osmedit.OpenstreetmapRemoteUtil;
|
||||
import net.osmand.plus.osmedit.OpenstreetmapUtil;
|
||||
import net.osmand.plus.osmedit.OsmEditingPlugin;
|
||||
import net.osmand.plus.osmedit.OsmPoint;
|
||||
|
@ -38,47 +31,31 @@ public class DeletePoiDialogFragment extends DialogFragment {
|
|||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
final Activity activity = getActivity();
|
||||
|
||||
OsmandSettings settings = ((OsmandApplication) activity.getApplication()).getSettings();
|
||||
OsmEditingPlugin plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
|
||||
final OpenstreetmapUtil mOpenstreetmapUtil;
|
||||
if (settings.OFFLINE_EDITION.get() || !settings.isInternetConnectionAvailable(true)) {
|
||||
mOpenstreetmapUtil = new OpenstreetmapLocalUtil(plugin, activity);
|
||||
} else if (!settings.isInternetConnectionAvailable(true)) {
|
||||
mOpenstreetmapUtil = new OpenstreetmapLocalUtil(plugin, activity);
|
||||
} else {
|
||||
mOpenstreetmapUtil = new OpenstreetmapRemoteUtil(activity);
|
||||
}
|
||||
mOpenstreetmapUtil = new OpenstreetmapLocalUtil(plugin, activity);
|
||||
|
||||
final Bundle args = getArguments();
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||
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.setTitle(R.string.poi_remove_title);;
|
||||
builder.setNegativeButton(R.string.shared_string_cancel, null);
|
||||
builder.setPositiveButton(R.string.shared_string_delete, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Node n = (Node) args.getSerializable(KEY_AMENITY_NODE);
|
||||
String c = comment.getText().toString();
|
||||
EditPoiFragment.commitNode(OsmPoint.Action.DELETE, n, mOpenstreetmapUtil.getEntityInfo(), c,
|
||||
closeChangeset == null ? false : closeChangeset.isSelected(), new Runnable() {
|
||||
Node node = (Node) args.getSerializable(KEY_AMENITY_NODE);
|
||||
EditPoiFragment.commitNode(OsmPoint.Action.DELETE, node,
|
||||
mOpenstreetmapUtil.getEntityInfo(), null, false,
|
||||
new Runnable() {
|
||||
@Override
|
||||
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) {
|
||||
((MapActivity) activity).getMapView().refreshMap(true);
|
||||
}
|
||||
}
|
||||
}, getActivity(), mOpenstreetmapUtil);
|
||||
},
|
||||
getActivity(), mOpenstreetmapUtil);
|
||||
}
|
||||
});
|
||||
return builder.create();
|
||||
|
|
Loading…
Reference in a new issue