From 5aa8afdc1c0c60a47f8e93076697ad65e702764d Mon Sep 17 00:00:00 2001 From: iNPUTmice Date: Sat, 16 Aug 2014 09:44:37 +0200 Subject: [PATCH] some improvements for the edit account activity --- .../services/XmppConnectionService.java | 1 + .../conversations/ui/EditAccountActivity.java | 54 +++++++++---------- .../ui/ManageAccountActivity.java | 1 - 3 files changed, 25 insertions(+), 31 deletions(-) diff --git a/src/eu/siacs/conversations/services/XmppConnectionService.java b/src/eu/siacs/conversations/services/XmppConnectionService.java index 01915806a..2c27315e2 100644 --- a/src/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/eu/siacs/conversations/services/XmppConnectionService.java @@ -1287,6 +1287,7 @@ public class XmppConnectionService extends Service { if (avatar!=null) { avatar.owner = account.getJid(); if (fileBackend.isAvatarCached(avatar)) { + account.setAvatar(avatar.getFilename()); callback.success(avatar); } else { fetchAvatar(account, avatar,callback); diff --git a/src/eu/siacs/conversations/ui/EditAccountActivity.java b/src/eu/siacs/conversations/ui/EditAccountActivity.java index 681be439c..e5920cdfe 100644 --- a/src/eu/siacs/conversations/ui/EditAccountActivity.java +++ b/src/eu/siacs/conversations/ui/EditAccountActivity.java @@ -31,28 +31,15 @@ public class EditAccountActivity extends XmppActivity { private String jidToEdit; private Account mAccount; - private Avatar mAvatar = null; private boolean mUserInputIsValid = false; private boolean mFetchingAvatar = false; - private boolean mFinishedInitialSetup = false; private OnClickListener mSaveButtonClickListener = new OnClickListener() { @Override public void onClick(View v) { - if (mAccount != null && mFinishedInitialSetup) { - Intent intent; - if (mAvatar!=null) { - intent = new Intent(getApplicationContext(), StartConversationActivity.class); - } else { - intent = new Intent(getApplicationContext(), PublishProfilePictureActivity.class); - intent.putExtra("account", mAccount.getJid()); - } - startActivity(intent); - finish(); - return; - } else if (mAccount != null && mAccount.errorStatus() + if (mAccount != null && mAccount.errorStatus() && !mUserInputIsValid) { xmppConnectionService.reconnectAccount(mAccount, true); return; @@ -116,11 +103,7 @@ public class EditAccountActivity extends XmppActivity { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { - if (Validator.isValidJid(mAccountJid.getText().toString())) { - mUserInputIsValid = inputDataDiffersFromAccount(); - } else { - mUserInputIsValid = false; - } + mUserInputIsValid = inputDataDiffersFromAccount() && Validator.isValidJid(mAccountJid.getText().toString()); updateSaveButton(); } @@ -171,14 +154,20 @@ public class EditAccountActivity extends XmppActivity { } }; - protected void finishInitialSetup(Avatar avatar) { - this.mFinishedInitialSetup = true; - this.mAvatar = avatar; + protected void finishInitialSetup(final Avatar avatar) { runOnUiThread(new Runnable() { @Override public void run() { - updateSaveButton(); + Intent intent; + if (avatar!=null) { + intent = new Intent(getApplicationContext(), StartConversationActivity.class); + } else { + intent = new Intent(getApplicationContext(), PublishProfilePictureActivity.class); + intent.putExtra("account", mAccount.getJid()); + } + startActivity(intent); + finish(); } }); } @@ -196,11 +185,7 @@ public class EditAccountActivity extends XmppActivity { } protected void updateSaveButton() { - if (mAccount != null && mFinishedInitialSetup) { - this.mSaveButton.setEnabled(true); - this.mSaveButton.setTextColor(getPrimaryTextColor()); - this.mSaveButton.setText(R.string.next); - } else if (mAccount != null + if (mAccount != null && mAccount.getStatus() == Account.STATUS_CONNECTING && !mUserInputIsValid) { this.mSaveButton.setEnabled(false); @@ -214,10 +199,19 @@ public class EditAccountActivity extends XmppActivity { } else if (mUserInputIsValid) { this.mSaveButton.setEnabled(true); this.mSaveButton.setTextColor(getPrimaryTextColor()); + if (jidToEdit!=null) { + this.mSaveButton.setText(R.string.save); + } else { + this.mSaveButton.setText(R.string.next); + } } else { this.mSaveButton.setEnabled(false); this.mSaveButton.setTextColor(getSecondaryTextColor()); - this.mSaveButton.setText(R.string.save); + if (jidToEdit!=null) { + this.mSaveButton.setText(R.string.save); + } else { + this.mSaveButton.setText(R.string.next); + } } } @@ -244,7 +238,7 @@ public class EditAccountActivity extends XmppActivity { } else { mPasswordConfirm.setVisibility(View.GONE); } - mUserInputIsValid = inputDataDiffersFromAccount(); + mUserInputIsValid = inputDataDiffersFromAccount() && Validator.isValidJid(mAccountJid.getText().toString()); updateSaveButton(); } }); diff --git a/src/eu/siacs/conversations/ui/ManageAccountActivity.java b/src/eu/siacs/conversations/ui/ManageAccountActivity.java index d522a733d..803917b97 100644 --- a/src/eu/siacs/conversations/ui/ManageAccountActivity.java +++ b/src/eu/siacs/conversations/ui/ManageAccountActivity.java @@ -8,7 +8,6 @@ import eu.siacs.conversations.entities.Account; import eu.siacs.conversations.services.XmppConnectionService.OnAccountUpdate; import eu.siacs.conversations.ui.adapter.AccountAdapter; import eu.siacs.conversations.xmpp.XmppConnection; -import android.app.Activity; import android.app.AlertDialog; import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener;