EditAccountActivity.java

  1package eu.siacs.conversations.ui;
  2
  3import android.app.AlertDialog.Builder;
  4import android.app.PendingIntent;
  5import android.content.DialogInterface;
  6import android.content.Intent;
  7import android.os.Bundle;
  8import android.text.Editable;
  9import android.text.TextUtils;
 10import android.text.TextWatcher;
 11import android.view.Menu;
 12import android.view.MenuItem;
 13import android.view.View;
 14import android.view.View.OnClickListener;
 15import android.widget.AutoCompleteTextView;
 16import android.widget.Button;
 17import android.widget.CheckBox;
 18import android.widget.CompoundButton;
 19import android.widget.CompoundButton.OnCheckedChangeListener;
 20import android.widget.EditText;
 21import android.widget.ImageButton;
 22import android.widget.ImageView;
 23import android.widget.LinearLayout;
 24import android.widget.RelativeLayout;
 25import android.widget.TableLayout;
 26import android.widget.TextView;
 27import android.widget.Toast;
 28
 29import org.whispersystems.libaxolotl.IdentityKey;
 30
 31import java.util.Set;
 32
 33import eu.siacs.conversations.R;
 34import eu.siacs.conversations.entities.Account;
 35import eu.siacs.conversations.services.XmppConnectionService.OnAccountUpdate;
 36import eu.siacs.conversations.ui.adapter.KnownHostsAdapter;
 37import eu.siacs.conversations.utils.CryptoHelper;
 38import eu.siacs.conversations.utils.UIHelper;
 39import eu.siacs.conversations.xmpp.XmppConnection.Features;
 40import eu.siacs.conversations.xmpp.jid.InvalidJidException;
 41import eu.siacs.conversations.xmpp.jid.Jid;
 42import eu.siacs.conversations.xmpp.pep.Avatar;
 43
 44public class EditAccountActivity extends XmppActivity implements OnAccountUpdate{
 45
 46	private AutoCompleteTextView mAccountJid;
 47	private EditText mPassword;
 48	private EditText mPasswordConfirm;
 49	private CheckBox mRegisterNew;
 50	private Button mCancelButton;
 51	private Button mSaveButton;
 52	private TableLayout mMoreTable;
 53
 54	private LinearLayout mStats;
 55	private TextView mServerInfoSm;
 56	private TextView mServerInfoRosterVersion;
 57	private TextView mServerInfoCarbons;
 58	private TextView mServerInfoMam;
 59	private TextView mServerInfoCSI;
 60	private TextView mServerInfoBlocking;
 61	private TextView mServerInfoPep;
 62	private TextView mSessionEst;
 63	private TextView mOtrFingerprint;
 64	private TextView mAxolotlFingerprint;
 65	private TextView mAxolotlDevicelist;
 66	private ImageView mAvatar;
 67	private RelativeLayout mOtrFingerprintBox;
 68	private RelativeLayout mAxolotlFingerprintBox;
 69	private RelativeLayout mAxolotlDevicelistBox;
 70	private ImageButton mOtrFingerprintToClipboardButton;
 71	private ImageButton mAxolotlFingerprintToClipboardButton;
 72	private ImageButton mWipeAxolotlPepButton;
 73	private ImageButton mRegenerateAxolotlKeyButton;
 74	private LinearLayout keys;
 75	private LinearLayout keysCard;
 76
 77	private Jid jidToEdit;
 78	private Account mAccount;
 79
 80	private boolean mFetchingAvatar = false;
 81
 82	private final OnClickListener mSaveButtonClickListener = new OnClickListener() {
 83
 84		@Override
 85		public void onClick(final View v) {
 86			if (mAccount != null && mAccount.getStatus() == Account.State.DISABLED && !accountInfoEdited()) {
 87				mAccount.setOption(Account.OPTION_DISABLED, false);
 88				xmppConnectionService.updateAccount(mAccount);
 89				return;
 90			}
 91			final boolean registerNewAccount = mRegisterNew.isChecked();
 92			final Jid jid;
 93			try {
 94				jid = Jid.fromString(mAccountJid.getText().toString());
 95			} catch (final InvalidJidException e) {
 96				mAccountJid.setError(getString(R.string.invalid_jid));
 97				mAccountJid.requestFocus();
 98				return;
 99			}
100			if (jid.isDomainJid()) {
101				mAccountJid.setError(getString(R.string.invalid_jid));
102				mAccountJid.requestFocus();
103				return;
104			}
105			final String password = mPassword.getText().toString();
106			final String passwordConfirm = mPasswordConfirm.getText().toString();
107			if (registerNewAccount) {
108				if (!password.equals(passwordConfirm)) {
109					mPasswordConfirm.setError(getString(R.string.passwords_do_not_match));
110					mPasswordConfirm.requestFocus();
111					return;
112				}
113			}
114			if (mAccount != null) {
115				try {
116					mAccount.setUsername(jid.hasLocalpart() ? jid.getLocalpart() : "");
117					mAccount.setServer(jid.getDomainpart());
118				} catch (final InvalidJidException ignored) {
119					return;
120				}
121				mAccountJid.setError(null);
122				mPasswordConfirm.setError(null);
123				mAccount.setPassword(password);
124				mAccount.setOption(Account.OPTION_REGISTER, registerNewAccount);
125				xmppConnectionService.updateAccount(mAccount);
126			} else {
127				try {
128					if (xmppConnectionService.findAccountByJid(Jid.fromString(mAccountJid.getText().toString())) != null) {
129						mAccountJid.setError(getString(R.string.account_already_exists));
130						mAccountJid.requestFocus();
131						return;
132					}
133				} catch (final InvalidJidException e) {
134					return;
135				}
136				mAccount = new Account(jid.toBareJid(), password);
137				mAccount.setOption(Account.OPTION_USETLS, true);
138				mAccount.setOption(Account.OPTION_USECOMPRESSION, true);
139				mAccount.setOption(Account.OPTION_REGISTER, registerNewAccount);
140				xmppConnectionService.createAccount(mAccount);
141			}
142			if (jidToEdit != null && !mAccount.isOptionSet(Account.OPTION_DISABLED)) {
143				finish();
144			} else {
145				updateSaveButton();
146				updateAccountInformation(true);
147			}
148
149		}
150	};
151	private final OnClickListener mCancelButtonClickListener = new OnClickListener() {
152
153		@Override
154		public void onClick(final View v) {
155			finish();
156		}
157	};
158	@Override
159	public void onAccountUpdate() {
160		runOnUiThread(new Runnable() {
161
162			@Override
163			public void run() {
164				invalidateOptionsMenu();
165				if (mAccount != null
166						&& mAccount.getStatus() != Account.State.ONLINE
167						&& mFetchingAvatar) {
168					startActivity(new Intent(getApplicationContext(),
169								ManageAccountActivity.class));
170					finish();
171				} else if (jidToEdit == null && mAccount != null
172						&& mAccount.getStatus() == Account.State.ONLINE) {
173					if (!mFetchingAvatar) {
174						mFetchingAvatar = true;
175						xmppConnectionService.checkForAvatar(mAccount,
176								mAvatarFetchCallback);
177					}
178				} else {
179					updateSaveButton();
180				}
181				if (mAccount != null) {
182					updateAccountInformation(false);
183				}
184			}
185		});
186	}
187	private final UiCallback<Avatar> mAvatarFetchCallback = new UiCallback<Avatar>() {
188
189		@Override
190		public void userInputRequried(final PendingIntent pi, final Avatar avatar) {
191			finishInitialSetup(avatar);
192		}
193
194		@Override
195		public void success(final Avatar avatar) {
196			finishInitialSetup(avatar);
197		}
198
199		@Override
200		public void error(final int errorCode, final Avatar avatar) {
201			finishInitialSetup(avatar);
202		}
203	};
204	private final TextWatcher mTextWatcher = new TextWatcher() {
205
206		@Override
207		public void onTextChanged(final CharSequence s, final int start, final int before, final int count) {
208			updateSaveButton();
209		}
210
211		@Override
212		public void beforeTextChanged(final CharSequence s, final int start, final int count, final int after) {
213		}
214
215		@Override
216		public void afterTextChanged(final Editable s) {
217
218		}
219	};
220
221	private final OnClickListener mAvatarClickListener = new OnClickListener() {
222		@Override
223		public void onClick(final View view) {
224			if (mAccount != null) {
225				final Intent intent = new Intent(getApplicationContext(),
226						PublishProfilePictureActivity.class);
227				intent.putExtra("account", mAccount.getJid().toBareJid().toString());
228				startActivity(intent);
229			}
230		}
231	};
232
233	protected void finishInitialSetup(final Avatar avatar) {
234		runOnUiThread(new Runnable() {
235
236			@Override
237			public void run() {
238				final Intent intent;
239				if (avatar != null) {
240					intent = new Intent(getApplicationContext(),
241							StartConversationActivity.class);
242					if (xmppConnectionService != null && xmppConnectionService.getAccounts().size() == 1) {
243						intent.putExtra("init", true);
244					}
245				} else {
246					intent = new Intent(getApplicationContext(),
247							PublishProfilePictureActivity.class);
248					intent.putExtra("account", mAccount.getJid().toBareJid().toString());
249					intent.putExtra("setup", true);
250				}
251				startActivity(intent);
252				finish();
253			}
254		});
255	}
256
257	protected void updateSaveButton() {
258		if (accountInfoEdited() && jidToEdit != null) {
259			this.mSaveButton.setText(R.string.save);
260			this.mSaveButton.setEnabled(true);
261			this.mSaveButton.setTextColor(getPrimaryTextColor());
262		} else if (mAccount != null && (mAccount.getStatus() == Account.State.CONNECTING || mFetchingAvatar)) {
263			this.mSaveButton.setEnabled(false);
264			this.mSaveButton.setTextColor(getSecondaryTextColor());
265			this.mSaveButton.setText(R.string.account_status_connecting);
266		} else if (mAccount != null && mAccount.getStatus() == Account.State.DISABLED) {
267			this.mSaveButton.setEnabled(true);
268			this.mSaveButton.setTextColor(getPrimaryTextColor());
269			this.mSaveButton.setText(R.string.enable);
270		} else {
271			this.mSaveButton.setEnabled(true);
272			this.mSaveButton.setTextColor(getPrimaryTextColor());
273			if (jidToEdit != null) {
274				if (mAccount != null && mAccount.isOnlineAndConnected()) {
275					this.mSaveButton.setText(R.string.save);
276					if (!accountInfoEdited()) {
277						this.mSaveButton.setEnabled(false);
278						this.mSaveButton.setTextColor(getSecondaryTextColor());
279					}
280				} else {
281					this.mSaveButton.setText(R.string.connect);
282				}
283			} else {
284				this.mSaveButton.setText(R.string.next);
285			}
286		}
287	}
288
289	protected boolean accountInfoEdited() {
290		return this.mAccount != null && (!this.mAccount.getJid().toBareJid().toString().equals(
291					this.mAccountJid.getText().toString())
292			|| !this.mAccount.getPassword().equals(
293						this.mPassword.getText().toString()));
294	}
295
296	@Override
297	protected String getShareableUri() {
298		if (mAccount!=null) {
299			return mAccount.getShareableUri();
300		} else {
301			return "";
302		}
303	}
304
305	@Override
306	protected void onCreate(final Bundle savedInstanceState) {
307		super.onCreate(savedInstanceState);
308		setContentView(R.layout.activity_edit_account);
309		this.mAccountJid = (AutoCompleteTextView) findViewById(R.id.account_jid);
310		this.mAccountJid.addTextChangedListener(this.mTextWatcher);
311		this.mPassword = (EditText) findViewById(R.id.account_password);
312		this.mPassword.addTextChangedListener(this.mTextWatcher);
313		this.mPasswordConfirm = (EditText) findViewById(R.id.account_password_confirm);
314		this.mAvatar = (ImageView) findViewById(R.id.avater);
315		this.mAvatar.setOnClickListener(this.mAvatarClickListener);
316		this.mRegisterNew = (CheckBox) findViewById(R.id.account_register_new);
317		this.mStats = (LinearLayout) findViewById(R.id.stats);
318		this.mSessionEst = (TextView) findViewById(R.id.session_est);
319		this.mServerInfoRosterVersion = (TextView) findViewById(R.id.server_info_roster_version);
320		this.mServerInfoCarbons = (TextView) findViewById(R.id.server_info_carbons);
321		this.mServerInfoMam = (TextView) findViewById(R.id.server_info_mam);
322		this.mServerInfoCSI = (TextView) findViewById(R.id.server_info_csi);
323		this.mServerInfoBlocking = (TextView) findViewById(R.id.server_info_blocking);
324		this.mServerInfoSm = (TextView) findViewById(R.id.server_info_sm);
325		this.mServerInfoPep = (TextView) findViewById(R.id.server_info_pep);
326		this.mOtrFingerprint = (TextView) findViewById(R.id.otr_fingerprint);
327		this.mOtrFingerprintBox = (RelativeLayout) findViewById(R.id.otr_fingerprint_box);
328		this.mOtrFingerprintToClipboardButton = (ImageButton) findViewById(R.id.action_copy_to_clipboard);
329		this.mAxolotlFingerprint = (TextView) findViewById(R.id.axolotl_fingerprint);
330		this.mAxolotlFingerprintBox = (RelativeLayout) findViewById(R.id.axolotl_fingerprint_box);
331		this.mAxolotlFingerprintToClipboardButton = (ImageButton) findViewById(R.id.action_copy_axolotl_to_clipboard);
332		this.mRegenerateAxolotlKeyButton = (ImageButton) findViewById(R.id.action_regenerate_axolotl_key);
333		this.mAxolotlDevicelist = (TextView) findViewById(R.id.axolotl_devicelist);
334		this.mAxolotlDevicelistBox = (RelativeLayout) findViewById(R.id.axolotl_devices_box);
335		this.mWipeAxolotlPepButton = (ImageButton) findViewById(R.id.action_wipe_axolotl_pep);
336		this.keysCard = (LinearLayout) findViewById(R.id.other_device_keys_card);
337		this.keys = (LinearLayout) findViewById(R.id.other_device_keys);
338		this.mSaveButton = (Button) findViewById(R.id.save_button);
339		this.mCancelButton = (Button) findViewById(R.id.cancel_button);
340		this.mSaveButton.setOnClickListener(this.mSaveButtonClickListener);
341		this.mCancelButton.setOnClickListener(this.mCancelButtonClickListener);
342		this.mMoreTable = (TableLayout) findViewById(R.id.server_info_more);
343		final OnCheckedChangeListener OnCheckedShowConfirmPassword = new OnCheckedChangeListener() {
344			@Override
345			public void onCheckedChanged(final CompoundButton buttonView,
346					final boolean isChecked) {
347				if (isChecked) {
348					mPasswordConfirm.setVisibility(View.VISIBLE);
349				} else {
350					mPasswordConfirm.setVisibility(View.GONE);
351				}
352				updateSaveButton();
353			}
354		};
355		this.mRegisterNew.setOnCheckedChangeListener(OnCheckedShowConfirmPassword);
356	}
357
358	@Override
359	public boolean onCreateOptionsMenu(final Menu menu) {
360		super.onCreateOptionsMenu(menu);
361		getMenuInflater().inflate(R.menu.editaccount, menu);
362		final MenuItem showQrCode = menu.findItem(R.id.action_show_qr_code);
363		final MenuItem showBlocklist = menu.findItem(R.id.action_show_block_list);
364		final MenuItem showMoreInfo = menu.findItem(R.id.action_server_info_show_more);
365		final MenuItem changePassword = menu.findItem(R.id.action_change_password_on_server);
366		if (mAccount != null && mAccount.isOnlineAndConnected()) {
367			if (!mAccount.getXmppConnection().getFeatures().blocking()) {
368				showBlocklist.setVisible(false);
369			}
370			if (!mAccount.getXmppConnection().getFeatures().register()) {
371				changePassword.setVisible(false);
372			}
373		} else {
374			showQrCode.setVisible(false);
375			showBlocklist.setVisible(false);
376			showMoreInfo.setVisible(false);
377			changePassword.setVisible(false);
378		}
379		return true;
380	}
381
382	@Override
383	protected void onStart() {
384		super.onStart();
385		if (getIntent() != null) {
386			try {
387				this.jidToEdit = Jid.fromString(getIntent().getStringExtra("jid"));
388			} catch (final InvalidJidException | NullPointerException ignored) {
389				this.jidToEdit = null;
390			}
391			if (this.jidToEdit != null) {
392				this.mRegisterNew.setVisibility(View.GONE);
393				if (getActionBar() != null) {
394					getActionBar().setTitle(getString(R.string.account_details));
395				}
396			} else {
397				this.mAvatar.setVisibility(View.GONE);
398				if (getActionBar() != null) {
399					getActionBar().setTitle(R.string.action_add_account);
400				}
401			}
402		}
403	}
404
405	@Override
406	protected void onBackendConnected() {
407		final KnownHostsAdapter mKnownHostsAdapter = new KnownHostsAdapter(this,
408				android.R.layout.simple_list_item_1,
409				xmppConnectionService.getKnownHosts());
410		if (this.jidToEdit != null) {
411			this.mAccount = xmppConnectionService.findAccountByJid(jidToEdit);
412			updateAccountInformation(true);
413		} else if (this.xmppConnectionService.getAccounts().size() == 0) {
414			if (getActionBar() != null) {
415				getActionBar().setDisplayHomeAsUpEnabled(false);
416				getActionBar().setDisplayShowHomeEnabled(false);
417				getActionBar().setHomeButtonEnabled(false);
418			}
419			this.mCancelButton.setEnabled(false);
420			this.mCancelButton.setTextColor(getSecondaryTextColor());
421		}
422		this.mAccountJid.setAdapter(mKnownHostsAdapter);
423		updateSaveButton();
424	}
425
426	@Override
427	public boolean onOptionsItemSelected(final MenuItem item) {
428		switch (item.getItemId()) {
429			case R.id.action_show_block_list:
430				final Intent showBlocklistIntent = new Intent(this, BlocklistActivity.class);
431				showBlocklistIntent.putExtra("account", mAccount.getJid().toString());
432				startActivity(showBlocklistIntent);
433				break;
434			case R.id.action_server_info_show_more:
435				mMoreTable.setVisibility(item.isChecked() ? View.GONE : View.VISIBLE);
436				item.setChecked(!item.isChecked());
437				break;
438			case R.id.action_change_password_on_server:
439				final Intent changePasswordIntent = new Intent(this, ChangePasswordActivity.class);
440				changePasswordIntent.putExtra("account", mAccount.getJid().toString());
441				startActivity(changePasswordIntent);
442				break;
443		}
444		return super.onOptionsItemSelected(item);
445	}
446
447	private void updateAccountInformation(boolean init) {
448		if (init) {
449			this.mAccountJid.setText(this.mAccount.getJid().toBareJid().toString());
450			this.mPassword.setText(this.mAccount.getPassword());
451		}
452		if (this.jidToEdit != null) {
453			this.mAvatar.setVisibility(View.VISIBLE);
454			this.mAvatar.setImageBitmap(avatarService().get(this.mAccount, getPixel(72)));
455		}
456		if (this.mAccount.isOptionSet(Account.OPTION_REGISTER)) {
457			this.mRegisterNew.setVisibility(View.VISIBLE);
458			this.mRegisterNew.setChecked(true);
459			this.mPasswordConfirm.setText(this.mAccount.getPassword());
460		} else {
461			this.mRegisterNew.setVisibility(View.GONE);
462			this.mRegisterNew.setChecked(false);
463		}
464		if (this.mAccount.isOnlineAndConnected() && !this.mFetchingAvatar) {
465			this.mStats.setVisibility(View.VISIBLE);
466			this.mSessionEst.setText(UIHelper.readableTimeDifferenceFull(this, this.mAccount.getXmppConnection()
467						.getLastSessionEstablished()));
468			Features features = this.mAccount.getXmppConnection().getFeatures();
469			if (features.rosterVersioning()) {
470				this.mServerInfoRosterVersion.setText(R.string.server_info_available);
471			} else {
472				this.mServerInfoRosterVersion.setText(R.string.server_info_unavailable);
473			}
474			if (features.carbons()) {
475				this.mServerInfoCarbons.setText(R.string.server_info_available);
476			} else {
477				this.mServerInfoCarbons
478					.setText(R.string.server_info_unavailable);
479			}
480			if (features.mam()) {
481				this.mServerInfoMam.setText(R.string.server_info_available);
482			} else {
483				this.mServerInfoMam.setText(R.string.server_info_unavailable);
484			}
485			if (features.csi()) {
486				this.mServerInfoCSI.setText(R.string.server_info_available);
487			} else {
488				this.mServerInfoCSI.setText(R.string.server_info_unavailable);
489			}
490			if (features.blocking()) {
491				this.mServerInfoBlocking.setText(R.string.server_info_available);
492			} else {
493				this.mServerInfoBlocking.setText(R.string.server_info_unavailable);
494			}
495			if (features.sm()) {
496				this.mServerInfoSm.setText(R.string.server_info_available);
497			} else {
498				this.mServerInfoSm.setText(R.string.server_info_unavailable);
499			}
500			if (features.pep()) {
501				this.mServerInfoPep.setText(R.string.server_info_available);
502			} else {
503				this.mServerInfoPep.setText(R.string.server_info_unavailable);
504			}
505			final String otrFingerprint = this.mAccount.getOtrFingerprint();
506			if (otrFingerprint != null) {
507				this.mOtrFingerprintBox.setVisibility(View.VISIBLE);
508				this.mOtrFingerprint.setText(CryptoHelper.prettifyFingerprint(otrFingerprint));
509				this.mOtrFingerprintToClipboardButton
510					.setVisibility(View.VISIBLE);
511				this.mOtrFingerprintToClipboardButton
512					.setOnClickListener(new View.OnClickListener() {
513
514						@Override
515						public void onClick(final View v) {
516
517							if (copyTextToClipboard(otrFingerprint, R.string.otr_fingerprint)) {
518								Toast.makeText(
519										EditAccountActivity.this,
520										R.string.toast_message_otr_fingerprint,
521										Toast.LENGTH_SHORT).show();
522							}
523						}
524					});
525			} else {
526				this.mOtrFingerprintBox.setVisibility(View.GONE);
527			}
528			final Set<Integer> ownDevices = this.mAccount.getAxolotlService().getOwnDeviceIds();
529			if (ownDevices != null && !ownDevices.isEmpty()) {
530				this.mAxolotlDevicelistBox.setVisibility(View.VISIBLE);
531				this.mAxolotlDevicelist.setText(TextUtils.join(", ", ownDevices));
532				this.mWipeAxolotlPepButton
533						.setVisibility(View.VISIBLE);
534				this.mWipeAxolotlPepButton
535						.setOnClickListener(new View.OnClickListener() {
536							@Override
537							public void onClick(final View v) {
538								showWipePepDialog();
539							}
540						});
541			} else {
542				this.mAxolotlDevicelistBox.setVisibility(View.GONE);
543			}
544			final String axolotlFingerprint = this.mAccount.getAxolotlService().getOwnPublicKey().getFingerprint();
545			if (axolotlFingerprint != null) {
546				this.mAxolotlFingerprintBox.setVisibility(View.VISIBLE);
547				this.mAxolotlFingerprint.setText(CryptoHelper.prettifyFingerprint(axolotlFingerprint));
548				this.mAxolotlFingerprintToClipboardButton
549						.setVisibility(View.VISIBLE);
550				this.mAxolotlFingerprintToClipboardButton
551						.setOnClickListener(new View.OnClickListener() {
552
553							@Override
554							public void onClick(final View v) {
555
556								if (copyTextToClipboard(axolotlFingerprint, R.string.axolotl_fingerprint)) {
557									Toast.makeText(
558											EditAccountActivity.this,
559											R.string.toast_message_axolotl_fingerprint,
560											Toast.LENGTH_SHORT).show();
561								}
562							}
563						});
564				this.mRegenerateAxolotlKeyButton
565						.setVisibility(View.VISIBLE);
566				this.mRegenerateAxolotlKeyButton
567						.setOnClickListener(new View.OnClickListener() {
568
569							@Override
570							public void onClick(final View v) {
571								showRegenerateAxolotlKeyDialog();
572							}
573						});
574			} else {
575				this.mAxolotlFingerprintBox.setVisibility(View.GONE);
576			}
577			final IdentityKey ownKey = mAccount.getAxolotlService().getOwnPublicKey();
578			boolean hasKeys = false;
579			keys.removeAllViews();
580			for(final IdentityKey identityKey : xmppConnectionService.databaseBackend.loadIdentityKeys(
581					mAccount, mAccount.getJid().toBareJid().toString())) {
582				if(ownKey.equals(identityKey)) {
583					continue;
584				}
585				hasKeys = true;
586				addFingerprintRow(keys, mAccount, identityKey);
587			}
588			if (hasKeys) {
589				keysCard.setVisibility(View.VISIBLE);
590			} else {
591				keysCard.setVisibility(View.GONE);
592			}
593		} else {
594			if (this.mAccount.errorStatus()) {
595				this.mAccountJid.setError(getString(this.mAccount.getStatus().getReadableId()));
596				if (init || !accountInfoEdited()) {
597					this.mAccountJid.requestFocus();
598				}
599			} else {
600				this.mAccountJid.setError(null);
601			}
602			this.mStats.setVisibility(View.GONE);
603		}
604	}
605
606	public void showRegenerateAxolotlKeyDialog() {
607		Builder builder = new Builder(this);
608		builder.setTitle("Regenerate Key");
609		builder.setIconAttribute(android.R.attr.alertDialogIcon);
610		builder.setMessage("Are you sure you want to regenerate your Identity Key? (This will also wipe all established sessions and contact Identity Keys)");
611		builder.setNegativeButton(getString(R.string.cancel), null);
612		builder.setPositiveButton("Yes",
613				new DialogInterface.OnClickListener() {
614					@Override
615					public void onClick(DialogInterface dialog, int which) {
616						mAccount.getAxolotlService().regenerateKeys();
617					}
618				});
619		builder.create().show();
620	}
621
622	public void showWipePepDialog() {
623		Builder builder = new Builder(this);
624		builder.setTitle("Wipe PEP");
625		builder.setIconAttribute(android.R.attr.alertDialogIcon);
626		builder.setMessage("Are you sure you want to wipe all other devices from the PEP device ID list?");
627		builder.setNegativeButton(getString(R.string.cancel), null);
628		builder.setPositiveButton("Yes",
629				new DialogInterface.OnClickListener() {
630					@Override
631					public void onClick(DialogInterface dialog, int which) {
632						mAccount.getAxolotlService().wipeOtherPepDevices();
633					}
634				});
635		builder.create().show();
636	}
637}