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		final MenuItem clearDevices = menu.findItem(R.id.action_clear_devices);
367		if (mAccount != null && mAccount.isOnlineAndConnected()) {
368			if (!mAccount.getXmppConnection().getFeatures().blocking()) {
369				showBlocklist.setVisible(false);
370			}
371			if (!mAccount.getXmppConnection().getFeatures().register()) {
372				changePassword.setVisible(false);
373			}
374			Set<Integer> otherDevices = mAccount.getAxolotlService().getOwnDeviceIds();
375			if (otherDevices == null || otherDevices.isEmpty()) {
376				clearDevices.setVisible(false);
377			}
378		} else {
379			showQrCode.setVisible(false);
380			showBlocklist.setVisible(false);
381			showMoreInfo.setVisible(false);
382			changePassword.setVisible(false);
383		}
384		return true;
385	}
386
387	@Override
388	protected void onStart() {
389		super.onStart();
390		if (getIntent() != null) {
391			try {
392				this.jidToEdit = Jid.fromString(getIntent().getStringExtra("jid"));
393			} catch (final InvalidJidException | NullPointerException ignored) {
394				this.jidToEdit = null;
395			}
396			if (this.jidToEdit != null) {
397				this.mRegisterNew.setVisibility(View.GONE);
398				if (getActionBar() != null) {
399					getActionBar().setTitle(getString(R.string.account_details));
400				}
401			} else {
402				this.mAvatar.setVisibility(View.GONE);
403				if (getActionBar() != null) {
404					getActionBar().setTitle(R.string.action_add_account);
405				}
406			}
407		}
408	}
409
410	@Override
411	protected void onBackendConnected() {
412		final KnownHostsAdapter mKnownHostsAdapter = new KnownHostsAdapter(this,
413				android.R.layout.simple_list_item_1,
414				xmppConnectionService.getKnownHosts());
415		if (this.jidToEdit != null) {
416			this.mAccount = xmppConnectionService.findAccountByJid(jidToEdit);
417			updateAccountInformation(true);
418		} else if (this.xmppConnectionService.getAccounts().size() == 0) {
419			if (getActionBar() != null) {
420				getActionBar().setDisplayHomeAsUpEnabled(false);
421				getActionBar().setDisplayShowHomeEnabled(false);
422				getActionBar().setHomeButtonEnabled(false);
423			}
424			this.mCancelButton.setEnabled(false);
425			this.mCancelButton.setTextColor(getSecondaryTextColor());
426		}
427		this.mAccountJid.setAdapter(mKnownHostsAdapter);
428		updateSaveButton();
429	}
430
431	@Override
432	public boolean onOptionsItemSelected(final MenuItem item) {
433		switch (item.getItemId()) {
434			case R.id.action_show_block_list:
435				final Intent showBlocklistIntent = new Intent(this, BlocklistActivity.class);
436				showBlocklistIntent.putExtra("account", mAccount.getJid().toString());
437				startActivity(showBlocklistIntent);
438				break;
439			case R.id.action_server_info_show_more:
440				mMoreTable.setVisibility(item.isChecked() ? View.GONE : View.VISIBLE);
441				item.setChecked(!item.isChecked());
442				break;
443			case R.id.action_change_password_on_server:
444				final Intent changePasswordIntent = new Intent(this, ChangePasswordActivity.class);
445				changePasswordIntent.putExtra("account", mAccount.getJid().toString());
446				startActivity(changePasswordIntent);
447				break;
448			case R.id.action_clear_devices:
449				showWipePepDialog();
450				break;
451		}
452		return super.onOptionsItemSelected(item);
453	}
454
455	private void updateAccountInformation(boolean init) {
456		if (init) {
457			this.mAccountJid.setText(this.mAccount.getJid().toBareJid().toString());
458			this.mPassword.setText(this.mAccount.getPassword());
459		}
460		if (this.jidToEdit != null) {
461			this.mAvatar.setVisibility(View.VISIBLE);
462			this.mAvatar.setImageBitmap(avatarService().get(this.mAccount, getPixel(72)));
463		}
464		if (this.mAccount.isOptionSet(Account.OPTION_REGISTER)) {
465			this.mRegisterNew.setVisibility(View.VISIBLE);
466			this.mRegisterNew.setChecked(true);
467			this.mPasswordConfirm.setText(this.mAccount.getPassword());
468		} else {
469			this.mRegisterNew.setVisibility(View.GONE);
470			this.mRegisterNew.setChecked(false);
471		}
472		if (this.mAccount.isOnlineAndConnected() && !this.mFetchingAvatar) {
473			this.mStats.setVisibility(View.VISIBLE);
474			this.mSessionEst.setText(UIHelper.readableTimeDifferenceFull(this, this.mAccount.getXmppConnection()
475						.getLastSessionEstablished()));
476			Features features = this.mAccount.getXmppConnection().getFeatures();
477			if (features.rosterVersioning()) {
478				this.mServerInfoRosterVersion.setText(R.string.server_info_available);
479			} else {
480				this.mServerInfoRosterVersion.setText(R.string.server_info_unavailable);
481			}
482			if (features.carbons()) {
483				this.mServerInfoCarbons.setText(R.string.server_info_available);
484			} else {
485				this.mServerInfoCarbons
486					.setText(R.string.server_info_unavailable);
487			}
488			if (features.mam()) {
489				this.mServerInfoMam.setText(R.string.server_info_available);
490			} else {
491				this.mServerInfoMam.setText(R.string.server_info_unavailable);
492			}
493			if (features.csi()) {
494				this.mServerInfoCSI.setText(R.string.server_info_available);
495			} else {
496				this.mServerInfoCSI.setText(R.string.server_info_unavailable);
497			}
498			if (features.blocking()) {
499				this.mServerInfoBlocking.setText(R.string.server_info_available);
500			} else {
501				this.mServerInfoBlocking.setText(R.string.server_info_unavailable);
502			}
503			if (features.sm()) {
504				this.mServerInfoSm.setText(R.string.server_info_available);
505			} else {
506				this.mServerInfoSm.setText(R.string.server_info_unavailable);
507			}
508			if (features.pep()) {
509				this.mServerInfoPep.setText(R.string.server_info_available);
510			} else {
511				this.mServerInfoPep.setText(R.string.server_info_unavailable);
512			}
513			final String otrFingerprint = this.mAccount.getOtrFingerprint();
514			if (otrFingerprint != null) {
515				this.mOtrFingerprintBox.setVisibility(View.VISIBLE);
516				this.mOtrFingerprint.setText(CryptoHelper.prettifyFingerprint(otrFingerprint));
517				this.mOtrFingerprintToClipboardButton
518					.setVisibility(View.VISIBLE);
519				this.mOtrFingerprintToClipboardButton
520					.setOnClickListener(new View.OnClickListener() {
521
522						@Override
523						public void onClick(final View v) {
524
525							if (copyTextToClipboard(otrFingerprint, R.string.otr_fingerprint)) {
526								Toast.makeText(
527										EditAccountActivity.this,
528										R.string.toast_message_otr_fingerprint,
529										Toast.LENGTH_SHORT).show();
530							}
531						}
532					});
533			} else {
534				this.mOtrFingerprintBox.setVisibility(View.GONE);
535			}
536			final Set<Integer> ownDevices = this.mAccount.getAxolotlService().getOwnDeviceIds();
537			if (ownDevices != null && !ownDevices.isEmpty()) {
538				this.mAxolotlDevicelistBox.setVisibility(View.VISIBLE);
539				this.mAxolotlDevicelist.setText(TextUtils.join(", ", ownDevices));
540				this.mWipeAxolotlPepButton
541						.setVisibility(View.VISIBLE);
542				this.mWipeAxolotlPepButton
543						.setOnClickListener(new View.OnClickListener() {
544							@Override
545							public void onClick(final View v) {
546								showWipePepDialog();
547							}
548						});
549			} else {
550				this.mAxolotlDevicelistBox.setVisibility(View.GONE);
551			}
552			final String axolotlFingerprint = this.mAccount.getAxolotlService().getOwnPublicKey().getFingerprint();
553			if (axolotlFingerprint != null) {
554				this.mAxolotlFingerprintBox.setVisibility(View.VISIBLE);
555				this.mAxolotlFingerprint.setText(CryptoHelper.prettifyFingerprint(axolotlFingerprint));
556				this.mAxolotlFingerprintToClipboardButton
557						.setVisibility(View.VISIBLE);
558				this.mAxolotlFingerprintToClipboardButton
559						.setOnClickListener(new View.OnClickListener() {
560
561							@Override
562							public void onClick(final View v) {
563
564								if (copyTextToClipboard(axolotlFingerprint, R.string.axolotl_fingerprint)) {
565									Toast.makeText(
566											EditAccountActivity.this,
567											R.string.toast_message_axolotl_fingerprint,
568											Toast.LENGTH_SHORT).show();
569								}
570							}
571						});
572				this.mRegenerateAxolotlKeyButton
573						.setVisibility(View.VISIBLE);
574				this.mRegenerateAxolotlKeyButton
575						.setOnClickListener(new View.OnClickListener() {
576
577							@Override
578							public void onClick(final View v) {
579								showRegenerateAxolotlKeyDialog();
580							}
581						});
582			} else {
583				this.mAxolotlFingerprintBox.setVisibility(View.GONE);
584			}
585			final IdentityKey ownKey = mAccount.getAxolotlService().getOwnPublicKey();
586			boolean hasKeys = false;
587			keys.removeAllViews();
588			for(final IdentityKey identityKey : xmppConnectionService.databaseBackend.loadIdentityKeys(
589					mAccount, mAccount.getJid().toBareJid().toString())) {
590				if(ownKey.equals(identityKey)) {
591					continue;
592				}
593				hasKeys = true;
594				addFingerprintRow(keys, mAccount, identityKey);
595			}
596			if (hasKeys) {
597				keysCard.setVisibility(View.VISIBLE);
598			} else {
599				keysCard.setVisibility(View.GONE);
600			}
601		} else {
602			if (this.mAccount.errorStatus()) {
603				this.mAccountJid.setError(getString(this.mAccount.getStatus().getReadableId()));
604				if (init || !accountInfoEdited()) {
605					this.mAccountJid.requestFocus();
606				}
607			} else {
608				this.mAccountJid.setError(null);
609			}
610			this.mStats.setVisibility(View.GONE);
611		}
612	}
613
614	public void showRegenerateAxolotlKeyDialog() {
615		Builder builder = new Builder(this);
616		builder.setTitle("Regenerate Key");
617		builder.setIconAttribute(android.R.attr.alertDialogIcon);
618		builder.setMessage("Are you sure you want to regenerate your Identity Key? (This will also wipe all established sessions and contact Identity Keys)");
619		builder.setNegativeButton(getString(R.string.cancel), null);
620		builder.setPositiveButton("Yes",
621				new DialogInterface.OnClickListener() {
622					@Override
623					public void onClick(DialogInterface dialog, int which) {
624						mAccount.getAxolotlService().regenerateKeys();
625					}
626				});
627		builder.create().show();
628	}
629
630	public void showWipePepDialog() {
631		Builder builder = new Builder(this);
632		builder.setTitle(getString(R.string.clear_other_devices));
633		builder.setIconAttribute(android.R.attr.alertDialogIcon);
634		builder.setMessage(getString(R.string.clear_other_devices_desc));
635		builder.setNegativeButton(getString(R.string.cancel), null);
636		builder.setPositiveButton(getString(R.string.accept),
637				new DialogInterface.OnClickListener() {
638					@Override
639					public void onClick(DialogInterface dialog, int which) {
640						mAccount.getAxolotlService().wipeOtherPepDevices();
641					}
642				});
643		builder.create().show();
644	}
645}