Poi bugs fix
This commit is contained in:
parent
34f1fd373c
commit
0c5d0f4902
3 changed files with 22 additions and 9 deletions
|
@ -20,6 +20,7 @@ import android.widget.ImageButton;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.osm.edit.OSMSettings;
|
import net.osmand.osm.edit.OSMSettings;
|
||||||
import net.osmand.plus.IconsCache;
|
import net.osmand.plus.IconsCache;
|
||||||
|
@ -229,8 +230,13 @@ public class BasicEditPoiFragment extends Fragment
|
||||||
linearLayout.addView(getView(i));
|
linearLayout.addView(getView(i));
|
||||||
}
|
}
|
||||||
if (!data.isInEdit()) {
|
if (!data.isInEdit()) {
|
||||||
|
String openingHoursString = openingHours.toStringNoMonths();
|
||||||
|
if (!TextUtils.isEmpty(openingHoursString)) {
|
||||||
data.putTag(OSMSettings.OSMTagKey.OPENING_HOURS.getValue(),
|
data.putTag(OSMSettings.OSMTagKey.OPENING_HOURS.getValue(),
|
||||||
openingHours.toStringNoMonths());
|
openingHoursString);
|
||||||
|
} else {
|
||||||
|
data.removeTag(OSMSettings.OSMTagKey.OPENING_HOURS.getValue());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
package net.osmand.plus.osmedit;
|
package net.osmand.plus.osmedit;
|
||||||
|
|
||||||
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.data.Amenity;
|
import net.osmand.data.Amenity;
|
||||||
import net.osmand.osm.PoiType;
|
import net.osmand.osm.PoiType;
|
||||||
import net.osmand.osm.edit.Node;
|
import net.osmand.osm.edit.Node;
|
||||||
import net.osmand.osm.edit.OSMSettings;
|
import net.osmand.osm.edit.OSMSettings;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
|
@ -13,6 +16,7 @@ import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class EditPoiData {
|
public class EditPoiData {
|
||||||
|
private static final Log LOG = PlatformUtil.getLog(EditPoiData.class);
|
||||||
private Set<TagsChangedListener> mListeners = new HashSet<>();
|
private Set<TagsChangedListener> mListeners = new HashSet<>();
|
||||||
private LinkedHashMap<String, String > tagValues = new LinkedHashMap<String, String>();
|
private LinkedHashMap<String, String > tagValues = new LinkedHashMap<String, String>();
|
||||||
private boolean isInEdit = false;
|
private boolean isInEdit = false;
|
||||||
|
@ -46,8 +50,8 @@ public class EditPoiData {
|
||||||
amenity.getPhone());
|
amenity.getPhone());
|
||||||
tryAddTag(OSMSettings.OSMTagKey.WEBSITE.getValue(),
|
tryAddTag(OSMSettings.OSMTagKey.WEBSITE.getValue(),
|
||||||
amenity.getSite());
|
amenity.getSite());
|
||||||
for (String tag : node.getTagKeySet()) {
|
for (String tag : amenity.getAdditionalInfo().keySet()) {
|
||||||
tryAddTag(tag, node.getTag(tag));
|
tryAddTag(tag, amenity.getAdditionalInfo(tag));
|
||||||
}
|
}
|
||||||
String subType = amenity.getSubType();
|
String subType = amenity.getSubType();
|
||||||
String key;
|
String key;
|
||||||
|
|
|
@ -216,7 +216,12 @@ public class EditPoiDialogFragment extends DialogFragment {
|
||||||
@Override
|
@Override
|
||||||
public void afterTextChanged(Editable s) {
|
public void afterTextChanged(Editable s) {
|
||||||
if (!getEditPoiData().isInEdit()) {
|
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());
|
poiTypeEditText.setText(editPoiData.amenity.getSubType());
|
||||||
|
|
||||||
Button saveButton = (Button) view.findViewById(R.id.saveButton);
|
Button saveButton = (Button) view.findViewById(R.id.saveButton);
|
||||||
int saveButtonTextId = R.string.default_buttons_commit;
|
saveButton.setText(R.string.shared_string_save);
|
||||||
saveButton.setText(saveButtonTextId);
|
|
||||||
saveButton.setOnClickListener(new View.OnClickListener() {
|
saveButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
@ -333,8 +337,7 @@ public class EditPoiDialogFragment extends DialogFragment {
|
||||||
getDialog().setOnKeyListener(new DialogInterface.OnKeyListener() {
|
getDialog().setOnKeyListener(new DialogInterface.OnKeyListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
|
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
|
||||||
if (keyCode == android.view.KeyEvent.KEYCODE_BACK
|
if (keyCode == android.view.KeyEvent.KEYCODE_BACK) {
|
||||||
&& editPoiData.hasChangesBeenMade()) {
|
|
||||||
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue