forked from organicmaps/organicmaps
[android][editor] poi name validation is added
This commit is contained in:
parent
76cbee1c32
commit
e7b3f716f0
4 changed files with 36 additions and 0 deletions
|
@ -592,6 +592,13 @@ Java_com_mapswithme_maps_editor_Editor_nativeIsEmailValid(JNIEnv * env, jclass c
|
|||
return osm::EditableMapObject::ValidateEmail(jni::ToNativeString(env, email));
|
||||
}
|
||||
|
||||
// static bool ValidateName(string const & name)
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_com_mapswithme_maps_editor_Editor_nativeIsNameValid(JNIEnv * env, jclass clazz, jstring name)
|
||||
{
|
||||
return osm::EditableMapObject::ValidateName(jni::ToNativeString(env, name));
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_mapswithme_maps_editor_Editor_nativeGetCategory(JNIEnv * env, jclass clazz)
|
||||
{
|
||||
|
|
|
@ -124,6 +124,7 @@ public final class Editor
|
|||
public static native boolean nativeIsPhoneValid(String phone);
|
||||
public static native boolean nativeIsWebsiteValid(String site);
|
||||
public static native boolean nativeIsEmailValid(String email);
|
||||
public static native boolean nativeIsNameValid(String name);
|
||||
|
||||
|
||||
public static native boolean nativeHasSomethingToUpload();
|
||||
|
|
|
@ -28,6 +28,7 @@ import com.mapswithme.maps.R;
|
|||
import com.mapswithme.maps.base.BaseMwmFragment;
|
||||
import com.mapswithme.maps.bookmarks.data.Metadata.MetadataType;
|
||||
import com.mapswithme.maps.dialog.EditTextDialogFragment;
|
||||
import com.mapswithme.maps.editor.data.LocalizedName;
|
||||
import com.mapswithme.maps.editor.data.LocalizedStreet;
|
||||
import com.mapswithme.maps.editor.data.TimeFormatUtils;
|
||||
import com.mapswithme.maps.editor.data.Timetable;
|
||||
|
@ -280,6 +281,28 @@ public class EditorFragment extends BaseMwmFragment implements View.OnClickListe
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!validateNames())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean validateNames()
|
||||
{
|
||||
for (int pos = 0; pos < mNamesAdapter.getItemCount(); pos++)
|
||||
{
|
||||
LocalizedName localizedName = mNamesAdapter.getNameAtPos(pos);
|
||||
if (Editor.nativeIsNameValid(localizedName.name))
|
||||
continue;
|
||||
|
||||
View nameView = mNamesView.getChildAt(pos);
|
||||
nameView.requestFocus();
|
||||
|
||||
InputUtils.showKeyboard(nameView);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -488,6 +511,8 @@ public class EditorFragment extends BaseMwmFragment implements View.OnClickListe
|
|||
break;
|
||||
case R.id.more_names:
|
||||
case R.id.show_additional_names:
|
||||
if (mNamesAdapter.areAdditionalLanguagesShown() && !validateNames())
|
||||
break;
|
||||
showAdditionalNames(!mNamesAdapter.areAdditionalLanguagesShown());
|
||||
break;
|
||||
case R.id.add_langs:
|
||||
|
|
|
@ -54,6 +54,8 @@ public class MultilanguageAdapter extends RecyclerView.Adapter<MultilanguageAdap
|
|||
return mNames.size();
|
||||
}
|
||||
|
||||
public LocalizedName getNameAtPos(int pos) { return mNames.get(pos); }
|
||||
|
||||
public int getMandatoryNamesCount()
|
||||
{
|
||||
return mMandatoryNamesCount;
|
||||
|
@ -99,6 +101,7 @@ public class MultilanguageAdapter extends RecyclerView.Adapter<MultilanguageAdap
|
|||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count)
|
||||
{
|
||||
UiUtils.setInputError(inputLayout, Editor.nativeIsNameValid(s.toString()) ? 0 : R.string.error_enter_correct_name);
|
||||
mNames.get(getAdapterPosition()).name = s.toString();
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue