Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
f5ed10a267
2 changed files with 47 additions and 5 deletions
|
@ -2060,5 +2060,6 @@ Afghanistan, Albania, Algeria, Andorra, Angola, Anguilla, Antigua and Barbuda, A
|
||||||
<string name="feedback">Feedback</string>
|
<string name="feedback">Feedback</string>
|
||||||
<string name="contact_us">Contact us</string>
|
<string name="contact_us">Contact us</string>
|
||||||
<string name="map_legend">Map legend</string>
|
<string name="map_legend">Map legend</string>
|
||||||
|
<string name="save_poi_without_poi_type_message">Do you really want to save poi without POI type?</string>
|
||||||
<!-- string name="map_legend_item_description">Legend for OsmAnd default map style, Internet connectivity needed to display</string -->
|
<!-- string name="map_legend_item_description">Legend for OsmAnd default map style, Internet connectivity needed to display</string -->
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -66,6 +66,7 @@ import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -79,6 +80,17 @@ public class EditPoiDialogFragment extends DialogFragment {
|
||||||
private static final String TAGS_LIST = "tags_list";
|
private static final String TAGS_LIST = "tags_list";
|
||||||
private static final String IS_ADDING_POI = "is_adding_poi";
|
private static final String IS_ADDING_POI = "is_adding_poi";
|
||||||
|
|
||||||
|
private static final HashSet<String> BASIC_TAGS = new HashSet<String>() {
|
||||||
|
{
|
||||||
|
add(OSMSettings.OSMTagKey.NAME.getValue());
|
||||||
|
add(OSMSettings.OSMTagKey.ADDR_STREET.getValue());
|
||||||
|
add(OSMSettings.OSMTagKey.ADDR_HOUSE_NUMBER.getValue());
|
||||||
|
add(OSMSettings.OSMTagKey.PHONE.getValue());
|
||||||
|
add(OSMSettings.OSMTagKey.WEBSITE.getValue());
|
||||||
|
add(OSMSettings.OSMTagKey.OPENING_HOURS.getValue());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
private EditPoiData editPoiData;
|
private EditPoiData editPoiData;
|
||||||
private ViewPager viewPager;
|
private ViewPager viewPager;
|
||||||
private AutoCompleteTextView poiTypeEditText;
|
private AutoCompleteTextView poiTypeEditText;
|
||||||
|
@ -257,7 +269,7 @@ public class EditPoiDialogFragment extends DialogFragment {
|
||||||
saveButton.setOnClickListener(new View.OnClickListener() {
|
saveButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
save();
|
trySave();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Button cancelButton = (Button) view.findViewById(R.id.cancelButton);
|
Button cancelButton = (Button) view.findViewById(R.id.cancelButton);
|
||||||
|
@ -280,11 +292,22 @@ public class EditPoiDialogFragment extends DialogFragment {
|
||||||
return dialog;
|
return dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void save() {
|
private void trySave() {
|
||||||
if (TextUtils.isEmpty(poiTypeEditText.getText())) {
|
if (TextUtils.isEmpty(poiTypeEditText.getText())) {
|
||||||
poiTypeEditText.setError(getResources().getString(R.string.please_specify_poi_type));
|
HashSet<String> tagsCopy = new HashSet<>();
|
||||||
|
tagsCopy.addAll(editPoiData.getTagValues().keySet());
|
||||||
|
tagsCopy.removeAll(BASIC_TAGS);
|
||||||
|
if (tagsCopy.isEmpty()) {
|
||||||
|
poiTypeEditText.setError(getResources().getString(R.string.please_specify_poi_type));
|
||||||
|
} else {
|
||||||
|
new SaveWithAdvancedTagsDialogFragment().show(getChildFragmentManager(), "dialog");
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void save() {
|
||||||
Node original = editPoiData.getEntity();
|
Node original = editPoiData.getEntity();
|
||||||
Node node = new Node(original.getLatitude(), original.getLongitude(), original.getId());
|
Node node = new Node(original.getLatitude(), original.getLongitude(), original.getId());
|
||||||
OsmPoint.Action action = node.getId() == -1 ? OsmPoint.Action.CREATE : OsmPoint.Action.MODIFY;
|
OsmPoint.Action action = node.getId() == -1 ? OsmPoint.Action.CREATE : OsmPoint.Action.MODIFY;
|
||||||
|
@ -650,13 +673,31 @@ public class EditPoiDialogFragment extends DialogFragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class SaveWithAdvancedTagsDialogFragment extends DialogFragment {
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||||
|
builder.setTitle(getResources().getString(R.string.are_you_sure))
|
||||||
|
.setMessage(getString(R.string.save_poi_without_poi_type_message))
|
||||||
|
.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
((EditPoiDialogFragment) getParentFragment()).save();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setNegativeButton(R.string.shared_string_cancel, null);
|
||||||
|
return builder.create();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static class AreYouSureDialogFragment extends DialogFragment {
|
public static class AreYouSureDialogFragment extends DialogFragment {
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||||
builder.setTitle(getResources().getString(R.string.are_you_sure))
|
builder.setTitle(getResources().getString(R.string.are_you_sure))
|
||||||
.setMessage(getResources().getString(R.string.unsaved_changes_will_be_lost))
|
.setMessage(getString(R.string.unsaved_changes_will_be_lost))
|
||||||
.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
|
.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
@ -674,7 +715,7 @@ public class EditPoiDialogFragment extends DialogFragment {
|
||||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||||
boolean handled = false;
|
boolean handled = false;
|
||||||
if (actionId == EditorInfo.IME_ACTION_SEND) {
|
if (actionId == EditorInfo.IME_ACTION_SEND) {
|
||||||
save();
|
trySave();
|
||||||
handled = true;
|
handled = true;
|
||||||
}
|
}
|
||||||
return handled;
|
return handled;
|
||||||
|
|
Loading…
Reference in a new issue