diff --git a/android/app/src/main/java/app/organicmaps/dialog/EditTextDialogFragment.java b/android/app/src/main/java/app/organicmaps/dialog/EditTextDialogFragment.java index f29d2fc2e..2bbe8ef4e 100644 --- a/android/app/src/main/java/app/organicmaps/dialog/EditTextDialogFragment.java +++ b/android/app/src/main/java/app/organicmaps/dialog/EditTextDialogFragment.java @@ -40,7 +40,6 @@ public class EditTextDialogFragment extends BaseMwmDialogFragment private String mHint; private TextInputEditText mEtInput; private TextInputLayout mEtInputLayout; - private Button mPositiveButton; private Validator mInputValidator; private OnTextSaveListener mTextSaveListener; @@ -117,21 +116,20 @@ public class EditTextDialogFragment extends BaseMwmDialogFragment AlertDialog editTextDialog = new MaterialAlertDialogBuilder(requireActivity(), R.style.MwmTheme_AlertDialog) .setView(buildView()) .setNegativeButton(negativeButtonText, null) - .setPositiveButton(positiveButtonText, - (dialog, which) -> { - final String result = mEtInput.getText().toString(); - processInput(result); - dismiss(); - }) + .setPositiveButton(positiveButtonText, null) .create(); - // Wait till alert is shown to get mPositiveButton. + // Set up onClick listener for mPositiveButton. editTextDialog.setOnShowListener((dialog) -> { - mPositiveButton = editTextDialog.getButton(DialogInterface.BUTTON_POSITIVE); - final FragmentActivity activity = getActivity(); - if (activity == null) - return; - this.validateInput(activity, mInitialText); + Button positiveButton = editTextDialog.getButton(DialogInterface.BUTTON_POSITIVE); + + positiveButton.setOnClickListener(view -> { + final String result = mEtInput.getText().toString(); + if (validateInput(requireActivity(), result)) { + processInput(result); + editTextDialog.dismiss(); + } + }); }); // Setup validation on input edit. @@ -149,14 +147,16 @@ public class EditTextDialogFragment extends BaseMwmDialogFragment return editTextDialog; } - private void validateInput(@NonNull FragmentActivity activity, @Nullable String input) + private boolean validateInput(@NonNull FragmentActivity activity, @Nullable String input) { - if (mPositiveButton != null && mInputValidator != null) + if (mInputValidator != null) { final String maybeError = mInputValidator.validate(activity, input); - mPositiveButton.setEnabled(maybeError == null); mEtInputLayout.getEditText().setError(maybeError); + mEtInputLayout.requestFocus(); + return maybeError == null; } + return false; } private void processInput(@Nullable String text) diff --git a/android/app/src/main/java/app/organicmaps/editor/EditorFragment.java b/android/app/src/main/java/app/organicmaps/editor/EditorFragment.java index 20f6d4ead..c9a33b2c4 100644 --- a/android/app/src/main/java/app/organicmaps/editor/EditorFragment.java +++ b/android/app/src/main/java/app/organicmaps/editor/EditorFragment.java @@ -1007,7 +1007,7 @@ public class EditorFragment extends BaseMwmFragment implements View.OnClickListe private void placeDoesntExist() { EditTextDialogFragment dialogFragment = EditTextDialogFragment.show( - getString(R.string.editor_place_doesnt_exist), "", getString(R.string.editor_comment_hint), + getString(R.string.editor_place_doesnt_exist), "", getString(R.string.editor_place_doesnt_exist_description), getString(R.string.editor_report_problem_send_button), getString(R.string.cancel), this, getDeleteCommentValidator()); dialogFragment.setTextSaveListener(this::commitPlaceDoesntExists); diff --git a/android/app/src/main/res/layout/dialog_edit_text.xml b/android/app/src/main/res/layout/dialog_edit_text.xml index 660933577..5e7c82ac3 100644 --- a/android/app/src/main/res/layout/dialog_edit_text.xml +++ b/android/app/src/main/res/layout/dialog_edit_text.xml @@ -23,7 +23,8 @@ style="@style/MwmWidget.Editor.CustomTextInput" android:layout_width="match_parent" android:layout_height="wrap_content" - android:inputType="text|textCapSentences" + android:inputType="textMultiLine" + android:gravity="top" android:padding="@dimen/margin_half_double_plus" android:maxLength="100" android:singleLine="true" /> diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml index 5d890ae99..7c050533f 100644 --- a/android/app/src/main/res/values/strings.xml +++ b/android/app/src/main/res/values/strings.xml @@ -535,12 +535,12 @@ More Edit Bookmark Personal notes (text or html) - Comment… Discard all local changes? Discard Delete added place? Delete Place does not exist + Describe what the place looks like now to send an error note to the OpenStreetMap community Please indicate the reason for deleting the place diff --git a/iphone/Maps/Classes/CustomAlert/MWMPlaceDoesntExistAlert.xib b/iphone/Maps/Classes/CustomAlert/MWMPlaceDoesntExistAlert.xib index 5659ac7e5..b7a902616 100644 --- a/iphone/Maps/Classes/CustomAlert/MWMPlaceDoesntExistAlert.xib +++ b/iphone/Maps/Classes/CustomAlert/MWMPlaceDoesntExistAlert.xib @@ -42,7 +42,7 @@ - + diff --git a/iphone/Maps/LocalizedStrings/en.lproj/Localizable.strings b/iphone/Maps/LocalizedStrings/en.lproj/Localizable.strings index 5a0f46da4..e7b65d46c 100644 --- a/iphone/Maps/LocalizedStrings/en.lproj/Localizable.strings +++ b/iphone/Maps/LocalizedStrings/en.lproj/Localizable.strings @@ -730,6 +730,7 @@ "editor_remove_place_message" = "Delete added place?"; "editor_remove_place_button" = "Delete"; "editor_place_doesnt_exist" = "Place does not exist"; +"editor_place_doesnt_exist_description" = "Describe what the place looks like now to send an error note to the OpenStreetMap community"; "text_more_button" = "…more"; /* Phone number error message */