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 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 @Override
156 public void onAccountUpdate() {
157 runOnUiThread(new Runnable() {
158
159 @Override
160 public void run() {
161 invalidateOptionsMenu();
162 if (mAccount != null
163 && mAccount.getStatus() != Account.State.ONLINE
164 && mFetchingAvatar) {
165 startActivity(new Intent(getApplicationContext(),
166 ManageAccountActivity.class));
167 finish();
168 } else if (jidToEdit == null && mAccount != null
169 && mAccount.getStatus() == Account.State.ONLINE) {
170 if (!mFetchingAvatar) {
171 mFetchingAvatar = true;
172 xmppConnectionService.checkForAvatar(mAccount,
173 mAvatarFetchCallback);
174 }
175 } else {
176 updateSaveButton();
177 }
178 if (mAccount != null) {
179 updateAccountInformation(false);
180 }
181 }
182 });
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 }
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 = true;
572 addFingerprintRow(keys, mAccount, identityKey);
573 }
574 if (hasKeys) {
575 keysCard.setVisibility(View.VISIBLE);
576 } else {
577 keysCard.setVisibility(View.GONE);
578 }
579 } else {
580 if (this.mAccount.errorStatus()) {
581 this.mAccountJid.setError(getString(this.mAccount.getStatus().getReadableId()));
582 if (init || !accountInfoEdited()) {
583 this.mAccountJid.requestFocus();
584 }
585 } else {
586 this.mAccountJid.setError(null);
587 }
588 this.mStats.setVisibility(View.GONE);
589 }
590 }
591
592 public void showRegenerateAxolotlKeyDialog() {
593 Builder builder = new Builder(this);
594 builder.setTitle("Regenerate Key");
595 builder.setIconAttribute(android.R.attr.alertDialogIcon);
596 builder.setMessage("Are you sure you want to regenerate your Identity Key? (This will also wipe all established sessions and contact Identity Keys)");
597 builder.setNegativeButton(getString(R.string.cancel), null);
598 builder.setPositiveButton("Yes",
599 new DialogInterface.OnClickListener() {
600 @Override
601 public void onClick(DialogInterface dialog, int which) {
602 mAccount.getAxolotlService().regenerateKeys();
603 }
604 });
605 builder.create().show();
606 }
607
608 public void showWipePepDialog() {
609 Builder builder = new Builder(this);
610 builder.setTitle(getString(R.string.clear_other_devices));
611 builder.setIconAttribute(android.R.attr.alertDialogIcon);
612 builder.setMessage(getString(R.string.clear_other_devices_desc));
613 builder.setNegativeButton(getString(R.string.cancel), null);
614 builder.setPositiveButton(getString(R.string.accept),
615 new DialogInterface.OnClickListener() {
616 @Override
617 public void onClick(DialogInterface dialog, int which) {
618 mAccount.getAxolotlService().wipeOtherPepDevices();
619 }
620 });
621 builder.create().show();
622 }
623}