diff --git a/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java index bc5dd9d2ef..38a342b246 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java @@ -1,10 +1,13 @@ package net.osmand.plus.osmedit; +import static net.osmand.plus.osmedit.EditPoiDialogFragment.AMENITY_TEXT_LENGTH; + import android.graphics.drawable.Drawable; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.text.Editable; +import android.text.InputFilter; import android.text.TextWatcher; import android.view.LayoutInflater; import android.view.View; @@ -205,6 +208,9 @@ public class AdvancedEditPoiFragment extends BaseOsmAndFragment }); final AutoCompleteTextView valueEditText = (AutoCompleteTextView) convertView.findViewById(R.id.valueEditText); + valueEditText.setFilters(new InputFilter[] { + new InputFilter.LengthFilter(AMENITY_TEXT_LENGTH) + }); tagEditText.setText(tg); tagEditText.setAdapter(tagAdapter); tagEditText.setThreshold(1); diff --git a/OsmAnd/src/net/osmand/plus/osmedit/BasicEditPoiFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/BasicEditPoiFragment.java index 4c52132564..228cf584be 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/BasicEditPoiFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/BasicEditPoiFragment.java @@ -1,5 +1,7 @@ package net.osmand.plus.osmedit; +import static net.osmand.plus.osmedit.EditPoiDialogFragment.AMENITY_TEXT_LENGTH; + import android.content.res.Resources; import android.graphics.drawable.Drawable; import android.os.Bundle; @@ -7,6 +9,9 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.text.Editable; +import android.text.InputFilter; +import android.text.InputFilter.LengthFilter; +import android.text.Spanned; import android.text.TextUtils; import android.text.TextWatcher; import android.util.TypedValue; @@ -46,7 +51,7 @@ public class BasicEditPoiFragment extends BaseOsmAndFragment private EditText webSiteEditText; private EditText descriptionEditText; OpeningHoursAdapter mOpeningHoursAdapter; - + private boolean basicTagsInitialized = false; @Nullable @@ -78,6 +83,9 @@ public class BasicEditPoiFragment extends BaseOsmAndFragment openingHoursImageView.setImageDrawable( getPaintedContentIcon(R.drawable.ic_action_time, iconColor)); + InputFilter[] lengthLimit = new InputFilter[] { + new InputFilter.LengthFilter(AMENITY_TEXT_LENGTH) + }; streetEditText = (EditText) view.findViewById(R.id.streetEditText); houseNumberEditText = (EditText) view.findViewById(R.id.houseNumberEditText); phoneEditText = (EditText) view.findViewById(R.id.phoneEditText); @@ -88,6 +96,11 @@ public class BasicEditPoiFragment extends BaseOsmAndFragment addTextWatcher(OSMSettings.OSMTagKey.PHONE.getValue(), phoneEditText); addTextWatcher(OSMSettings.OSMTagKey.ADDR_HOUSE_NUMBER.getValue(), houseNumberEditText); addTextWatcher(OSMSettings.OSMTagKey.DESCRIPTION.getValue(), descriptionEditText); + streetEditText.setFilters(lengthLimit); + houseNumberEditText.setFilters(lengthLimit); + phoneEditText.setFilters(lengthLimit); + webSiteEditText.setFilters(lengthLimit); + descriptionEditText.setFilters(lengthLimit); Button addOpeningHoursButton = (Button) view.findViewById(R.id.addOpeningHoursButton); addOpeningHoursButton.setOnClickListener(new View.OnClickListener() { @Override diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java index 5f46d5d387..9aabc22266 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java @@ -48,6 +48,7 @@ import android.widget.LinearLayout; import android.widget.TextView; import android.widget.Toast; +import java.util.Map.Entry; import net.osmand.CallbackWithObject; import net.osmand.PlatformUtil; import net.osmand.data.Amenity; @@ -108,6 +109,8 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment { private TextInputLayout poiTypeTextInputLayout; private View view; + public static final int AMENITY_TEXT_LENGTH= 255; + @Override public void onAttach(Context activity) { super.onAttach(activity); @@ -438,9 +441,9 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment { } private String isTextLengthInRange() { - for (String s: editPoiData.getChangedTags()) { - if (editPoiData.getTag(s).length() > 255) { - return s; + for (Entry s: editPoiData.getTagValues().entrySet()) { + if (s.getValue().length() > AMENITY_TEXT_LENGTH) { + return s.getKey(); } } return "";