Merge branch 'master' of github.com:osmandapp/Osmand

Conflicts:
	OsmAnd/src/net/osmand/plus/osmedit/EditPoiData.java
This commit is contained in:
Victor Shcherb 2015-11-12 10:35:21 +01:00
commit 977c75af8f
6 changed files with 75 additions and 21 deletions

View file

@ -2090,4 +2090,5 @@ Afghanistan, Albanie, Algérie, Allemagne, Andorre, Angola, Anguilla, Antigua-et
<string name="lang_als">Tosque</string>
<string name="lang_nds">Bas allemand</string>
<string name="share_osm_edits_subject">Éditions OSM partagées grâce à OsmAnd</string>
<string name="save_poi_without_poi_type_message">Souhaitez-vous enregistrer ce point d\'intérêt sans définir son type ?</string>
</resources>

View file

@ -1973,4 +1973,5 @@
<string name="lang_mk">Makedonska</string>
<string name="lang_fy">Frisiska</string>
<string name="lang_als">Albanska (Toskiska)</string>
<string name="share_osm_edits_subject">Osm-redigeringar delade via OsmAnd</string>
</resources>

View file

@ -322,7 +322,7 @@
<string name="poi_training">培訓設施</string>
<string name="poi_university">大學</string>
<string name="poi_social_facility">公共設施</string>
<string name="poi_social_facility">社會設施</string>
<string name="poi_courthouse">法院</string>
<string name="poi_prison">監獄</string>
<string name="poi_register_office">民事登記處</string>
@ -2158,4 +2158,16 @@
<string name="poi_refugee_yes">為難民的福利設施</string>
<string name="poi_refugee_no">難民:無</string>
<string name="poi_sanitary_dump_station_yes">衛生轉儲站:有</string>
<string name="poi_sanitary_dump_station_no">衛生轉儲站:無</string>
<string name="poi_sanitary_dump_station_customers">衛生轉儲站:僅客戶</string>
<string name="poi_social_facility_group_home">社會設施:團體家屋</string>
<string name="poi_social_facility_assisted_living">社會設施:輔助生活</string>
<string name="poi_social_facility_outreach">社會設施:推廣</string>
<string name="poi_social_facility_food_bank">社會設施:食物銀行</string>
<string name="poi_social_facility_shelter">社會設施:收容所</string>
<string name="poi_social_facility_ambulatory_care">社會設施:門診</string>
<string name="poi_social_facility_workshop">社會設施:工場</string>
<string name="poi_social_facility_day_care">社會設施:日間護理</string>
</resources>

View file

@ -2060,5 +2060,6 @@ Afghanistan, Albania, Algeria, Andorra, Angola, Anguilla, Antigua and Barbuda, A
<string name="feedback">Feedback</string>
<string name="contact_us">Contact us</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 -->
</resources>

View file

@ -1,7 +1,19 @@
package net.osmand.plus;
import gnu.trove.list.array.TIntArrayList;
import android.content.Context;
import android.graphics.Color;
import net.osmand.Location;
import net.osmand.PlatformUtil;
import net.osmand.data.LocationPoint;
import net.osmand.data.PointDescription;
import net.osmand.util.Algorithms;
import org.apache.commons.logging.Log;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlSerializer;
import java.io.BufferedInputStream;
import java.io.File;
@ -30,20 +42,6 @@ import java.util.Map;
import java.util.Stack;
import java.util.TimeZone;
import net.osmand.Location;
import net.osmand.PlatformUtil;
import net.osmand.data.LocationPoint;
import net.osmand.data.PointDescription;
import net.osmand.util.Algorithms;
import org.apache.commons.logging.Log;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlSerializer;
import android.content.Context;
import android.graphics.Color;
public class GPXUtilities {
public final static Log log = PlatformUtil.getLog(GPXUtilities.class);

View file

@ -66,6 +66,7 @@ import org.apache.commons.logging.Log;
import java.io.Serializable;
import java.util.Comparator;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@ -78,6 +79,17 @@ public class EditPoiDialogFragment extends DialogFragment {
private static final String TAGS_LIST = "tags_list";
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 ViewPager viewPager;
private AutoCompleteTextView poiTypeEditText;
@ -253,7 +265,7 @@ public class EditPoiDialogFragment extends DialogFragment {
saveButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
save();
trySave();
}
});
Button cancelButton = (Button) view.findViewById(R.id.cancelButton);
@ -276,11 +288,22 @@ public class EditPoiDialogFragment extends DialogFragment {
return dialog;
}
private void save() {
private void trySave() {
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;
}
save();
}
private void save() {
Node original = editPoiData.getEntity();
Node node = new Node(original.getLatitude(), original.getLongitude(), original.getId());
OsmPoint.Action action = node.getId() == -1 ? OsmPoint.Action.CREATE : OsmPoint.Action.MODIFY;
@ -639,13 +662,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 {
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
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() {
@Override
public void onClick(DialogInterface dialog, int which) {
@ -663,7 +704,7 @@ public class EditPoiDialogFragment extends DialogFragment {
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
boolean handled = false;
if (actionId == EditorInfo.IME_ACTION_SEND) {
save();
trySave();
handled = true;
}
return handled;