some improvements for the edit account activity

This commit is contained in:
iNPUTmice 2014-08-16 09:44:37 +02:00
parent 32c3dd4f4a
commit 5aa8afdc1c
3 changed files with 25 additions and 31 deletions

View file

@ -1287,6 +1287,7 @@ public class XmppConnectionService extends Service {
if (avatar!=null) { if (avatar!=null) {
avatar.owner = account.getJid(); avatar.owner = account.getJid();
if (fileBackend.isAvatarCached(avatar)) { if (fileBackend.isAvatarCached(avatar)) {
account.setAvatar(avatar.getFilename());
callback.success(avatar); callback.success(avatar);
} else { } else {
fetchAvatar(account, avatar,callback); fetchAvatar(account, avatar,callback);

View file

@ -31,28 +31,15 @@ public class EditAccountActivity extends XmppActivity {
private String jidToEdit; private String jidToEdit;
private Account mAccount; private Account mAccount;
private Avatar mAvatar = null;
private boolean mUserInputIsValid = false; private boolean mUserInputIsValid = false;
private boolean mFetchingAvatar = false; private boolean mFetchingAvatar = false;
private boolean mFinishedInitialSetup = false;
private OnClickListener mSaveButtonClickListener = new OnClickListener() { private OnClickListener mSaveButtonClickListener = new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (mAccount != null && mFinishedInitialSetup) { if (mAccount != null && mAccount.errorStatus()
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()
&& !mUserInputIsValid) { && !mUserInputIsValid) {
xmppConnectionService.reconnectAccount(mAccount, true); xmppConnectionService.reconnectAccount(mAccount, true);
return; return;
@ -116,11 +103,7 @@ public class EditAccountActivity extends XmppActivity {
@Override @Override
public void onTextChanged(CharSequence s, int start, int before, public void onTextChanged(CharSequence s, int start, int before,
int count) { int count) {
if (Validator.isValidJid(mAccountJid.getText().toString())) { mUserInputIsValid = inputDataDiffersFromAccount() && Validator.isValidJid(mAccountJid.getText().toString());
mUserInputIsValid = inputDataDiffersFromAccount();
} else {
mUserInputIsValid = false;
}
updateSaveButton(); updateSaveButton();
} }
@ -171,14 +154,20 @@ public class EditAccountActivity extends XmppActivity {
} }
}; };
protected void finishInitialSetup(Avatar avatar) { protected void finishInitialSetup(final Avatar avatar) {
this.mFinishedInitialSetup = true;
this.mAvatar = avatar;
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
@Override @Override
public void run() { 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() { protected void updateSaveButton() {
if (mAccount != null && mFinishedInitialSetup) { if (mAccount != null
this.mSaveButton.setEnabled(true);
this.mSaveButton.setTextColor(getPrimaryTextColor());
this.mSaveButton.setText(R.string.next);
} else if (mAccount != null
&& mAccount.getStatus() == Account.STATUS_CONNECTING && mAccount.getStatus() == Account.STATUS_CONNECTING
&& !mUserInputIsValid) { && !mUserInputIsValid) {
this.mSaveButton.setEnabled(false); this.mSaveButton.setEnabled(false);
@ -214,10 +199,19 @@ public class EditAccountActivity extends XmppActivity {
} else if (mUserInputIsValid) { } else if (mUserInputIsValid) {
this.mSaveButton.setEnabled(true); this.mSaveButton.setEnabled(true);
this.mSaveButton.setTextColor(getPrimaryTextColor()); this.mSaveButton.setTextColor(getPrimaryTextColor());
if (jidToEdit!=null) {
this.mSaveButton.setText(R.string.save);
} else {
this.mSaveButton.setText(R.string.next);
}
} else { } else {
this.mSaveButton.setEnabled(false); this.mSaveButton.setEnabled(false);
this.mSaveButton.setTextColor(getSecondaryTextColor()); 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 { } else {
mPasswordConfirm.setVisibility(View.GONE); mPasswordConfirm.setVisibility(View.GONE);
} }
mUserInputIsValid = inputDataDiffersFromAccount(); mUserInputIsValid = inputDataDiffersFromAccount() && Validator.isValidJid(mAccountJid.getText().toString());
updateSaveButton(); updateSaveButton();
} }
}); });

View file

@ -8,7 +8,6 @@ import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.services.XmppConnectionService.OnAccountUpdate; import eu.siacs.conversations.services.XmppConnectionService.OnAccountUpdate;
import eu.siacs.conversations.ui.adapter.AccountAdapter; import eu.siacs.conversations.ui.adapter.AccountAdapter;
import eu.siacs.conversations.xmpp.XmppConnection; import eu.siacs.conversations.xmpp.XmppConnection;
import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener; import android.content.DialogInterface.OnClickListener;