check empty names

This commit is contained in:
arrase 2016-11-24 03:06:40 +01:00
parent d28db41782
commit 17efdcafa2
2 changed files with 8 additions and 2 deletions

View File

@ -42,7 +42,7 @@ public class HSDataDialog extends DialogFragment {
((EditText) dialog_view.findViewById(R.id.hsOnionPort)).getText().toString()
);
if (checkInput(localPort, onionPort)) {
if (checkInput(serverName, localPort, onionPort)) {
saveData(serverName, localPort, onionPort);
serviceDataDialog.dismiss();
}
@ -59,7 +59,7 @@ public class HSDataDialog extends DialogFragment {
return serviceDataDialog;
}
private boolean checkInput(Integer local, Integer remote) {
private boolean checkInput(String serverName, Integer local, Integer remote) {
boolean is_ok = true;
Integer error_msg = 0;
@ -68,6 +68,11 @@ public class HSDataDialog extends DialogFragment {
is_ok = false;
}
if (serverName == null || serverName.length() < 1) {
error_msg = R.string.name_can_t_be_empty;
is_ok = false;
}
if (!is_ok) {
Toast.makeText(getContext(), error_msg, Toast.LENGTH_SHORT).show();
}

View File

@ -349,4 +349,5 @@
<string name="permission_denied">Permission denied</string>
<string name="restore_backup">Restore Backup</string>
<string name="create_a_backup_first">Create a backup first</string>
<string name="name_can_t_be_empty">Name can't be empty</string>
</resources>