From 8fd688ca96005152be754eeba1be72c7c0aab9ad Mon Sep 17 00:00:00 2001 From: lookshe Date: Tue, 11 Aug 2015 17:35:53 +0200 Subject: Merge tag '1.5.2' into trz/rebase --- .../conversations/ui/EditAccountActivity.java | 40 ++++++++++++++-------- 1 file changed, 25 insertions(+), 15 deletions(-) (limited to 'src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java') diff --git a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java index 27dfc492..908c29d2 100644 --- a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java @@ -67,7 +67,7 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate @Override public void onClick(final View v) { - if (mAccount != null && mAccount.getStatus() == Account.State.DISABLED) { + if (mAccount != null && mAccount.getStatus() == Account.State.DISABLED && !accountInfoEdited()) { mAccount.setOption(Account.OPTION_DISABLED, false); xmppConnectionService.updateAccount(mAccount); return; @@ -123,11 +123,11 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate mAccount.setOption(Account.OPTION_REGISTER, registerNewAccount); xmppConnectionService.createAccount(mAccount); } - if (jidToEdit != null) { + if (jidToEdit != null && !mAccount.isOptionSet(Account.OPTION_DISABLED)) { finish(); } else { updateSaveButton(); - updateAccountInformation(); + updateAccountInformation(true); } } @@ -163,7 +163,7 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate updateSaveButton(); } if (mAccount != null) { - updateAccountInformation(); + updateAccountInformation(false); } } }); @@ -223,7 +223,9 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate if (avatar != null) { intent = new Intent(getApplicationContext(), StartConversationActivity.class); - intent.putExtra("init",true); + if (xmppConnectionService != null && xmppConnectionService.getAccounts().size() == 1) { + intent.putExtra("init", true); + } } else { intent = new Intent(getApplicationContext(), PublishProfilePictureActivity.class); @@ -237,7 +239,11 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate } protected void updateSaveButton() { - if (mAccount != null && (mAccount.getStatus() == Account.State.CONNECTING || mFetchingAvatar)) { + if (accountInfoEdited() && jidToEdit != null) { + this.mSaveButton.setText(R.string.save); + this.mSaveButton.setEnabled(true); + this.mSaveButton.setTextColor(getPrimaryTextColor()); + } else if (mAccount != null && (mAccount.getStatus() == Account.State.CONNECTING || mFetchingAvatar)) { this.mSaveButton.setEnabled(false); this.mSaveButton.setTextColor(getSecondaryTextColor()); this.mSaveButton.setText(R.string.account_status_connecting); @@ -265,9 +271,9 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate } protected boolean accountInfoEdited() { - return (!this.mAccount.getJid().toBareJid().toString().equals( - this.mAccountJid.getText().toString())) - || (!this.mAccount.getPassword().equals( + return this.mAccount != null && (!this.mAccount.getJid().toBareJid().toString().equals( + this.mAccountJid.getText().toString()) + || !this.mAccount.getPassword().equals( this.mPassword.getText().toString())); } @@ -378,7 +384,7 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate xmppConnectionService.getKnownHosts()); if (this.jidToEdit != null) { this.mAccount = xmppConnectionService.findAccountByJid(jidToEdit); - updateAccountInformation(); + updateAccountInformation(true); } else if (this.xmppConnectionService.getAccounts().size() == 0) { if (getActionBar() != null) { getActionBar().setDisplayHomeAsUpEnabled(false); @@ -413,9 +419,11 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate return super.onOptionsItemSelected(item); } - private void updateAccountInformation() { - this.mAccountJid.setText(this.mAccount.getJid().toBareJid().toString()); - this.mPassword.setText(this.mAccount.getPassword()); + private void updateAccountInformation(boolean init) { + if (init) { + this.mAccountJid.setText(this.mAccount.getJid().toBareJid().toString()); + this.mPassword.setText(this.mAccount.getPassword()); + } if (this.jidToEdit != null) { this.mAvatar.setVisibility(View.VISIBLE); this.mAvatar.setImageBitmap(avatarService().get(this.mAccount, getPixel(72))); @@ -464,7 +472,7 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate } else { this.mServerInfoSm.setText(R.string.server_info_unavailable); } - if (features.pubsub()) { + if (features.pep()) { this.mServerInfoPep.setText(R.string.server_info_available); } else { this.mServerInfoPep.setText(R.string.server_info_unavailable); @@ -495,7 +503,9 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate } else { if (this.mAccount.errorStatus()) { this.mAccountJid.setError(getString(this.mAccount.getStatus().getReadableId())); - this.mAccountJid.requestFocus(); + if (init || !accountInfoEdited()) { + this.mAccountJid.requestFocus(); + } } else { this.mAccountJid.setError(null); } -- cgit v1.2.3