issue #1500, POI dialog fix
This commit is contained in:
parent
362aecfc7a
commit
97754ea50c
1 changed files with 229 additions and 231 deletions
|
@ -29,14 +29,13 @@ import android.widget.TableLayout;
|
||||||
import android.widget.TableRow;
|
import android.widget.TableRow;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import net.osmand.access.AccessibleToast;
|
import net.osmand.access.AccessibleToast;
|
||||||
import net.osmand.data.Amenity;
|
import net.osmand.data.Amenity;
|
||||||
import net.osmand.osm.MapPoiTypes;
|
import net.osmand.osm.MapPoiTypes;
|
||||||
import net.osmand.osm.MapRenderingTypes;
|
|
||||||
import net.osmand.osm.PoiCategory;
|
import net.osmand.osm.PoiCategory;
|
||||||
import net.osmand.osm.PoiType;
|
import net.osmand.osm.PoiType;
|
||||||
import net.osmand.osm.edit.EntityInfo;
|
import net.osmand.osm.edit.EntityInfo;
|
||||||
import net.osmand.osm.edit.EntityParser;
|
|
||||||
import net.osmand.osm.edit.Node;
|
import net.osmand.osm.edit.Node;
|
||||||
import net.osmand.osm.edit.OSMSettings.OSMTagKey;
|
import net.osmand.osm.edit.OSMSettings.OSMTagKey;
|
||||||
import net.osmand.plus.OsmAndFormatter;
|
import net.osmand.plus.OsmAndFormatter;
|
||||||
|
@ -151,23 +150,23 @@ public class EditingPOIDialogProvider implements DialogProvider {
|
||||||
showPOIDialog(DIALOG_CREATE_POI, n, null);
|
showPOIDialog(DIALOG_CREATE_POI, n, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showPOIDialog(int dialogID, Node n, Amenity a) {
|
private void showPOIDialog(int dialogID, Node node, Amenity amenity) {
|
||||||
Amenity am;
|
Amenity localAmenity;
|
||||||
if(a == null) {
|
if(amenity == null) {
|
||||||
am = new Amenity();
|
localAmenity = new Amenity();
|
||||||
am.setType(poiTypes.getOtherPoiCategory());
|
localAmenity.setType(poiTypes.getOtherPoiCategory());
|
||||||
am.setSubType("");
|
localAmenity.setSubType("");
|
||||||
am.setAdditionalInfo(OSMTagKey.OPENING_HOURS.getValue(), "");
|
localAmenity.setAdditionalInfo(OSMTagKey.OPENING_HOURS.getValue(), "");
|
||||||
} else {
|
} else {
|
||||||
am = new Amenity();
|
localAmenity = new Amenity();
|
||||||
am.copyNames(a);
|
localAmenity.copyNames(amenity);
|
||||||
am.setType(a.getType());
|
localAmenity.setType(amenity.getType());
|
||||||
am.setSubType(a.getSubType());
|
localAmenity.setSubType(amenity.getSubType());
|
||||||
am.setAdditionalInfo(a.getAdditionalInfo());
|
localAmenity.setAdditionalInfo(amenity.getAdditionalInfo());
|
||||||
}
|
}
|
||||||
// Amenity a = EntityParser.parseAmenity(n, n.getTags(), type, subType, MapRenderingTypes.getDefault());
|
// Amenity amenity = EntityParser.parseAmenity(node, node.getTags(), type, subType, MapRenderingTypes.getDefault());
|
||||||
dialogBundle.putSerializable(KEY_AMENITY, a);
|
dialogBundle.putSerializable(KEY_AMENITY, localAmenity);
|
||||||
dialogBundle.putSerializable(KEY_AMENITY_NODE, n);
|
dialogBundle.putSerializable(KEY_AMENITY_NODE, node);
|
||||||
createPOIDialog(dialogID, dialogBundle).show();
|
createPOIDialog(dialogID, dialogBundle).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,20 +221,20 @@ public class EditingPOIDialogProvider implements DialogProvider {
|
||||||
String c = comment.getText().toString();
|
String c = comment.getText().toString();
|
||||||
commitNode(OsmPoint.Action.DELETE, n, openstreetmapUtil.getEntityInfo(), c,
|
commitNode(OsmPoint.Action.DELETE, n, openstreetmapUtil.getEntityInfo(), c,
|
||||||
closeChangeset == null ? false : closeChangeset.isSelected(), new Runnable() {
|
closeChangeset == null ? false : closeChangeset.isSelected(), new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (isLocalEdit) {
|
if (isLocalEdit) {
|
||||||
AccessibleToast.makeText(
|
AccessibleToast.makeText(
|
||||||
activity,R.string.osm_changes_added_to_local_edits,
|
activity,R.string.osm_changes_added_to_local_edits,
|
||||||
Toast.LENGTH_LONG).show();
|
Toast.LENGTH_LONG).show();
|
||||||
} else {
|
} else {
|
||||||
AccessibleToast.makeText(activity, R.string.poi_remove_success, Toast.LENGTH_LONG).show();
|
AccessibleToast.makeText(activity, R.string.poi_remove_success, Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
if(activity instanceof MapActivity){
|
if(activity instanceof MapActivity){
|
||||||
((MapActivity) activity).getMapView().refreshMap(true);
|
((MapActivity) activity).getMapView().refreshMap(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return builder.create();
|
return builder.create();
|
||||||
|
@ -263,25 +262,25 @@ public class EditingPOIDialogProvider implements DialogProvider {
|
||||||
|
|
||||||
private void addTagValueRow(final Node n, final TableLayout layout, String tg, String vl) {
|
private void addTagValueRow(final Node n, final TableLayout layout, String tg, String vl) {
|
||||||
final TableRow newTagRow = new TableRow(activity);
|
final TableRow newTagRow = new TableRow(activity);
|
||||||
TableRow.LayoutParams tlp = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
|
TableRow.LayoutParams tlp = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
|
||||||
tlp.leftMargin = 5;
|
tlp.leftMargin = 5;
|
||||||
tlp.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM;
|
tlp.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM;
|
||||||
newTagRow.setLayoutParams(tlp);
|
newTagRow.setLayoutParams(tlp);
|
||||||
|
|
||||||
final AutoCompleteTextView tag = new AutoCompleteTextView(activity);
|
final AutoCompleteTextView tag = new AutoCompleteTextView(activity);
|
||||||
final AutoCompleteTextView value = new AutoCompleteTextView(activity);
|
final AutoCompleteTextView value = new AutoCompleteTextView(activity);
|
||||||
final Button delete = new Button(activity);
|
final Button delete = new Button(activity);
|
||||||
|
|
||||||
tag.setDropDownWidth(ViewGroup.LayoutParams.MATCH_PARENT);
|
tag.setDropDownWidth(ViewGroup.LayoutParams.MATCH_PARENT);
|
||||||
value.setDropDownWidth(ViewGroup.LayoutParams.MATCH_PARENT);
|
value.setDropDownWidth(ViewGroup.LayoutParams.MATCH_PARENT);
|
||||||
tag.setLayoutParams(tlp);
|
tag.setLayoutParams(tlp);
|
||||||
if(tg != null) {
|
if(tg != null) {
|
||||||
tag.setText(tg);
|
tag.setText(tg);
|
||||||
} else {
|
} else {
|
||||||
tag.setHint("Tag");
|
tag.setHint("Tag");
|
||||||
}
|
}
|
||||||
|
|
||||||
final Set<String> tagKeys = new TreeSet<String>();
|
final Set<String> tagKeys = new TreeSet<String>();
|
||||||
for (OSMTagKey t : OSMTagKey.values()) {
|
for (OSMTagKey t : OSMTagKey.values()) {
|
||||||
if ((t != OSMTagKey.NAME) && (t != OSMTagKey.OPENING_HOURS) && (t != OSMTagKey.PHONE)
|
if ((t != OSMTagKey.NAME) && (t != OSMTagKey.OPENING_HOURS) && (t != OSMTagKey.PHONE)
|
||||||
&& (t != OSMTagKey.WEBSITE)) {
|
&& (t != OSMTagKey.WEBSITE)) {
|
||||||
|
@ -289,9 +288,9 @@ public class EditingPOIDialogProvider implements DialogProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ArrayAdapter<Object> adapter = new ArrayAdapter<Object>(activity, R.layout.list_textview, tagKeys.toArray());
|
ArrayAdapter<Object> adapter = new ArrayAdapter<Object>(activity, R.layout.list_textview, tagKeys.toArray());
|
||||||
tag.setAdapter(adapter);
|
tag.setAdapter(adapter);
|
||||||
tag.setThreshold(1);
|
tag.setThreshold(1);
|
||||||
tag.setOnClickListener(new View.OnClickListener() {
|
tag.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
Builder builder = new AlertDialog.Builder(activity);
|
Builder builder = new AlertDialog.Builder(activity);
|
||||||
|
@ -307,25 +306,25 @@ public class EditingPOIDialogProvider implements DialogProvider {
|
||||||
builder.show();
|
builder.show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
tlp = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.FILL_PARENT);
|
tlp = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.FILL_PARENT);
|
||||||
tlp.leftMargin = 5;
|
tlp.leftMargin = 5;
|
||||||
tlp.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM;
|
tlp.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM;
|
||||||
value.setLayoutParams(tlp);
|
value.setLayoutParams(tlp);
|
||||||
if(vl != null) {
|
if(vl != null) {
|
||||||
value.setText(vl);
|
value.setText(vl);
|
||||||
} else {
|
} else {
|
||||||
value.setHint("Value");
|
value.setHint("Value");
|
||||||
}
|
}
|
||||||
Set<String> subCategories = new LinkedHashSet<String>();
|
Set<String> subCategories = new LinkedHashSet<String>();
|
||||||
// could be osm values
|
// could be osm values
|
||||||
// for (String s : poiTypes.getAllTranslatedNames().keySet()) {
|
// for (String s : poiTypes.getAllTranslatedNames().keySet()) {
|
||||||
// if (!subCategories.contains(s)) {
|
// if (!subCategories.contains(s)) {
|
||||||
// subCategories.add(s);
|
// subCategories.add(s);
|
||||||
// }
|
// }
|
||||||
// } ;
|
// } ;
|
||||||
ArrayAdapter<Object> valueAdapter = new ArrayAdapter<Object>(activity, R.layout.list_textview, subCategories.toArray());
|
ArrayAdapter<Object> valueAdapter = new ArrayAdapter<Object>(activity, R.layout.list_textview, subCategories.toArray());
|
||||||
value.setThreshold(1);
|
value.setThreshold(1);
|
||||||
value.setAdapter(valueAdapter);
|
value.setAdapter(valueAdapter);
|
||||||
value.addTextChangedListener(new TextWatcher() {
|
value.addTextChangedListener(new TextWatcher() {
|
||||||
@Override
|
@Override
|
||||||
public void afterTextChanged(Editable s) {
|
public void afterTextChanged(Editable s) {
|
||||||
|
@ -343,24 +342,24 @@ public class EditingPOIDialogProvider implements DialogProvider {
|
||||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
tlp = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
|
tlp = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
|
||||||
tlp.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM;
|
tlp.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM;
|
||||||
tlp.rightMargin = 5;
|
tlp.rightMargin = 5;
|
||||||
delete.setLayoutParams(tlp);
|
delete.setLayoutParams(tlp);
|
||||||
delete.setText("X");
|
delete.setText("X");
|
||||||
delete.setOnClickListener(new View.OnClickListener() {
|
delete.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
layout.removeView(newTagRow);
|
layout.removeView(newTagRow);
|
||||||
layout.invalidate();
|
layout.invalidate();
|
||||||
n.removeTag(tag.getText().toString());
|
n.removeTag(tag.getText().toString());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
newTagRow.addView(tag);
|
newTagRow.addView(tag);
|
||||||
newTagRow.addView(value);
|
newTagRow.addView(value);
|
||||||
newTagRow.addView(delete);
|
newTagRow.addView(delete);
|
||||||
layout.addView(newTagRow);
|
layout.addView(newTagRow);
|
||||||
layout.invalidate();
|
layout.invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Builder createPOIDialog(final int dialogID, Bundle args) {
|
private Builder createPOIDialog(final int dialogID, Bundle args) {
|
||||||
|
@ -405,64 +404,64 @@ public class EditingPOIDialogProvider implements DialogProvider {
|
||||||
});
|
});
|
||||||
linkToOsmDoc.setMovementMethod(LinkMovementMethod.getInstance());
|
linkToOsmDoc.setMovementMethod(LinkMovementMethod.getInstance());
|
||||||
|
|
||||||
final Amenity a = (Amenity) args.getSerializable(KEY_AMENITY);
|
final Amenity amenity = (Amenity) args.getSerializable(KEY_AMENITY);
|
||||||
final Node n = (Node) args.getSerializable(KEY_AMENITY_NODE);
|
final Node node = (Node) args.getSerializable(KEY_AMENITY_NODE);
|
||||||
dlg.setNegativeButton(R.string.shared_string_cancel, null);
|
dlg.setNegativeButton(R.string.shared_string_cancel, null);
|
||||||
dlg.setPositiveButton(
|
dlg.setPositiveButton(
|
||||||
isLocalEdit ? R.string.shared_string_save :
|
isLocalEdit ? R.string.shared_string_save :
|
||||||
R.string.default_buttons_commit, new DialogInterface.OnClickListener() {
|
R.string.default_buttons_commit, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
Resources resources = view.getResources();
|
Resources resources = view.getResources();
|
||||||
final String msg = n.getId() == -1 ? resources.getString(R.string.poi_action_add) : resources
|
final String msg = node.getId() == -1 ? resources.getString(R.string.poi_action_add) : resources
|
||||||
.getString(R.string.poi_action_change);
|
.getString(R.string.poi_action_change);
|
||||||
OsmPoint.Action action = n.getId() == -1 ? OsmPoint.Action.CREATE : OsmPoint.Action.MODIFY;
|
OsmPoint.Action action = node.getId() == -1 ? OsmPoint.Action.CREATE : OsmPoint.Action.MODIFY;
|
||||||
String subType = typeText.getText().toString().trim().toLowerCase();
|
String subType = typeText.getText().toString().trim().toLowerCase();
|
||||||
if (allTranslatedSubTypes.get(subType) != null) {
|
if (allTranslatedSubTypes.get(subType) != null) {
|
||||||
PoiType pt = allTranslatedSubTypes.get(subType);
|
PoiType pt = allTranslatedSubTypes.get(subType);
|
||||||
n.putTag(pt.getOsmTag(), pt.getOsmValue());
|
node.putTag(pt.getOsmTag(), pt.getOsmValue());
|
||||||
if (pt.getOsmTag2() != null) {
|
if (pt.getOsmTag2() != null) {
|
||||||
n.putTag(pt.getOsmTag2(), pt.getOsmValue2());
|
node.putTag(pt.getOsmTag2(), pt.getOsmValue2());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
n.putTag(a.getType().getDefaultTag(), subType);
|
node.putTag(amenity.getType().getDefaultTag(), subType);
|
||||||
}
|
}
|
||||||
String name = nameText.getText().toString();
|
String name = nameText.getText().toString();
|
||||||
if(name.length() > 0) {
|
if(name.length() > 0) {
|
||||||
n.putTag(OSMTagKey.NAME.getValue(), name);
|
node.putTag(OSMTagKey.NAME.getValue(), name);
|
||||||
}
|
}
|
||||||
if (openingHours.getText().toString().length() == 0) {
|
if (openingHours.getText().toString().length() == 0) {
|
||||||
n.removeTag(OSMTagKey.OPENING_HOURS.getValue());
|
node.removeTag(OSMTagKey.OPENING_HOURS.getValue());
|
||||||
} else {
|
} else {
|
||||||
n.putTag(OSMTagKey.OPENING_HOURS.getValue(), openingHours.getText().toString());
|
node.putTag(OSMTagKey.OPENING_HOURS.getValue(), openingHours.getText().toString());
|
||||||
}
|
}
|
||||||
String website = websiteText.getText().toString();
|
String website = websiteText.getText().toString();
|
||||||
if (website.length() > 0 ){
|
if (website.length() > 0 ){
|
||||||
n.putTag(OSMTagKey.WEBSITE.getValue(),website);
|
node.putTag(OSMTagKey.WEBSITE.getValue(), website);
|
||||||
} else {
|
} else {
|
||||||
n.removeTag(OSMTagKey.WEBSITE.getValue());
|
node.removeTag(OSMTagKey.WEBSITE.getValue());
|
||||||
}
|
}
|
||||||
String phone = phoneText.getText().toString();
|
String phone = phoneText.getText().toString();
|
||||||
if (phone.length() > 0 ){
|
if (phone.length() > 0 ){
|
||||||
n.putTag(OSMTagKey.PHONE.getValue(),phone);
|
node.putTag(OSMTagKey.PHONE.getValue(), phone);
|
||||||
} else {
|
} else {
|
||||||
n.removeTag(OSMTagKey.PHONE.getValue());
|
node.removeTag(OSMTagKey.PHONE.getValue());
|
||||||
}
|
}
|
||||||
String str = streetNameText.getText().toString();
|
String str = streetNameText.getText().toString();
|
||||||
if (str .length() > 0 ){
|
if (str .length() > 0 ){
|
||||||
n.putTag(OSMTagKey.ADDR_STREET.getValue(),str);
|
node.putTag(OSMTagKey.ADDR_STREET.getValue(), str);
|
||||||
} else {
|
} else {
|
||||||
n.removeTag(OSMTagKey.ADDR_STREET.getValue());
|
node.removeTag(OSMTagKey.ADDR_STREET.getValue());
|
||||||
}
|
}
|
||||||
String hno = hnoText.getText().toString();
|
String hno = hnoText.getText().toString();
|
||||||
if (hno .length() > 0 ){
|
if (hno .length() > 0 ){
|
||||||
n.putTag(OSMTagKey.ADDR_HOUSE_NUMBER.getValue(),hno);
|
node.putTag(OSMTagKey.ADDR_HOUSE_NUMBER.getValue(), hno);
|
||||||
} else {
|
} else {
|
||||||
n.removeTag(OSMTagKey.ADDR_HOUSE_NUMBER.getValue());
|
node.removeTag(OSMTagKey.ADDR_HOUSE_NUMBER.getValue());
|
||||||
}
|
}
|
||||||
commitNode(action, n, openstreetmapUtil.getEntityInfo(), commentText.getText().toString(), closeChange.isSelected(),
|
commitNode(action, node, openstreetmapUtil.getEntityInfo(), commentText.getText().toString(), closeChange.isSelected(),
|
||||||
new Runnable() {
|
new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (isLocalEdit) {
|
if (isLocalEdit) {
|
||||||
AccessibleToast.makeText(
|
AccessibleToast.makeText(
|
||||||
|
@ -481,12 +480,12 @@ public class EditingPOIDialogProvider implements DialogProvider {
|
||||||
}
|
}
|
||||||
activity.removeDialog(dialogID);
|
activity.removeDialog(dialogID);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
preparePOIDialog(view, args);
|
preparePOIDialog(view, args);
|
||||||
attachListeners(view, a, n);
|
attachListeners(view, amenity, node);
|
||||||
updateOsmTagValue(a);
|
updateOsmTagValue(amenity);
|
||||||
return dlg;
|
return dlg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -684,8 +683,8 @@ public class EditingPOIDialogProvider implements DialogProvider {
|
||||||
|
|
||||||
|
|
||||||
public void commitNode(final OsmPoint.Action action, final Node n, final EntityInfo info, final String comment,
|
public void commitNode(final OsmPoint.Action action, final Node n, final EntityInfo info, final String comment,
|
||||||
final boolean closeChangeSet,
|
final boolean closeChangeSet,
|
||||||
final Runnable successAction) {
|
final Runnable successAction) {
|
||||||
if (info == null && OsmPoint.Action.CREATE != action) {
|
if (info == null && OsmPoint.Action.CREATE != action) {
|
||||||
AccessibleToast.makeText(activity, activity.getResources().getString(R.string.poi_error_info_not_loaded), Toast.LENGTH_LONG).show();
|
AccessibleToast.makeText(activity, activity.getResources().getString(R.string.poi_error_info_not_loaded), Toast.LENGTH_LONG).show();
|
||||||
return;
|
return;
|
||||||
|
@ -717,60 +716,60 @@ public class EditingPOIDialogProvider implements DialogProvider {
|
||||||
public Dialog onCreateDialog(int id) {
|
public Dialog onCreateDialog(int id) {
|
||||||
Bundle args = dialogBundle;
|
Bundle args = dialogBundle;
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case DIALOG_DELETE_POI:
|
case DIALOG_DELETE_POI:
|
||||||
return createDeleteDialog(args);
|
return createDeleteDialog(args);
|
||||||
case DIALOG_SUB_CATEGORIES: {
|
case DIALOG_SUB_CATEGORIES: {
|
||||||
Builder builder = new AlertDialog.Builder(activity);
|
Builder builder = new AlertDialog.Builder(activity);
|
||||||
final Amenity a = (Amenity) args.getSerializable(KEY_AMENITY);
|
final Amenity a = (Amenity) args.getSerializable(KEY_AMENITY);
|
||||||
final Map<String, PoiType> allTranslatedNames = poiTypes.getAllTranslatedNames(a.getType(), true);
|
final Map<String, PoiType> allTranslatedNames = poiTypes.getAllTranslatedNames(a.getType(), true);
|
||||||
final String[] subCats = allTranslatedNames.keySet().toArray(new String[0]);
|
final String[] subCats = allTranslatedNames.keySet().toArray(new String[0]);
|
||||||
builder.setItems(subCats, new DialogInterface.OnClickListener() {
|
builder.setItems(subCats, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
PoiType poiType = allTranslatedNames.get(subCats[which]);
|
PoiType poiType = allTranslatedNames.get(subCats[which]);
|
||||||
typeText.setText(subCats[which]);
|
typeText.setText(subCats[which]);
|
||||||
activity.removeDialog(DIALOG_SUB_CATEGORIES);
|
activity.removeDialog(DIALOG_SUB_CATEGORIES);
|
||||||
}
|
|
||||||
});
|
|
||||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
|
||||||
@Override
|
|
||||||
public void onCancel(DialogInterface dialog) {
|
|
||||||
activity.removeDialog(DIALOG_SUB_CATEGORIES);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return builder.create();
|
|
||||||
}
|
|
||||||
case DIALOG_POI_TYPES: {
|
|
||||||
final Amenity a = (Amenity) args.getSerializable(KEY_AMENITY);
|
|
||||||
Builder builder = new AlertDialog.Builder(activity);
|
|
||||||
final List<PoiCategory> categories = poiTypes.getCategories(false);
|
|
||||||
String[] vals = new String[categories.size()];
|
|
||||||
for (int i = 0; i < vals.length; i++) {
|
|
||||||
vals[i] = categories.get(i).getTranslation();
|
|
||||||
}
|
|
||||||
builder.setItems(vals, new Dialog.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
PoiCategory aType = categories.get(which);
|
|
||||||
if (aType != a.getType()) {
|
|
||||||
a.setType(aType);
|
|
||||||
a.setSubType(""); //$NON-NLS-1$
|
|
||||||
updateType(a);
|
|
||||||
}
|
}
|
||||||
activity.removeDialog(DIALOG_POI_TYPES);
|
});
|
||||||
|
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||||
|
@Override
|
||||||
|
public void onCancel(DialogInterface dialog) {
|
||||||
|
activity.removeDialog(DIALOG_SUB_CATEGORIES);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return builder.create();
|
||||||
|
}
|
||||||
|
case DIALOG_POI_TYPES: {
|
||||||
|
final Amenity a = (Amenity) args.getSerializable(KEY_AMENITY);
|
||||||
|
Builder builder = new AlertDialog.Builder(activity);
|
||||||
|
final List<PoiCategory> categories = poiTypes.getCategories(false);
|
||||||
|
String[] vals = new String[categories.size()];
|
||||||
|
for (int i = 0; i < vals.length; i++) {
|
||||||
|
vals[i] = categories.get(i).getTranslation();
|
||||||
}
|
}
|
||||||
});
|
builder.setItems(vals, new Dialog.OnClickListener() {
|
||||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
@Override
|
||||||
@Override
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
public void onCancel(DialogInterface dialog) {
|
PoiCategory aType = categories.get(which);
|
||||||
activity.removeDialog(DIALOG_POI_TYPES);
|
if (aType != a.getType()) {
|
||||||
}
|
a.setType(aType);
|
||||||
});
|
a.setSubType(""); //$NON-NLS-1$
|
||||||
return builder.create();
|
updateType(a);
|
||||||
}
|
}
|
||||||
case DIALOG_OPENING_HOURS: {
|
activity.removeDialog(DIALOG_POI_TYPES);
|
||||||
return createOpenHoursDlg();
|
}
|
||||||
}
|
});
|
||||||
|
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||||
|
@Override
|
||||||
|
public void onCancel(DialogInterface dialog) {
|
||||||
|
activity.removeDialog(DIALOG_POI_TYPES);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return builder.create();
|
||||||
|
}
|
||||||
|
case DIALOG_OPENING_HOURS: {
|
||||||
|
return createOpenHoursDlg();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -787,4 +786,3 @@ public class EditingPOIDialogProvider implements DialogProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue