Merge pull request #9350 from osmandapp/Empty_favorite_name

Fix #9320 Bug: Add favorite allows to create empty favorite without name
This commit is contained in:
Vitaliy 2020-07-02 18:06:47 +03:00 committed by GitHub
commit f86df0f9ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 2 deletions

View file

@ -11,6 +11,7 @@
Thx - Hardy
-->
<string name="please_provide_point_name_error">Please provide a name for the point</string>
<string name="use_volume_buttons_as_zoom">Volume buttons as zoom</string>
<string name="use_volume_buttons_as_zoom_descr">Enable to control the map zoom level with device volume buttons.</string>
<string name="app_mode_inline_skates">Inline skates</string>

View file

@ -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_point_name_error));
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) {