Merge pull request #6690 from osmandapp/issue_6520
Issue #6520 Add warning dialog
This commit is contained in:
commit
289b263802
2 changed files with 40 additions and 4 deletions
|
@ -10,7 +10,8 @@
|
||||||
- For wording and consistency, please note https://osmand.net/help-online?id=technical-articles#Creating_a_Consistent_User_Experience
|
- For wording and consistency, please note https://osmand.net/help-online?id=technical-articles#Creating_a_Consistent_User_Experience
|
||||||
Thx - Hardy
|
Thx - Hardy
|
||||||
|
|
||||||
-->
|
--> <string name="save_poi_value_exceed_length">Value of tag \"%s\" cannot exceed 255 chars. \nPlease edit it before continue.</string>
|
||||||
|
<string name="save_poi_value_exceed_length_title">Length of \"%s\" value</string>
|
||||||
<string name="public_transport_warning_descr_blog">Learn more about how OsmAnd calculates routes in our blog.</string>
|
<string name="public_transport_warning_descr_blog">Learn more about how OsmAnd calculates routes in our blog.</string>
|
||||||
<string name="public_transport_warning_title">Public transport routes are now in the beta testing phase, so errors and inaccuracies may occur.</string>
|
<string name="public_transport_warning_title">Public transport routes are now in the beta testing phase, so errors and inaccuracies may occur.</string>
|
||||||
<string name="add_intermediate">Add intermediate point</string>
|
<string name="add_intermediate">Add intermediate point</string>
|
||||||
|
|
|
@ -3,6 +3,7 @@ package net.osmand.plus.osmedit;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
|
@ -108,7 +109,7 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment {
|
||||||
private View view;
|
private View view;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAttach(Activity activity) {
|
public void onAttach(Context activity) {
|
||||||
super.onAttach(activity);
|
super.onAttach(activity);
|
||||||
OsmEditingPlugin plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
|
OsmEditingPlugin plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
|
||||||
if (getSettings().OFFLINE_EDITION.get()
|
if (getSettings().OFFLINE_EDITION.get()
|
||||||
|
@ -400,7 +401,14 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void trySave() {
|
private void trySave() {
|
||||||
if (TextUtils.isEmpty(poiTypeEditText.getText())) {
|
String tagWithExceedingValue = isTextLengthInRange();
|
||||||
|
if (!Algorithms.isEmpty(tagWithExceedingValue)){
|
||||||
|
ValueExceedLimitDialogFragment f = new ValueExceedLimitDialogFragment();
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putString("tag", tagWithExceedingValue);
|
||||||
|
f.setArguments(args);
|
||||||
|
f.show(getChildFragmentManager(), "exceedDialog");
|
||||||
|
} else if (TextUtils.isEmpty(poiTypeEditText.getText())) {
|
||||||
HashSet<String> tagsCopy = new HashSet<>();
|
HashSet<String> tagsCopy = new HashSet<>();
|
||||||
tagsCopy.addAll(editPoiData.getTagValues().keySet());
|
tagsCopy.addAll(editPoiData.getTagValues().keySet());
|
||||||
if (Algorithms.isEmpty(editPoiData.getTag(OSMSettings.OSMTagKey.ADDR_HOUSE_NUMBER.getValue()))) {
|
if (Algorithms.isEmpty(editPoiData.getTag(OSMSettings.OSMTagKey.ADDR_HOUSE_NUMBER.getValue()))) {
|
||||||
|
@ -422,12 +430,22 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment {
|
||||||
} else if (editPoiData.getPoiCategory() == getMyApplication().getPoiTypes().getOtherPoiCategory()) {
|
} else if (editPoiData.getPoiCategory() == getMyApplication().getPoiTypes().getOtherPoiCategory()) {
|
||||||
poiTypeEditText.setError(getResources().getString(R.string.please_specify_poi_type));
|
poiTypeEditText.setError(getResources().getString(R.string.please_specify_poi_type));
|
||||||
} else if (editPoiData.getPoiTypeDefined() == null) {
|
} else if (editPoiData.getPoiTypeDefined() == null) {
|
||||||
poiTypeEditText.setError(getResources().getString(R.string.please_specify_poi_type_only_from_list));
|
poiTypeEditText.setError(
|
||||||
|
getResources().getString(R.string.please_specify_poi_type_only_from_list));
|
||||||
} else {
|
} else {
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String isTextLengthInRange() {
|
||||||
|
for (String s: editPoiData.getChangedTags()) {
|
||||||
|
if (editPoiData.getTag(s).length() > 255) {
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
private boolean testTooManyCapitalLetters(String name) {
|
private boolean testTooManyCapitalLetters(String name) {
|
||||||
if(name == null) {
|
if(name == null) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -889,6 +907,23 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class ValueExceedLimitDialogFragment extends DialogFragment {
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||||
|
String msg = getString(R.string.save_poi_value_exceed_length);
|
||||||
|
String fieldTag = getArguments().getString("tag", "");
|
||||||
|
if(!Algorithms.isEmpty(fieldTag)) {
|
||||||
|
msg = String.format(msg, fieldTag);
|
||||||
|
}
|
||||||
|
builder.setTitle(String.format(getResources().getString(R.string.save_poi_value_exceed_length_title), fieldTag))
|
||||||
|
.setMessage(msg)
|
||||||
|
.setNegativeButton(R.string.shared_string_ok, null);
|
||||||
|
return builder.create();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private TextView.OnEditorActionListener mOnEditorActionListener =
|
private TextView.OnEditorActionListener mOnEditorActionListener =
|
||||||
new TextView.OnEditorActionListener() {
|
new TextView.OnEditorActionListener() {
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue