show error if jid couldn't be parsed in new contact dialog

This commit is contained in:
iNPUTmice 2014-12-17 21:04:54 +01:00
parent c30108eb17
commit de952cc959

View File

@ -318,13 +318,10 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
protected void showCreateContactDialog(final String prefilledJid, final String fingerprint) { protected void showCreateContactDialog(final String prefilledJid, final String fingerprint) {
AlertDialog.Builder builder = new AlertDialog.Builder(this); AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.create_contact); builder.setTitle(R.string.create_contact);
View dialogView = getLayoutInflater().inflate( View dialogView = getLayoutInflater().inflate(R.layout.create_contact_dialog, null);
R.layout.create_contact_dialog, null);
final Spinner spinner = (Spinner) dialogView.findViewById(R.id.account); final Spinner spinner = (Spinner) dialogView.findViewById(R.id.account);
final AutoCompleteTextView jid = (AutoCompleteTextView) dialogView final AutoCompleteTextView jid = (AutoCompleteTextView) dialogView.findViewById(R.id.jid);
.findViewById(R.id.jid); jid.setAdapter(new KnownHostsAdapter(this,android.R.layout.simple_list_item_1, mKnownHosts));
jid.setAdapter(new KnownHostsAdapter(this,
android.R.layout.simple_list_item_1, mKnownHosts));
if (prefilledJid != null) { if (prefilledJid != null) {
jid.append(prefilledJid); jid.append(prefilledJid);
if (fingerprint!=null) { if (fingerprint!=null) {
@ -351,8 +348,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
if (Validator.isValidJid(jid.getText().toString())) { if (Validator.isValidJid(jid.getText().toString())) {
final Jid accountJid; final Jid accountJid;
try { try {
accountJid = Jid.fromString((String) spinner accountJid = Jid.fromString((String) spinner.getSelectedItem());
.getSelectedItem());
} catch (final InvalidJidException e) { } catch (final InvalidJidException e) {
return; return;
} }
@ -360,6 +356,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
try { try {
contactJid = Jid.fromString(jid.getText().toString()); contactJid = Jid.fromString(jid.getText().toString());
} catch (final InvalidJidException e) { } catch (final InvalidJidException e) {
jid.setError(getString(R.string.invalid_jid));
return; return;
} }
Account account = xmppConnectionService Account account = xmppConnectionService
@ -389,13 +386,10 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
protected void showJoinConferenceDialog(String prefilledJid) { protected void showJoinConferenceDialog(String prefilledJid) {
AlertDialog.Builder builder = new AlertDialog.Builder(this); AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.join_conference); builder.setTitle(R.string.join_conference);
View dialogView = getLayoutInflater().inflate( View dialogView = getLayoutInflater().inflate(R.layout.join_conference_dialog, null);
R.layout.join_conference_dialog, null);
final Spinner spinner = (Spinner) dialogView.findViewById(R.id.account); final Spinner spinner = (Spinner) dialogView.findViewById(R.id.account);
final AutoCompleteTextView jid = (AutoCompleteTextView) dialogView final AutoCompleteTextView jid = (AutoCompleteTextView) dialogView.findViewById(R.id.jid);
.findViewById(R.id.jid); jid.setAdapter(new KnownHostsAdapter(this,android.R.layout.simple_list_item_1, mKnownConferenceHosts));
jid.setAdapter(new KnownHostsAdapter(this,
android.R.layout.simple_list_item_1, mKnownConferenceHosts));
if (prefilledJid != null) { if (prefilledJid != null) {
jid.append(prefilledJid); jid.append(prefilledJid);
} }
@ -426,7 +420,8 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
try { try {
conferenceJid = Jid.fromString(jid.getText().toString()); conferenceJid = Jid.fromString(jid.getText().toString());
} catch (final InvalidJidException e) { } catch (final InvalidJidException e) {
return; // TODO: Do some error handling... jid.setError(getString(R.string.invalid_jid));
return;
} }
Account account = xmppConnectionService Account account = xmppConnectionService
.findAccountByJid(accountJid); .findAccountByJid(accountJid);