diff options
Diffstat (limited to 'src/main/java/de/pixart/messenger/ui/EditAccountActivity.java')
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/EditAccountActivity.java | 56 |
1 files changed, 20 insertions, 36 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java index 5daaafacd..92962fb45 100644 --- a/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java +++ b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java @@ -56,6 +56,7 @@ import de.pixart.messenger.entities.Presence; import de.pixart.messenger.entities.PresenceTemplate; import de.pixart.messenger.entities.ServiceDiscoveryResult; import de.pixart.messenger.services.BarcodeProvider; +import de.pixart.messenger.services.QuickConversationsService; import de.pixart.messenger.services.XmppConnectionService; import de.pixart.messenger.services.XmppConnectionService.OnAccountUpdate; import de.pixart.messenger.services.XmppConnectionService.OnCaptchaRequested; @@ -66,6 +67,7 @@ import de.pixart.messenger.ui.util.SoftKeyboardUtils; import de.pixart.messenger.utils.CryptoHelper; import de.pixart.messenger.utils.MenuDoubleTabUtil; import de.pixart.messenger.utils.Namespace; +import de.pixart.messenger.utils.Resolver; import de.pixart.messenger.utils.SignupUtils; import de.pixart.messenger.utils.UIHelper; import de.pixart.messenger.utils.XmppUri; @@ -106,11 +108,6 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat final String password = binding.accountPassword.getText().toString(); final boolean wasDisabled = mAccount != null && mAccount.getStatus() == Account.State.DISABLED; final boolean accountInfoEdited = accountInfoEdited(); - - if (!mInitMode && passwordChangedInMagicCreateMode()) { - gotoChangePassword(password); - return; - } if (mInitMode && mAccount != null) { mAccount.setOption(Account.OPTION_DISABLED, false); } @@ -206,7 +203,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat } } if (mAccount != null) { - if (mInitMode && mAccount.isOptionSet(Account.OPTION_MAGIC_CREATE)) { + if (mAccount.isOptionSet(Account.OPTION_MAGIC_CREATE)) { mAccount.setOption(Account.OPTION_MAGIC_CREATE, mAccount.getPassword().contains(password)); } mAccount.setJid(jid); @@ -465,11 +462,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat protected void updateSaveButton() { boolean accountInfoEdited = accountInfoEdited(); - - if (!mInitMode && passwordChangedInMagicCreateMode()) { - this.binding.saveButton.setText(R.string.change_password); - this.binding.saveButton.setEnabled(true); - } else if (accountInfoEdited && !mInitMode) { + if (accountInfoEdited && !mInitMode) { this.binding.saveButton.setText(R.string.save); this.binding.saveButton.setEnabled(true); } else if (mAccount != null @@ -528,14 +521,6 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat return !unmodified.equals(this.binding.accountJid.getText().toString()); } - protected boolean passwordChangedInMagicCreateMode() { - return mAccount != null - && mAccount.isOptionSet(Account.OPTION_MAGIC_CREATE) - && !this.mAccount.getPassword().equals(binding.accountPassword.getText().toString()) - && !this.jidEdited() - && mAccount.isOnlineAndConnected(); - } - @Override protected String getShareableUri(boolean http) { if (mAccount != null) { @@ -562,20 +547,17 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat this.binding.hostname.addTextChangedListener(mTextWatcher); this.binding.hostname.setOnFocusChangeListener(mEditTextFocusListener); this.binding.clearDevices.setOnClickListener(v -> showWipePepDialog()); - this.binding.port.setText("5222"); + this.binding.port.setText(String.valueOf(Resolver.DEFAULT_PORT_XMPP)); this.binding.port.addTextChangedListener(mTextWatcher); this.binding.saveButton.setOnClickListener(this.mSaveButtonClickListener); this.binding.cancelButton.setOnClickListener(this.mCancelButtonClickListener); if (savedInstanceState != null && savedInstanceState.getBoolean("showMoreTable")) { changeMoreTableVisibility(true); } - final OnCheckedChangeListener OnCheckedShowConfirmPassword = new OnCheckedChangeListener() { - @Override - public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) { - updatePortLayout(); - updateSaveButton(); - updateInfoButtons(); - } + final OnCheckedChangeListener OnCheckedShowConfirmPassword = (buttonView, isChecked) -> { + updatePortLayout(); + updateSaveButton(); + updateInfoButtons(); }; this.binding.accountRegisterNew.setOnCheckedChangeListener(OnCheckedShowConfirmPassword); if (Config.DISALLOW_REGISTRATION_IN_UI) { @@ -689,8 +671,8 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat } } SharedPreferences preferences = getPreferences(); - mUseTor = Config.FORCE_ORBOT || preferences.getBoolean("use_tor", false); - this.mShowOptions = mUseTor || preferences.getBoolean("show_connection_options", false); + mUseTor = QuickConversationsService.isConversations() && preferences.getBoolean("use_tor", getResources().getBoolean(R.bool.use_tor)); + this.mShowOptions = mUseTor || (QuickConversationsService.isConversations() && preferences.getBoolean("show_connection_options", getResources().getBoolean(R.bool.show_connection_options))); this.binding.namePort.setVisibility(mShowOptions ? View.VISIBLE : View.GONE); } @@ -976,16 +958,18 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat } - final boolean editable = !mAccount.isOptionSet(Account.OPTION_LOGGED_IN_SUCCESSFULLY); + final boolean editable = !mAccount.isOptionSet(Account.OPTION_LOGGED_IN_SUCCESSFULLY) && QuickConversationsService.isConversations(); this.binding.accountJid.setEnabled(editable); this.binding.accountJid.setFocusable(editable); this.binding.accountJid.setFocusableInTouchMode(editable); - if (mAccount.isOptionSet(Account.OPTION_MAGIC_CREATE) || !mAccount.isOptionSet(Account.OPTION_LOGGED_IN_SUCCESSFULLY)) { - this.binding.accountPasswordLayout.setPasswordVisibilityToggleEnabled(true); - } else { - this.binding.accountPasswordLayout.setPasswordVisibilityToggleEnabled(false); - } + final boolean tooglePassword = mAccount.isOptionSet(Account.OPTION_MAGIC_CREATE) || !mAccount.isOptionSet(Account.OPTION_LOGGED_IN_SUCCESSFULLY); + final boolean editPassword = !mAccount.isOptionSet(Account.OPTION_MAGIC_CREATE) || (!mAccount.isOptionSet(Account.OPTION_LOGGED_IN_SUCCESSFULLY) && QuickConversationsService.isConversations()) || mAccount.getLastErrorStatus() == Account.State.UNAUTHORIZED; + this.binding.accountPasswordLayout.setPasswordVisibilityToggleEnabled(tooglePassword); + this.binding.accountPassword.setFocusable(editPassword); + this.binding.accountPassword.setFocusableInTouchMode(editPassword); + this.binding.accountPassword.setCursorVisible(editPassword); + this.binding.accountPassword.setEnabled(editPassword); if (!mInitMode) { binding.avater.setVisibility(View.VISIBLE); @@ -1062,7 +1046,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat if (getHttpUploadMaxFileSize().equals("0")) { this.binding.serverInfoHttpUpload.setText(R.string.server_info_available); } else { - this.binding.serverInfoHttpUpload.setText(getString(R.string.server_info_available_with, getHttpUploadMaxFileSize())); + this.binding.serverInfoHttpUpload.setText(getHttpUploadMaxFileSize()); } } else if (features.p1S3FileTransfer()) { this.binding.serverInfoHttpUploadDescription.setText(R.string.p1_s3_filetransfer); |