From 7fc7201abbef6b8532eaa35b1f896eb216e6b0eb Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sun, 18 May 2014 11:49:44 +0200 Subject: [PATCH] cleaned up edit account dialog a little --- res/values-de/strings.xml | 4 +++ res/values/strings.xml | 4 +++ .../siacs/conversations/ui/EditAccount.java | 33 ++++++++----------- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml index 883768420..292a81e81 100644 --- a/res/values-de/strings.xml +++ b/res/values-de/strings.xml @@ -164,5 +164,9 @@ Vorübergehend abschalten Anschalten Sprache aufzeichnen + Kontoeinstellungen + Speichern + Passwörter stimmen nicht überein + Ungültige Jabber ID \ No newline at end of file diff --git a/res/values/strings.xml b/res/values/strings.xml index 9841aa60c..2b5c25f27 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -164,5 +164,9 @@ Temporarily disable Enable Record voice + Account Settings + Save + Passwords do not match + This is not a valid Jabber ID \ No newline at end of file diff --git a/src/eu/siacs/conversations/ui/EditAccount.java b/src/eu/siacs/conversations/ui/EditAccount.java index 8b1c0fa64..47930747b 100644 --- a/src/eu/siacs/conversations/ui/EditAccount.java +++ b/src/eu/siacs/conversations/ui/EditAccount.java @@ -51,27 +51,19 @@ public class EditAccount extends DialogFragment { final CheckBox registerAccount = (CheckBox) view .findViewById(R.id.edit_account_register_new); - final String okButtonDesc; - if (account != null) { jidText.setText(account.getJid()); password.setText(account.getPassword()); - Log.d("xmppService","mein debugger. account != null"); if (account.isOptionSet(Account.OPTION_REGISTER)) { registerAccount.setChecked(true); - builder.setTitle(getString(R.string.register_account)); - okButtonDesc = "Register"; passwordConfirm.setVisibility(View.VISIBLE); passwordConfirm.setText(account.getPassword()); } else { registerAccount.setVisibility(View.GONE); - builder.setTitle("Edit account"); - okButtonDesc = "Edit"; } - } else { - builder.setTitle("Add account"); - okButtonDesc = "Add"; } + builder.setTitle(R.string.account_settings); + registerAccount .setOnCheckedChangeListener(new OnCheckedChangeListener() { @@ -79,26 +71,19 @@ public class EditAccount extends DialogFragment { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - AlertDialog d = (AlertDialog) getDialog(); - Button positiveButton = (Button) d - .getButton(Dialog.BUTTON_POSITIVE); if (isChecked) { - d.setTitle(getString(R.string.register_account)); - positiveButton.setText("Register"); passwordConfirm.setVisibility(View.VISIBLE); confirmPwDesc.setVisibility(View.VISIBLE); } else { - d.setTitle("Add account"); passwordConfirm.setVisibility(View.GONE); - positiveButton.setText("Add"); confirmPwDesc.setVisibility(View.GONE); } } }); builder.setView(view); - builder.setNeutralButton("Cancel", null); - builder.setPositiveButton(okButtonDesc, null); + builder.setNeutralButton(R.string.cancel, null); + builder.setPositiveButton(R.string.save, null); return builder.create(); } @@ -114,7 +99,9 @@ public class EditAccount extends DialogFragment { String jid = jidEdit.getText().toString(); EditText passwordEdit = (EditText) d .findViewById(R.id.account_password); + EditText passwordConfirmEdit = (EditText) d.findViewById(R.id.account_password_confirm2); String password = passwordEdit.getText().toString(); + String passwordConfirm = passwordConfirmEdit.getText().toString(); CheckBox register = (CheckBox) d.findViewById(R.id.edit_account_register_new); String username; String server; @@ -123,9 +110,15 @@ public class EditAccount extends DialogFragment { username = parts[0]; server = parts[1]; } else { - jidEdit.setError("Invalid Jabber ID"); + jidEdit.setError(getString(R.string.invalid_jid)); return; } + if (register.isChecked()) { + if (!passwordConfirm.equals(password)) { + passwordConfirmEdit.setError(getString(R.string.passwords_do_not_match)); + return; + } + } if (account != null) { account.setPassword(password); account.setUsername(username);