Poi bugs fix

This commit is contained in:
GaidamakUA 2015-11-05 10:27:13 +02:00
parent 34f1fd373c
commit 0c5d0f4902
3 changed files with 22 additions and 9 deletions

View file

@ -20,6 +20,7 @@ import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import net.osmand.PlatformUtil;
import net.osmand.osm.edit.OSMSettings;
import net.osmand.plus.IconsCache;
@ -229,8 +230,13 @@ public class BasicEditPoiFragment extends Fragment
linearLayout.addView(getView(i));
}
if (!data.isInEdit()) {
String openingHoursString = openingHours.toStringNoMonths();
if (!TextUtils.isEmpty(openingHoursString)) {
data.putTag(OSMSettings.OSMTagKey.OPENING_HOURS.getValue(),
openingHours.toStringNoMonths());
openingHoursString);
} else {
data.removeTag(OSMSettings.OSMTagKey.OPENING_HOURS.getValue());
}
}
}

View file

@ -1,11 +1,14 @@
package net.osmand.plus.osmedit;
import net.osmand.PlatformUtil;
import net.osmand.data.Amenity;
import net.osmand.osm.PoiType;
import net.osmand.osm.edit.Node;
import net.osmand.osm.edit.OSMSettings;
import net.osmand.util.Algorithms;
import org.apache.commons.logging.Log;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashMap;
@ -13,6 +16,7 @@ import java.util.Map;
import java.util.Set;
public class EditPoiData {
private static final Log LOG = PlatformUtil.getLog(EditPoiData.class);
private Set<TagsChangedListener> mListeners = new HashSet<>();
private LinkedHashMap<String, String > tagValues = new LinkedHashMap<String, String>();
private boolean isInEdit = false;
@ -46,8 +50,8 @@ public class EditPoiData {
amenity.getPhone());
tryAddTag(OSMSettings.OSMTagKey.WEBSITE.getValue(),
amenity.getSite());
for (String tag : node.getTagKeySet()) {
tryAddTag(tag, node.getTag(tag));
for (String tag : amenity.getAdditionalInfo().keySet()) {
tryAddTag(tag, amenity.getAdditionalInfo(tag));
}
String subType = amenity.getSubType();
String key;

View file

@ -216,7 +216,12 @@ public class EditPoiDialogFragment extends DialogFragment {
@Override
public void afterTextChanged(Editable s) {
if (!getEditPoiData().isInEdit()) {
getEditPoiData().putTag(OSMSettings.OSMTagKey.NAME.getValue(), s.toString());
if (!TextUtils.isEmpty(s)) {
getEditPoiData().putTag(OSMSettings.OSMTagKey.NAME.getValue(),
s.toString());
} else {
getEditPoiData().removeTag(OSMSettings.OSMTagKey.NAME.getValue());
}
}
}
});
@ -244,8 +249,7 @@ public class EditPoiDialogFragment extends DialogFragment {
poiTypeEditText.setText(editPoiData.amenity.getSubType());
Button saveButton = (Button) view.findViewById(R.id.saveButton);
int saveButtonTextId = R.string.default_buttons_commit;
saveButton.setText(saveButtonTextId);
saveButton.setText(R.string.shared_string_save);
saveButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -333,8 +337,7 @@ public class EditPoiDialogFragment extends DialogFragment {
getDialog().setOnKeyListener(new DialogInterface.OnKeyListener() {
@Override
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
if (keyCode == android.view.KeyEvent.KEYCODE_BACK
&& editPoiData.hasChangesBeenMade()) {
if (keyCode == android.view.KeyEvent.KEYCODE_BACK) {
if (event.getAction() == KeyEvent.ACTION_DOWN) {
return true;
} else {