gt: 			if (!mAccount.getXmppConnection().getFeatures().blocking()) {
context: package org.frozenbox.frozenchat.ui;
  
  import android.app.AlertDialog;
  import android.app.AlertDialog.Builder;
  import android.app.PendingIntent;
  import android.content.DialogInterface;
  import android.content.Intent;
  import android.content.SharedPreferences;
  import android.graphics.Bitmap;
  import android.net.Uri;
  import android.os.Bundle;
  import android.provider.Settings;
  import android.security.KeyChain;
  import android.security.KeyChainAliasCallback;
  import android.text.Editable;
  import android.text.TextWatcher;
  import android.view.Menu;
  import android.view.MenuItem;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.widget.AutoCompleteTextView;
  import android.widget.Button;
  import android.widget.CheckBox;
  import android.widget.CompoundButton;
  import android.widget.CompoundButton.OnCheckedChangeListener;
  import android.widget.EditText;
  import android.widget.ImageButton;
  import android.widget.ImageView;
  import android.widget.LinearLayout;
  import android.widget.RelativeLayout;
  import android.widget.TableLayout;
  import android.widget.TableRow;
  import android.widget.TextView;
  import android.widget.Toast;
  
  import java.util.Arrays;
  import java.util.List;
  import java.util.Set;
  import java.util.concurrent.atomic.AtomicInteger;
  
  import org.frozenbox.frozenchat.Config;
  import org.frozenbox.frozenchat.R;
  import org.frozenbox.frozenchat.crypto.axolotl.AxolotlService;
  import org.frozenbox.frozenchat.entities.Account;
  import org.frozenbox.frozenchat.services.XmppConnectionService.OnCaptchaRequested;
  import org.frozenbox.frozenchat.services.XmppConnectionService;
  import org.frozenbox.frozenchat.services.XmppConnectionService.OnAccountUpdate;
  import org.frozenbox.frozenchat.ui.adapter.KnownHostsAdapter;
  import org.frozenbox.frozenchat.utils.CryptoHelper;
  import org.frozenbox.frozenchat.utils.UIHelper;
  import org.frozenbox.frozenchat.xml.Element;
  import org.frozenbox.frozenchat.xmpp.OnKeyStatusUpdated;
  import org.frozenbox.frozenchat.xmpp.XmppConnection;
  import org.frozenbox.frozenchat.xmpp.XmppConnection.Features;
  import org.frozenbox.frozenchat.xmpp.forms.Data;
  import org.frozenbox.frozenchat.xmpp.jid.InvalidJidException;
  import org.frozenbox.frozenchat.xmpp.jid.Jid;
  import org.frozenbox.frozenchat.xmpp.pep.Avatar;
  
  public class EditAccountActivity extends XmppActivity implements OnAccountUpdate,
  		OnKeyStatusUpdated, OnCaptchaRequested, KeyChainAliasCallback, XmppConnectionService.OnShowErrorToast, XmppConnectionService.OnMamPreferencesFetched {
  
  	private AutoCompleteTextView mAccountJid;
  	private EditText mPassword;
  	private EditText mPasswordConfirm;
  	private CheckBox mRegisterNew;
  	private Button mCancelButton;
  	private Button mSaveButton;
  	private Button mDisableBatterOptimizations;
  	private TableLayout mMoreTable;
  
  	private LinearLayout mStats;
  	private RelativeLayout mBatteryOptimizations;
  	private TextView mServerInfoSm;
  	private TextView mServerInfoRosterVersion;
  	private TextView mServerInfoCarbons;
  	private TextView mServerInfoMam;
  	private TextView mServerInfoCSI;
  	private TextView mServerInfoBlocking;
  	private TextView mServerInfoPep;
  	private TextView mServerInfoHttpUpload;
  	private TextView mServerInfoPush;
  	private TextView mSessionEst;
  	private TextView mOtrFingerprint;
  	private TextView mAxolotlFingerprint;
  	private TextView mAccountJidLabel;
  	private ImageView mAvatar;
  	private RelativeLayout mOtrFingerprintBox;
  	private RelativeLayout mAxolotlFingerprintBox;
  	private ImageButton mOtrFingerprintToClipboardButton;
  	private ImageButton mAxolotlFingerprintToClipboardButton;
  	private ImageButton mRegenerateAxolotlKeyButton;
  	private LinearLayout keys;
  	private LinearLayout keysCard;
  	private LinearLayout mNamePort;
  	private EditText mHostname;
  	private EditText mPort;
  	private AlertDialog mCaptchaDialog = null;
  
  	private Jid jidToEdit;
  	private boolean mInitMode = false;
  	private boolean mShowOptions = false;
  	private Account mAccount;
  	private String messageFingerprint;
  
  	private boolean mFetchingAvatar = false;
  
  	private final OnClickListener mSaveButtonClickListener = new OnClickListener() {
  
  		@Override
  		public void onClick(final View v) {
  			if (mInitMode && mAccount != null) {
  				mAccount.setOption(Account.OPTION_DISABLED, false);
  			}
  			if (mAccount != null && mAccount.getStatus() == Account.State.DISABLED && !accountInfoEdited()) {
  				mAccount.setOption(Account.OPTION_DISABLED, false);
  				xmppConnectionService.updateAccount(mAccount);
  				return;
  			}
  			final boolean registerNewAccount = mRegisterNew.isChecked() && !Config.DISALLOW_REGISTRATION_IN_UI;
  			if (Config.DOMAIN_LOCK != null && mAccountJid.getText().toString().contains("@")) {
  				mAccountJid.setError(getString(R.string.invalid_username));
  				mAccountJid.requestFocus();
  				return;
  			}
  			final Jid jid;
  			try {
  				if (Config.DOMAIN_LOCK != null) {
  					jid = Jid.fromParts(mAccountJid.getText().toString(), Config.DOMAIN_LOCK, null);
  				} else {
  					jid = Jid.fromString(mAccountJid.getText().toString());
  				}
  			} catch (final InvalidJidException e) {
  				if (Config.DOMAIN_LOCK != null) {
  					mAccountJid.setError(getString(R.string.invalid_username));
  				} else {
  					mAccountJid.setError(getString(R.string.invalid_jid));
  				}
  				mAccountJid.requestFocus();
  				return;
  			}
  			String hostname = null;
  			int numericPort = 5222;
  			if (mShowOptions) {
  				hostname = mHostname.getText().toString();
  				final String port = mPort.getText().toString();
  				if (hostname.contains(" ")) {
  					mHostname.setError(getString(R.string.not_valid_hostname));
  					mHostname.requestFocus();
  					return;
  				}
  				try {
  					numericPort = Integer.parseInt(port);
  					if (numericPort < 0 || numericPort > 65535) {
  						mPort.setError(getString(R.string.not_a_valid_port));
  						mPort.requestFocus();
  						return;
  					}
  
  				} catch (NumberFormatException e) {
  					mPort.setError(getString(R.string.not_a_valid_port));
  					mPort.requestFocus();
  					return;
  				}
  			}
  
  			if (jid.isDomainJid()) {
  				if (Config.DOMAIN_LOCK != null) {
  					mAccountJid.setError(getString(R.string.invalid_username));
  				} else {
  					mAccountJid.setError(getString(R.string.invalid_jid));
  				}
  				mAccountJid.requestFocus();
  				return;
  			}
  			final String password = mPassword.getText().toString();
  			final String passwordConfirm = mPasswordConfirm.getText().toString();
  			if (registerNewAccount) {
  				if (!password.equals(passwordConfirm)) {
  					mPasswordConfirm.setError(getString(R.string.passwords_do_not_match));
  					mPasswordConfirm.requestFocus();
  					return;
  				}
  			}
  			if (mAccount != null) {
  				mAccount.setJid(jid);
  				mAccount.setPort(numericPort);
  				mAccount.setHostname(hostname);
  				mAccountJid.setError(null);
  				mPasswordConfirm.setError(null);
  				mAccount.setPassword(password);
  				mAccount.setOption(Account.OPTION_REGISTER, registerNewAccount);
  				xmppConnectionService.updateAccount(mAccount);
  			} else {
  				if (xmppConnectionService.findAccountByJid(jid) != null) {
  					mAccountJid.setError(getString(R.string.account_already_exists));
  					mAccountJid.requestFocus();
  					return;
  				}
  				mAccount = new Account(jid.toBareJid(), password);
  				mAccount.setPort(numericPort);
  				mAccount.setHostname(hostname);
  				mAccount.setOption(Account.OPTION_USETLS, true);
  				mAccount.setOption(Account.OPTION_USECOMPRESSION, true);
  				mAccount.setOption(Account.OPTION_REGISTER, registerNewAccount);
  				xmppConnectionService.createAccount(mAccount);
  			}
  			mHostname.setError(null);
  			mPort.setError(null);
  			if (!mAccount.isOptionSet(Account.OPTION_DISABLED)
  					&& !registerNewAccount
  					&& !mInitMode) {
  				finish();
  			} else {
  				updateSaveButton();
  				updateAccountInformation(true);
  			}
  
  		}
  	};
  	private final OnClickListener mCancelButtonClickListener = new OnClickListener() {
  
  		@Override
  		public void onClick(final View v) {
  			finish();
  		}
  	};
  	private Toast mFetchingMamPrefsToast;
  	private TableRow mPushRow;
  
  	public void refreshUiReal() {
  		invalidateOptionsMenu();
  		if (mAccount != null
  				&& mAccount.getStatus() != Account.State.ONLINE
  				&& mFetchingAvatar) {
  			startActivity(new Intent(getApplicationContext(),
  					ManageAccountActivity.class));
  			finish();
  		} else if (mInitMode && mAccount != null && mAccount.getStatus() == Account.State.ONLINE) {
  			if (!mFetchingAvatar) {
  				mFetchingAvatar = true;
  				xmppConnectionService.checkForAvatar(mAccount, mAvatarFetchCallback);
  			}
  		} else {
  			updateSaveButton();
  		}
  		if (mAccount != null) {
  			updateAccountInformation(false);
  		}
  	}
  
  	@Override
  	public void onAccountUpdate() {
  		refreshUi();
  	}
  
  	private final UiCallback<Avatar> mAvatarFetchCallback = new UiCallback<Avatar>() {
  
  		@Override
  		public void userInputRequried(final PendingIntent pi, final Avatar avatar) {
  			finishInitialSetup(avatar);
  		}
  
  		@Override
  		public void success(final Avatar avatar) {
  			finishInitialSetup(avatar);
  		}
  
  		@Override
  		public void error(final int errorCode, final Avatar avatar) {
  			finishInitialSetup(avatar);
  		}
  	};
  	private final TextWatcher mTextWatcher = new TextWatcher() {
  
  		@Override
  		public void onTextChanged(final CharSequence s, final int start, final int before, final int count) {
  			updateSaveButton();
  		}
  
  		@Override
  		public void beforeTextChanged(final CharSequence s, final int start, final int count, final int after) {
  		}
  
  		@Override
  		public void afterTextChanged(final Editable s) {
  
  		}
  	};
  
  	private final OnClickListener mAvatarClickListener = new OnClickListener() {
  		@Override
  		public void onClick(final View view) {
  			if (mAccount != null) {
  				final Intent intent = new Intent(getApplicationContext(), PublishProfilePictureActivity.class);
  				intent.putExtra(EXTRA_ACCOUNT, mAccount.getJid().toBareJid().toString());
  				startActivity(intent);
  			}
  		}
  	};
  
  	protected void finishInitialSetup(final Avatar avatar) {
  		runOnUiThread(new Runnable() {
  
  			@Override
  			public void run() {
  				final Intent intent;
  				final XmppConnection connection = mAccount.getXmppConnection();
  				if (avatar != null || (connection != null && !connection.getFeatures().pep())) {
  					intent = new Intent(getApplicationContext(), StartConversationActivity.class);
  					if (xmppConnectionService != null && xmppConnectionService.getAccounts().size() == 1) {
  						intent.putExtra("init", true);
  					}
  				} else {
  					intent = new Intent(getApplicationContext(), PublishProfilePictureActivity.class);
  					intent.putExtra(EXTRA_ACCOUNT, mAccount.getJid().toBareJid().toString());
  					intent.putExtra("setup", true);
  				}
  				startActivity(intent);
  				finish();
  			}
  		});
  	}
  
  	@Override
  	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  		super.onActivityResult(requestCode, resultCode, data);
  		if (requestCode == REQUEST_BATTERY_OP) {
  			updateAccountInformation(mAccount == null);
  		}
  	}
  
  	protected void updateSaveButton() {
  		if (accountInfoEdited() && !mInitMode) {
  			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);
  		} else if (mAccount != null && mAccount.getStatus() == Account.State.DISABLED && !mInitMode) {
  			this.mSaveButton.setEnabled(true);
  			this.mSaveButton.setTextColor(getPrimaryTextColor());
  			this.mSaveButton.setText(R.string.enable);
  		} else {
  			this.mSaveButton.setEnabled(true);
  			this.mSaveButton.setTextColor(getPrimaryTextColor());
  			if (!mInitMode) {
  				if (mAccount != null && mAccount.isOnlineAndConnected()) {
  					this.mSaveButton.setText(R.string.save);
  					if (!accountInfoEdited()) {
  						this.mSaveButton.setEnabled(false);
  						this.mSaveButton.setTextColor(getSecondaryTextColor());
  					}
  				} else {
  					this.mSaveButton.setText(R.string.connect);
  				}
  			} else {
  				this.mSaveButton.setText(R.string.next);
  			}
  		}
  	}
  
  	protected boolean accountInfoEdited() {
  		if (this.mAccount == null) {
  			return false;
  		}
  		final String unmodified;
  		if (Config.DOMAIN_LOCK != null) {
  			unmodified = this.mAccount.getJid().getLocalpart();
  		} else {
  			unmodified = this.mAccount.getJid().toBareJid().toString();
  		}
  		return !unmodified.equals(this.mAccountJid.getText().toString()) ||
  				!this.mAccount.getPassword().equals(this.mPassword.getText().toString()) ||
  				!this.mAccount.getHostname().equals(this.mHostname.getText().toString()) ||
  				!String.valueOf(this.mAccount.getPort()).equals(this.mPort.getText().toString());
  	}
  
  	@Override
  	protected String getShareableUri() {
  		if (mAccount != null) {
  			return mAccount.getShareableUri();
  		} else {
  			return "";
  		}
  	}
  
  	@Override
  	protected void onCreate(final Bundle savedInstanceState) {
  		super.onCreate(savedInstanceState);
  		setContentView(R.layout.activity_edit_account);
  		this.mAccountJid = (AutoCompleteTextView) findViewById(R.id.account_jid);
  		this.mAccountJid.addTextChangedListener(this.mTextWatcher);
  		this.mAccountJidLabel = (TextView) findViewById(R.id.account_jid_label);
  		if (Config.DOMAIN_LOCK != null) {
  			this.mAccountJidLabel.setText(R.string.username);
  			this.mAccountJid.setHint(R.string.username_hint);
  		}
  		this.mPassword = (EditText) findViewById(R.id.account_password);
  		this.mPassword.addTextChangedListener(this.mTextWatcher);
  		this.mPasswordConfirm = (EditText) findViewById(R.id.account_password_confirm);
  		this.mAvatar = (ImageView) findViewById(R.id.avater);
  		this.mAvatar.setOnClickListener(this.mAvatarClickListener);
  		this.mRegisterNew = (CheckBox) findViewById(R.id.account_register_new);
  		this.mStats = (LinearLayout) findViewById(R.id.stats);
  		this.mBatteryOptimizations = (RelativeLayout) findViewById(R.id.battery_optimization);
  		this.mDisableBatterOptimizations = (Button) findViewById(R.id.batt_op_disable);
  		this.mDisableBatterOptimizations.setOnClickListener(new OnClickListener() {
  			@Override
  			public void onClick(View v) {
  				Intent intent = new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
  				Uri uri = Uri.parse("package:"+getPackageName());
  				intent.setData(uri);
  				startActivityForResult(intent,REQUEST_BATTERY_OP);
  			}
  		});
  		this.mSessionEst = (TextView) findViewById(R.id.session_est);
  		this.mServerInfoRosterVersion = (TextView) findViewById(R.id.server_info_roster_version);
  		this.mServerInfoCarbons = (TextView) findViewById(R.id.server_info_carbons);
  		this.mServerInfoMam = (TextView) findViewById(R.id.server_info_mam);
  		this.mServerInfoCSI = (TextView) findViewById(R.id.server_info_csi);
  		this.mServerInfoBlocking = (TextView) findViewById(R.id.server_info_blocking);
  		this.mServerInfoSm = (TextView) findViewById(R.id.server_info_sm);
  		this.mServerInfoPep = (TextView) findViewById(R.id.server_info_pep);
  		this.mServerInfoHttpUpload = (TextView) findViewById(R.id.server_info_http_upload);
  		this.mPushRow = (TableRow) findViewById(R.id.push_row);
  		this.mServerInfoPush = (TextView) findViewById(R.id.server_info_push);
  		this.mOtrFingerprint = (TextView) findViewById(R.id.otr_fingerprint);
  		this.mOtrFingerprintBox = (RelativeLayout) findViewById(R.id.otr_fingerprint_box);
  		this.mOtrFingerprintToClipboardButton = (ImageButton) findViewById(R.id.action_copy_to_clipboard);
  		this.mAxolotlFingerprint = (TextView) findViewById(R.id.axolotl_fingerprint);
  		this.mAxolotlFingerprintBox = (RelativeLayout) findViewById(R.id.axolotl_fingerprint_box);
  		this.mAxolotlFingerprintToClipboardButton = (ImageButton) findViewById(R.id.action_copy_axolotl_to_clipboard);
  		this.mRegenerateAxolotlKeyButton = (ImageButton) findViewById(R.id.action_regenerate_axolotl_key);
  		this.keysCard = (LinearLayout) findViewById(R.id.other_device_keys_card);
  		this.keys = (LinearLayout) findViewById(R.id.other_device_keys);
  		this.mNamePort = (LinearLayout) findViewById(R.id.name_port);
  		this.mHostname = (EditText) findViewById(R.id.hostname);
  		this.mHostname.addTextChangedListener(mTextWatcher);
  		this.mPort = (EditText) findViewById(R.id.port);
  		this.mPort.setText("5222");
  		this.mPort.addTextChangedListener(mTextWatcher);
  		this.mSaveButton = (Button) findViewById(R.id.save_button);
  		this.mCancelButton = (Button) findViewById(R.id.cancel_button);
  		this.mSaveButton.setOnClickListener(this.mSaveButtonClickListener);
  		this.mCancelButton.setOnClickListener(this.mCancelButtonClickListener);
  		this.mMoreTable = (TableLayout) findViewById(R.id.server_info_more);
  		final OnCheckedChangeListener OnCheckedShowConfirmPassword = new OnCheckedChangeListener() {
  			@Override
  			public void onCheckedChanged(final CompoundButton buttonView,
  										 final boolean isChecked) {
  				if (isChecked) {
  					mPasswordConfirm.setVisibility(View.VISIBLE);
  				} else {
  					mPasswordConfirm.setVisibility(View.GONE);
  				}
  				updateSaveButton();
  			}
  		};
  		this.mRegisterNew.setOnCheckedChangeListener(OnCheckedShowConfirmPassword);
  		if (Config.DISALLOW_REGISTRATION_IN_UI) {
  			this.mRegisterNew.setVisibility(View.GONE);
  		}
  	}
  
  	@Override
  	public boolean onCreateOptionsMenu(final Menu menu) {
  		super.onCreateOptionsMenu(menu);
  		getMenuInflater().inflate(R.menu.editaccount, menu);
  		final MenuItem showQrCode = menu.findItem(R.id.action_show_qr_code);
  		final MenuItem showBlocklist = menu.findItem(R.id.action_show_block_list);
  		final MenuItem showMoreInfo = menu.findItem(R.id.action_server_info_show_more);
  		final MenuItem changePassword = menu.findItem(R.id.action_change_password_on_server);
  		final MenuItem clearDevices = menu.findItem(R.id.action_clear_devices);
  		final MenuItem renewCertificate = menu.findItem(R.id.action_renew_certificate);
  		final MenuItem mamPrefs = menu.findItem(R.id.action_mam_prefs);
  
  		renewCertificate.setVisible(mAccount != null && mAccount.getPrivateKeyAlias() != null);
  
  		if (mAccount != null && mAccount.isOnlineAndConnected()) {
  