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