From 9595b25fc6397e6684e2175117d9c23670951b4d Mon Sep 17 00:00:00 2001 From: GaidamakUA Date: Mon, 7 Sep 2015 13:55:08 +0300 Subject: [PATCH] work in progress --- .../plus/osmedit/DashOsmEditsFragment.java | 50 +------------- .../dialogs/SendPoiDialogFragment.java | 69 +++++++++++++++++++ 2 files changed, 70 insertions(+), 49 deletions(-) create mode 100644 OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendPoiDialogFragment.java diff --git a/OsmAnd/src/net/osmand/plus/osmedit/DashOsmEditsFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/DashOsmEditsFragment.java index 653b6f1707..6a0e3bbe8a 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/DashOsmEditsFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/DashOsmEditsFragment.java @@ -1,29 +1,24 @@ package net.osmand.plus.osmedit; import android.app.AlertDialog; -import android.app.Dialog; import android.app.ProgressDialog; import android.content.DialogInterface; import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.v4.app.DialogFragment; 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 net.osmand.data.PointDescription; import net.osmand.plus.OsmandPlugin; -import net.osmand.plus.OsmandSettings; import net.osmand.plus.ProgressImplementation; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.dashboard.DashBaseFragment; +import net.osmand.plus.osmedit.dialogs.SendPoiDialogFragment; import java.util.ArrayList; import java.util.List; @@ -201,47 +196,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 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()); - 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, - closeChangeSetCheckBox.isChecked()); - } - }) - .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; - } - } } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendPoiDialogFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendPoiDialogFragment.java new file mode 100644 index 0000000000..499500bb4e --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendPoiDialogFragment.java @@ -0,0 +1,69 @@ +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.OsmandSettings; +import net.osmand.plus.R; +import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.osmedit.DashOsmEditsFragment; +import net.osmand.plus.osmedit.OpenstreetmapPoint; +import net.osmand.plus.osmedit.OsmPoint; + +/** + * Created by GaidamakUA on 9/7/15. + */ +public class SendPoiDialogFragment extends DialogFragment { + public static final String OPENSTREETMAP_POINT = "openstreetmap_point"; + + @NonNull + @Override + public Dialog onCreateDialog(Bundle savedInstanceState) { + + final OsmPoint 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()); + 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()); + ((ProgressDialogPoiUploader) getParentFragment()).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; + } + + interface ProgressDialogPoiUploader { + void showProgressDialog(OsmPoint[] points, boolean closeChangeSet); + } +}