check if caption is empty too
This commit is contained in:
parent
e413d85c21
commit
1d8d04fecb
|
@ -225,7 +225,7 @@ public class GpodnetAuthenticationActivity extends ActionBarActivity {
|
|||
createNewDevice.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (checkDeviceIDText(deviceID, txtvError, devices.get())) {
|
||||
if (checkDeviceIDText(deviceID, caption, txtvError, devices.get())) {
|
||||
final String deviceStr = deviceID.getText().toString();
|
||||
final String captionStr = caption.getText().toString();
|
||||
|
||||
|
@ -311,20 +311,22 @@ public class GpodnetAuthenticationActivity extends ActionBarActivity {
|
|||
return false;
|
||||
}
|
||||
|
||||
private boolean checkDeviceIDText(EditText deviceID, TextView txtvError, List<GpodnetDevice> devices) {
|
||||
private boolean checkDeviceIDText(EditText deviceID, EditText caption, TextView txtvError, List<GpodnetDevice> devices) {
|
||||
String text = deviceID.getText().toString();
|
||||
if (text.length() == 0) {
|
||||
txtvError.setText(R.string.gpodnetauth_device_errorEmpty);
|
||||
txtvError.setVisibility(View.VISIBLE);
|
||||
return false;
|
||||
} else if (caption.length() == 0) {
|
||||
txtvError.setText(R.string.gpodnetauth_device_caption_errorEmpty);
|
||||
txtvError.setVisibility(View.VISIBLE);
|
||||
return false;
|
||||
} else {
|
||||
if (devices != null) {
|
||||
for (GpodnetDevice device : devices) {
|
||||
if (device.getId().equals(text)) {
|
||||
txtvError.setText(R.string.gpodnetauth_device_errorAlreadyUsed);
|
||||
txtvError.setVisibility(View.VISIBLE);
|
||||
return false;
|
||||
}
|
||||
if (isDeviceWithIdInList(text, devices)) {
|
||||
txtvError.setText(R.string.gpodnetauth_device_errorAlreadyUsed);
|
||||
txtvError.setVisibility(View.VISIBLE);
|
||||
return false;
|
||||
}
|
||||
txtvError.setVisibility(View.GONE);
|
||||
return true;
|
||||
|
|
|
@ -485,6 +485,7 @@
|
|||
<string name="gpodnetauth_device_chooseExistingDevice">Choose existing device:</string>
|
||||
<string name="gpodnetauth_device_errorEmpty">Device ID must not be empty</string>
|
||||
<string name="gpodnetauth_device_errorAlreadyUsed">Device ID already in use</string>
|
||||
<string name="gpodnetauth_device_caption_errorEmpty">Caption must not be empty</string>
|
||||
|
||||
<string name="gpodnetauth_device_butChoose">Choose</string>
|
||||
<string name="gpodnetauth_finish_title">Login successful!</string>
|
||||
|
|
Loading…
Reference in New Issue