From 73f2196e88e17d1ef52502bcb3fa214e6bb974dc Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Tue, 30 Jun 2020 11:55:55 +0300 Subject: [PATCH 1/2] Fix #9320 Bug: Add favorite allows to create empty favorite without name --- .../editors/PointEditorFragmentNew.java | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java index 565331bd05..647f249de7 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java @@ -11,6 +11,8 @@ import android.os.Build; import android.os.Bundle; import android.os.IBinder; +import android.text.Editable; +import android.text.TextWatcher; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; @@ -163,7 +165,7 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment { } }); view.findViewById(R.id.buttons_divider).setVisibility(View.VISIBLE); - View saveButton = view.findViewById(R.id.right_bottom_button); + final View saveButton = view.findViewById(R.id.right_bottom_button); saveButton.setVisibility(View.VISIBLE); saveButton.setOnClickListener(new View.OnClickListener() { @Override @@ -183,11 +185,32 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment { UiUtilities.setupDialogButton(nightMode, cancelButton, UiUtilities.DialogButtonType.SECONDARY, R.string.shared_string_cancel); UiUtilities.setupDialogButton(nightMode, saveButton, UiUtilities.DialogButtonType.PRIMARY, R.string.shared_string_save); - TextInputLayout nameCaption = (TextInputLayout) view.findViewById(R.id.name_caption); + final TextInputLayout nameCaption = (TextInputLayout) view.findViewById(R.id.name_caption); nameCaption.setHint(getString(R.string.shared_string_name)); nameEdit = (EditText) view.findViewById(R.id.name_edit); nameEdit.setText(getNameInitValue()); + nameEdit.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) { + } + + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) { + } + + @Override + public void afterTextChanged(Editable s) { + if (s.toString().trim().isEmpty()) { + nameCaption.setError(app.getString(R.string.please_provide_profile_name_message)); + saveButton.setEnabled(false); + } else { + nameCaption.setError(null); + saveButton.setEnabled(true); + } + } + }); + nameIcon = (ImageView) view.findViewById(R.id.name_icon); TextView categoryEdit = view.findViewById(R.id.groupName); if (categoryEdit != null) { From 50d1ac4b721077c4f8c1dad825df3ee1c64a3e72 Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Tue, 30 Jun 2020 12:16:57 +0300 Subject: [PATCH 2/2] Fix error string --- OsmAnd/res/values/strings.xml | 1 + .../plus/mapcontextmenu/editors/PointEditorFragmentNew.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 6eacd5c202..7ff492d045 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -11,6 +11,7 @@ Thx - Hardy --> + Please provide a name for the point Volume buttons as zoom Enable to control the map zoom level with device volume buttons. Inline skates diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java index 647f249de7..96c464bd39 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java @@ -202,7 +202,7 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment { @Override public void afterTextChanged(Editable s) { if (s.toString().trim().isEmpty()) { - nameCaption.setError(app.getString(R.string.please_provide_profile_name_message)); + nameCaption.setError(app.getString(R.string.please_provide_point_name_error)); saveButton.setEnabled(false); } else { nameCaption.setError(null);