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