diff --git a/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java b/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java index 3798985de..6c89d9d5f 100644 --- a/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java +++ b/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java @@ -535,7 +535,7 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded { } else { if (AxolotlService.this.changeAccessMode.compareAndSet(true,false)) { Log.d(Config.LOGTAG,account.getJid().toBareJid()+": done changing access mode"); - account.setOption(Account.OPTION_REQURIES_ACCESS_MODE_CHANGE,false); + account.setOption(Account.OPTION_REQUIRES_ACCESS_MODE_CHANGE,false); mXmppConnectionService.databaseBackend.updateAccount(account); } ownPushPending.set(false); @@ -591,7 +591,7 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded { Log.d(Config.LOGTAG, getLogprefix(account) + "publishBundlesIfNeeded called, but PEP is broken. Ignoring... "); return; } - this.changeAccessMode.set(account.isOptionSet(Account.OPTION_REQURIES_ACCESS_MODE_CHANGE) && account.getXmppConnection().getFeatures().pepPublishOptions()); + this.changeAccessMode.set(account.isOptionSet(Account.OPTION_REQUIRES_ACCESS_MODE_CHANGE) && account.getXmppConnection().getFeatures().pepPublishOptions()); if (this.changeAccessMode.get()) { Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": server gained publish-options capabilities. changing access model"); } diff --git a/src/main/java/eu/siacs/conversations/entities/Account.java b/src/main/java/eu/siacs/conversations/entities/Account.java index fb06de7d0..08975db66 100644 --- a/src/main/java/eu/siacs/conversations/entities/Account.java +++ b/src/main/java/eu/siacs/conversations/entities/Account.java @@ -57,7 +57,8 @@ public class Account extends AbstractEntity { public static final int OPTION_REGISTER = 2; public static final int OPTION_USECOMPRESSION = 3; public static final int OPTION_MAGIC_CREATE = 4; - public static final int OPTION_REQURIES_ACCESS_MODE_CHANGE = 5; + public static final int OPTION_REQUIRES_ACCESS_MODE_CHANGE = 5; + public static final int OPTION_LOGGED_IN_SUCCESSFULLY = 6; public final HashSet> inProgressDiscoFetches = new HashSet<>(); public boolean httpUploadAvailable(long filesize) { @@ -295,12 +296,14 @@ public class Account extends AbstractEntity { return ((options & (1 << option)) != 0); } - public void setOption(final int option, final boolean value) { + public boolean setOption(final int option, final boolean value) { + final int before = this.options; if (value) { this.options |= 1 << option; } else { this.options &= ~(1 << option); } + return before != this.options; } public String getUsername() { diff --git a/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java b/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java index 8dc9e62ce..d9e431034 100644 --- a/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java +++ b/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java @@ -10,7 +10,6 @@ import android.database.sqlite.SQLiteOpenHelper; import android.os.Environment; import android.util.Base64; import android.util.Log; -import android.util.Pair; import org.json.JSONObject; import org.whispersystems.libsignal.SignalProtocolAddress; @@ -449,7 +448,8 @@ public class DatabaseBackend extends SQLiteOpenHelper { if (oldVersion < 36 && newVersion >= 36) { List accounts = getAccounts(db); for (Account account : accounts) { - account.setOption(Account.OPTION_REQURIES_ACCESS_MODE_CHANGE,true); + account.setOption(Account.OPTION_REQUIRES_ACCESS_MODE_CHANGE,true); + account.setOption(Account.OPTION_LOGGED_IN_SUCCESSFULLY,false); db.update(Account.TABLENAME, account.getContentValues(), Account.UUID + "=?", new String[]{account.getUuid()}); } diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 392939bd8..9c54741d5 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -300,6 +300,9 @@ public class XmppConnectionService extends Service { } } } + if (account.setOption(Account.OPTION_LOGGED_IN_SUCCESSFULLY,true)) { + databaseBackend.updateAccount(account); + } account.getRoster().clearPresences(); mJingleConnectionManager.cancelInTransmission(); fetchRosterFromServer(account); diff --git a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java index 0da8ed158..481039156 100644 --- a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java @@ -843,7 +843,8 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat } else { this.mAccountJid.getEditableText().append(this.mAccount.getJid().toBareJid().toString()); } - this.mPassword.setText(this.mAccount.getPassword()); + this.mPassword.getEditableText().clear(); + this.mPassword.getEditableText().append(this.mAccount.getPassword()); this.mHostname.setText(""); this.mHostname.getEditableText().append(this.mAccount.getHostname()); this.mPort.setText(""); @@ -852,6 +853,11 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat } + final boolean editable = !mAccount.isOptionSet(Account.OPTION_LOGGED_IN_SUCCESSFULLY); + this.mAccountJid.setEnabled(editable); + this.mAccountJid.setFocusable(editable); + this.mAccountJid.setFocusableInTouchMode(editable); + if (!mInitMode) { this.mAvatar.setVisibility(View.VISIBLE); this.mAvatar.setImageBitmap(avatarService().get(this.mAccount, getPixel(72)));