Fix #7065 Quick Action: allow to add "Add POI" action with empty value filed
This commit is contained in:
parent
284a007189
commit
3f6d9518f1
4 changed files with 20 additions and 6 deletions
|
@ -121,7 +121,7 @@ public class AddPOIAction extends QuickAction {
|
|||
Node node = new Node(latLon.getLatitude(), latLon.getLongitude(), -1);
|
||||
node.replaceTags(getTagsFromParams());
|
||||
EditPoiData editPoiData = new EditPoiData(node, activity.getMyApplication());
|
||||
if (Boolean.valueOf(getParams().get(KEY_DIALOG))) {
|
||||
if (Boolean.parseBoolean(getParams().get(KEY_DIALOG)) || editPoiData.hasEmptyValue()) {
|
||||
Entity newEntity = editPoiData.getEntity();
|
||||
EditPoiDialogFragment editPoiDialogFragment =
|
||||
EditPoiDialogFragment.createInstance(newEntity, true, getTagsFromParams());
|
||||
|
|
|
@ -196,6 +196,9 @@ public class AdvancedEditPoiFragment extends BaseOsmAndFragment
|
|||
continue;
|
||||
addTagView(tag.getKey(), tag.getValue());
|
||||
}
|
||||
if (editPoiData.hasEmptyValue()) {
|
||||
linearLayout.findViewById(R.id.valueEditText).requestFocus();
|
||||
}
|
||||
editPoiData.setIsInEdit(false);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ import net.osmand.osm.PoiCategory;
|
|||
import net.osmand.osm.PoiType;
|
||||
import net.osmand.osm.edit.Entity;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
|
@ -91,7 +90,7 @@ public class EditPoiData {
|
|||
}
|
||||
|
||||
private void tryAddTag(String key, String value) {
|
||||
if (!Algorithms.isEmpty(value)) {
|
||||
if (value != null) {
|
||||
tagValues.put(key, value);
|
||||
}
|
||||
}
|
||||
|
@ -118,7 +117,6 @@ public class EditPoiData {
|
|||
return Collections.unmodifiableMap(tagValues);
|
||||
}
|
||||
|
||||
|
||||
public void putTag(String tag, String value) {
|
||||
checkNotInEdit();
|
||||
try {
|
||||
|
@ -136,7 +134,6 @@ public class EditPoiData {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private void checkNotInEdit() {
|
||||
if(isInEdit) {
|
||||
throw new IllegalStateException("Can't modify in edit mode");
|
||||
|
@ -254,4 +251,13 @@ public class EditPoiData {
|
|||
changedTags.removeAll(Arrays.asList(currentPoiType.getEditOsmTag(), currentPoiType.getOsmTag2()));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasEmptyValue() {
|
||||
for (String value : tagValues.values()) {
|
||||
if (value.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -97,7 +97,9 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment {
|
|||
private static final String TAGS_LIST = "tags_list";
|
||||
private static final String IS_ADDING_POI = "is_adding_poi";
|
||||
|
||||
public static final HashSet<String> BASIC_TAGS = new HashSet<String>() ;
|
||||
public static final HashSet<String> BASIC_TAGS = new HashSet<String>();
|
||||
public static final int ADVANCED_TAB = 1;
|
||||
|
||||
static {
|
||||
BASIC_TAGS.add(OSMSettings.OSMTagKey.NAME.getValue());
|
||||
BASIC_TAGS.add(OSMSettings.OSMTagKey.ADDR_STREET.getValue());
|
||||
|
@ -379,6 +381,9 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment {
|
|||
});
|
||||
setAdapterForPoiTypeEditText();
|
||||
setCancelable(false);
|
||||
if (editPoiData.hasEmptyValue()) {
|
||||
viewPager.setCurrentItem(ADVANCED_TAB);
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue