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