mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-19 04:53:36 +00:00
Improve place does not exist dialog
Signed-off-by: map-per <map-per@gmx.de>
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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" />
|
||||
|
||||
@@ -535,12 +535,12 @@
|
||||
<string name="placepage_more_button">More</string>
|
||||
<string name="placepage_edit_bookmark_button">Edit Bookmark</string>
|
||||
<string name="placepage_personal_notes_hint">Personal notes (text or html)</string>
|
||||
<string name="editor_comment_hint">Comment…</string>
|
||||
<string name="editor_reset_edits_message">Discard all local changes?</string>
|
||||
<string name="editor_reset_edits_button">Discard</string>
|
||||
<string name="editor_remove_place_message">Delete added place?</string>
|
||||
<string name="editor_remove_place_button">Delete</string>
|
||||
<string name="editor_place_doesnt_exist">Place does not exist</string>
|
||||
<string name="editor_place_doesnt_exist_description">Describe what the place looks like now to send an error note to the OpenStreetMap community</string>
|
||||
<!-- Error message for "Place doesn't exist" dialog when comment is empty -->
|
||||
<string name="delete_place_empty_comment_error">Please indicate the reason for deleting the place</string>
|
||||
<!-- Phone number error message -->
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
<nil key="highlightedColor"/>
|
||||
<userDefinedRuntimeAttributes>
|
||||
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="regular14:blackSecondaryText"/>
|
||||
<userDefinedRuntimeAttribute type="string" keyPath="localizedText" value="editor_detailed_description"/>
|
||||
<userDefinedRuntimeAttribute type="string" keyPath="localizedText" value="editor_place_doesnt_exist_description"/>
|
||||
</userDefinedRuntimeAttributes>
|
||||
</label>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="npf-dH-f50">
|
||||
|
||||
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user