diff --git a/OsmAnd/res/layout/fragment_edit_poi_advanced.xml b/OsmAnd/res/layout/fragment_edit_poi_advanced.xml index 9c4b2e9bf5..c9109e4217 100644 --- a/OsmAnd/res/layout/fragment_edit_poi_advanced.xml +++ b/OsmAnd/res/layout/fragment_edit_poi_advanced.xml @@ -32,6 +32,7 @@ android:layout_marginLeft="16dp" android:layout_marginRight="16dp" android:text="name" + android:textColor="@color/dashboard_black" android:textSize="14sp" osmand:typeface="@string/font_roboto_regular"/> @@ -46,6 +47,7 @@ android:layout_height="wrap_content" android:layout_marginLeft="16dp" android:layout_marginRight="16dp" + android:textColor="@color/dashboard_black" android:textSize="14sp" osmand:typeface="@string/font_roboto_medium"/> @@ -67,6 +69,7 @@ android:layout_marginLeft="16dp" android:layout_marginRight="16dp" android:text="amenity" + android:textColor="@color/dashboard_black" android:textSize="14sp" osmand:typeface="@string/font_roboto_regular"/> @@ -81,6 +84,7 @@ android:layout_height="wrap_content" android:layout_marginLeft="16dp" android:layout_marginRight="16dp" + android:textColor="@color/dashboard_black" android:textSize="14sp" osmand:typeface="@string/font_roboto_medium"/> @@ -93,12 +97,12 @@ android:orientation="vertical" android:saveEnabled="false"/> - - diff --git a/OsmAnd/res/layout/fragment_edit_poi_normal.xml b/OsmAnd/res/layout/fragment_edit_poi_normal.xml index 21039f941b..ef38599adb 100644 --- a/OsmAnd/res/layout/fragment_edit_poi_normal.xml +++ b/OsmAnd/res/layout/fragment_edit_poi_normal.xml @@ -93,9 +93,10 @@ android:layout_height="wrap_content" android:layout_below="@id/descriptionEditText" android:layout_marginLeft="16dp" + android:layout_marginTop="18dp" android:text="Open hours" android:textColor="@color/color_black" - osmand:typeface="@string/font_roboto_medium" /> + osmand:typeface="@string/font_roboto_medium"/> + + + android:layout_height="500dp" + tools:visibility="gone"/> \ No newline at end of file diff --git a/OsmAnd/res/layout/open_time_list_item.xml b/OsmAnd/res/layout/open_time_list_item.xml index c0bf33deb3..aa58741f9a 100644 --- a/OsmAnd/res/layout/open_time_list_item.xml +++ b/OsmAnd/res/layout/open_time_list_item.xml @@ -9,16 +9,15 @@ diff --git a/OsmAnd/res/layout/poi_tag_list_item.xml b/OsmAnd/res/layout/poi_tag_list_item.xml index ad8c2b878a..86fa1193ff 100644 --- a/OsmAnd/res/layout/poi_tag_list_item.xml +++ b/OsmAnd/res/layout/poi_tag_list_item.xml @@ -4,55 +4,42 @@ xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" - android:orientation="vertical"> + android:orientation="horizontal" + android:paddingTop="16dp"> - + android:layout_marginLeft="16dp" + android:layout_marginRight="16dp" + android:layout_weight="1"> - + android:hint="Tag"/> - + - + - + android:hint="Value"/> - + - - - - - - - + \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index e54718397e..9e63f8a53b 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -10,6 +10,7 @@ import net.londatiga.android.ActionItem; import net.londatiga.android.QuickAction; import net.osmand.IndexConstants; import net.osmand.Location; +import net.osmand.PlatformUtil; import net.osmand.access.AccessibleAlertBuilder; import net.osmand.access.AccessibleToast; import net.osmand.data.LatLon; @@ -58,8 +59,10 @@ import android.widget.EditText; import android.widget.TextView; import android.widget.Toast; +import org.apache.commons.logging.Log; + public class MapActivityActions implements DialogProvider { - + private static final Log LOG = PlatformUtil.getLog(MapActivityActions.class); public static final String KEY_LONGITUDE = "longitude"; public static final String KEY_LATITUDE = "latitude"; public static final String KEY_NAME = "name"; @@ -283,7 +286,7 @@ public class MapActivityActions implements DialogProvider { R.drawable.ic_action_fav_dark).reg(); - + LOG.debug("contextMenuPoint()"); OsmandPlugin.registerMapContextMenu(mapActivity, latitude, longitude, adapter, selectedObj); getMyApplication().getAppCustomization().prepareLocationMenu(mapActivity, adapter); diff --git a/OsmAnd/src/net/osmand/plus/osmedit/AdvancedDataFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/AdvancedDataFragment.java index 84a73e7885..7f9845f27c 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/AdvancedDataFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/AdvancedDataFragment.java @@ -49,23 +49,10 @@ public class AdvancedDataFragment extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.fragment_edit_poi_advanced, container, false); - final EditText tagEditText = (EditText) view.findViewById(R.id.tagEditText); - final EditText valueEditText = (EditText) view.findViewById(R.id.valueEditText); - ImageButton deleteItemImageButton = - (ImageButton) view.findViewById(R.id.deleteItemImageButton); - deleteItemImageButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - tagEditText.setText(null); - tagEditText.clearFocus(); - valueEditText.setText(null); - valueEditText.clearFocus(); - } - }); deleteDrawable = ((MapActivity)getActivity()).getMyApplication().getIconsCache() - .getPaintedContentIcon(R.drawable.ic_action_remove_dark, R.color.icon_color_light); - deleteItemImageButton.setImageDrawable(deleteDrawable); + .getPaintedContentIcon(R.drawable.ic_action_remove_dark, + getActivity().getResources().getColor(R.color.icon_color_light)); TextView nameTextView = (TextView) view.findViewById(R.id.nameTextView); TextView amenityTagTextView = (TextView) view.findViewById(R.id.amenityTagTextView); TextView amenityTextView = (TextView) view.findViewById(R.id.amenityTextView); @@ -79,16 +66,7 @@ public class AdvancedDataFragment extends Fragment { addTagButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - String tag = String.valueOf(tagEditText.getText()); - String value = String.valueOf(valueEditText.getText()); - if (!TextUtils.isEmpty(tag) && !TextUtils.isEmpty(value)) { - mAdapter.addTag(new Tag(tag, value)); -// setListViewHeightBasedOnChildren(editTagsLineaLayout); - tagEditText.setText(null); - tagEditText.clearFocus(); - valueEditText.setText(null); - valueEditText.clearFocus(); - } + mAdapter.addTag(new Tag("", "")); } }); return view; @@ -145,11 +123,10 @@ public class AdvancedDataFragment extends Fragment { } public void addTag(Tag tag) { - View view = getView(tag); editPoiData.tags.add(tag); if (mIsUserInput) editPoiData.notifyDatasetChanged(mTagsChangedListener); - linearLayout.addView(view); + updateViews(); } public void updateViews() { diff --git a/OsmAnd/src/net/osmand/plus/osmedit/BasicDataFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/BasicDataFragment.java index 6322109aa5..15382822a1 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/BasicDataFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/BasicDataFragment.java @@ -65,6 +65,8 @@ public class BasicDataFragment extends Fragment { webSiteImageView.setImageDrawable(iconsCache.getContentIcon(R.drawable.ic_world_globe_dark)); ImageView descriptionImageView = (ImageView) view.findViewById(R.id.descriptionImageView); descriptionImageView.setImageDrawable(iconsCache.getContentIcon(R.drawable.ic_action_description)); + ImageView openingHoursImageView = (ImageView) view.findViewById(R.id.openingHoursImageView); + openingHoursImageView.setImageDrawable(iconsCache.getContentIcon(R.drawable.ic_action_time)); streetEditText = (EditText) view.findViewById(R.id.streetEditText); streetEditText.addTextChangedListener(new MyOnFocusChangeListener(getData(), diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiFragment.java index b1e96186ed..0227d1e8cf 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiFragment.java @@ -16,6 +16,7 @@ import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.view.ViewCompat; import android.support.v4.view.ViewPager; +import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.text.Editable; import android.text.TextWatcher; @@ -44,6 +45,7 @@ import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.osmedit.data.EditPoiData; import net.osmand.plus.osmedit.data.Tag; +import net.osmand.plus.osmedit.dialogs.DeletePoiDialogFragment; import net.osmand.plus.osmedit.dialogs.PoiSubTypeDialogFragment; import net.osmand.plus.osmedit.dialogs.PoiTypeDialogFragment; import net.osmand.util.Algorithms; @@ -73,7 +75,7 @@ public class EditPoiFragment extends Fragment { private Node node; private Map allTranslatedSubTypes; public static final String POI_TYPE_TAG = "poi_type_tag"; - private OpenstreetmapUtil openstreetmapUtil; + private OpenstreetmapUtil mOpenstreetmapUtil; private TextInputLayout poiTypeTextInputLayout; @Override @@ -83,17 +85,17 @@ public class EditPoiFragment extends Fragment { // allTranslatedSubTypes = poiTypes.getAllTranslatedNames(); OsmandSettings settings = ((OsmandApplication) activity.getApplication()).getSettings(); // editPoiData.isLocalEdit = true; - OsmEditingPlugin plugin = (OsmEditingPlugin) OsmandPlugin.getPlugin(OsmEditingPlugin.class); + OsmEditingPlugin plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class); if (settings.OFFLINE_EDITION.get() || !settings.isInternetConnectionAvailable(true)) { - openstreetmapUtil = new OpenstreetmapLocalUtil(plugin, activity); -// openstreetmapUtilToLoad = openstreetmapUtil; + mOpenstreetmapUtil = new OpenstreetmapLocalUtil(plugin, activity); +// openstreetmapUtilToLoad = mOpenstreetmapUtil; } else if (!settings.isInternetConnectionAvailable(true)) { - openstreetmapUtil = new OpenstreetmapLocalUtil(plugin, activity); + mOpenstreetmapUtil = new OpenstreetmapLocalUtil(plugin, activity); // openstreetmapUtilToLoad = new OpenstreetmapRemoteUtil(activity); } else { isLocalEdit = false; - openstreetmapUtil = new OpenstreetmapRemoteUtil(activity); -// openstreetmapUtilToLoad = openstreetmapUtil; + mOpenstreetmapUtil = new OpenstreetmapRemoteUtil(activity); +// openstreetmapUtilToLoad = mOpenstreetmapUtil; } node = (Node) getArguments().getSerializable(KEY_AMENITY_NODE); @@ -215,7 +217,7 @@ public class EditPoiFragment extends Fragment { poiTypeEditText.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - if(poiTypeEditText.getText().length() == 0 && editPoiData.amenity.getType() != null){ + if (poiTypeEditText.getText().length() == 0 && editPoiData.amenity.getType() != null) { DialogFragment dialogFragment = PoiSubTypeDialogFragment.createInstance(editPoiData.amenity); dialogFragment.show(getChildFragmentManager(), "PoiSubTypeDialogFragment"); @@ -254,7 +256,7 @@ public class EditPoiFragment extends Fragment { } } } - commitNode(action, node, openstreetmapUtil.getEntityInfo(), + commitNode(action, node, mOpenstreetmapUtil.getEntityInfo(), "", false,//closeChange.isSelected(), new Runnable() { @@ -286,7 +288,7 @@ public class EditPoiFragment extends Fragment { .commit(); fragmentManager.popBackStack(); } - }, getActivity()); + }, getActivity(), mOpenstreetmapUtil); } }); @@ -337,13 +339,15 @@ public class EditPoiFragment extends Fragment { poiTypeEditText.setText(subCategory); } - public void commitNode(final OsmPoint.Action action, - final Node n, - final EntityInfo info, - final String comment, - final boolean closeChangeSet, - final Runnable successAction, - final Activity activity) { + // TODO: 8/28/15 Move to some king of helper class + public static void commitNode(final OsmPoint.Action action, + final Node n, + final EntityInfo info, + final String comment, + final boolean closeChangeSet, + final Runnable successAction, + final Activity activity, + final 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; @@ -409,12 +413,12 @@ public class EditPoiFragment extends Fragment { } public static void showEditInstance(final Amenity amenity, OsmandSettings settings, - final MapActivity mapActivity) { + final MapActivity mapActivity) { final OpenstreetmapUtil openstreetmapUtilToLoad; if (settings.OFFLINE_EDITION.get() || !settings.isInternetConnectionAvailable(true)) { OsmEditingPlugin plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class); openstreetmapUtilToLoad = new OpenstreetmapLocalUtil(plugin, mapActivity); - } else if(!settings.isInternetConnectionAvailable(true)) { + } else if (!settings.isInternetConnectionAvailable(true)) { openstreetmapUtilToLoad = new OpenstreetmapRemoteUtil(mapActivity); } else { openstreetmapUtilToLoad = new OpenstreetmapRemoteUtil(mapActivity); @@ -427,7 +431,7 @@ public class EditPoiFragment extends Fragment { } protected void onPostExecute(Node n) { - if(n != null){ + if (n != null) { EditPoiFragment fragment = EditPoiFragment.createInstance(n, (Amenity) amenity); mapActivity.getSupportFragmentManager().beginTransaction() @@ -437,7 +441,9 @@ public class EditPoiFragment extends Fragment { mapActivity.getString(R.string.poi_error_poi_not_found), Toast.LENGTH_SHORT).show(); } - }; + } + + ; }.execute(new Void[0]); } @@ -445,6 +451,7 @@ public class EditPoiFragment extends Fragment { public static class MyAdapter extends FragmentPagerAdapter { private final String basicTitle; private final String extendedTitle; + public MyAdapter(FragmentManager fm, String basicTitle, String extendedTitle) { super(fm); this.basicTitle = basicTitle; @@ -479,4 +486,35 @@ public class EditPoiFragment extends Fragment { throw new IllegalArgumentException("Unexpected position"); } } + + // TODO: 8/28/15 Move to helper + public static class ShowDeleteDialogAsyncTask extends AsyncTask { + private final OpenstreetmapUtil openstreetmapUtil; + private final AppCompatActivity activity; + public ShowDeleteDialogAsyncTask(AppCompatActivity activity) { + this.activity = activity; + OsmandSettings settings = ((OsmandApplication) activity.getApplication()).getSettings(); + OsmEditingPlugin plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class); + if (settings.OFFLINE_EDITION.get() || !settings.isInternetConnectionAvailable(true)) { + openstreetmapUtil = new OpenstreetmapLocalUtil(plugin, activity); + } else if (!settings.isInternetConnectionAvailable(true)) { + openstreetmapUtil = new OpenstreetmapLocalUtil(plugin, activity); + } else { + openstreetmapUtil = new OpenstreetmapRemoteUtil(activity); + } + } + + protected Node doInBackground(Amenity[] params) { + return openstreetmapUtil.loadNode(params[0]); + }; + + protected void onPostExecute(Node n) { + if(n == null){ + AccessibleToast.makeText(activity, activity.getResources().getString(R.string.poi_error_poi_not_found), Toast.LENGTH_LONG).show(); + return; + } + DeletePoiDialogFragment.createInstance(n).show(activity.getSupportFragmentManager(), + "DeletePoiDialogFragment"); + }; +} } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java index 56dbd43af1..289554c5ab 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java @@ -15,6 +15,7 @@ import android.widget.EditText; import android.widget.Spinner; import android.widget.Toast; +import net.osmand.PlatformUtil; import net.osmand.access.AccessibleToast; import net.osmand.data.Amenity; import net.osmand.plus.ContextMenuAdapter; @@ -35,6 +36,8 @@ import net.osmand.plus.myplaces.FavoritesActivity; import net.osmand.plus.views.OsmandMapTileView; import net.osmand.util.Algorithms; +import org.apache.commons.logging.Log; + import java.util.List; @@ -163,10 +166,12 @@ public class OsmEditingPlugin extends OsmandPlugin { registerLayers(mapActivity); } osmBugsLayer.openBug(latitude, longitude); - } //else if (resId == R.string.poi_context_menu_delete) { + } else if (resId == R.string.poi_context_menu_delete) { + new EditPoiFragment.ShowDeleteDialogAsyncTask(mapActivity) + .execute((Amenity) selectedObj); // TODO implement delete // getPoiActions(mapActivity).showDeleteDialog((Amenity) selectedObj); -// } else if (resId == R.string.poi_context_menu_modify) { + }//} else if (resId == R.string.poi_context_menu_modify) { // TODO implement edit // getPoiActions(mapActivity).showEditDialog((Amenity) selectedObj); // } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/data/Tag.java b/OsmAnd/src/net/osmand/plus/osmedit/data/Tag.java index 292dce865e..9fa98c83f5 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/data/Tag.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/data/Tag.java @@ -1,8 +1,13 @@ package net.osmand.plus.osmedit.data; +import net.osmand.PlatformUtil; + +import org.apache.commons.logging.Log; + import java.io.Serializable; public class Tag implements Serializable { + private static final Log LOG = PlatformUtil.getLog(Tag.class); public String tag; public String value; @@ -16,6 +21,7 @@ public class Tag implements Serializable { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Tag tag1 = (Tag) o; + LOG.debug("this=" + this + "; that=" + tag1); return tag.equals(tag1.tag); } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/DeletePoiDialogFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/DeletePoiDialogFragment.java new file mode 100644 index 0000000000..bb960ebf93 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/DeletePoiDialogFragment.java @@ -0,0 +1,94 @@ +package net.osmand.plus.osmedit.dialogs; + +import android.app.Activity; +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.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; + +/** + * Created by GaidamakUA on 8/28/15. + */ +public class DeletePoiDialogFragment extends DialogFragment { + private static final String KEY_AMENITY_NODE = "amenity_node"; + + @NonNull + @Override + 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); + } + + 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.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() { + @Override + public void run() { + AccessibleToast.makeText(activity, R.string.poi_remove_success, Toast.LENGTH_LONG).show(); + if (activity instanceof MapActivity) { + ((MapActivity) activity).getMapView().refreshMap(true); + } + } + }, getActivity(), mOpenstreetmapUtil); + } + }); + return builder.create(); + } + + public static DeletePoiDialogFragment createInstance(Node amenityNode) { + DeletePoiDialogFragment fragment = new DeletePoiDialogFragment(); + Bundle bundle = new Bundle(); + bundle.putSerializable(KEY_AMENITY_NODE, amenityNode); + fragment.setArguments(bundle); + return fragment; + } +}